1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Merge pull request #274 from dydzio0614/ShooterInit

Approved. One guy named Avatar requested it recently ;)
This commit is contained in:
DjWarmonger
2017-02-06 21:18:19 +01:00
committed by GitHub
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;