1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

VCAI: add any newly found teleports to knownTeleportChannels

Now all new objects added to visitableObjs only using addVisitableObj so we can catch them for teleports handling.
I also simplified one of retreiveVisitableObjs functions because it's only used for inserting things into visitableObjs.
This commit is contained in:
ArseniyShestakov 2015-03-08 17:38:09 +03:00
parent ab7ad4741a
commit 665712c196
2 changed files with 14 additions and 7 deletions

View File

@ -505,7 +505,7 @@ void VCAI::objectPropertyChanged(const SetObjectProperty * sop)
auto obj = myCb->getObj(sop->id, false);
if (obj)
{
visitableObjs.insert(obj);
addVisitableObj(obj);
erase_if_present(alreadyVisited, obj);
}
}
@ -543,7 +543,7 @@ void VCAI::init(shared_ptr<CCallback> CB)
if(!fh)
fh = new FuzzyHelper();
retreiveVisitableObjs(visitableObjs);
retreiveVisitableObjs();
}
void VCAI::yourTurn()
@ -667,7 +667,7 @@ void VCAI::makeTurn()
{
if (isWeeklyRevisitable(obj))
{
visitableObjs.insert(obj); //set doesn't need duplicate check
addVisitableObj(obj);
erase_if_present (alreadyVisited, obj);
}
}
@ -1552,14 +1552,15 @@ void VCAI::retreiveVisitableObjs(std::vector<const CGObjectInstance *> &out, boo
}
});
}
void VCAI::retreiveVisitableObjs(std::set<const CGObjectInstance *> &out, bool includeOwned /*= false*/) const
void VCAI::retreiveVisitableObjs()
{
foreach_tile_pos([&](const int3 &pos)
{
for(const CGObjectInstance *obj : myCb->getVisitableObjs(pos, false))
{
if(includeOwned || obj->tempOwner != playerID)
out.insert(obj);
addVisitableObj(obj);
}
});
}
@ -1579,6 +1580,11 @@ void VCAI::addVisitableObj(const CGObjectInstance *obj)
{
visitableObjs.insert(obj);
helperObjInfo[obj] = ObjInfo(obj);
// All teleport objects seen automatically assigned to appropriate channels
auto teleportObj = dynamic_cast<const CGTeleport *>(obj);
if(teleportObj)
CGTeleport::addToChannel(knownTeleportChannels, teleportObj);
}
const CGObjectInstance * VCAI::lookForArt(int aid) const

View File

@ -141,6 +141,7 @@ public:
friend class FuzzyHelper;
std::map<TeleportChannelID, shared_ptr<TeleportChannel> > knownTeleportChannels;
std::map<const CGObjectInstance *, const CGObjectInstance *> knownSubterraneanGates;
//std::vector<const CGObjectInstance *> visitedThisWeek; //only OPWs
std::map<HeroPtr, std::set<const CGTownInstance *> > townVisitsThisWeek;
@ -293,7 +294,7 @@ public:
void validateObject(ObjectIdRef obj); //checks if object is still visible and if not, removes references to it
void validateVisitableObjs();
void retreiveVisitableObjs(std::vector<const CGObjectInstance *> &out, bool includeOwned = false) const;
void retreiveVisitableObjs(std::set<const CGObjectInstance *> &out, bool includeOwned = false) const;
void retreiveVisitableObjs();
std::vector<const CGObjectInstance *> getFlaggedObjects() const;
const CGObjectInstance *lookForArt(int aid) const;
@ -346,7 +347,7 @@ public:
template <typename Handler> void serializeInternal(Handler &h, const int version)
{
h & knownSubterraneanGates & townVisitsThisWeek & lockedHeroes & reservedHeroesMap; //FIXME: cannot instantiate abstract class
h & knownTeleportChannels & knownSubterraneanGates & townVisitsThisWeek & lockedHeroes & reservedHeroesMap; //FIXME: cannot instantiate abstract class
h & visitableObjs & alreadyVisited & reservedObjs;
h & saving & status & battlename;
h & heroesUnableToExplore;