mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 18:42:26 +00:00
PCExhumed: Fixed Ignited sprite anim issue that could cause invalid array access.
* Fixes #638.
This commit is contained in:
parent
0dba1af7c0
commit
fb97e3c6ca
3 changed files with 39 additions and 1 deletions
|
@ -27,10 +27,16 @@ BEGIN_PS_NS
|
|||
|
||||
// anims
|
||||
|
||||
enum
|
||||
{
|
||||
kAnimFlag1 = (1 << 2),
|
||||
kAnimLoop = (1 << 4)
|
||||
};
|
||||
|
||||
void InitAnims();
|
||||
void DestroyAnim(DExhumedActor* nAnim);
|
||||
DExhumedActor* BuildAnim(DExhumedActor* actor, int val, int val2, const DVector3& pos, sectortype* pSector, double nScale, int nFlag);
|
||||
|
||||
void UnlinkIgnitedAnim(DExhumedActor* pActor);
|
||||
void FuncAnim(int, int, int, int);
|
||||
void BuildExplosion(DExhumedActor* actor);
|
||||
void BuildSplash(DExhumedActor* actor, sectortype* pSector);
|
||||
|
|
|
@ -54,6 +54,36 @@ void InitAnims()
|
|||
nSavePointSeq = SeqOffsets[kSeqItems] + 12;
|
||||
}
|
||||
|
||||
/*
|
||||
Use when deleting an ignited sprite to check if any anims reference it.
|
||||
Will remove the Anim's loop flag and set the source (the ignited sprite's) sprite reference to -1.
|
||||
FuncAnim() will then delete the anim on next call for this anim.
|
||||
|
||||
Without this, the anim will hold reference to a sprite which will eventually be reused, but the anim code
|
||||
will continue to manipulate its hitag value. This can break runlist records for things like LavaDude
|
||||
limbs that store these in the sprite hitag.
|
||||
|
||||
Specifically needed for IgniteSprite() anims which can become orphaned from the source sprite (e.g a bullet)
|
||||
when the bullet sprite is deleted.
|
||||
*/
|
||||
void UnlinkIgnitedAnim(DExhumedActor* pActor)
|
||||
{
|
||||
// scan the active anims (that aren't in the 'free' section of AnimsFree[])
|
||||
ExhumedStatIterator it(500);
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
if (itActor->spr.statnum == kStatIgnited)
|
||||
{
|
||||
// .hitag holds the sprite number of the source 'sprite that's on fire' sprite
|
||||
if (pActor == itActor->pTarget)
|
||||
{
|
||||
itActor->nAction &= ~kAnimLoop; // clear the animation loop flag
|
||||
itActor->pTarget = nullptr; // set the sprite reference to -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyAnim(DExhumedActor* pActor)
|
||||
{
|
||||
if (pActor)
|
||||
|
|
|
@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "ns.h"
|
||||
#include "engine.h"
|
||||
#include "exhumed.h"
|
||||
#include "aistuff.h"
|
||||
#include "sequence.h"
|
||||
#include "names.h"
|
||||
#include "player.h"
|
||||
|
@ -603,6 +604,7 @@ void DeleteActor(DExhumedActor* actor)
|
|||
bestTarget = nullptr;
|
||||
}
|
||||
|
||||
UnlinkIgnitedAnim(actor);
|
||||
actor->Destroy();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue