1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Map objects now use shared_ptr (game)

This commit is contained in:
Ivan Savenko
2025-03-13 19:42:18 +00:00
parent 2ca1748e96
commit 0ada2a5ebd
49 changed files with 487 additions and 613 deletions

View File

@ -507,7 +507,7 @@ RumorState NewTurnProcessor::pickNewRumor()
std::tuple<EWeekType, CreatureID> NewTurnProcessor::pickWeekType(bool newMonth)
{
for (const CGTownInstance *t : gameHandler->gameState()->getMap().towns)
for (const auto & t : gameHandler->gameState()->getMap().towns)
{
if (t->hasBuilt(BuildingID::GRAIL, ETownType::INFERNO))
return { EWeekType::DEITYOFFIRE, CreatureID::IMP };
@ -666,8 +666,8 @@ NewTurn NewTurnProcessor::generateNewTurnPack()
if (newWeek)
{
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
n.availableCreatures.push_back(generateTownGrowth(t, n.specialWeek, n.creatureid, firstTurn));
for (const auto & t : gameHandler->gameState()->getMap().towns)
n.availableCreatures.push_back(generateTownGrowth(t.get(), n.specialWeek, n.creatureid, firstTurn));
}
if (newWeek)
@ -695,17 +695,17 @@ void NewTurnProcessor::onNewTurn()
if (newWeek)
{
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
for (const auto & t : gameHandler->gameState()->getMap().towns)
if (t->hasBuilt(BuildingSubID::PORTAL_OF_SUMMONING))
gameHandler->setPortalDwelling(t, true, (n.specialWeek == EWeekType::PLAGUE ? true : false)); //set creatures for Portal of Summoning
gameHandler->setPortalDwelling(t.get(), true, (n.specialWeek == EWeekType::PLAGUE ? true : false)); //set creatures for Portal of Summoning
}
if (newWeek && !firstTurn)
{
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
for (const auto & t : gameHandler->gameState()->getMap().towns)
{
if (!t->getOwner().isValidPlayer())
updateNeutralTownGarrison(t, 1 + gameHandler->getDate(Date::DAY) / 7);
updateNeutralTownGarrison(t.get(), 1 + gameHandler->getDate(Date::DAY) / 7);
}
}