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
<map>_point.txt, which read past the token vector and crashed a warp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-24 20:33:51 +09:00
co-authored by Claude Opus 5.5
parent da26f52df5
commit 1757643b07
9 changed files with 19 additions and 76 deletions
@@ -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);
+3
View File
@@ -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();
+2 -13
View File
@@ -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)
@@ -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();
@@ -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");
@@ -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<PLAYER_PER_ACCOUNT4; ++i)
{
m_akSimplePlayerInfo[i]=kPacketLoginSuccess.akSimplePlayerInformation[i];
m_adwGuildID[i]=kPacketLoginSuccess.guild_id[i];
m_astrGuildName[i]=kPacketLoginSuccess.guild_name[i];
}
memset(&m_akSimplePlayerInfo[4], 0, sizeof(m_akSimplePlayerInfo[4]));
m_adwGuildID[4] = 0;
m_astrGuildName[4] = "";
m_kMarkAuth.m_dwHandle=kPacketLoginSuccess.handle;
m_kMarkAuth.m_dwRandomKey=kPacketLoginSuccess.random_key;
if (__DirectEnterMode_IsSet())
{
}
else
{
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_SELECT], "Refresh", Py_BuildValue("()"));
}
return true;
// PORT: header 32 carries PLAYER_PER_ACCOUNT5 slots (AVA2 HEADER_GC_LOGIN_SUCCESS_NEWSLOT).
return __RecvLoginSuccessPacket5();
}
bool CPythonNetworkStream::__RecvLoginSuccessPacket5()
+2 -2
View File
@@ -37,7 +37,7 @@ inline constexpr int GUILD_NAME_MAX_LEN = 12; // -> 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<PLAYER_PER_ACCOUNT>; // header 32
using GCLoginSuccess3 = GCLoginSuccessT<PLAYER_PER_ACCOUNT3>; // 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]; };
+4 -4
View File
@@ -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());
+1 -1
View File
@@ -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)},