From 43377fdc5e8faec7235d9d7173ff8fcb6afeef74 Mon Sep 17 00:00:00 2001 From: Yves Date: Sat, 22 Feb 2014 14:30:29 +0000 Subject: [PATCH] Fixes an assertion when DEBUG_SERIALIZER_ANNOTATE is set to 1 and you click on "Host Game" from the main menu. The reason was that CSimulationMessage uses the CBufferBinarySerializer which did not add debugging annotations and deserialized the created data with the CStdDeserializer which expects these annotations. I did not fix the tests which remain broken as before this patch when annotation is enabled. This was SVN commit r14775. --- source/network/NetMessageSim.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/network/NetMessageSim.cpp b/source/network/NetMessageSim.cpp index 5ff765c47a..ef71c659a7 100644 --- a/source/network/NetMessageSim.cpp +++ b/source/network/NetMessageSim.cpp @@ -23,6 +23,7 @@ #include "scriptinterface/ScriptInterface.h" #include "simulation2/serialization/BinarySerializer.h" #include "simulation2/serialization/StdDeserializer.h" +#include "simulation2/serialization/StdSerializer.h" // for DEBUG_SERIALIZER_ANNOTATE #include @@ -34,8 +35,17 @@ public: { } - void Put(const char* UNUSED(name), const u8* data, size_t len) + void Put(const char* name, const u8* data, size_t len) { + #if DEBUG_SERIALIZER_ANNOTATE + std::string tag = "<"; + tag.append(name); + tag.append(">"); + memcpy(m_Buffer, tag.c_str(), tag.length()); + m_Buffer += tag.length(); + #else + UNUSED2(name); + #endif memcpy(m_Buffer, data, len); m_Buffer += len; } @@ -68,8 +78,14 @@ public: { } - void Put(const char* UNUSED(name), const u8* UNUSED(data), size_t len) + void Put(const char* name, const u8* UNUSED(data), size_t len) { + #if DEBUG_SERIALIZER_ANNOTATE + m_Length += 2; // '<' and '>' + m_Length += strlen(name); + #else + UNUSED2(name); + #endif m_Length += len; }