diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 8a3589a99..36c09d716 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -66,6 +66,8 @@ #include "vmbuilder.h" #include "stats.h" +TDeletingArray ActorDamageFuncs; + // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- void InitThingdef(); void ParseDecorate (FScanner &sc); @@ -351,8 +353,8 @@ static void FinishThingdef() if (def->Damage != NULL) { + FxDamageValue *dmg = (FxDamageValue *)ActorDamageFuncs[(uintptr_t)def->Damage - 1]; VMScriptFunction *sfunc; - FxDamageValue *dmg = (FxDamageValue *)def->Damage; sfunc = dmg->GetFunction(); if (sfunc == NULL) { @@ -389,6 +391,9 @@ static void FinishThingdef() 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. for(int i = 0; i < 31; i++) { @@ -415,6 +420,7 @@ void LoadActors () timer.Reset(); timer.Clock(); StateParams.Clear(); + ActorDamageFuncs.Clear(); GlobalSymbols.ReleaseSymbols(); FScriptPosition::ResetErrorCounter(); InitThingdef(); diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 76479bc4d..b65bb4637 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -154,6 +154,7 @@ public: extern FStateExpressions StateParams; +extern TDeletingArray ActorDamageFuncs; //========================================================================== // diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index b1df39d90..12cb318b1 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -544,7 +544,14 @@ DEFINE_PROPERTY(damage, X, Actor) // Store this expression here for now. It will be converted to a function // 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); + } } //==========================================================================