From 6dfff83589bc727d08991c7e592d31ca93439234 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 14 Nov 2020 14:17:44 +0800 Subject: [PATCH] Need to start PACKED at 4 bits to get the full 64 bits value range encoded, use nullable for better 0 compression --- nel/src/misc/cdb_leaf.cpp | 2 +- .../player_manager/cdb_synchronised.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nel/src/misc/cdb_leaf.cpp b/nel/src/misc/cdb_leaf.cpp index 3b7e86d70..33d21ec2e 100644 --- a/nel/src/misc/cdb_leaf.cpp +++ b/nel/src/misc/cdb_leaf.cpp @@ -150,7 +150,7 @@ inline uint readPackedBitCount(CBitMemStream & f) { uint64 nibbleCount; f.serial(nibbleCount, 4); - uint bits = (nibbleCount << 2); + uint bits = (nibbleCount << 2) + 4; // nlinfo("PACKED: %u bits", (uint32)(bits)); return bits; } diff --git a/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.cpp b/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.cpp index 3e9327231..99805ee44 100644 --- a/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.cpp @@ -519,7 +519,7 @@ bool CCDBSynchronised::writePermanentDelta( NLMISC::CBitMemStream& s ) inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, uint &bits ) { // fast count of max bit - uint32 next = (uint32)(value >> 32); + uint32 next = (uint32)(value >> (32 + 4)); uint32 test; bits = 0; if (next) // 64bit @@ -529,7 +529,7 @@ inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, ui } else { - test = (uint32)(value & 0xFFFFFFFF); // 32 lsb + test = (uint32)((value >> 4) & 0xFFFFFFFF); // 32 lsb } next = (test >> 16); if (next) @@ -562,6 +562,7 @@ inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, ui } uint64 nibbleCount = (bits >> 2); s.serialAndLog2( nibbleCount, 4 ); + bits += 4; s.serialAndLog2( value, bits ); bitsize += (4 + bits); }