mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-27 21:49:10 +02:00
Replaced iterators with auto & loop.
This commit is contained in:
parent
eb0af0096e
commit
c47c08aa01
@ -1511,20 +1511,20 @@ void CGameHandler::newTurn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//count days without town for all players, regardless of their turn order
|
//count days without town for all players, regardless of their turn order
|
||||||
for (auto p = gs->players.begin(); p != gs->players.end(); p++)
|
for (auto &p : gs->players)
|
||||||
{
|
{
|
||||||
PlayerState * playerState = &p->second;
|
PlayerState & playerState = p.second;
|
||||||
if (playerState->status == EPlayerStatus::INGAME)
|
if (playerState.status == EPlayerStatus::INGAME)
|
||||||
{
|
{
|
||||||
if (playerState->towns.empty())
|
if (playerState.towns.empty())
|
||||||
{
|
{
|
||||||
if (playerState->daysWithoutCastle)
|
if (playerState.daysWithoutCastle)
|
||||||
++(*playerState->daysWithoutCastle);
|
++(*playerState.daysWithoutCastle);
|
||||||
else playerState->daysWithoutCastle = 0;
|
else playerState.daysWithoutCastle = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerState->daysWithoutCastle = boost::none;
|
playerState.daysWithoutCastle = boost::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4825,10 +4825,10 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
|||||||
std::set<PlayerColor> playerColors;
|
std::set<PlayerColor> playerColors;
|
||||||
|
|
||||||
//do not copy player state (CBonusSystemNode) by value
|
//do not copy player state (CBonusSystemNode) by value
|
||||||
for (auto p = gs->players.begin(); p != gs->players.end(); p++) //players may have different colors, iterate over players and not integers
|
for (auto &p : gs->players) //players may have different colors, iterate over players and not integers
|
||||||
{
|
{
|
||||||
if (p->first != player)
|
if (p.first != player)
|
||||||
playerColors.insert(p->first);
|
playerColors.insert(p.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
//notify all players
|
//notify all players
|
||||||
|
Loading…
x
Reference in New Issue
Block a user