Restore legacy FourCC reversal in LOGON_CHALLENGE

This commit is contained in:
Kelsi 2026-02-13 00:43:22 -08:00
parent dc21b08eff
commit d2a2f82542

View file

@ -25,13 +25,14 @@ network::Packet LogonChallengePacket::build(const std::string& account, const Cl
// Payload size // Payload size
packet.writeUInt16(payloadSize); packet.writeUInt16(payloadSize);
// Write a 4-byte ASCII field (FourCC-ish): bytes are sent in-order and null-padded. // Write a FourCC-like 4-byte ASCII field in the legacy login wire format:
// Auth servers expect literal "x86\0", "Win\0", "enUS", etc (not reversed). // reverse the characters and null-pad to 4 bytes.
auto writeFourCC = [&packet](const std::string& str) { // Example (1.12.1): platform "x86" is sent as bytes "68x\\0"; os "Win" as "niW\\0"; locale "enGB" as "BGne".
auto writeFourCCLE = [&packet](const std::string& str) {
uint8_t buf[4] = {0, 0, 0, 0}; uint8_t buf[4] = {0, 0, 0, 0};
size_t len = std::min<size_t>(4, str.length()); size_t len = std::min<size_t>(4, str.length());
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
buf[i] = static_cast<uint8_t>(str[i]); buf[i] = static_cast<uint8_t>(str[len - 1 - i]);
} }
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
packet.writeUInt8(buf[i]); packet.writeUInt8(buf[i]);
@ -58,14 +59,14 @@ network::Packet LogonChallengePacket::build(const std::string& account, const Cl
// Build (2 bytes) // Build (2 bytes)
packet.writeUInt16(info.build); packet.writeUInt16(info.build);
// Platform (4 bytes) // Platform (4 bytes, legacy reversed encoding)
writeFourCC(info.platform); writeFourCCLE(info.platform);
// OS (4 bytes) // OS (4 bytes, legacy reversed encoding)
writeFourCC(info.os); writeFourCCLE(info.os);
// Locale (4 bytes) // Locale (4 bytes, legacy reversed encoding)
writeFourCC(info.locale); writeFourCCLE(info.locale);
// Timezone // Timezone
packet.writeUInt32(info.timezone); packet.writeUInt32(info.timezone);