From 2fc99d2fe7422e1f1515bbfab8a515b52d2f45d6 Mon Sep 17 00:00:00 2001 From: shen <> Date: Tue, 20 Oct 2026 01:46:17 -0700 Subject: [PATCH] feat: add 6th and 7th rare attribute client networking, constants, and locale --- .../ScriptLib/Ava2NativeSupportScript.inc | 10 ++++ src/port/UserInterface/Locale_inc.h | 2 + src/port/UserInterface/Packet.h | 25 +++++++++ .../UserInterface/PythonApplicationModule.cpp | 12 +++++ src/port/UserInterface/PythonNetworkStream.h | 7 +++ .../PythonNetworkStreamModule.cpp | 34 ++++++++++++ .../PythonNetworkStreamPhaseGame.cpp | 53 +++++++++++++++++++ src/port/UserInterface/PythonPlayerModule.cpp | 9 ++++ tests/port/port_python_ui_modules_test.cpp | 9 ++++ 9 files changed, 161 insertions(+) diff --git a/src/platform/ScriptLib/Ava2NativeSupportScript.inc b/src/platform/ScriptLib/Ava2NativeSupportScript.inc index bdf5d2e5..e4a1aace 100644 --- a/src/platform/ScriptLib/Ava2NativeSupportScript.inc +++ b/src/platform/ScriptLib/Ava2NativeSupportScript.inc @@ -169,4 +169,14 @@ nonplayer.GetMonsterRaceFlag=lambda v:(nonplayer.GetWikiInfo(v) or (0,)*9)[7] nonplayer.GetMonsterResist=lambda v,i:(nonplayer.GetWikiInfo(v)[8][i] if nonplayer.GetWikiInfo(v) and 0<=i<11 else 0) for i,name in enumerate('SWORD TWOHAND DAGGER BELL FAN BOW FIRE ELECT MAGIC WIND POISON'.split()):setattr(nonplayer,'MOB_RESIST_'+name,i) +app.BL_67_ATTR = 1 +app.ENABLE_ATTR_6TH_7TH = 1 +import sys +if 'localeInfo' in sys.modules: + li = sys.modules['localeInfo'] + li.ATTR_6TH_7TH_DESC1 = "a. 您需要添加正确的材料来为装备赋予第 6/7 条属性。" + li.ATTR_6TH_7TH_DESC2 = "b. 每个主材料可提升 2% 的成功率。" + li.ATTR_6TH_7TH_DESC3 = "c. 使用辅助增率道具可进一步提高成功概率。" + li.ATTR_6TH_7TH_DESC4 = "d. 属性赋予立即生效。若添加失败,您可以再次尝试。" + )PY"; diff --git a/src/port/UserInterface/Locale_inc.h b/src/port/UserInterface/Locale_inc.h index 2d7b64ba..004378ec 100644 --- a/src/port/UserInterface/Locale_inc.h +++ b/src/port/UserInterface/Locale_inc.h @@ -4,4 +4,6 @@ #define ENABLE_DRAGON_SOUL_SYSTEM #define ENABLE_NEW_EQUIPMENT_SYSTEM #define ENABLE_NEW_PET_SYSTEM +#define ENABLE_ATTR_6TH_7TH +#define __BL_67_ATTR__ //#define ENABLE_DISCORD_RPC diff --git a/src/port/UserInterface/Packet.h b/src/port/UserInterface/Packet.h index 0c5cfd44..37505623 100644 --- a/src/port/UserInterface/Packet.h +++ b/src/port/UserInterface/Packet.h @@ -155,6 +155,10 @@ enum HEADER_CG_DRAGON_SOUL_REFINE = 205, HEADER_CG_STATE_CHECKER = 206, HEADER_CG_SASH = 211, // PORT: AVA2 sash (metin2-server FEATURE-AVA2-UNLOCK P4) +#if defined(ENABLE_ATTR_6TH_7TH) + HEADER_CG_67_ATTR = 208, + HEADER_CG_CLOSE_67_ATTR = 209, +#endif HEADER_CG_ITEMS_PICKUP = 235, // PORT: AVA2 HEADER_CG_SWITCHBOT = 171, // PORT: AVA2 switchbot (metin2-server FEATURE-SWITCHBOT) @@ -367,6 +371,9 @@ enum HEADER_GC_AVA2_DROP = 220, HEADER_GC_SWITCHBOT = 171, // PORT: AVA2 switchbot, DYNAMIC_SIZE_PACKET HEADER_GC_EXTENDED_POINTS = 218, // PORT: AVA2 64-bit gold and extended points +#if defined(ENABLE_ATTR_6TH_7TH) + HEADER_GC_OPEN_67_ATTR = 242, +#endif HEADER_GC_KEY_AGREEMENT_COMPLETED = 0xfa, // _IMPROVED_PACKET_ENCRYPTION_ HEADER_GC_KEY_AGREEMENT = 0xfb, // _IMPROVED_PACKET_ENCRYPTION_ @@ -2811,6 +2818,24 @@ typedef struct SPacketCGDragonSoulRefine TItemPos ItemGrid[DS_REFINE_WINDOW_MAX_NUM]; } TPacketCGDragonSoulRefine; +#if defined(ENABLE_ATTR_6TH_7TH) +#pragma pack(push, 1) +typedef struct command_67_attr +{ + BYTE bHeader; + BYTE bMaterialCount; + BYTE bSupportCount; + short sSupportPos; + short sItemPos; +} TPacketCG67Attr; + +typedef struct command_67_attr_open_close +{ + BYTE bHeader; +} TPacket67AttrOpenClose; +#pragma pack(pop) +#endif + typedef struct SPacketGCDragonSoulRefine { SPacketGCDragonSoulRefine() : header(HEADER_GC_DRAGON_SOUL_REFINE) diff --git a/src/port/UserInterface/PythonApplicationModule.cpp b/src/port/UserInterface/PythonApplicationModule.cpp index d09523b3..e1bc4acf 100644 --- a/src/port/UserInterface/PythonApplicationModule.cpp +++ b/src/port/UserInterface/PythonApplicationModule.cpp @@ -1565,6 +1565,18 @@ void initapp() PyModule_AddIntConstant(poModule, "ENABLE_NEW_PET_SYSTEM", 0); #endif +#ifdef ENABLE_ATTR_6TH_7TH + PyModule_AddIntConstant(poModule, "ENABLE_ATTR_6TH_7TH", 1); +#else + PyModule_AddIntConstant(poModule, "ENABLE_ATTR_6TH_7TH", 0); +#endif + +#ifdef __BL_67_ATTR__ + PyModule_AddIntConstant(poModule, "BL_67_ATTR", 1); +#else + PyModule_AddIntConstant(poModule, "BL_67_ATTR", 0); +#endif + #ifdef USE_OPENID PyModule_AddIntConstant(poModule, "USE_OPENID", 1); if (openid_test) diff --git a/src/port/UserInterface/PythonNetworkStream.h b/src/port/UserInterface/PythonNetworkStream.h index 2cd15cd4..929934d7 100644 --- a/src/port/UserInterface/PythonNetworkStream.h +++ b/src/port/UserInterface/PythonNetworkStream.h @@ -280,6 +280,10 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton alternatives); bool SendSwitchbotStopPacket(BYTE slot); +#if defined(ENABLE_ATTR_6TH_7TH) + bool Send67AttrPacket(int iMaterialCount, int iSupportCount, int iSupportPos, int iItemPos); + bool Send67AttrClosePacket(); +#endif // Handshake bool RecvHandshakePacket(); @@ -565,6 +569,9 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton(HEADER_CG_67_ATTR), + static_cast(iMaterialCount), + static_cast(iSupportCount), + static_cast(iSupportPos), + static_cast(iItemPos), + }; + + if (!Send(sizeof(p), &p)) + { + Tracef("Send67AttrPacket Error\n"); + return false; + } + + return SendSequence(); +} + +bool CPythonNetworkStream::Send67AttrClosePacket() +{ + TPacket67AttrOpenClose p; + p.bHeader = HEADER_CG_CLOSE_67_ATTR; + + if (!Send(sizeof(p), &p)) + { + Tracef("Send67AttrClosePacket Error\n"); + return false; + } + + return SendSequence(); +} + +bool CPythonNetworkStream::Recv67AttrOpenPacket() +{ + TPacket67AttrOpenClose p; + + if (!Recv(sizeof(p), &p)) + return false; + + PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OpenAttr67AddDlg", Py_BuildValue("()")); + + return true; +} +#endif diff --git a/src/port/UserInterface/PythonPlayerModule.cpp b/src/port/UserInterface/PythonPlayerModule.cpp index ec3c310d..98e05b08 100644 --- a/src/port/UserInterface/PythonPlayerModule.cpp +++ b/src/port/UserInterface/PythonPlayerModule.cpp @@ -2629,6 +2629,15 @@ void initPlayer() PyModule_AddIntConstant(poModule, "SLOT_TYPE_DRAGON_SOUL_INVENTORY", SLOT_TYPE_DRAGON_SOUL_INVENTORY); PyModule_AddIntConstant(poModule, "SLOT_TYPE_SWITCHBOT", SLOT_TYPE_SWITCHBOT); // PORT: AVA2 switchbot + PyModule_AddIntConstant(poModule, "ON_TOP_WND_NONE", 0); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_SHOP", 1); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_EXCHANGE", 2); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_SAFEBOX", 3); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_PRIVATE_SHOP", 4); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_ITEM_COMB", 5); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_PET_FEED", 6); + PyModule_AddIntConstant(poModule, "ON_TOP_WND_ATTR_67", 7); + PyModule_AddIntConstant(poModule, "RESERVED_WINDOW", RESERVED_WINDOW); PyModule_AddIntConstant(poModule, "INVENTORY", INVENTORY); PyModule_AddIntConstant(poModule, "EQUIPMENT", EQUIPMENT); diff --git a/tests/port/port_python_ui_modules_test.cpp b/tests/port/port_python_ui_modules_test.cpp index 64cfc014..d5ba5990 100644 --- a/tests/port/port_python_ui_modules_test.cpp +++ b/tests/port/port_python_ui_modules_test.cpp @@ -6,6 +6,7 @@ extern void initapp(); extern void initPlayer(); extern void initItem(); extern void initchrmgr(); +extern void initnet(); #include "UserInterface/PythonPlayer.h" #include #include "../../src/platform/ScriptLib/PythonHost.h" @@ -36,6 +37,7 @@ int main(int argc, char** argv) initapp(); initItem(); initchrmgr(); + initnet(); CPythonPlayer player; initPlayer(); CPythonPlayer::Instance().SetGold64(123456789012345LL); @@ -79,6 +81,13 @@ int main(int argc, char** argv) "assert item.PET_SKILL == 6\n" "assert item.PET_SKILL_DEL_BOOK == 11\n" "assert item.PET_SKILL_ALL_DEL_BOOK == 12\n" + "assert app.ENABLE_ATTR_6TH_7TH == 1\n" + "assert app.BL_67_ATTR == 1\n" + "assert player.ON_TOP_WND_ATTR_67 == 7\n" + "assert player.ON_TOP_WND_NONE == 0\n" + "import net\n" + "assert hasattr(net, 'Send67AttrPacket')\n" + "assert hasattr(net, 'Send67AttrClosePacket')\n" )) return 1; if (!launcher.RunLine("import wndMgr, grp, grpImage, grpText, grpThing, app"))