1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00

Fixed AI-exploration-data being lost after loading savegame

The information of whether objects like a redwood-observatory or subterranian gates have been interacted with by the AI will now be retrieved from the game-state instead of using an AI-internal memory that won't survive loading a save-game.
This commit is contained in:
Xilmi 2024-07-07 22:08:19 +02:00
parent 54c6d99de3
commit e0a81b3e69

View File

@ -35,44 +35,29 @@ Goals::TGoalVec ExplorationBehavior::decompose(const Nullkiller * ai) const
for(auto obj : ai->memory->visitableObjs) for(auto obj : ai->memory->visitableObjs)
{ {
if(!vstd::contains(ai->memory->alreadyVisited, obj)) switch (obj->ID.num)
{ {
switch(obj->ID.num) case Obj::REDWOOD_OBSERVATORY:
case Obj::PILLAR_OF_FIRE:
{ {
case Obj::REDWOOD_OBSERVATORY: auto rObj = dynamic_cast<const CRewardableObject*>(obj);
case Obj::PILLAR_OF_FIRE: if(!rObj->wasScouted(ai->playerID))
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 200)).addNext(CaptureObject(obj)))); tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 200)).addNext(CaptureObject(obj))));
break;
case Obj::MONOLITH_ONE_WAY_ENTRANCE:
case Obj::MONOLITH_TWO_WAY:
case Obj::SUBTERRANEAN_GATE:
auto tObj = dynamic_cast<const CGTeleport *>(obj);
if(TeleportChannel::IMPASSABLE != ai->memory->knownTeleportChannels[tObj->channel]->passability)
{
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj))));
}
break; break;
} }
} case Obj::MONOLITH_ONE_WAY_ENTRANCE:
else case Obj::MONOLITH_TWO_WAY:
{ case Obj::SUBTERRANEAN_GATE:
switch(obj->ID.num)
{ {
case Obj::MONOLITH_TWO_WAY: auto tObj = dynamic_cast<const CGTeleport*>(obj);
case Obj::SUBTERRANEAN_GATE: for (auto exit : cb->getTeleportChannelExits(tObj->channel))
auto tObj = dynamic_cast<const CGTeleport *>(obj);
if(TeleportChannel::IMPASSABLE == ai->memory->knownTeleportChannels[tObj->channel]->passability)
break;
for(auto exit : ai->memory->knownTeleportChannels[tObj->channel]->exits)
{ {
if(!cb->getObj(exit)) if (exit != tObj->id)
{ {
// Always attempt to visit two-way teleports if one of channel exits is not visible if (!cb->isVisible(cb->getObjInstance(exit)))
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj)))); tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj))));
break;
} }
} }
break;
} }
} }
} }