From: Perttu Ahola Date: Sun, 25 Mar 2012 15:45:27 +0000 (+0300) Subject: Some serialization version stuff X-Git-Tag: 0.4.dev-20120326~18 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f01c988094ee53920602a7a296264528095fc9bd;p=oweals%2Fminetest.git Some serialization version stuff --- 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); }