1
0
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:
Ivan Savenko
2024-01-04 23:57:36 +02:00
parent ceea341bb0
commit edb2ecd751
12 changed files with 87 additions and 59 deletions

View File

@@ -1138,7 +1138,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
xp = h->calculateXp(static_cast<int>(xp));
iw.text.appendLocalString(EMetaText::ADVOB_TXT,132);
iw.text.replaceNumber(static_cast<int>(xp));
cb->changePrimSkill(h, PrimarySkill::EXPERIENCE, xp, false);
cb->giveExperience(h, xp);
}
else
{