mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implement "emergency" projectile init attempt
This commit is contained in:
parent
c91bc25e70
commit
141e5ad032
@ -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());
|
||||
|
||||
|
@ -985,20 +985,25 @@ void CBattleInterface::newStack(const CStack *stack)
|
||||
//loading projectiles for units
|
||||
if (stack->getCreature()->isShooting())
|
||||
{
|
||||
CDefHandler *&projectile = idToProjectile[stack->getCreature()->idNumber];
|
||||
initStackProjectile(stack);
|
||||
}
|
||||
}
|
||||
|
||||
const CCreature *creature;//creature whose shots should be loaded
|
||||
if (stack->getCreature()->idNumber == CreatureID::ARROW_TOWERS)
|
||||
creature = CGI->creh->creatures[siegeH->town->town->clientInfo.siegeShooter];
|
||||
else
|
||||
creature = stack->getCreature();
|
||||
void CBattleInterface::initStackProjectile(const CStack * stack)
|
||||
{
|
||||
CDefHandler *&projectile = idToProjectile[stack->getCreature()->idNumber];
|
||||
|
||||
projectile = CDefHandler::giveDef(creature->animation.projectileImageName);
|
||||
const CCreature *creature;//creature whose shots should be loaded
|
||||
if (stack->getCreature()->idNumber == CreatureID::ARROW_TOWERS)
|
||||
creature = CGI->creh->creatures[siegeH->town->town->clientInfo.siegeShooter];
|
||||
else
|
||||
creature = stack->getCreature();
|
||||
|
||||
for (auto & elem : projectile->ourImages) //alpha transforming
|
||||
{
|
||||
CSDL_Ext::alphaTransform(elem.bitmap);
|
||||
}
|
||||
projectile = CDefHandler::giveDef(creature->animation.projectileImageName);
|
||||
|
||||
for (auto & elem : projectile->ourImages) //alpha transforming
|
||||
{
|
||||
CSDL_Ext::alphaTransform(elem.bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,6 +363,8 @@ public:
|
||||
|
||||
void gateStateChanged(const EGateState state);
|
||||
|
||||
void initStackProjectile(const CStack *stack);
|
||||
|
||||
const CGHeroInstance *currentHero() const;
|
||||
InfoAboutHero enemyHero() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user