From f01c988094ee53920602a7a296264528095fc9bd Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 25 Mar 2012 18:45:27 +0300 Subject: [PATCH] Some serialization version stuff --- src/game.cpp | 9 +++++++++ src/nodedef.cpp | 31 ++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index d6c9910be..7515af8d9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -991,6 +991,7 @@ void the_game( server->start(port); } + try{ do{ // Client scope (breakable do-while(0)) /* @@ -2911,6 +2912,14 @@ void the_game( // Client scope (client is destructed before destructing *def and tsrc) }while(0); + } // try-catch + catch(SerializationError &e) + { + error_message = L"A serialization error occurred:\n" + + narrow_to_wide(e.what()) + L"\n\nThe server is probably " + L" running a different version of Minetest."; + errorstream<name == "") continue; - writeU16(tmp_os, i); - f->serialize(tmp_os); + writeU16(os2, i); + // Wrap it in a string to allow different lengths without + // strict version incompatibilities + std::ostringstream wrapper_os(std::ios::binary); + f->serialize(wrapper_os); + os2< MAX_CONTENT){ errorstream<<"ContentFeatures::deSerialize(): " <<"Too large content id: "<deSerialize(tmp_is); + // Read it from the string wrapper + std::string wrapper = deSerializeString(is2); + std::istringstream wrapper_is(wrapper, std::ios::binary); + f->deSerialize(wrapper_is); if(f->name != "") addNameIdMapping(i, f->name); } -- 2.25.1