mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
- Proper heap handling of HWSprite
pointer
- Added `Construct()` method and ensure it's called when created from any means
This commit is contained in:
parent
0b6bae59ee
commit
48e7c2d994
3 changed files with 14 additions and 10 deletions
|
@ -991,13 +991,13 @@ void P_DisconnectEffect (AActor *actor)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
DZSprite::DZSprite()
|
||||
void DZSprite::Construct()
|
||||
{
|
||||
PT = {};
|
||||
PT.sprite = this;
|
||||
Pos = Vel = {0,0,0};
|
||||
Offset = {0,0};
|
||||
Scale = {1,1};
|
||||
Pos = Vel = { 0,0,0 };
|
||||
Offset = { 0,0 };
|
||||
Scale = { 1,1 };
|
||||
Roll = 0.0;
|
||||
Alpha = 1.0;
|
||||
LightLevel = -1;
|
||||
|
@ -1009,6 +1009,11 @@ DZSprite::DZSprite()
|
|||
scolor = 0xffffff;
|
||||
}
|
||||
|
||||
DZSprite::DZSprite()
|
||||
{
|
||||
Construct();
|
||||
}
|
||||
|
||||
void DZSprite::CallPostBeginPlay()
|
||||
{
|
||||
PT.texture = Texture;
|
||||
|
@ -1018,7 +1023,7 @@ void DZSprite::CallPostBeginPlay()
|
|||
void DZSprite::OnDestroy()
|
||||
{
|
||||
PT.alpha = 0.0; // stops all rendering.
|
||||
spr = nullptr;
|
||||
if (spr) delete spr;
|
||||
Super::OnDestroy();
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1043,7 @@ DZSprite* DZSprite::NewZSprite(FLevelLocals* Level, PClass* type)
|
|||
}
|
||||
|
||||
DZSprite *zs = static_cast<DZSprite*>(Level->CreateThinker(type, STAT_SPRITE));
|
||||
|
||||
zs->Construct();
|
||||
return zs;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ public:
|
|||
|
||||
|
||||
DZSprite();
|
||||
void Construct();
|
||||
void CallPostBeginPlay() override;
|
||||
void OnDestroy() override;
|
||||
|
||||
|
|
|
@ -608,10 +608,8 @@ void HWDrawInfo::RenderParticles(subsector_t *sub, sector_t *front)
|
|||
if (clipres == PClip_InFront) continue;
|
||||
}
|
||||
if (!sp->spr)
|
||||
{
|
||||
HWSprite sprite;
|
||||
sp->spr = &sprite;
|
||||
}
|
||||
sp->spr = new HWSprite();
|
||||
|
||||
sp->spr->ProcessParticle(this, &sp->PT, front);
|
||||
}
|
||||
for (int i = Level->ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Level->Particles[i].snext)
|
||||
|
|
Loading…
Reference in a new issue