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

Fix checking PlayerColor's for validness

This commit is contained in:
Ivan Savenko
2023-08-27 01:35:38 +03:00
parent 3b06abd0d7
commit ce20d913e0
25 changed files with 55 additions and 49 deletions

View File

@ -770,7 +770,7 @@ void LobbyShowMessage::visitTyped(ICPackVisitor & visitor)
void SetResources::applyGs(CGameState * gs) const
{
assert(player < PlayerColor::PLAYER_LIMIT);
assert(player.isValidPlayer());
if(abs)
gs->getPlayerState(player)->resources = res;
else
@ -2018,7 +2018,7 @@ void NewTurn::applyGs(CGameState *gs)
for(const auto & re : res)
{
assert(re.first < PlayerColor::PLAYER_LIMIT);
assert(re.first.isValidPlayer());
gs->getPlayerState(re.first)->resources = re.second;
}
@ -2058,7 +2058,7 @@ void SetObjectProperty::applyGs(CGameState * gs) const
if(state->towns.empty())
*state->daysWithoutCastle = 0;
}
if(val < PlayerColor::PLAYER_LIMIT_I)
if(PlayerColor(val).isValidPlayer())
{
PlayerState * p = gs->getPlayerState(PlayerColor(val));
p->towns.emplace_back(t);