1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Limit resources to 1000 000 000 to prevent overflow

This commit is contained in:
Ivan Savenko
2023-11-20 20:50:37 +02:00
parent 842d66afbc
commit a4d5c4917b
2 changed files with 3 additions and 0 deletions

View File

@@ -797,6 +797,7 @@ void SetResources::applyGs(CGameState * gs) const
gs->getPlayerState(player)->resources = res;
else
gs->getPlayerState(player)->resources += res;
gs->getPlayerState(player)->resources.amin(GameConstants::PLAYER_RESOURCES_CAP);
//just ensure that player resources are not negative
//server is responsible to check if player can afford deal
@@ -2022,6 +2023,7 @@ void NewTurn::applyGs(CGameState *gs)
{
assert(re.first.isValidPlayer());
gs->getPlayerState(re.first)->resources = re.second;
gs->getPlayerState(re.first)->resources.amin(GameConstants::PLAYER_RESOURCES_CAP);
}
for(const auto & creatureSet : cres) //set available creatures in towns