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
@@ -59,6 +59,7 @@
|
||||
#include "UserInterface/PythonNetworkStream.h"
|
||||
#include "UserInterface/PythonPlayer.h"
|
||||
#include "UserInterface/PythonExchange.h"
|
||||
#include "UserInterface/PythonShop.h"
|
||||
#include "UserInterface/PythonTextTail.h"
|
||||
#include "UserInterface/PythonCharacterManager.h"
|
||||
#include "UserInterface/InstanceBase.h"
|
||||
@@ -450,7 +451,6 @@ int main(int argc, char** argv)
|
||||
CHECK(pump_until(8,[&] {return type()==9 || failed();}));
|
||||
CHECK(type()==9 && !failed());
|
||||
if (std::getenv("MT_TEST_QUIVER_MOTION")) {
|
||||
CHECK(py("import app\nassert not app.ENABLE_CHEQUE_SYSTEM and not app.ENABLE_WON_EXCHANGE_WINDOW"));
|
||||
// Do not call Register here: loading-phase registration itself must have worked.
|
||||
CHECK(py("import mt_quiver_motion\nassert mt_quiver_motion.loaded == {1: True, 5: True}"));
|
||||
CHECK(py("_bag=_stream.curPhaseWindow.interface.wndInventory\nassert len(_bag.inventoryTab)==5\n_bag.SetInventoryPage(4)\nassert _bag.GetInventoryPageIndex()==4\n_bag.SetInventoryPage(0)"));
|
||||
@@ -1889,7 +1889,7 @@ int main(int argc, char** argv)
|
||||
CHECK(py_true("app.ENABLE_QUIVER_SYSTEM == 0"));
|
||||
CHECK(py_true("app.ENABLE_MAGIC_REDUCTION_SYSTEM == 0"));
|
||||
CHECK(py_true("app.ENABLE_DS_CHANGE_ATTR == 0"));
|
||||
CHECK(py_true("app.ENABLE_CUBE_RENEWAL_WORLDARD == 0"));
|
||||
CHECK(py_true("app.ENABLE_CUBE_RENEWAL_WORLDARD == 1"));
|
||||
|
||||
// Python item constants & methods
|
||||
CHECK(py_true("item.EQUIPMENT_GLOVE == player.EQUIPMENT_SLOT_START + 37"));
|
||||
@@ -1931,7 +1931,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// F30: Won & Cheque currency system
|
||||
CHECK(POINT_CHEQUE == 249);
|
||||
CHECK(py_true("app.ENABLE_CHEQUE_SYSTEM == 0"));
|
||||
CHECK(py_true("app.ENABLE_CHEQUE_SYSTEM == 1 and app.ENABLE_WON_EXCHANGE_WINDOW == 1"));
|
||||
CHECK(py_true("player.CHEQUE == 249"));
|
||||
CHECK(py_true("hasattr(player, 'GetCheque')"));
|
||||
CHECK(py_true("player.GetCheque() == 0"));
|
||||
@@ -1950,6 +1950,21 @@ int main(int argc, char** argv)
|
||||
// Won UI components
|
||||
CHECK(py("import uiPickETC; p = uiPickETC.PickETCDialog(); p.LoadDialog(); p.Open(100); p.Close()"));
|
||||
CHECK(py("import uiWonExchange; w = uiWonExchange.WonExchangeWindow(); w.Open(); w.Close()"));
|
||||
// revision27 Won bindings and the mt_won script fixes
|
||||
CHECK(py("import net, shop"));
|
||||
CHECK(py_true("hasattr(net, 'SendExchangeChequeAddPacket') and hasattr(net, 'SendGoldChequePacketNew')"));
|
||||
CHECK(py_true("shop.GetItemCheque(0) == 0"));
|
||||
CPythonShop::Instance().SetItemCheque(3, 25);
|
||||
CHECK(py_true("shop.GetItemCheque(3) == 25"));
|
||||
CPythonShop::Instance().Clear();
|
||||
CHECK(py_true("shop.GetItemCheque(3) == 0"));
|
||||
CHECK(py("shop.AddPrivateShopItemStock(1, 7, 2, 0, 5)"));
|
||||
CHECK(py_true("shop.GetPrivateShopItemCheque(1, 7) == 5 and shop.GetPrivateShopItemPrice(1, 7) == 0"));
|
||||
CHECK(py("shop.DelPrivateShopItemStock(1, 7)"));
|
||||
CHECK(py_true("shop.GetPrivateShopItemCheque(1, 7) == 0"));
|
||||
CHECK(!py("shop.AddPrivateShopItemStock(1, 7, 2, 0, 0)"));
|
||||
CHECK(!py("shop.AddPrivateShopItemStock(1, 7, 2, 1, 1000)"));
|
||||
CHECK(py_true("__import__('uiExchange').ExchangeDialog.SelectOwnerEmptySlot.__module__ == 'mt_won'"));
|
||||
|
||||
// Sound & music volume
|
||||
CHECK(py("systemSetting.SetMusicVolume(0.5)"));
|
||||
|
||||
@@ -79,6 +79,22 @@ int main(int argc, char** argv)
|
||||
assert(PortShopPayloadValid(SHOP_SUBHEADER_GC_UPDATE_PRICE,(char*)&price,sizeof(price)));
|
||||
assert(!PortShopPayloadValid(SHOP_SUBHEADER_GC_UPDATE_PRICE,(char*)&price,4));
|
||||
assert(!PortShopPayloadValid(255,nullptr,0));
|
||||
// revision27 Won prices: START + int32 cheque[SHOP_HOST_ITEM_MAX_NUM], each 0..999 on a real item.
|
||||
static_assert(SHOP_SUBHEADER_GC_START_CHEQUE==40 && SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE==41);
|
||||
static_assert(EXCHANGE_SUBHEADER_CG_CHEQUE_ADD==6 && EXCHANGE_SUBHEADER_GC_CHEQUE_ADD==8 && EXCHANGE_SUBHEADER_GC_LESS_CHEQUE==9);
|
||||
records[0].price=0;
|
||||
int32_t cheques[SHOP_HOST_ITEM_MAX_NUM]={};cheques[0]=999;
|
||||
std::vector<char> won(sizeof(DWORD)+sizeof(records)+sizeof(cheques));
|
||||
memcpy(won.data()+sizeof(DWORD),records,sizeof(records));
|
||||
memcpy(won.data()+sizeof(DWORD)+sizeof(records),cheques,sizeof(cheques));
|
||||
assert(PortShopPayloadValid(SHOP_SUBHEADER_GC_START_CHEQUE,won.data(),won.size()));
|
||||
assert(!PortShopPayloadValid(SHOP_SUBHEADER_GC_START_CHEQUE,won.data(),won.size()-4));
|
||||
assert(!PortShopPayloadValid(SHOP_SUBHEADER_GC_START,won.data(),won.size()));
|
||||
cheques[0]=1000;memcpy(won.data()+sizeof(DWORD)+sizeof(records),cheques,sizeof(cheques));
|
||||
assert(!PortShopPayloadValid(SHOP_SUBHEADER_GC_START_CHEQUE,won.data(),won.size()));
|
||||
cheques[0]=0;cheques[1]=5;memcpy(won.data()+sizeof(DWORD)+sizeof(records),cheques,sizeof(cheques));
|
||||
assert(!PortShopPayloadValid(SHOP_SUBHEADER_GC_START_CHEQUE,won.data(),won.size()));
|
||||
assert(PortShopPayloadValid(SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE,nullptr,0));
|
||||
}
|
||||
static_assert(sizeof(TPacketCGExchange::arg1)==8);
|
||||
static_assert(sizeof(TPacketCGExchange)==14);
|
||||
|
||||
@@ -10,11 +10,11 @@ ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
class QuiverMotionTests(unittest.TestCase):
|
||||
def test_disabled_wallet_also_disables_dependent_window(self):
|
||||
def test_wallet_and_dependent_window_switch_together(self):
|
||||
source=(ROOT/'src/port/UserInterface/PythonApplicationModule.cpp').read_text()
|
||||
for name in ('ENABLE_CHEQUE_SYSTEM','ENABLE_WON_EXCHANGE_WINDOW'):
|
||||
values=re.findall(r'PyModule_AddIntConstant\(poModule,\s*"'+name+r'",\s*(\d+)\)',source)
|
||||
self.assertEqual(values,['0'])
|
||||
self.assertEqual(values,['1'])
|
||||
|
||||
def load(self, missing=None):
|
||||
names = ['chr', 'chrmgr', 'pack', 'playerSettingModule']
|
||||
|
||||
Reference in New Issue
Block a user