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.
This commit is contained in:
Sais
2026-07-25 03:52:43 -04:00
parent 8fbee78517
commit 55c8f225f2
3 changed files with 15 additions and 15 deletions
@@ -32,8 +32,8 @@ namespace Archive
char temp[200];
AutoDeltaMap<NetworkId, int>::Command c;
Archive::put(target, countCharacter(buffer,':'));
Archive::put(target, static_cast<size_t>(0)); // baselineCommandCount
Archive::put(target, static_cast<int32_t>(countCharacter(buffer,':')));
Archive::put(target, static_cast<int32_t>(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<NetworkId, int>::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);
@@ -21,8 +21,8 @@ namespace Archive
char value[200];
Command c;
Archive::put(target, countCharacter(buffer,':'));
Archive::put(target, static_cast<size_t>(0)); // baselineCommandCount
Archive::put(target, static_cast<int32_t>(countCharacter(buffer,':')));
Archive::put(target, static_cast<int32_t>(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);
@@ -21,8 +21,8 @@ namespace Archive
char temp[200];
Command c;
Archive::put(target, countCharacter(buffer,':'));
Archive::put(target, static_cast<size_t>(0)); // baselineCommandCount
Archive::put(target, static_cast<int32_t>(countCharacter(buffer,':')));
Archive::put(target, static_cast<int32_t>(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