From 166c04e2e0ddd53e2af1fdfdc816ff66353cbe2b Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 25 Feb 2018 10:31:17 +0300 Subject: [PATCH] Hack fixed serializer assertion by completely disabling AI goals serialization --- AI/VCAI/VCAI.cpp | 6 ++++++ AI/VCAI/VCAI.h | 44 ++++++++++++++++++++++++++++++++++++++ client/VCMI_client.cbp | 1 - lib/serializer/CTypeList.h | 3 ++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 762678a79..fc6819279 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -714,7 +714,10 @@ void VCAI::saveGame(BinarySerializer & h, const int version) NET_EVENT_HANDLER; validateVisitableObjs(); + #if 0 + //disabled due to issue 2890 registerGoals(h); + #endif // 0 CAdventureAI::saveGame(h, version); serializeInternal(h, version); } @@ -724,7 +727,10 @@ void VCAI::loadGame(BinaryDeserializer & h, const int version) LOG_TRACE_PARAMS(logAi, "version '%i'", version); NET_EVENT_HANDLER; + #if 0 + //disabled due to issue 2890 registerGoals(h); + #endif // 0 CAdventureAI::loadGame(h, version); serializeInternal(h, version); } diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index 06b1f8478..98ac5a1dc 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -327,6 +327,8 @@ public: //special function that can be called ONLY from game events handling thread and will send request ASAP void requestActionASAP(std::function whatToDo); + #if 0 + //disabled due to issue 2890 template void registerGoals(Handler &h) { //h.template registerType(); @@ -350,6 +352,7 @@ public: h.template registerType(); h.template registerType(); } + #endif template void serializeInternal(Handler &h, const int version) { @@ -357,7 +360,48 @@ public: h & knownSubterraneanGates; h & destinationTeleport; h & townVisitsThisWeek; + + #if 0 + //disabled due to issue 2890 h & lockedHeroes; + #else + { + ui32 length = 0; + h & length; + if(!h.saving) + { + std::set loadedPointers; + lockedHeroes.clear(); + for(ui32 index = 0; index < length; index++) + { + HeroPtr ignored1; + h & ignored1; + + ui8 flag = 0; + h & flag; + + if(flag) + { + ui32 pid = 0xffffffff; + h & pid; + + if(!vstd::contains(loadedPointers, pid)) + { + loadedPointers.insert(pid); + + ui16 typeId = 0; + //this is the problem requires such hack + //we have to explicitly ignore invalid goal class type id + h & typeId; + Goals::AbstractGoal ignored2; + ignored2.serialize(h, version); + } + } + } + } + } + #endif + h & reservedHeroesMap; //FIXME: cannot instantiate abstract class h & visitableObjs; h & alreadyVisited; diff --git a/client/VCMI_client.cbp b/client/VCMI_client.cbp index d1a8e725d..d760e65cf 100644 --- a/client/VCMI_client.cbp +++ b/client/VCMI_client.cbp @@ -13,7 +13,6 @@