1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Hack fixed serializer assertion by completely disabling AI goals serialization

This commit is contained in:
AlexVinS
2018-02-25 10:31:17 +03:00
committed by ArseniyShestakov
parent 3c67e12620
commit 166c04e2e0
4 changed files with 52 additions and 2 deletions

View File

@@ -714,7 +714,10 @@ void VCAI::saveGame(BinarySerializer & h, const int version)
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
validateVisitableObjs(); validateVisitableObjs();
#if 0
//disabled due to issue 2890
registerGoals(h); registerGoals(h);
#endif // 0
CAdventureAI::saveGame(h, version); CAdventureAI::saveGame(h, version);
serializeInternal(h, version); serializeInternal(h, version);
} }
@@ -724,7 +727,10 @@ void VCAI::loadGame(BinaryDeserializer & h, const int version)
LOG_TRACE_PARAMS(logAi, "version '%i'", version); LOG_TRACE_PARAMS(logAi, "version '%i'", version);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
#if 0
//disabled due to issue 2890
registerGoals(h); registerGoals(h);
#endif // 0
CAdventureAI::loadGame(h, version); CAdventureAI::loadGame(h, version);
serializeInternal(h, version); serializeInternal(h, version);
} }

View File

@@ -327,6 +327,8 @@ public:
//special function that can be called ONLY from game events handling thread and will send request ASAP //special function that can be called ONLY from game events handling thread and will send request ASAP
void requestActionASAP(std::function<void()> whatToDo); void requestActionASAP(std::function<void()> whatToDo);
#if 0
//disabled due to issue 2890
template <typename Handler> void registerGoals(Handler &h) template <typename Handler> void registerGoals(Handler &h)
{ {
//h.template registerType<Goals::AbstractGoal, Goals::BoostHero>(); //h.template registerType<Goals::AbstractGoal, Goals::BoostHero>();
@@ -350,6 +352,7 @@ public:
h.template registerType<Goals::AbstractGoal, Goals::VisitTile>(); h.template registerType<Goals::AbstractGoal, Goals::VisitTile>();
h.template registerType<Goals::AbstractGoal, Goals::Win>(); h.template registerType<Goals::AbstractGoal, Goals::Win>();
} }
#endif
template <typename Handler> void serializeInternal(Handler &h, const int version) template <typename Handler> void serializeInternal(Handler &h, const int version)
{ {
@@ -357,7 +360,48 @@ public:
h & knownSubterraneanGates; h & knownSubterraneanGates;
h & destinationTeleport; h & destinationTeleport;
h & townVisitsThisWeek; h & townVisitsThisWeek;
#if 0
//disabled due to issue 2890
h & lockedHeroes; h & lockedHeroes;
#else
{
ui32 length = 0;
h & length;
if(!h.saving)
{
std::set<ui32> 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 & reservedHeroesMap; //FIXME: cannot instantiate abstract class
h & visitableObjs; h & visitableObjs;
h & alreadyVisited; h & alreadyVisited;

View File

@@ -13,7 +13,6 @@
<Option object_output="../obj/Client/Debug/x86" /> <Option object_output="../obj/Client/Debug/x86" />
<Option type="1" /> <Option type="1" />
<Option compiler="gcc" /> <Option compiler="gcc" />
<Option parameters="--donotstartserver" />
<Compiler> <Compiler>
<Add option="-Og" /> <Add option="-Og" />
<Add option="-g" /> <Add option="-g" />

View File

@@ -215,7 +215,8 @@ class CApplier : boost::noncopyable
public: public:
T * getApplier(ui16 ID) T * getApplier(ui16 ID)
{ {
assert(apps.count(ID)); if(!apps.count(ID))
throw std::runtime_error("No applier found.");
return apps[ID].get(); return apps[ID].get();
} }