// 批次 2V1: the ported 40250 UserInterface/Packet.h against the classic wire layouts in net/classic/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 #include 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)}, {"TPacketGCLoginSuccess4", sizeof(TPacketGCLoginSuccess4)}, {"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; }