client: AVA2 Won (cheque) system, revision mt20261027
ENABLE_CHEQUE_SYSTEM / ENABLE_WON_EXCHANGE_WINDOW = 1: Won in trades, private shop Won prices (int32 cheque[] after the CG_MYSHOP items), shop item cheque prices, mt_won script fixes, zh locale_game_ex overlay staged into locale_zh_ava2 (fixes the swapped %s/%d in WONEXCHANGE_CONFIRM_QUESTION_2). Also zero-init every TPacketCGExchange: arg1 was uninitialised and the HEAD server drops arg1 > UINT32_MAX, so accept/cancel/item-add were lost and trades never completed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
909fc8f851
commit
1a4d8295ff
@@ -1802,6 +1802,7 @@ bool CPythonNetworkStream::RecvShopPacket()
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME],"OnShopError",Py_BuildValue("(s)","NOT_ENOUGH_COUNT"));
|
||||
break;
|
||||
case SHOP_SUBHEADER_GC_START:
|
||||
case SHOP_SUBHEADER_GC_START_CHEQUE: // PORT revision27: START + int32 cheque[SHOP_HOST_ITEM_MAX_NUM]
|
||||
{
|
||||
CPythonShop::Instance().Clear();
|
||||
|
||||
@@ -1813,6 +1814,15 @@ bool CPythonNetworkStream::RecvShopPacket()
|
||||
{
|
||||
CPythonShop::Instance().SetItemData(iItemIndex, pShopStartPacket->items[iItemIndex]);
|
||||
}
|
||||
if (packet_shop.subheader == SHOP_SUBHEADER_GC_START_CHEQUE)
|
||||
{
|
||||
const char* cheques = &vecBuffer[4 + sizeof(TPacketGCShopStart)];
|
||||
for (unsigned i = 0; i < SHOP_HOST_ITEM_MAX_NUM; ++i)
|
||||
{
|
||||
int32_t cheque; memcpy(&cheque, cheques + i * sizeof(cheque), sizeof(cheque));
|
||||
CPythonShop::Instance().SetItemCheque(i, cheque);
|
||||
}
|
||||
}
|
||||
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "StartShop", Py_BuildValue("(i)", dwVID));
|
||||
}
|
||||
@@ -1860,6 +1870,8 @@ bool CPythonNetworkStream::RecvShopPacket()
|
||||
{
|
||||
TPacketGCShopUpdateItem * pShopUpdateItemPacket = (TPacketGCShopUpdateItem *)&vecBuffer[0];
|
||||
CPythonShop::Instance().SetItemData(pShopUpdateItemPacket->pos, pShopUpdateItemPacket->item);
|
||||
if (!pShopUpdateItemPacket->item.vnum)
|
||||
CPythonShop::Instance().SetItemCheque(pShopUpdateItemPacket->pos, 0);
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshShop", Py_BuildValue("()"));
|
||||
}
|
||||
break;
|
||||
@@ -1876,6 +1888,10 @@ bool CPythonNetworkStream::RecvShopPacket()
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_MONEY_EX"));
|
||||
break;
|
||||
|
||||
case SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE:
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_CHEQUE"));
|
||||
break;
|
||||
|
||||
case SHOP_SUBHEADER_GC_SOLD_OUT:
|
||||
case SHOP_SUBHEADER_GC_SOLDOUT:
|
||||
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "SOLDOUT"));
|
||||
@@ -1999,6 +2015,22 @@ bool CPythonNetworkStream::RecvExchangePacket()
|
||||
case EXCHANGE_SUBHEADER_GC_LESS_ELK:
|
||||
Tracef("trade_less_elk");
|
||||
break;
|
||||
|
||||
// PORT revision27: Won offered in the trade window (0..999).
|
||||
case EXCHANGE_SUBHEADER_GC_CHEQUE_ADD:
|
||||
if (exchange_packet.arg1 < 0 || exchange_packet.arg1 > 999)
|
||||
break;
|
||||
if (exchange_packet.is_me)
|
||||
CPythonExchange::Instance().SetChequeToSelf((DWORD) exchange_packet.arg1);
|
||||
else
|
||||
CPythonExchange::Instance().SetChequeToTarget((DWORD) exchange_packet.arg1);
|
||||
|
||||
__RefreshExchangeWindow();
|
||||
break;
|
||||
|
||||
case EXCHANGE_SUBHEADER_GC_LESS_CHEQUE:
|
||||
Tracef("trade_less_cheque");
|
||||
break;
|
||||
};
|
||||
|
||||
return true;
|
||||
@@ -2193,7 +2225,7 @@ bool CPythonNetworkStream::SendExchangeStartPacket(DWORD vid)
|
||||
if (!__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {}; // PORT: the server drops arg1 > UINT32_MAX, so every exchange packet zeroes its unset fields
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_START;
|
||||
@@ -2211,10 +2243,11 @@ bool CPythonNetworkStream::SendExchangeStartPacket(DWORD vid)
|
||||
|
||||
bool CPythonNetworkStream::SendExchangeElkAddPacket(int64_t elk)
|
||||
{
|
||||
if (!__CanActMainInstance())
|
||||
// PORT: the cheque pick dialog submits both amounts; an empty one is not an offer.
|
||||
if (elk <= 0 || !__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_ELK_ADD;
|
||||
@@ -2229,12 +2262,32 @@ bool CPythonNetworkStream::SendExchangeElkAddPacket(int64_t elk)
|
||||
return SendSequence();
|
||||
}
|
||||
|
||||
bool CPythonNetworkStream::SendExchangeChequeAddPacket(int cheque)
|
||||
{
|
||||
if (cheque <= 0 || !__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_CHEQUE_ADD;
|
||||
packet.arg1 = cheque;
|
||||
|
||||
if (!Send(sizeof(packet), &packet))
|
||||
{
|
||||
Tracef("send_trade_cheque_add_packet Error\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return SendSequence();
|
||||
}
|
||||
|
||||
bool CPythonNetworkStream::SendExchangeItemAddPacket(TItemPos ItemPos, BYTE byDisplayPos)
|
||||
{
|
||||
if (!__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_ITEM_ADD;
|
||||
@@ -2258,7 +2311,7 @@ bool CPythonNetworkStream::SendExchangeItemDelPacket(BYTE pos)
|
||||
if (!__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_ITEM_DEL;
|
||||
@@ -2278,7 +2331,7 @@ bool CPythonNetworkStream::SendExchangeAcceptPacket()
|
||||
if (!__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_ACCEPT;
|
||||
@@ -2297,7 +2350,7 @@ bool CPythonNetworkStream::SendExchangeExitPacket()
|
||||
if (!__CanActMainInstance())
|
||||
return true;
|
||||
|
||||
TPacketCGExchange packet;
|
||||
TPacketCGExchange packet = {};
|
||||
|
||||
packet.header = HEADER_CG_EXCHANGE;
|
||||
packet.subheader = EXCHANGE_SUBHEADER_CG_CANCEL;
|
||||
@@ -4031,8 +4084,11 @@ bool CPythonNetworkStream::RecvDungeon()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// MyShop
|
||||
bool CPythonNetworkStream::SendBuildPrivateShopPacket(const char * c_szName, const std::vector<TShopItemTable> & c_rSellingItemStock)
|
||||
bool CPythonNetworkStream::SendBuildPrivateShopPacket(const char * c_szName, const std::vector<TShopItemTable> & c_rSellingItemStock, const std::vector<int> & c_rCheques)
|
||||
{
|
||||
if (c_rCheques.size() != c_rSellingItemStock.size())
|
||||
return false;
|
||||
|
||||
TPacketCGMyShop packet;
|
||||
packet.bHeader = HEADER_CG_MYSHOP;
|
||||
strncpy(packet.szSign, c_szName, SHOP_SIGN_MAX_LEN);
|
||||
@@ -4047,6 +4103,14 @@ bool CPythonNetworkStream::SendBuildPrivateShopPacket(const char * c_szName, con
|
||||
return false;
|
||||
}
|
||||
|
||||
// PORT revision27: int32 Won price per item, in the same order as the items.
|
||||
for (size_t i = 0; i < c_rCheques.size(); ++i)
|
||||
{
|
||||
const int32_t cheque = c_rCheques[i];
|
||||
if (!Send(sizeof(cheque), &cheque))
|
||||
return false;
|
||||
}
|
||||
|
||||
return SendSequence();
|
||||
}
|
||||
|
||||
@@ -4533,7 +4597,7 @@ bool CPythonNetworkStream::SendClientVersionPacket()
|
||||
kVersionPacket.header = HEADER_CG_CLIENT_VERSION2;
|
||||
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
|
||||
// PORT: revision mt20261024 adds 64-bit shop prices, fixed offline records and 64-bit exchange/guild money; preserve the numeric prefix for atoi version checks.
|
||||
strncpy(kVersionPacket.timestamp, "1215955205 mt20261026", sizeof(kVersionPacket.timestamp)-1); // PORT: revision26 adds the AVA2 Cube Renewal packets (CG216/GC221).
|
||||
strncpy(kVersionPacket.timestamp, "1215955205 mt20261027", sizeof(kVersionPacket.timestamp)-1); // PORT: revision27 adds the Won (cheque) exchange/shop packets; revision26 the AVA2 Cube Renewal packets.
|
||||
//strncpy(kVersionPacket.timestamp, __TIMESTAMP__, sizeof(kVersionPacket.timestamp)-1); // old_string_ver
|
||||
//strncpy(kVersionPacket.timestamp, "1218055205", sizeof(kVersionPacket.timestamp)-1); // new_future
|
||||
//strncpy(kVersionPacket.timestamp, "1214055205", sizeof(kVersionPacket.timestamp)-1); // old_past
|
||||
@@ -4547,7 +4611,7 @@ bool CPythonNetworkStream::SendClientVersionPacket()
|
||||
kVersionPacket.header = HEADER_CG_CLIENT_VERSION;
|
||||
strncpy(kVersionPacket.filename, filename.c_str(), sizeof(kVersionPacket.filename)-1);
|
||||
// PORT: 64-bit money protocol requires mt20261024; older AVA2 services retain their own revision gates.
|
||||
strncpy(kVersionPacket.timestamp, "mt20261026", sizeof(kVersionPacket.timestamp)-1); // PORT: revision26 is backward-compatible with revision24 money.
|
||||
strncpy(kVersionPacket.timestamp, "mt20261027", sizeof(kVersionPacket.timestamp)-1); // PORT: revision27 is backward-compatible with revision24 money.
|
||||
|
||||
if (!Send(sizeof(kVersionPacket), &kVersionPacket))
|
||||
Tracef("SendClientReportPacket Error");
|
||||
|
||||
Reference in New Issue
Block a user