Files
metin2-client/tests/port/port_packet_test.cpp
T
shenleiandClaude Opus 5.5 1757643b07 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>
2026-10-24 20:33:51 +09:00

78 lines
3.4 KiB
C++

// 批次 2V1: the ported 40250 UserInterface/Packet.h against the classic wire layouts in wire_classic.h,
// which the mtnet backend checked 1:1 against the 40250 server on 192.168.21.203. Win32 `long` is 32 bits and
// Packet.h now says LONG; a 64-bit long, or a missing #pragma pack(1), shows up here as a size mismatch.
// Covers the packets the login/select/loading phases send and read. The two headers cannot share a translation unit
// (Packet.h's macros such as SKILL_MAX_NUM collide with wire_classic.h's constants), so the wire sizes come from
// port_packet_test_wire.cpp.
#include "UserInterface/StdAfx.h"
#include "UserInterface/Packet.h"
#include <cstdio>
#include <cstddef>
struct WireSize { const char* name; std::size_t size; };
extern const WireSize kWireSizes[];
static const WireSize kPortSizes[] = {
// HandShake phase
{"TPacketGCHandshake", sizeof(TPacketGCHandshake)},
{"TPacketGCPhase", sizeof(TPacketGCPhase)},
{"TPacketGCBindUDP", sizeof(TPacketGCBindUDP)},
{"TPacketKeyAgreement", sizeof(TPacketKeyAgreement)},
{"TPacketKeyAgreementCompleted", sizeof(TPacketKeyAgreementCompleted)},
{"TPacketGCPing", sizeof(TPacketGCPing)},
{"TPacketCGPong", sizeof(TPacketCGPong)},
// Login phase (and the auth server, CAccountConnector)
{"TPacketCGLogin", sizeof(TPacketCGLogin)},
{"TPacketCGLogin2", sizeof(TPacketCGLogin2)},
{"TPacketCGLogin3", sizeof(TPacketCGLogin3)},
{"TPacketGCLoginKey", sizeof(TPacketGCLoginKey)},
{"TPacketGCAuthSuccess", sizeof(TPacketGCAuthSuccess)},
{"TSimplePlayerInformation", sizeof(TSimplePlayerInformation)},
{"TPacketGCLoginSuccess3", sizeof(TPacketGCLoginSuccess3)},
{"TPacketGCLoginSuccess5", sizeof(TPacketGCLoginSuccess5)}, // header 32 carries five slots
{"TPacketGCLoginFailure", sizeof(TPacketGCLoginFailure)},
{"TPacketGCEmpire", sizeof(TPacketGCEmpire)},
{"TPacketCGEmpire", sizeof(TPacketCGEmpire)},
// Select phase
{"TPacketCGSelectCharacter", sizeof(TPacketCGSelectCharacter)},
{"TPacketCGCreateCharacter", sizeof(TPacketCGCreateCharacter)},
{"TPacketCGDestroyCharacter", sizeof(TPacketCGDestroyCharacter)},
{"TPacketCGChangeName", sizeof(TPacketCGChangeName)},
{"TPacketGCPlayerCreateSuccess", sizeof(TPacketGCPlayerCreateSuccess)},
{"TPacketGCCreateFailure", sizeof(TPacketGCCreateFailure)},
{"TPacketGCDestroyCharacterSuccess", sizeof(TPacketGCDestroyCharacterSuccess)},
{"TPacketGCChangeName", sizeof(TPacketGCChangeName)},
// Loading phase
{"TPacketGCMainCharacter", sizeof(TPacketGCMainCharacter)},
{"TPacketGCMainCharacter2_EMPIRE", sizeof(TPacketGCMainCharacter2_EMPIRE)},
{"TPacketGCMainCharacter3_BGM", sizeof(TPacketGCMainCharacter3_BGM)},
{"TPacketGCMainCharacter4_BGM_VOL", sizeof(TPacketGCMainCharacter4_BGM_VOL)},
{"TPacketGCPoints", sizeof(TPacketGCPoints)},
{"TPacketGCPointChange", sizeof(TPacketGCPointChange)},
{"TPacketGCItemSet2", sizeof(TPacketGCItemSet2)},
{"TPacketGCQuickSlotAdd", sizeof(TPacketGCQuickSlotAdd)},
{"TPacketGCCharacterUpdate", sizeof(TPacketGCCharacterUpdate)},
{"TPacketCGClientVersion2", sizeof(TPacketCGClientVersion2)},
{"TPacketCGEnterFrontGame", sizeof(TPacketCGEnterFrontGame)},
{nullptr, 0},
};
int main()
{
int failures = 0;
for (int i = 0; kPortSizes[i].name; ++i)
{
if (kPortSizes[i].size != kWireSizes[i].size)
{
std::fprintf(stderr, "%s is %zu bytes, %s is %zu\n", kPortSizes[i].name, kPortSizes[i].size,
kWireSizes[i].name, kWireSizes[i].size);
++failures;
}
}
if (failures)
return 1;
std::printf("port_packet_test: ok\n");
return 0;
}