1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix game hang on invalid shooter animation config

This commit is contained in:
Ivan Savenko 2023-03-28 17:04:18 +03:00
parent ae242be180
commit fd3f80e860

View File

@ -756,7 +756,15 @@ void ShootingAnimation::createProjectile(const Point & from, const Point & dest)
uint32_t ShootingAnimation::getAttackClimaxFrame() const
{
const CCreature *shooterInfo = getCreature();
return shooterInfo->animation.attackClimaxFrame;
uint32_t maxFrames = stackAnimation(attackingStack)->framesInGroup(getGroup());
uint32_t climaxFrame = shooterInfo->animation.attackClimaxFrame;
uint32_t selectedFrame = vstd::clamp(shooterInfo->animation.attackClimaxFrame, 1, maxFrames);
if (climaxFrame != selectedFrame)
logGlobal->warn("Shooter %s has ranged attack climax frame set to %d, but only %d available!", shooterInfo->getNamePluralTranslated(), climaxFrame, maxFrames);
return selectedFrame - 1; // H3 counts frames from 1
}
ECreatureAnimType ShootingAnimation::getUpwardsGroup() const