mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Limit resources to 1000 000 000 to prevent overflow
This commit is contained in:
parent
842d66afbc
commit
a4d5c4917b
@ -50,6 +50,7 @@ namespace GameConstants
|
||||
constexpr int CREATURES_COUNT = 197;
|
||||
|
||||
constexpr ui32 BASE_MOVEMENT_COST = 100; //default cost for non-diagonal movement
|
||||
constexpr int64_t PLAYER_RESOURCES_CAP = 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user