mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
Stop leaking function damage expressions.
- Function damage expressions parsed from DECORATE are now stored in a single array and deleted at the end of FinishThingdef().
This commit is contained in:
parent
e3e32d7cca
commit
070c0a9e30
3 changed files with 16 additions and 2 deletions
|
@ -66,6 +66,8 @@
|
||||||
#include "vmbuilder.h"
|
#include "vmbuilder.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
|
||||||
|
TDeletingArray<class FxExpression *> ActorDamageFuncs;
|
||||||
|
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
void InitThingdef();
|
void InitThingdef();
|
||||||
void ParseDecorate (FScanner &sc);
|
void ParseDecorate (FScanner &sc);
|
||||||
|
@ -351,8 +353,8 @@ static void FinishThingdef()
|
||||||
|
|
||||||
if (def->Damage != NULL)
|
if (def->Damage != NULL)
|
||||||
{
|
{
|
||||||
|
FxDamageValue *dmg = (FxDamageValue *)ActorDamageFuncs[(uintptr_t)def->Damage - 1];
|
||||||
VMScriptFunction *sfunc;
|
VMScriptFunction *sfunc;
|
||||||
FxDamageValue *dmg = (FxDamageValue *)def->Damage;
|
|
||||||
sfunc = dmg->GetFunction();
|
sfunc = dmg->GetFunction();
|
||||||
if (sfunc == NULL)
|
if (sfunc == NULL)
|
||||||
{
|
{
|
||||||
|
@ -389,6 +391,9 @@ static void FinishThingdef()
|
||||||
I_Error("%d errors during actor postprocessing", errorcount);
|
I_Error("%d errors during actor postprocessing", errorcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActorDamageFuncs.DeleteAndClear();
|
||||||
|
StateTempCalls.DeleteAndClear();
|
||||||
|
|
||||||
// Since these are defined in DECORATE now the table has to be initialized here.
|
// Since these are defined in DECORATE now the table has to be initialized here.
|
||||||
for(int i = 0; i < 31; i++)
|
for(int i = 0; i < 31; i++)
|
||||||
{
|
{
|
||||||
|
@ -415,6 +420,7 @@ void LoadActors ()
|
||||||
|
|
||||||
timer.Reset(); timer.Clock();
|
timer.Reset(); timer.Clock();
|
||||||
StateParams.Clear();
|
StateParams.Clear();
|
||||||
|
ActorDamageFuncs.Clear();
|
||||||
GlobalSymbols.ReleaseSymbols();
|
GlobalSymbols.ReleaseSymbols();
|
||||||
FScriptPosition::ResetErrorCounter();
|
FScriptPosition::ResetErrorCounter();
|
||||||
InitThingdef();
|
InitThingdef();
|
||||||
|
|
|
@ -154,6 +154,7 @@ public:
|
||||||
|
|
||||||
extern FStateExpressions StateParams;
|
extern FStateExpressions StateParams;
|
||||||
|
|
||||||
|
extern TDeletingArray<class FxExpression *> ActorDamageFuncs;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
|
|
@ -544,7 +544,14 @@ DEFINE_PROPERTY(damage, X, Actor)
|
||||||
|
|
||||||
// Store this expression here for now. It will be converted to a function
|
// Store this expression here for now. It will be converted to a function
|
||||||
// later once all actors have been processed.
|
// later once all actors have been processed.
|
||||||
defaults->Damage = (VMFunction *)id;
|
if (id == NULL)
|
||||||
|
{
|
||||||
|
defaults->Damage = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defaults->Damage = (VMFunction *)(uintptr_t)(ActorDamageFuncs.Push(id) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue