mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-01 23:12:49 +02:00
PlayerState now stores all objects owned by player
This commit is contained in:
@@ -237,7 +237,7 @@ void CGameInfoCallback::getThievesGuildInfo(SThievesGuildInfo & thi, const CGObj
|
||||
if(obj->ID == Obj::TOWN || obj->ID == Obj::TAVERN)
|
||||
{
|
||||
int taverns = 0;
|
||||
for(auto town : gs->players[*getPlayerID()].towns)
|
||||
for(auto town : gs->players[*getPlayerID()].getTowns())
|
||||
{
|
||||
if(town->hasBuilt(BuildingID::TAVERN))
|
||||
taverns++;
|
||||
@@ -256,7 +256,7 @@ void CGameInfoCallback::getThievesGuildInfo(SThievesGuildInfo & thi, const CGObj
|
||||
int CGameInfoCallback::howManyTowns(PlayerColor Player) const
|
||||
{
|
||||
ERROR_RET_VAL_IF(!hasAccess(Player), "Access forbidden!", -1);
|
||||
return static_cast<int>(gs->players[Player].towns.size());
|
||||
return static_cast<int>(gs->players[Player].getTowns().size());
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::getTownInfo(const CGObjectInstance * town, InfoAboutTown & dest, const CGObjectInstance * selectedObject) const
|
||||
@@ -609,7 +609,7 @@ EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, Bu
|
||||
const PlayerState *ps = getPlayerState(t->tempOwner, false);
|
||||
if(ps)
|
||||
{
|
||||
for(const CGTownInstance *town : ps->towns)
|
||||
for(const CGTownInstance *town : ps->getTowns())
|
||||
{
|
||||
if(town->hasBuilt(BuildingID::CAPITOL))
|
||||
{
|
||||
@@ -711,9 +711,9 @@ int CGameInfoCallback::getHeroCount( PlayerColor player, bool includeGarrisoned
|
||||
ERROR_RET_VAL_IF(!p, "No such player!", -1);
|
||||
|
||||
if(includeGarrisoned)
|
||||
return static_cast<int>(p->heroes.size());
|
||||
return static_cast<int>(p->getHeroes().size());
|
||||
else
|
||||
for(const auto & elem : p->heroes)
|
||||
for(const auto & elem : p->getHeroes())
|
||||
if(!elem->inTownGarrison)
|
||||
ret++;
|
||||
return ret;
|
||||
@@ -757,7 +757,7 @@ std::vector < const CGTownInstance *> CPlayerSpecificInfoCallback::getTownsInfo(
|
||||
auto ret = std::vector < const CGTownInstance *>();
|
||||
for(const auto & i : gs->players)
|
||||
{
|
||||
for(const auto & town : i.second.towns)
|
||||
for(const auto & town : i.second.getTowns())
|
||||
{
|
||||
if(i.first == getPlayerID() || (!onlyOur && isVisible(town, getPlayerID())))
|
||||
{
|
||||
@@ -789,7 +789,7 @@ int CPlayerSpecificInfoCallback::getHeroSerial(const CGHeroInstance * hero, bool
|
||||
return -1;
|
||||
|
||||
size_t index = 0;
|
||||
auto & heroes = gs->players[*getPlayerID()].heroes;
|
||||
const auto & heroes = gs->players[*getPlayerID()].getHeroes();
|
||||
|
||||
for (auto & possibleHero : heroes)
|
||||
{
|
||||
@@ -835,7 +835,7 @@ std::vector < const CGDwelling * > CPlayerSpecificInfoCallback::getMyDwellings()
|
||||
{
|
||||
ASSERT_IF_CALLED_WITH_PLAYER
|
||||
std::vector < const CGDwelling * > ret;
|
||||
for(CGDwelling * dw : gs->getPlayerState(*getPlayerID())->dwellings)
|
||||
for(const CGDwelling * dw : gs->getPlayerState(*getPlayerID())->getDwellings())
|
||||
{
|
||||
ret.push_back(dw);
|
||||
}
|
||||
@@ -867,12 +867,12 @@ const CGHeroInstance* CPlayerSpecificInfoCallback::getHeroBySerial(int serialId,
|
||||
|
||||
if (!includeGarrisoned)
|
||||
{
|
||||
for(ui32 i = 0; i < p->heroes.size() && static_cast<int>(i) <= serialId; i++)
|
||||
if(p->heroes[i]->inTownGarrison)
|
||||
for(ui32 i = 0; i < p->getHeroes().size() && static_cast<int>(i) <= serialId; i++)
|
||||
if(p->getHeroes()[i]->inTownGarrison)
|
||||
serialId++;
|
||||
}
|
||||
ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->heroes.size(), "No player info", nullptr);
|
||||
return p->heroes[serialId];
|
||||
ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->getHeroes().size(), "No player info", nullptr);
|
||||
return p->getHeroes()[serialId];
|
||||
}
|
||||
|
||||
const CGTownInstance* CPlayerSpecificInfoCallback::getTownBySerial(int serialId) const
|
||||
@@ -880,8 +880,8 @@ const CGTownInstance* CPlayerSpecificInfoCallback::getTownBySerial(int serialId)
|
||||
ASSERT_IF_CALLED_WITH_PLAYER
|
||||
const PlayerState *p = getPlayerState(*getPlayerID());
|
||||
ERROR_RET_VAL_IF(!p, "No player info", nullptr);
|
||||
ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->towns.size(), "No player info", nullptr);
|
||||
return p->towns[serialId];
|
||||
ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->getTowns().size(), "No player info", nullptr);
|
||||
return p->getTowns()[serialId];
|
||||
}
|
||||
|
||||
int CPlayerSpecificInfoCallback::getResourceAmount(GameResID type) const
|
||||
|
||||
Reference in New Issue
Block a user