forked from Mirrors/openclonk
Unite getting the effects list from a C4Object pointer into a function
This way, that function can be re-implemented in standalone c4script.liquid_container
parent
42a15e3be9
commit
c89e73608b
|
@ -43,6 +43,11 @@
|
|||
#include <C4Viewport.h>
|
||||
#include <C4FoW.h>
|
||||
|
||||
C4Effect ** FnGetEffectsFor(C4Object * pTarget)
|
||||
{
|
||||
return pTarget ? &pTarget->pEffects : &Game.pGlobalEffects;
|
||||
}
|
||||
|
||||
// undocumented!
|
||||
static bool FnIncinerateLandscape(C4PropList * _this, long iX, long iY, long caused_by_plr)
|
||||
{
|
||||
|
@ -2165,7 +2170,7 @@ static C4Effect * FnGetEffect(C4PropList * _this, C4String *psEffectName, C4Obje
|
|||
{
|
||||
const char *szEffect = FnStringPar(psEffectName);
|
||||
// get effects
|
||||
C4Effect *pEffect = pTarget ? pTarget->pEffects : Game.pGlobalEffects;
|
||||
C4Effect *pEffect = *FnGetEffectsFor(pTarget);
|
||||
if (!pEffect) return NULL;
|
||||
// name/wildcard given: find effect by name and index
|
||||
if (szEffect && *szEffect)
|
||||
|
@ -2182,7 +2187,7 @@ static bool FnRemoveEffect(C4PropList * _this, C4String *psEffectName, C4Object
|
|||
// otherwise, the correct effect will be searched in the target's effects or in the global ones
|
||||
if (!pEffect)
|
||||
{
|
||||
pEffect = pTarget ? pTarget->pEffects : Game.pGlobalEffects;
|
||||
pEffect = *FnGetEffectsFor(pTarget);
|
||||
// the object has no effects attached, nothing to look for
|
||||
if (!pEffect) return 0;
|
||||
// name/wildcard given: find effect by name
|
||||
|
@ -2211,7 +2216,7 @@ static C4Value FnCheckEffect(C4PropList * _this, C4String * psEffectName, C4Obje
|
|||
if (pTarget && !pTarget->Status) return C4Value();
|
||||
if (!szEffect || !*szEffect) return C4Value();
|
||||
// get effects
|
||||
C4Effect *pEffect = pTarget ? pTarget->pEffects : Game.pGlobalEffects;
|
||||
C4Effect *pEffect = *FnGetEffectsFor(pTarget);
|
||||
if (!pEffect) return C4Value();
|
||||
// let them check
|
||||
C4Effect * r = pEffect->Check(pTarget, szEffect, iPrio, iTimerInterval, Val1, Val2, Val3, Val4);
|
||||
|
@ -2225,7 +2230,7 @@ static long FnGetEffectCount(C4PropList * _this, C4String *psEffectName, C4Objec
|
|||
// evaluate parameters
|
||||
const char *szEffect = FnStringPar(psEffectName);
|
||||
// get effects
|
||||
C4Effect *pEffect = pTarget ? pTarget->pEffects : Game.pGlobalEffects;
|
||||
C4Effect *pEffect = *FnGetEffectsFor(pTarget);
|
||||
if (!pEffect) return false;
|
||||
// count effects
|
||||
if (!*szEffect) szEffect = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@ inline C4Object * Object(C4PropList * _this)
|
|||
return _this ? _this->GetObject() : NULL;
|
||||
}
|
||||
StdStrBuf FnStringFormat(C4PropList * _this, C4String *szFormatPar, C4Value * Pars, int ParCount);
|
||||
C4Effect ** FnGetEffectsFor(C4Object * pTarget);
|
||||
|
||||
// Nillable: Allow integer and boolean parameters to be nil
|
||||
// pointer parameters represent nil via plain NULL
|
||||
|
|
Loading…
Reference in New Issue