From 55c8f225f2cce71dd3a5d44e990ed76043a61ba6 Mon Sep 17 00:00:00 2001 From: Sais Date: Sat, 25 Jul 2026 02:19:32 -0400 Subject: [PATCH] Use fixed-width counts in the NetworkId and Unicode packed maps These three AutoDeltaPackedMap specializations wrote their command count as int32 but wrote the baseline count, and read both counts, as size_t. Under ILP32 size_t was 4 bytes so pack and unpack agreed. Under LP64 size_t binds to the 8-byte uint64 Archive overload, so pack writes 4+8 bytes while unpack reads 8+8 and leaves the stream misaligned by 4 bytes for every subsequent key and value. Switch both counts to int32_t, matching the generic internal_pack/ internal_unpack path and the already-converted PlayerQuestData specialization. This also keeps the serialized form identical to the 32-bit server, so data written by either architecture stays readable by the other. --- .../src/shared/AutoDeltaNetworkIdPackedMap.h | 10 +++++----- .../src/shared/NetworkIdAutoDeltaPackedMap.cpp | 10 +++++----- .../src/shared/UnicodeAutoDeltaPackedMap.cpp | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/engine/shared/library/sharedFoundation/src/shared/AutoDeltaNetworkIdPackedMap.h b/engine/shared/library/sharedFoundation/src/shared/AutoDeltaNetworkIdPackedMap.h index 62d073ad..eeed4ede 100755 --- a/engine/shared/library/sharedFoundation/src/shared/AutoDeltaNetworkIdPackedMap.h +++ b/engine/shared/library/sharedFoundation/src/shared/AutoDeltaNetworkIdPackedMap.h @@ -32,8 +32,8 @@ namespace Archive char temp[200]; AutoDeltaMap::Command c; - Archive::put(target, countCharacter(buffer,':')); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(countCharacter(buffer,':'))); + Archive::put(target, static_cast(0)); // baselineCommandCount int tempPos = 0; for (std::string::const_iterator i=buffer.begin(); i!=buffer.end(); ++i) @@ -64,8 +64,8 @@ namespace Archive char temp[200]; AutoDeltaMap::Command c; - size_t commandCount; - size_t baselineCommandCount; + int32_t commandCount; + int32_t baselineCommandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); @@ -76,7 +76,7 @@ namespace Archive } else { - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); Archive::get(source, c.key); diff --git a/engine/shared/library/sharedUtility/src/shared/NetworkIdAutoDeltaPackedMap.cpp b/engine/shared/library/sharedUtility/src/shared/NetworkIdAutoDeltaPackedMap.cpp index d1ba7a66..6e4c58fe 100755 --- a/engine/shared/library/sharedUtility/src/shared/NetworkIdAutoDeltaPackedMap.cpp +++ b/engine/shared/library/sharedUtility/src/shared/NetworkIdAutoDeltaPackedMap.cpp @@ -21,8 +21,8 @@ namespace Archive char value[200]; Command c; - Archive::put(target, countCharacter(buffer,':')); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(countCharacter(buffer,':'))); + Archive::put(target, static_cast(0)); // baselineCommandCount int tempPos = 0; for (std::string::const_iterator i=buffer.begin(); i!=buffer.end(); ++i) @@ -52,8 +52,8 @@ namespace Archive char temp[200]; Command c; - size_t commandCount; - size_t baselineCommandCount; + int32_t commandCount; + int32_t baselineCommandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); @@ -64,7 +64,7 @@ namespace Archive } else { - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); Archive::get(source, c.key); diff --git a/external/ours/library/unicodeArchive/src/shared/UnicodeAutoDeltaPackedMap.cpp b/external/ours/library/unicodeArchive/src/shared/UnicodeAutoDeltaPackedMap.cpp index 8138fdbb..513d0690 100755 --- a/external/ours/library/unicodeArchive/src/shared/UnicodeAutoDeltaPackedMap.cpp +++ b/external/ours/library/unicodeArchive/src/shared/UnicodeAutoDeltaPackedMap.cpp @@ -21,8 +21,8 @@ namespace Archive char temp[200]; Command c; - Archive::put(target, countCharacter(buffer,':')); - Archive::put(target, static_cast(0)); // baselineCommandCount + Archive::put(target, static_cast(countCharacter(buffer,':'))); + Archive::put(target, static_cast(0)); // baselineCommandCount int tempPos = 0; for (std::string::const_iterator i=buffer.begin(); i!=buffer.end(); ++i) @@ -55,8 +55,8 @@ namespace Archive char temp[200]; Command c; - size_t commandCount; - size_t baselineCommandCount; + int32_t commandCount; + int32_t baselineCommandCount; Archive::get(source, commandCount); Archive::get(source, baselineCommandCount); @@ -67,7 +67,7 @@ namespace Archive } else { - for (size_t i = 0; i < commandCount; ++i) + for (int32_t i = 0; i < commandCount; ++i) { Archive::get(source, c.cmd); assert(c.cmd == Command::ADD); // only add is valid in unpack