mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix possible overflow errors on leveling up beyond int64_t limit
- added separate giveExperience method instead of weird changePrimSkill - experience is now always used in form of int64_t - max supported level reduced from 201 to 197 to fit into int64_t - fixed undefined behavior in experience calculation
This commit is contained in:
@@ -261,7 +261,7 @@ void PlayerMessageProcessor::cheatLevelup(PlayerColor player, const CGHeroInstan
|
||||
levelsToGain = 1;
|
||||
}
|
||||
|
||||
gameHandler->changePrimSkill(hero, PrimarySkill::EXPERIENCE, VLC->heroh->reqExp(hero->level + levelsToGain) - VLC->heroh->reqExp(hero->level));
|
||||
gameHandler->giveExperience(hero, VLC->heroh->reqExp(hero->level + levelsToGain) - VLC->heroh->reqExp(hero->level));
|
||||
}
|
||||
|
||||
void PlayerMessageProcessor::cheatExperience(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words)
|
||||
@@ -280,7 +280,7 @@ void PlayerMessageProcessor::cheatExperience(PlayerColor player, const CGHeroIns
|
||||
expAmountProcessed = 10000;
|
||||
}
|
||||
|
||||
gameHandler->changePrimSkill(hero, PrimarySkill::EXPERIENCE, expAmountProcessed);
|
||||
gameHandler->giveExperience(hero, expAmountProcessed);
|
||||
}
|
||||
|
||||
void PlayerMessageProcessor::cheatMovement(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words)
|
||||
|
||||
Reference in New Issue
Block a user