Store a pointer to the effect target in the effect itself

qteditor
Günther Brammer 2016-05-04 03:44:59 +02:00
parent 3e5d982475
commit 6aaf7cd2ef
4 changed files with 13 additions and 10 deletions

View File

@ -2326,7 +2326,7 @@ void C4Object::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers)
pComp->Value(mkNamingAdapt( Layer, "Layer", C4ObjectPtr::Null ));
pComp->Value(mkNamingAdapt( C4DefGraphicsAdapt(pGraphics), "Graphics", &Def->Graphics ));
pComp->Value(mkNamingPtrAdapt( pDrawTransform, "DrawTransform" ));
pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), numbers));
pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), this, numbers));
pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)NULL));
// Serialize mesh instance if we have a mesh graphics

View File

@ -119,13 +119,13 @@ void C4AulScriptEngine::Denumerate(C4ValueNumbers * numbers)
if (pGlobalEffects) pGlobalEffects->Denumerate(numbers);
}
static void GlobalEffectsMergeCompileFunc(StdCompiler *pComp, C4Effect * & pEffects, const char * name, C4ValueNumbers * numbers)
static void GlobalEffectsMergeCompileFunc(StdCompiler *pComp, C4Effect * & pEffects, const char * name, C4PropList * pForObj, C4ValueNumbers * numbers)
{
C4Effect *pOldEffect, *pNextOldEffect=pEffects;
pEffects = NULL;
try
{
pComp->Value(mkParAdapt(mkNamingPtrAdapt(pEffects, name), numbers));
pComp->Value(mkParAdapt(mkNamingPtrAdapt(pEffects, name), pForObj, numbers));
}
catch (...)
{
@ -154,14 +154,14 @@ void C4AulScriptEngine::CompileFunc(StdCompiler *pComp, bool fScenarioSection, C
// loading scenario section: Merge effects
// Must keep old effects here even if they're dead, because the LoadScenarioSection call typically came from execution of a global effect
// and otherwise dead pointers would remain on the stack
GlobalEffectsMergeCompileFunc(pComp, pGlobalEffects, "Effects", numbers);
GlobalEffectsMergeCompileFunc(pComp, GameScript.pScenarioEffects, "ScenarioEffects", numbers);
GlobalEffectsMergeCompileFunc(pComp, pGlobalEffects, "Effects", this, numbers);
GlobalEffectsMergeCompileFunc(pComp, GameScript.pScenarioEffects, "ScenarioEffects", GameScript.ScenPropList._getPropList(), numbers);
}
else
{
// Otherwise, just compile effects
pComp->Value(mkParAdapt(mkNamingPtrAdapt(pGlobalEffects, "Effects"), numbers));
pComp->Value(mkParAdapt(mkNamingPtrAdapt(GameScript.pScenarioEffects, "ScenarioEffects"), numbers));
pComp->Value(mkParAdapt(mkNamingPtrAdapt(pGlobalEffects, "Effects"), this, numbers));
pComp->Value(mkParAdapt(mkNamingPtrAdapt(GameScript.pScenarioEffects, "ScenarioEffects"), GameScript.ScenPropList._getPropList(), numbers));
}
pComp->Value(mkNamingAdapt(*numbers, "Values"));
}

View File

@ -102,6 +102,7 @@ C4Effect * C4Effect::New(C4PropList *pForObj, C4Effect **ppEffectList, C4PropLis
C4Effect * C4Effect::Init(C4PropList *pForObj, int32_t iPrio, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
{
Target = pForObj;
// ask all effects with higher priority first - except for prio 1 effects, which are considered out of the priority call chain (as per doc)
bool fRemoveUpper = (iPrio != 1);
// note that apart from denying the creation of this effect, higher priority effects may also remove themselves
@ -509,8 +510,9 @@ void C4Effect::TempReaddUpperEffects(C4PropList *pObj, C4Effect *pLastReaddEffec
}
}
void C4Effect::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers)
void C4Effect::CompileFunc(StdCompiler *pComp, C4PropList * Owner, C4ValueNumbers * numbers)
{
if (pComp->isCompiler()) Target = Owner;
// read name
pComp->Separator(StdCompiler::SEP_START); // '('
// read priority
@ -561,7 +563,7 @@ void C4Effect::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers)
pComp->Value(fNext);
if (!fNext) return;
// read next
pComp->Value(mkParAdapt(mkPtrAdaptNoNull(pNext), numbers));
pComp->Value(mkParAdapt(mkPtrAdaptNoNull(pNext), Owner, numbers));
// denumeration and callback assignment will be done later
}

View File

@ -76,6 +76,7 @@ public:
protected:
C4Value CommandTarget; // target object for script callbacks - if deleted, the effect is removed without callbacks
C4PropList * Target; // target the effect is contained in
// presearched callback functions for faster calling
C4AulFunc *pFnTimer; // timer function Fx%sTimer
C4AulFunc *pFnStart, *pFnStop; // init/deinit-functions Fx%sStart, Fx%sStop
@ -132,7 +133,7 @@ public:
}
void OnObjectChangedDef(C4PropList *pObj);
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *);
void CompileFunc(StdCompiler *pComp, C4PropList *Owner, C4ValueNumbers *);
virtual C4Effect * GetEffect() { return this; }
virtual void SetPropertyByS(C4String * k, const C4Value & to);
virtual void ResetProperty(C4String * k);