1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

finished removing thread local from NK2

This commit is contained in:
Mircea TheHonestCTO
2025-09-12 19:25:56 +02:00
parent 2f1c6946e3
commit b8eb49bc82
25 changed files with 117 additions and 264 deletions

View File

@@ -30,38 +30,27 @@ namespace NK2AI
const CGObjectInstance * ObjectIdRef::operator->() const
{
return ccTl->getObj(id, false);
return cpsic->getObj(id, false);
}
ObjectIdRef::operator const CGObjectInstance *() const
{
return ccTl->getObj(id, false);
return cpsic->getObj(id, false);
}
ObjectIdRef::operator bool() const
{
return ccTl->getObj(id, false);
return cpsic->getObj(id, false);
}
ObjectIdRef::ObjectIdRef(ObjectInstanceID _id)
: id(_id)
{
}
ObjectIdRef::ObjectIdRef(const CGObjectInstance * obj)
: id(obj->id)
{
}
ObjectIdRef::ObjectIdRef(ObjectInstanceID id, const CPlayerSpecificInfoCallback * cpsic) : id(id), cpsic(cpsic) {}
bool ObjectIdRef::operator<(const ObjectIdRef & rhs) const
{
return id < rhs.id;
}
HeroPtr::HeroPtr(const CGHeroInstance * input, std::shared_ptr<CPlayerSpecificInfoCallback> cpsic)
: hero(input), cpsic(cpsic)
{
}
HeroPtr::HeroPtr(const CGHeroInstance * input, const CPlayerSpecificInfoCallback * cpsic) : hero(input), cpsic(cpsic) {}
bool HeroPtr::operator<(const HeroPtr & rhs) const
{
@@ -181,22 +170,6 @@ bool isObjectRemovable(const CGObjectInstance * obj)
}
}
bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
{
// TODO: Such information should be provided by pathfinder
// Tile must be free or with unoccupied boat
if(!t->blocked())
{
return true;
}
else if(!fromWater) // do not try to board when in water sector
{
if(t->visitableObjects.size() == 1 && ccTl->getObjInstance(t->topVisitableObj())->ID == Obj::BOAT)
return true;
}
return false;
}
bool isObjectPassable(const Nullkiller * aiNk, const CGObjectInstance * obj)
{
return isObjectPassable(obj, aiNk->playerID, aiNk->cc->getPlayerRelations(obj->tempOwner, aiNk->playerID));
@@ -220,17 +193,6 @@ bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, Pla
return false;
}
bool isBlockVisitObj(const int3 & pos)
{
if(auto obj = ccTl->getTopObj(pos))
{
if(obj->isBlockedVisitable()) //we can't stand on that object
return true;
}
return false;
}
creInfo infoFromDC(const dwellingContent & dc)
{
creInfo ci;