From 1b6e5a9295787f831339262a64bd7f805e966819 Mon Sep 17 00:00:00 2001 From: Zwelf Date: Sat, 9 Nov 2024 22:27:53 +0100 Subject: [PATCH] Fix incomplete Teehistorian chunks being written Save/Load code are up to 65536 bytes long. However, Packer only has a buffer of 2048 bytes. Writing SAVE_SUCCESS and LOAD_SUCCESS chunks likely for saves with 3 or more tees. This increases the buffer size for all packing including networking packets and is therefore probably not the optimal solution. An alternative would be to create an additional packer CLargePacker or make the size a template argument. The suggested change is the simplest fix adding not much complexity, but increases the chance of overrunning the stack size. I'm open to take another approach. --- src/engine/shared/packer.h | 2 +- src/game/server/teehistorian.cpp | 2 +- src/test/teehistorian.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/shared/packer.h b/src/engine/shared/packer.h index 7b633c417..3ee622f6f 100644 --- a/src/engine/shared/packer.h +++ b/src/engine/shared/packer.h @@ -8,7 +8,7 @@ class CPacker public: enum { - PACKER_BUFFER_SIZE = 1024 * 2 + PACKER_BUFFER_SIZE = 1024 * 64 }; private: diff --git a/src/game/server/teehistorian.cpp b/src/game/server/teehistorian.cpp index 3316ae6d9..16c43b290 100644 --- a/src/game/server/teehistorian.cpp +++ b/src/game/server/teehistorian.cpp @@ -10,7 +10,7 @@ static const char TEEHISTORIAN_NAME[] = "teehistorian@ddnet.tw"; static const CUuid TEEHISTORIAN_UUID = CalculateUuid(TEEHISTORIAN_NAME); static const char TEEHISTORIAN_VERSION[] = "2"; -static const char TEEHISTORIAN_VERSION_MINOR[] = "8"; +static const char TEEHISTORIAN_VERSION_MINOR[] = "9"; #define UUID(id, name) static const CUuid UUID_##id = CalculateUuid(name); #include diff --git a/src/test/teehistorian.cpp b/src/test/teehistorian.cpp index 1a42e6f16..3f0964aa7 100644 --- a/src/test/teehistorian.cpp +++ b/src/test/teehistorian.cpp @@ -105,7 +105,7 @@ protected: void Expect(const unsigned char *pOutput, size_t OutputSize) { static CUuid TEEHISTORIAN_UUID = CalculateUuid("teehistorian@ddnet.tw"); - static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"8\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; + static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"9\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; static const char PREFIX2[] = "\",\"server_name\":\"server name\",\"server_port\":\"8303\",\"game_type\":\"game type\",\"map_name\":\"Kobra 3 Solo\",\"map_size\":\"903514\",\"map_sha256\":\"0123456789012345678901234567890123456789012345678901234567890123\",\"map_crc\":\"eceaf25c\",\"prng_description\":\"test-prng:02468ace\",\"config\":{},\"tuning\":{},\"uuids\":["; static const char PREFIX3[] = "]}";