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

Implement "emergency" projectile init attempt

This commit is contained in:
dydzio 2017-02-02 20:27:51 +01:00
parent c91bc25e70
commit 141e5ad032
3 changed files with 21 additions and 11 deletions

View File

@ -798,6 +798,9 @@ bool CShootingAnimation::init()
auto & angles = shooterInfo->animation.missleFrameAngles;
double pi = boost::math::constants::pi<double>();
if (owner->idToProjectile.count(spi.creID) == 0) //in some cases (known one: hero grants shooter bonus to unit) the shooter stack's projectile may not be properly initialized
owner->initStackProjectile(shooter);
// only frames below maxFrame are usable: anything higher is either no present or we don't know when it should be used
size_t maxFrame = std::min<size_t>(angles.size(), owner->idToProjectile.at(spi.creID)->ourImages.size());

View File

@ -984,6 +984,12 @@ void CBattleInterface::newStack(const CStack *stack)
//loading projectiles for units
if (stack->getCreature()->isShooting())
{
initStackProjectile(stack);
}
}
void CBattleInterface::initStackProjectile(const CStack * stack)
{
CDefHandler *&projectile = idToProjectile[stack->getCreature()->idNumber];
@ -1000,7 +1006,6 @@ void CBattleInterface::newStack(const CStack *stack)
CSDL_Ext::alphaTransform(elem.bitmap);
}
}
}
void CBattleInterface::stackRemoved(int stackID)
{

View File

@ -363,6 +363,8 @@ public:
void gateStateChanged(const EGateState state);
void initStackProjectile(const CStack *stack);
const CGHeroInstance *currentHero() const;
InfoAboutHero enemyHero() const;