From 344783efb5a73487249d5c3e3eb95ca9e6d05a97 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sat, 28 Dec 2013 16:39:47 +0000 Subject: [PATCH] An attempt to handle spawning objects. However, on a day of double growth, when multiple monsters spawn, game freezes. Looks like engine issue, code is commented out. --- AI/VCAI/VCAI.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index f32b3e2f6..ed821cb1d 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -358,6 +358,25 @@ void VCAI::newObject(const CGObjectInstance * obj) NET_EVENT_HANDLER; if(obj->isVisitable()) addVisitableObj(obj); + + //AI should reconsider strategy when spawning monsters block the way and free reserved objects + + //FIXME: AI tends to freeze forever on a week of double growth if this code is active + //auto safeCopy = reservedHeroesMap; + //for (auto hero : safeCopy) + //{ + // auto h = hero.first; + // for (auto reservedObj : hero.second) + // { + // auto pos = reservedObj->visitablePos(); + // if (!(isAccessibleForHero(pos, h) && isSafeToVisit(h, pos))) + // { + // erase_if_present (reservedObjs, reservedObj); + // for(auto &p : reservedHeroesMap) + // erase_if_present (p.second, reservedObj); + // } + // } + //} } void VCAI::objectRemoved(const CGObjectInstance *obj)