From 1757643b07962df75d5715ff3082ca4422661233 Mon Sep 17 00:00:00 2001 From: shenlei Date: Sat, 24 Oct 2026 20:33:51 +0900 Subject: [PATCH] Five character slots: header 32 carries PLAYER_PER_ACCOUNT5 LOGIN_SUCCESS4 (32) now always reads the five-slot packet, replacing the racy size-sniffing check; slot index bounds use PLAYER_PER_ACCOUNT5; version mt20261029. Also skip short rows in _point.txt, which read past the token vector and crashed a warp. Co-Authored-By: Claude Opus 5.5 --- .../UserInterface/PythonApplicationModule.cpp | 2 +- src/port/UserInterface/PythonMiniMap.cpp | 3 ++ .../UserInterface/PythonNetworkStream.cpp | 15 +----- .../PythonNetworkStreamModule.cpp | 4 +- .../PythonNetworkStreamPhaseGame.cpp | 4 +- .../PythonNetworkStreamPhaseLogin.cpp | 53 +------------------ tests/port/classic/wire_classic.h | 4 +- tests/port/port_login_flow_test.cpp | 8 +-- tests/port/port_packet_test.cpp | 2 +- 9 files changed, 19 insertions(+), 76 deletions(-) diff --git a/src/port/UserInterface/PythonApplicationModule.cpp b/src/port/UserInterface/PythonApplicationModule.cpp index 00f2b35a..d1a45792 100644 --- a/src/port/UserInterface/PythonApplicationModule.cpp +++ b/src/port/UserInterface/PythonApplicationModule.cpp @@ -1680,7 +1680,7 @@ void initapp() PyModule_AddIntConstant(poModule, "ENABLE_CUBE_RENEWAL_WORLDARD", 1); PyModule_AddIntConstant(poModule, "ENABLE_CHEQUE_SYSTEM", 1); PyModule_AddIntConstant(poModule, "ENABLE_RANKING_SYSTEM", 1); - PyModule_AddIntConstant(poModule, "ENABLE_PLAYER_PER_ACCOUNT5", 0); + PyModule_AddIntConstant(poModule, "ENABLE_PLAYER_PER_ACCOUNT5", 1); PyModule_AddIntConstant(poModule, "ENABLE_CONQUEROR_LEVEL", 1); PyModule_AddIntConstant(poModule, "ENABLE_CONQUEROR_UI", 0); PyModule_AddIntConstant(poModule, "ENABLE_WOLFMAN_CHARACTER", 1); diff --git a/src/port/UserInterface/PythonMiniMap.cpp b/src/port/UserInterface/PythonMiniMap.cpp index 8f626aa4..b969c90a 100644 --- a/src/port/UserInterface/PythonMiniMap.cpp +++ b/src/port/UserInterface/PythonMiniMap.cpp @@ -834,6 +834,9 @@ void CPythonMiniMap::__LoadAtlasMarkInfo() continue; const CTokenVector & rVector = stTokenVectorMap[szMarkInfoName]; + // PORT: rows with fewer than 4 tokens read past the vector; that crashed the client while warping (2026-10-24). + if (rVector.size() < 4) + continue; const std::string & c_rstrType = rVector[0].c_str(); const std::string & c_rstrPositionX = rVector[1].c_str(); diff --git a/src/port/UserInterface/PythonNetworkStream.cpp b/src/port/UserInterface/PythonNetworkStream.cpp index 919e88eb..2ba9f159 100644 --- a/src/port/UserInterface/PythonNetworkStream.cpp +++ b/src/port/UserInterface/PythonNetworkStream.cpp @@ -48,7 +48,8 @@ class CMainPacketHeaderMap : public CNetworkPacketHeaderMap Set(HEADER_GC_SYNC_POSITION, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCC2C), DYNAMIC_SIZE_PACKET)); Set(HEADER_GC_LOGIN_SUCCESS3, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLoginSuccess3), STATIC_SIZE_PACKET)); - Set(HEADER_GC_LOGIN_SUCCESS4, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLoginSuccess4), STATIC_SIZE_PACKET)); + // PORT: AVA2 ENABLE_PLAYER_PER_ACCOUNT5 sends five slots under HEADER_GC_LOGIN_SUCCESS_NEWSLOT (32). + Set(HEADER_GC_LOGIN_SUCCESS4, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLoginSuccess5), STATIC_SIZE_PACKET)); Set(HEADER_GC_LOGIN_SUCCESS5, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLoginSuccess5), STATIC_SIZE_PACKET)); Set(HEADER_GC_LOGIN_FAILURE, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLoginFailure), STATIC_SIZE_PACKET)); @@ -581,18 +582,6 @@ bool CPythonNetworkStream::CheckPacket(TPacketHeader * pRetHeader) if(!Peek(p.size)) return false; *pRetHeader=header; return true; - } - // 5-slot adaptive check for HEADER_GC_LOGIN_SUCCESS4: - // If stream contains full 5-slot packet, accept it. Otherwise wait for standard 4-slot size. - if (header == HEADER_GC_LOGIN_SUCCESS4) { - if (GetRecvBufferSize() >= (int)sizeof(TPacketGCLoginSuccess5)) { - *pRetHeader = header; - return true; - } - if (!Peek(sizeof(TPacketGCLoginSuccess4))) - return false; - *pRetHeader = header; - return true; } // Code for dynamic size packet if (PacketType.isDynamicSizePacket) diff --git a/src/port/UserInterface/PythonNetworkStreamModule.cpp b/src/port/UserInterface/PythonNetworkStreamModule.cpp index 4c06c6d0..ee3c6585 100644 --- a/src/port/UserInterface/PythonNetworkStreamModule.cpp +++ b/src/port/UserInterface/PythonNetworkStreamModule.cpp @@ -635,7 +635,7 @@ PyObject* netSendCreateCharacterPacket(PyObject* poSelf, PyObject* poArgs) if (!PyTuple_GetInteger(poArgs, 7, &stat4)) return Py_BuildException(); - if (index<0 && index>3) + if (index < 0 || index >= PLAYER_PER_ACCOUNT5) return Py_BuildException(); CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance(); @@ -653,7 +653,7 @@ PyObject* netSendDestroyCharacterPacket(PyObject* poSelf, PyObject* poArgs) if (!PyTuple_GetString(poArgs, 1, &szPrivateCode)) return Py_BuildException(); - if (index<0 && index>3) + if (index < 0 || index >= PLAYER_PER_ACCOUNT5) return Py_BuildException(); CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance(); diff --git a/src/port/UserInterface/PythonNetworkStreamPhaseGame.cpp b/src/port/UserInterface/PythonNetworkStreamPhaseGame.cpp index 08ea3f0f..99b0836a 100644 --- a/src/port/UserInterface/PythonNetworkStreamPhaseGame.cpp +++ b/src/port/UserInterface/PythonNetworkStreamPhaseGame.cpp @@ -4606,7 +4606,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 mt20261028", sizeof(kVersionPacket.timestamp)-1); // PORT: revision28 adds the AVA2 conqueror fields (simple player, actor info/update, sungma packet); revision27 adds the Won (cheque) exchange/shop packets; revision26 the AVA2 Cube Renewal packets. + strncpy(kVersionPacket.timestamp, "1215955205 mt20261029", sizeof(kVersionPacket.timestamp)-1); // PORT: revision29 sends five character slots under login success header 32; revision28 adds the AVA2 conqueror fields (simple player, actor info/update, sungma packet); 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 @@ -4620,7 +4620,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, "mt20261028", sizeof(kVersionPacket.timestamp)-1); // PORT: revision28 is backward-compatible with revision24 money. + strncpy(kVersionPacket.timestamp, "mt20261029", sizeof(kVersionPacket.timestamp)-1); // PORT: revision29 is backward-compatible with revision24 money. if (!Send(sizeof(kVersionPacket), &kVersionPacket)) Tracef("SendClientReportPacket Error"); diff --git a/src/port/UserInterface/PythonNetworkStreamPhaseLogin.cpp b/src/port/UserInterface/PythonNetworkStreamPhaseLogin.cpp index 0e62797f..68ce2ab2 100644 --- a/src/port/UserInterface/PythonNetworkStreamPhaseLogin.cpp +++ b/src/port/UserInterface/PythonNetworkStreamPhaseLogin.cpp @@ -185,57 +185,8 @@ bool CPythonNetworkStream::__RecvLoginSuccessPacket3() bool CPythonNetworkStream::__RecvLoginSuccessPacket4() { - if (GetRecvBufferSize() >= (int)sizeof(TPacketGCLoginSuccess5)) - { - TPacketGCLoginSuccess5 kPacket5; - if (Recv(sizeof(kPacket5), &kPacket5)) - { - for (int i = 0; i < PLAYER_PER_ACCOUNT5; ++i) - { - m_akSimplePlayerInfo[i] = kPacket5.akSimplePlayerInformation[i]; - m_adwGuildID[i] = kPacket5.guild_id[i]; - m_astrGuildName[i] = kPacket5.guild_name[i]; - } - - m_kMarkAuth.m_dwHandle = kPacket5.handle; - m_kMarkAuth.m_dwRandomKey = kPacket5.random_key; - - if (!__DirectEnterMode_IsSet()) - { - PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_SELECT], "Refresh", Py_BuildValue("()")); - } - return true; - } - } - - TPacketGCLoginSuccess4 kPacketLoginSuccess; - - if (!Recv(sizeof(kPacketLoginSuccess), &kPacketLoginSuccess)) - return false; - - for (int i = 0; i guild_name[13] inline constexpr int GUILD_GRADE_NAME_MAX_LEN = 8; inline constexpr int GUILD_COMMENT_MAX_LEN = 50; inline constexpr int GUILD_SKILL_MAX_NUM = 12; -inline constexpr int PLAYER_PER_ACCOUNT = 4; // common/length.h +inline constexpr int PLAYER_PER_ACCOUNT = 5; // common/length.h (ENABLE_PLAYER_PER_ACCOUNT5) inline constexpr int PLAYER_PER_ACCOUNT3 = 3; // legacy GC_LOGIN_SUCCESS (hdr 6) inline constexpr int ID_MAX_NUM = 30; // Packet.h -> login[31] inline constexpr int PASS_MAX_NUM = 16; // -> passwd[17] @@ -445,7 +445,7 @@ struct GCLoginSuccessT { // packet_login_success — 40250 sends the NEWSLOT (N= using GCLoginSuccess = GCLoginSuccessT; // header 32 using GCLoginSuccess3 = GCLoginSuccessT; // header 6 (legacy) // 1 + 103*N + 4*N + 13*N + 4 + 4 -static_assert(sizeof(GCLoginSuccess) == 1 + sizeof(SimplePlayer) * 4 + 4 * 4 + 13 * 4 + 4 + 4); // 349 +static_assert(sizeof(GCLoginSuccess) == 1 + sizeof(SimplePlayer) * 5 + 4 * 5 + 13 * 5 + 4 + 4); // 434 static_assert(sizeof(GCLoginSuccess3) == 1 + sizeof(SimplePlayer) * 3 + 4 * 3 + 13 * 3 + 4 + 4); // 264 struct GCLoginFailure { uint8_t header; char status[LOGIN_STATUS_MAX_LEN + 1]; }; diff --git a/tests/port/port_login_flow_test.cpp b/tests/port/port_login_flow_test.cpp index 26b9f4c4..965f0a49 100644 --- a/tests/port/port_login_flow_test.cpp +++ b/tests/port/port_login_flow_test.cpp @@ -2033,15 +2033,15 @@ int main(int argc, char** argv) { // 1. Python 导出验证 CHECK(py("import app, net\n" - "assert app.ENABLE_PLAYER_PER_ACCOUNT5 == 0, 'unsupported fifth slot advertised'\n" + "assert app.ENABLE_PLAYER_PER_ACCOUNT5 == 1, 'fifth slot not advertised'\n" "import introselect\n" - "assert introselect.SelectCharacterWindow.SLOT_COUNT == 4, 'current server supports four slots'\n" - "assert len(introselect.SelectCharacterWindow.SLOT_ROTATION) == 4, 'current selection requires four angles'\n")); + "assert introselect.SelectCharacterWindow.SLOT_COUNT == 5, 'server sends five slots'\n" + "assert len(introselect.SelectCharacterWindow.SLOT_ROTATION) == 5, 'five-slot selection needs five angles'\n")); // 2. 槽位范围与边界安全检查 (0..4 合法, 5 越界) CPythonNetworkStream& stream = CPythonNetworkStream::Instance(); CHECK(stream.GetAccountCharacterSlotDatau(0, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_ID) == 1); // 登录成功包设置的第 1 角色 - CHECK(stream.GetAccountCharacterSlotDatau(4, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_ID) == 0); // 4 槽服务器模式下第 5 槽为空 + CHECK(stream.GetAccountCharacterSlotDatau(4, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_ID) == 0); // 第 5 槽 (slot 4) 在登录成功包中为空 CHECK(std::string(stream.GetAccountCharacterSlotDataz(4, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_NAME)).empty()); CHECK(stream.GetAccountCharacterSlotDatau(5, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_ID) == 0); // 越界槽位安全防御 CHECK(std::string(stream.GetAccountCharacterSlotDataz(5, CPythonNetworkStream::ACCOUNT_CHARACTER_SLOT_NAME)).empty()); diff --git a/tests/port/port_packet_test.cpp b/tests/port/port_packet_test.cpp index 75b70f7a..5e014ad7 100644 --- a/tests/port/port_packet_test.cpp +++ b/tests/port/port_packet_test.cpp @@ -30,7 +30,7 @@ static const WireSize kPortSizes[] = { {"TPacketGCAuthSuccess", sizeof(TPacketGCAuthSuccess)}, {"TSimplePlayerInformation", sizeof(TSimplePlayerInformation)}, {"TPacketGCLoginSuccess3", sizeof(TPacketGCLoginSuccess3)}, - {"TPacketGCLoginSuccess4", sizeof(TPacketGCLoginSuccess4)}, + {"TPacketGCLoginSuccess5", sizeof(TPacketGCLoginSuccess5)}, // header 32 carries five slots {"TPacketGCLoginFailure", sizeof(TPacketGCLoginFailure)}, {"TPacketGCEmpire", sizeof(TPacketGCEmpire)}, {"TPacketCGEmpire", sizeof(TPacketCGEmpire)},