1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Added API for owned towns access

This commit is contained in:
Ivan Savenko
2023-04-17 15:32:18 +03:00
parent 5cbd0f8fc8
commit 365f552fa1
7 changed files with 55 additions and 21 deletions

View File

@ -177,3 +177,29 @@ void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
vstd::erase(wanderingHeroes, hero);
vstd::erase(sleepingHeroes, hero);
}
const std::vector<const CGTownInstance *> & PlayerLocalState::getOwnedTowns()
{
return ownedTowns;
}
const CGTownInstance * PlayerLocalState::getOwnedTown(size_t index)
{
if (index < ownedTowns.size())
return ownedTowns[index];
return nullptr;
}
void PlayerLocalState::addOwnedTown(const CGTownInstance * town)
{
assert(town);
assert(!vstd::contains(ownedTowns, town));
ownedTowns.push_back(town);
}
void PlayerLocalState::removeOwnedTown(const CGTownInstance * town)
{
assert(town);
assert(vstd::contains(ownedTowns, town));
vstd::erase(ownedTowns, town);
}