OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Effect Class Reference

#include <C4Effect.h>

Inheritance diagram for C4Effect:
[legend]
Collaboration diagram for C4Effect:
[legend]

Public Member Functions

 ~C4Effect () override
 
void Register (C4Effect **ppEffectList, int32_t iPrio)
 
void Denumerate (C4ValueNumbers *) override
 
void ClearPointers (C4PropList *pObj)
 
void SetDead ()
 
bool IsDead ()
 
void FlipActive ()
 
bool IsActive ()
 
bool IsInactiveAndNotDead ()
 
C4EffectGet (const char *szName, int32_t iIndex=0, int32_t iMaxPriority=0)
 
int32_t GetCount (const char *szMask, int32_t iMaxPriority=0)
 
C4EffectCheck (const char *szCheckEffect, int32_t iPrio, int32_t iTimer, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
 
C4PropListGetCallbackScript ()
 
void Kill ()
 
void ClearAll (int32_t iClearFlag)
 
void DoDamage (int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
 
C4Value DoCall (C4PropList *pObj, const char *szFn, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4, const C4Value &rVal5, const C4Value &rVal6, const C4Value &rVal7)
 
void ReAssignCallbackFunctions ()
 
void ReAssignAllCallbackFunctions ()
 
void OnObjectChangedDef (C4PropList *pObj)
 
void CompileFunc (StdCompiler *pComp, C4PropList *Owner, C4ValueNumbers *)
 
C4EffectGetEffect () override
 
void SetPropertyByS (C4String *k, const C4Value &to) override
 
void ResetProperty (C4String *k) override
 
bool GetPropertyByS (const C4String *k, C4Value *pResult) const override
 
C4ValueArrayGetProperties () const override
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *numbers)
 
C4PropListNumberedGetPropListNumbered () override
 
bool IsNumbered () const override
 
void Clear ()
 
virtual const char * GetName () const
 
virtual void SetName (const char *NewName=nullptr)
 
virtual void SetOnFire (bool OnFire)
 
virtual C4Def const * GetDef () const
 
virtual C4DefGetDef ()
 
virtual C4ObjectGetObject ()
 
virtual C4Object const * GetObject () const
 
virtual class C4MapScriptLayerGetMapScriptLayer ()
 
virtual class C4MapScriptMapGetMapScriptMap ()
 
C4PropListGetPrototype () const
 
void RemoveCyclicPrototypes ()
 
virtual class C4PropListStaticIsStatic ()
 
const class C4PropListStaticIsStatic () const
 
virtual bool Delete ()
 
bool GetProperty (C4PropertyName k, C4Value *pResult) const
 
C4StringGetPropertyStr (C4PropertyName k) const
 
C4ValueArrayGetPropertyArray (C4PropertyName n) const
 
C4AulFuncGetFunc (C4PropertyName k) const
 
C4AulFuncGetFunc (C4String *k) const
 
C4AulFuncGetFunc (const char *k) const
 
C4StringEnumerateOwnFuncs (C4String *prev=nullptr) const
 
C4Value Call (C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (C4String *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (const char *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4PropertyName GetPropertyP (C4PropertyName k) const
 
int32_t GetPropertyBool (C4PropertyName n, bool default_val=false) const
 
int32_t GetPropertyInt (C4PropertyName k, int32_t default_val=0) const
 
C4PropListGetPropertyPropList (C4PropertyName k) const
 
bool HasProperty (C4String *k) const
 
void SetProperty (C4PropertyName k, const C4Value &to)
 
void Freeze ()
 
void Thaw ()
 
void ThawRecursively ()
 
bool IsFrozen () const
 
C4PropListStaticFreezeAndMakeStaticRecursively (std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
 
void AppendDataString (StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
 
StdStrBuf ToJSON (int depth=10, bool ignore_reference_parent=false) const
 
std::vector< C4String * > GetSortedLocalProperties (bool add_prototype=true) const
 
std::vector< C4String * > GetSortedLocalProperties (const char *prefix, const C4PropList *ignore_overridden) const
 
std::vector< C4String * > GetUnsortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
std::vector< C4String * > GetSortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
bool operator== (const C4PropList &b) const
 
Iterator begin ()
 
Iterator end ()
 

Static Public Member Functions

static C4EffectNew (C4PropList *pForObj, C4Effect **ppEffectList, C4String *szName, int32_t iPrio, int32_t iTimerInterval, C4PropList *pCmdTarget, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
 
static C4EffectNew (C4PropList *pForObj, C4Effect **ppEffectList, C4PropList *prototype, int32_t iPrio, int32_t iTimerInterval, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
 
static void Execute (C4Effect **ppEffectList)
 
static C4PropListGetByNumber (int32_t iNumber)
 
static bool CheckPropList (C4PropList *)
 
static void SetEnumerationIndex (int32_t iMaxObjectNumber)
 
static int32_t GetEnumerationIndex ()
 
static void ResetEnumerationIndex ()
 
static void ShelveNumberedPropLists ()
 
static void UnshelveNumberedPropLists ()
 
static void ClearShelve ()
 
static void ClearNumberedPropLists ()
 
static C4PropListNew (C4PropList *prototype=nullptr)
 
static C4PropListStaticNewStatic (C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
 

Public Attributes

int32_t iPriority
 
int32_t iTime
 
int32_t iInterval
 
C4EffectpNext
 
int32_t Number {-1}
 
int32_t Status {1}
 

Protected Member Functions

void AssignCallbackFunctions ()
 
int CallStart (int temporary, const C4Value &var1, const C4Value &var2, const C4Value &var3, const C4Value &var4)
 
int CallStop (int reason, bool temporary)
 
int CallTimer (int time)
 
void CallDamage (int32_t &damage, int damagetype, int plr)
 
int CallEffect (const char *effect, const C4Value &var1, const C4Value &var2, const C4Value &var3, const C4Value &var4)
 
 C4Effect (C4Effect **ppEffectList, C4String *szName, int32_t iPrio, int32_t iTimerInterval, C4PropList *pCmdTarget)
 
 C4Effect (C4Effect **ppEffectList, C4PropList *prototype, int32_t iPrio, int32_t iTimerInterval)
 
 C4Effect (const C4Effect &)=delete
 
 C4Effect ()
 
C4EffectInit (C4PropList *pForObj, int32_t iPrio, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
 
void TempRemoveUpperEffects (bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
 
void TempReaddUpperEffects (C4Effect *pLastReaddEffect)
 
void AcquireNumber ()
 
void ClearNumber ()
 
void ClearRefs ()
 

Protected Attributes

C4Value CommandTarget
 
C4PropListTarget
 
C4AulFuncpFnTimer
 
C4AulFuncpFnStart
 
C4AulFuncpFnStop
 
C4AulFuncpFnEffect
 
C4AulFuncpFnDamage
 

Static Protected Attributes

static C4Set
< C4PropListNumbered * > 
PropLists
 
static std::vector
< C4PropListNumbered * > 
ShelvedPropLists
 
static int32_t EnumerationIndex = 0
 

Friends

template<class T , typename... P>
void CompileNewFunc (T *&, StdCompiler *, P &&...)
 

Detailed Description

Definition at line 69 of file C4Effect.h.

Constructor & Destructor Documentation

C4Effect::C4Effect ( C4Effect **  ppEffectList,
C4String szName,
int32_t  iPrio,
int32_t  iTimerInterval,
C4PropList pCmdTarget 
)
protected

Definition at line 45 of file C4Effect.cpp.

References C4PropListNumbered::AcquireNumber(), C4VString(), CommandTarget, iInterval, iPriority, iTime, P_Name, Register(), C4PropList::SetProperty(), and C4Value::SetPropList().

46 {
47  // assign values
48  iPriority = 0; // effect is not yet valid; some callbacks to other effects are done before
49  iInterval = iTimerInterval;
50  iTime = 0;
51  CommandTarget.SetPropList(pCmdTarget);
52  AcquireNumber();
53  Register(ppEffectList, iPrio);
54  // Set name and callback functions
55  SetProperty(P_Name, C4VString(szName));
56 }
void Register(C4Effect **ppEffectList, int32_t iPrio)
Definition: C4Effect.cpp:71
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
int32_t iInterval
Definition: C4Effect.h:73
C4Value CommandTarget
Definition: C4Effect.h:78
int32_t iTime
Definition: C4Effect.h:73
int32_t iPriority
Definition: C4Effect.h:72
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141

Here is the call graph for this function:

C4Effect::C4Effect ( C4Effect **  ppEffectList,
C4PropList prototype,
int32_t  iPrio,
int32_t  iTimerInterval 
)
protected

Definition at line 58 of file C4Effect.cpp.

References C4PropListNumbered::AcquireNumber(), C4VString(), CommandTarget, C4PropList::GetName(), iInterval, iPriority, iTime, P_Name, Register(), C4Value::Set0(), and C4PropList::SetProperty().

58  :
59  C4PropListNumbered(prototype)
60 {
61  // assign values
62  iPriority = 0; // effect is not yet valid; some callbacks to other effects are done before
63  iInterval = iTimerInterval;
64  iTime = 0;
66  AcquireNumber();
67  Register(ppEffectList, iPrio);
68  SetProperty(P_Name, C4VString(prototype->GetName()));
69 }
void Register(C4Effect **ppEffectList, int32_t iPrio)
Definition: C4Effect.cpp:71
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
int32_t iInterval
Definition: C4Effect.h:73
void Set0()
Definition: C4Value.h:336
C4Value CommandTarget
Definition: C4Effect.h:78
virtual const char * GetName() const
Definition: C4PropList.cpp:649
int32_t iTime
Definition: C4Effect.h:73
C4PropListNumbered(C4PropList *prototype=nullptr)
Definition: C4PropList.cpp:151
int32_t iPriority
Definition: C4Effect.h:72
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246

Here is the call graph for this function:

C4Effect::C4Effect ( const C4Effect )
protecteddelete
C4Effect::C4Effect ( )
protected

Definition at line 156 of file C4Effect.cpp.

References CommandTarget, iInterval, iPriority, iTime, pNext, and C4Value::Set0().

Referenced by New().

157 {
158  // defaults
161  pNext = nullptr;
162 }
C4Effect * pNext
Definition: C4Effect.h:75
int32_t iInterval
Definition: C4Effect.h:73
void Set0()
Definition: C4Value.h:336
C4Value CommandTarget
Definition: C4Effect.h:78
int32_t iTime
Definition: C4Effect.h:73
int32_t iPriority
Definition: C4Effect.h:72

Here is the call graph for this function:

Here is the caller graph for this function:

C4Effect::~C4Effect ( )
override

Definition at line 164 of file C4Effect.cpp.

References pNext.

165 {
166  // del following effects (not recursively)
167  C4Effect *pEffect;
168  while ((pEffect = pNext))
169  {
170  pNext = pEffect->pNext;
171  pEffect->pNext = nullptr;
172  delete pEffect;
173  }
174 }
C4Effect * pNext
Definition: C4Effect.h:75

Member Function Documentation

void C4PropListNumbered::AcquireNumber ( )
protectedinherited

Definition at line 155 of file C4PropList.cpp.

References C4Set< T >::Add(), C4PropListNumbered::EnumerationIndex, C4Set< T >::Get(), C4PropListNumbered::Number, and C4PropListNumbered::PropLists.

Referenced by C4Effect(), C4MapScriptLayer::C4MapScriptLayer(), and C4Object::Init().

156 {
157  // Enumerate object
158  do
160  while (PropLists.Get(Number));
161  // Add to list
162  PropLists.Add(this);
163 }
T * Add(T const &e)
T & Get(H e) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
static int32_t EnumerationIndex
Definition: C4PropList.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::AppendDataString ( StdStrBuf out,
const char *  delim,
int  depth = 3,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 518 of file C4PropList.cpp.

References StdStrBuf::Append(), C4Value::GetDataString(), C4Set< T >::GetSize(), C4Set< T >::GetSortedListOfElementPointers(), and C4PropList::IsStatic().

Referenced by C4Value::GetDataString(), and C4Object::GetDataString().

519 {
520  StdStrBuf & DataString = *out;
521  if (depth <= 0 && Properties.GetSize())
522  {
523  DataString.Append("...");
524  return;
525  }
526  bool has_elements = false;
527  // Append prototype
528  if (prototype)
529  {
530  DataString.Append("Prototype = ");
531  DataString.Append(prototype.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
532  has_elements = true;
533  }
534  // Append other properties
535  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
536  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
537  {
538  if (has_elements) DataString.Append(delim);
539  DataString.Append((*p)->Key->GetData());
540  DataString.Append(" = ");
541  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
542  has_elements = true;
543  }
544 }
std::list< const T * > GetSortedListOfElementPointers() const
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::AssignCallbackFunctions ( )
protected

Definition at line 27 of file C4Effect.cpp.

References C4AUL_MAX_Identifier, GetCallbackScript(), C4PropList::GetFunc(), C4PropList::GetName(), pFnDamage, pFnEffect, pFnStart, pFnStop, pFnTimer, PSF_FxDamage, PSF_FxEffect, PSF_FxStart, PSF_FxStop, PSF_FxTimer, and sprintf.

Referenced by Denumerate(), and ReAssignCallbackFunctions().

28 {
30  if (!p) return;
31  // compose function names and search them
32  char fn[C4AUL_MAX_Identifier+1];
33  sprintf(fn, PSF_FxStart, GetName()); pFnStart = p->GetFunc(fn);
34  sprintf(fn, PSF_FxStop, GetName()); pFnStop = p->GetFunc(fn);
35  sprintf(fn, PSF_FxTimer, GetName()); pFnTimer = p->GetFunc(fn);
36  sprintf(fn, PSF_FxEffect, GetName()); pFnEffect = p->GetFunc(fn);
37  sprintf(fn, PSF_FxDamage, GetName()); pFnDamage = p->GetFunc(fn);
38 }
C4AulFunc * pFnStop
Definition: C4Effect.h:82
#define sprintf
Definition: Standard.h:164
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
#define PSF_FxTimer
Definition: C4GameScript.h:111
#define PSF_FxStop
Definition: C4GameScript.h:110
#define PSF_FxStart
Definition: C4GameScript.h:109
C4AulFunc * pFnEffect
Definition: C4Effect.h:83
#define PSF_FxEffect
Definition: C4GameScript.h:112
virtual const char * GetName() const
Definition: C4PropList.cpp:649
#define C4AUL_MAX_Identifier
Definition: C4Aul.h:26
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4AulFunc * pFnStart
Definition: C4Effect.h:82
C4AulFunc * pFnTimer
Definition: C4Effect.h:81
#define PSF_FxDamage
Definition: C4GameScript.h:113
C4AulFunc * pFnDamage
Definition: C4Effect.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 1007 of file C4PropList.cpp.

References C4PropList::begin(), C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::GetSize(), and C4Set< T >::Next().

Referenced by C4PropList::begin(), and C4ParticleProperties::Set().

1008 {
1009  C4PropList::Iterator iter;
1010 
1011  if (GetPrototype())
1012  {
1013  iter = GetPrototype()->begin();
1014  }
1015  else
1016  {
1017  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1018  }
1019  iter.Reserve(Properties.GetSize());
1020 
1021  const C4Property * p = Properties.First();
1022  while (p)
1023  {
1024  iter.AddProperty(p);
1025  p = Properties.Next(p);
1026  }
1027 
1028  iter.Init();
1029  return iter;
1030 }
T const * Next(T const *p) const
unsigned int GetSize() const
Iterator begin()
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

C4Value C4PropList::Call ( C4PropertyName  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inlineinherited

Definition at line 110 of file C4PropList.h.

References C4StringTable::P, and Strings.

Referenced by C4Command::Acquire(), C4Object::ActivateEntrance(), C4Object::ActivateMenu(), C4Object::AssignDeath(), C4Object::AssignRemoval(), C4Command::Call(), C4GameScriptHost::Call(), CallEffect(), C4Command::CallFailed(), CallStart(), CallStop(), CallTimer(), C4FindObjectFunc::Check(), ClearAll(), C4Object::Collect(), C4SortObjectFunc::CompareGetValue(), C4Object::Contact(), C4GameObjects::CrossCheck(), C4Landscape::P::DigMaterial2Objects(), C4Object::DirectComContents(), C4Object::DoBreath(), C4Object::DoCon(), C4Object::DoDamage(), C4Object::DoEnergy(), C4Object::DoMovement(), C4ObjectMenu::DoRefillInternal(), C4Object::DoSelect(), C4Object::Enter(), C4RoundResults::EvaluateGame(), C4RoundResults::EvaluateGoals(), C4Object::ExecAction(), C4Object::ExecLife(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Object::ExecuteCommand(), C4Object::Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), C4Object::GetValue(), GrabLost(), C4GameObjects::GRBroadcast(), C4Landscape::Incinerate(), Init(), C4Player::Init(), C4Game::InitGame(), C4ObjectMenu::IsCloseDenied(), Kill(), C4Object::Lift(), C4Player::MakeCrewMember(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4GameObjects::OnSynchronized(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Player::PlaceReadyCrew(), C4Landscape::P::PostFreeShape(), C4Object::Promote(), C4Object::Push(), C4Game::SaveData(), C4Object::SetAction(), C4GUI::FrameDecoration::SetByDef(), C4Object::SetCommand(), C4Player::SetObjectCrewStatus(), C4Object::SetOwner(), C4Object::StatusActivate(), C4Command::Transfer(), and C4Object::UnSelect().

111  { return Call(&Strings.P[k], pPars, fPassErrors); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the caller graph for this function:

C4Value C4PropList::Call ( C4String k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 828 of file C4PropList.cpp.

References C4PropList::C4Value, C4AulFunc::Exec(), C4PropList::GetFunc(), and C4PropList::Status.

829 {
830  if (!Status) return C4Value();
831  C4AulFunc *pFn = GetFunc(k);
832  if (!pFn) return C4Value();
833  return pFn->Exec(this, Pars, fPassErrors);
834 }
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t Status
Definition: C4PropList.h:168

Here is the call graph for this function:

C4Value C4PropList::Call ( const char *  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 836 of file C4PropList.cpp.

References C4PropList::C4Value, C4AulFunc::Exec(), FormatString(), C4AulScriptEngine::GetErrorHandler(), C4PropList::GetFunc(), C4AulErrorHandler::OnError(), ScriptEngine, C4PropList::Status, and C4AulError::what().

837 {
838  if (!Status) return C4Value();
839  assert(s && s[0]);
840  C4AulFunc *pFn = GetFunc(s);
841  if (!pFn)
842  {
843  if (s[0] != '~')
844  {
845  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
846  if (fPassErrors)
847  throw err;
848  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
849  }
850  return C4Value();
851  }
852  return pFn->Exec(this, Pars, fPassErrors);
853 }
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t Status
Definition: C4PropList.h:168
virtual void OnError(const char *msg)=0
#define s
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

void C4Effect::CallDamage ( int32_t &  damage,
int  damagetype,
int  plr 
)
protected

Definition at line 451 of file C4Effect.cpp.

References C4AulFunc::Exec(), GetCallbackScript(), C4PropList::GetFunc(), C4Value::getInt(), P_Damage, pFnDamage, and Target.

Referenced by DoDamage().

452 {
453  if (!GetCallbackScript())
454  {
455  C4AulFunc *pFn = GetFunc(P_Damage);
456  if (pFn)
457  damage = pFn->Exec(this, &C4AulParSet(damage, damagetype, plr)).getInt();
458  }
459  else if (pFnDamage)
460  damage = pFnDamage->Exec(GetCallbackScript(), &C4AulParSet(Obj(Target), this, damage, damagetype, plr)).getInt();
461 }
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * pFnDamage
Definition: C4Effect.h:84
int32_t getInt() const
Definition: C4Value.h:112
C4PropList * Target
Definition: C4Effect.h:79

Here is the call graph for this function:

Here is the caller graph for this function:

int C4Effect::CallEffect ( const char *  effect,
const C4Value var1,
const C4Value var2,
const C4Value var3,
const C4Value var4 
)
protected

Definition at line 462 of file C4Effect.cpp.

References C4Fx_OK, C4PropList::Call(), C4AulFunc::Exec(), GetCallbackScript(), C4Value::getInt(), P_Effect, pFnEffect, and Target.

463 {
464  if (!GetCallbackScript())
465  return Call(P_Effect, &C4AulParSet(effect, var1, var2, var3, var4)).getInt();
466  if (pFnEffect)
467  return pFnEffect->Exec(GetCallbackScript(), &C4AulParSet(effect, Obj(Target), this, var1, var2, var3, var4)).getInt();
468  return C4Fx_OK;
469 }
C4AulFunc * pFnEffect
Definition: C4Effect.h:83
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t getInt() const
Definition: C4Value.h:112
C4PropList * Target
Definition: C4Effect.h:79
#define C4Fx_OK
Definition: C4Effect.h:30
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

int C4Effect::CallStart ( int  temporary,
const C4Value var1,
const C4Value var2,
const C4Value var3,
const C4Value var4 
)
protected

Definition at line 427 of file C4Effect.cpp.

References C4Fx_OK, C4PropList::Call(), C4AulFunc::Exec(), GetCallbackScript(), C4Value::getInt(), P_Start, pFnStart, and Target.

Referenced by Init(), and Kill().

428 {
429  if (!GetCallbackScript())
430  return Call(P_Start, &C4AulParSet(temporary, var1, var2, var3, var4)).getInt();
431  if (pFnStart)
432  return pFnStart->Exec(GetCallbackScript(), &C4AulParSet(Obj(Target), this, temporary, var1, var2, var3, var4)).getInt();
433  return C4Fx_OK;
434 }
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * pFnStart
Definition: C4Effect.h:82
int32_t getInt() const
Definition: C4Value.h:112
C4PropList * Target
Definition: C4Effect.h:79
#define C4Fx_OK
Definition: C4Effect.h:30
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

int C4Effect::CallStop ( int  reason,
bool  temporary 
)
protected

Definition at line 435 of file C4Effect.cpp.

References C4Fx_OK, C4PropList::Call(), C4AulFunc::Exec(), GetCallbackScript(), C4Value::getInt(), P_Stop, pFnStop, and Target.

Referenced by ClearAll(), Kill(), and TempRemoveUpperEffects().

436 {
437  if (!GetCallbackScript())
438  return Call(P_Stop, &C4AulParSet(reason, temporary)).getInt();
439  if (pFnStop)
440  return pFnStop->Exec(GetCallbackScript(), &C4AulParSet(Obj(Target), this, reason, temporary)).getInt();
441  return C4Fx_OK;
442 }
C4AulFunc * pFnStop
Definition: C4Effect.h:82
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t getInt() const
Definition: C4Value.h:112
C4PropList * Target
Definition: C4Effect.h:79
#define C4Fx_OK
Definition: C4Effect.h:30
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

int C4Effect::CallTimer ( int  time)
protected

Definition at line 443 of file C4Effect.cpp.

References C4Fx_Execute_Kill, C4PropList::Call(), C4AulFunc::Exec(), GetCallbackScript(), C4Value::getInt(), P_Timer, pFnTimer, and Target.

Referenced by Execute().

444 {
445  if (!GetCallbackScript())
446  return Call(P_Timer, &C4AulParSet(time)).getInt();
447  if (pFnTimer)
448  return pFnTimer->Exec(GetCallbackScript(), &C4AulParSet(Obj(Target), this, time)).getInt();
449  return C4Fx_Execute_Kill;
450 }
#define C4Fx_Execute_Kill
Definition: C4Effect.h:36
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * pFnTimer
Definition: C4Effect.h:81
int32_t getInt() const
Definition: C4Value.h:112
C4PropList * Target
Definition: C4Effect.h:79
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

C4Effect * C4Effect::Check ( const char *  szCheckEffect,
int32_t  iPrio,
int32_t  iTimer,
const C4Value rVal1,
const C4Value rVal2,
const C4Value rVal3,
const C4Value rVal4 
)

Definition at line 249 of file C4Effect.cpp.

References C4Fx_Effect_Annul, C4Fx_Effect_AnnulCalls, C4Fx_Effect_Deny, C4Fx_Start_Deny, C4VInt(), C4VString(), DoCall(), C4Value::getInt(), iResult, Kill(), pNext, PSFS_FxAdd, Target, TempReaddUpperEffects(), and TempRemoveUpperEffects().

Referenced by Init().

250 {
251  // priority=1: always OK; no callbacks
252  if (iPrio == 1) return nullptr;
253  // check this and other effects
254  C4Effect *pAddToEffect = nullptr; bool fDoTempCallsForAdd = false;
255  C4Effect *pLastRemovedEffect=nullptr;
256  for (C4Effect *pCheck = this; pCheck; pCheck = pCheck->pNext)
257  {
258  if (!pCheck->IsDead() && pCheck->iPriority >= iPrio)
259  {
260  int32_t iResult = pCheck->CallEffect(szCheckEffect, rVal1, rVal2, rVal3, rVal4);
261  if (iResult == C4Fx_Effect_Deny)
262  // effect denied
263  return (C4Effect*)C4Fx_Effect_Deny;
264  // add to other effect
265  if (iResult == C4Fx_Effect_Annul || iResult == C4Fx_Effect_AnnulCalls)
266  {
267  pAddToEffect = pCheck;
268  fDoTempCallsForAdd = (iResult == C4Fx_Effect_AnnulCalls);
269  }
270  }
271  }
272  // adding to other effect?
273  if (pAddToEffect)
274  {
275  // do temp remove calls if desired
276  if (pAddToEffect->pNext && fDoTempCallsForAdd)
277  pAddToEffect->TempRemoveUpperEffects(false, &pLastRemovedEffect);
278  C4Value Par1 = C4VString(szCheckEffect), Par2 = C4VInt(iTimer), Par8;
279  int32_t iResult = pAddToEffect->DoCall(Target, PSFS_FxAdd, Par1, Par2, rVal1, rVal2, rVal3, rVal4, Par8).getInt();
280  // do temp readd calls if desired
281  if (pAddToEffect->pNext && fDoTempCallsForAdd)
282  pAddToEffect->TempReaddUpperEffects(pLastRemovedEffect);
283  // effect removed by this call?
284  if (iResult == C4Fx_Start_Deny)
285  {
286  pAddToEffect->Kill();
287  return (C4Effect*)C4Fx_Effect_Annul;
288  }
289  else
290  // other effect is the target effect number
291  return pAddToEffect;
292  }
293  // added to no effect and not denied
294  return nullptr;
295 }
C4Effect * pNext
Definition: C4Effect.h:75
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
void TempReaddUpperEffects(C4Effect *pLastReaddEffect)
Definition: C4Effect.cpp:510
#define PSFS_FxAdd
Definition: C4GameScript.h:156
#define C4Fx_Effect_Deny
Definition: C4Effect.h:32
void TempRemoveUpperEffects(bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
Definition: C4Effect.cpp:485
#define C4Fx_Effect_AnnulCalls
Definition: C4Effect.h:34
int iResult
Definition: C4GroupMain.cpp:39
void Kill()
Definition: C4Effect.cpp:343
int32_t getInt() const
Definition: C4Value.h:112
#define C4Fx_Start_Deny
Definition: C4Effect.h:39
C4PropList * Target
Definition: C4Effect.h:79
#define C4Fx_Effect_Annul
Definition: C4Effect.h:33
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
C4Value DoCall(C4PropList *pObj, const char *szFn, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4, const C4Value &rVal5, const C4Value &rVal6, const C4Value &rVal7)
Definition: C4Effect.cpp:409

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PropListNumbered::CheckPropList ( C4PropList pObj)
staticinherited

Definition at line 80 of file C4PropList.cpp.

References C4Set< T >::First(), C4Set< T >::Next(), and C4PropListNumbered::PropLists.

Referenced by C4Object::SetOCF(), C4Object::UpdateOCF(), and C4PropList::~C4PropList().

81 {
82  if (!pObj) return false;
83  C4PropListNumbered * const * p = PropLists.First();
84  while (p)
85  {
86  if (*p == pObj)
87  return true;
88  p = PropLists.Next(p);
89  }
90  return false;
91 }
T const * Next(T const *p) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::Clear ( )
inlineinherited

Definition at line 66 of file C4PropList.h.

References C4Set< T >::Clear(), and C4Value::Set0().

Referenced by C4ExtraScriptHost::Clear(), C4Def::Clear(), C4PropListNumbered::ClearNumberedPropLists(), C4ScriptHost::DeleteOwnedPropLists(), and C4Def::~C4Def().

66 { constant = false; Properties.Clear(); prototype.Set0(); }
void Set0()
Definition: C4Value.h:336
void Clear()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::ClearAll ( int32_t  iClearFlag)

Definition at line 369 of file C4Effect.cpp.

References C4Fx_AnyFire, C4Fx_Stop_Deny, C4PropList::Call(), CallStop(), ClearAll(), Get(), GetCallbackScript(), C4PropList::GetName(), iPriority, IsDead(), P_Destruction, pNext, SetDead(), C4PropList::SetOnFire(), C4PropList::Status, Target, and WildcardMatch().

Referenced by C4Object::AssignDeath(), C4Object::AssignRemoval(), ClearAll(), and C4Game::LoadScenarioSection().

370 {
371  // simply remove access all effects recursively, and do removal calls
372  // this does not regard lower-level effects being added in the removal calls,
373  // because this could hang the engine with poorly coded effects
374  if (pNext) pNext->ClearAll(iClearFlag);
375  if ((Target && !Target->Status) || IsDead()) return;
376  int32_t iPrevPrio = iPriority;
377  SetDead();
378  if (CallStop(iClearFlag, false) == C4Fx_Stop_Deny)
379  {
380  // this stop-callback might have deleted the object and then denied its own removal
381  // must not modify self in this case...
382  if (Target && !Target->Status) return;
383  // effect denied to be removed: recover it
384  iPriority = iPrevPrio;
385  }
386  // Update OnFire cache
388  if (!Get(C4Fx_AnyFire))
389  Target->SetOnFire(false);
390  if (IsDead() && !GetCallbackScript())
391  Call(P_Destruction, &C4AulParSet(iClearFlag));
392 }
C4Effect * pNext
Definition: C4Effect.h:75
void ClearAll(int32_t iClearFlag)
Definition: C4Effect.cpp:369
bool IsDead()
Definition: C4Effect.h:110
int CallStop(int reason, bool temporary)
Definition: C4Effect.cpp:435
virtual const char * GetName() const
Definition: C4PropList.cpp:649
#define C4Fx_AnyFire
Definition: C4Effect.h:151
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
void SetDead()
Definition: C4Effect.cpp:205
int32_t Status
Definition: C4PropList.h:168
C4Effect * Get(const char *szName, int32_t iIndex=0, int32_t iMaxPriority=0)
Definition: C4Effect.cpp:210
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
#define C4Fx_Stop_Deny
Definition: C4Effect.h:38
virtual void SetOnFire(bool OnFire)
Definition: C4PropList.h:69
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumber ( )
protectedinherited

Definition at line 165 of file C4PropList.cpp.

References C4PropListNumbered::Number, C4PropListNumbered::PropLists, and C4Set< T >::Remove().

Referenced by C4PropListNumbered::ShelveNumberedPropLists().

166 {
167  // Make proplist invisible during denumeration process
168  if (Number != -1)
169  {
170  PropLists.Remove(this);
171  Number = -1;
172  }
173 }
void Remove(H e)
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumberedPropLists ( )
staticinherited

Definition at line 137 of file C4PropList.cpp.

References C4PropList::Clear(), C4Set< T >::First(), C4Set< T >::Next(), and C4PropListNumbered::PropLists.

Referenced by C4Game::Clear().

138 {
139  // empty all proplists to ensure safe deletion of proplists with circular references
140  // note that this the call to Clear() might delete some prop lists. So it is assumed that
141  // PropLists does not shrink its table as the number of values goes down
142  C4PropListNumbered *const* p_next = PropLists.First(), *const* p;
143  while ((p = p_next))
144  {
145  p_next = PropLists.Next(p);
146  // check *p since it might have been deleted by clearing the previous prop list
147  if (*p) (*p)->Clear();
148  }
149 }
void Clear()
Definition: C4PropList.h:66
T const * Next(T const *p) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::ClearPointers ( C4PropList pObj)

Definition at line 191 of file C4Effect.cpp.

References CommandTarget, C4Value::getPropList(), pNext, C4Value::Set0(), and SetDead().

Referenced by C4Game::ClearPointers(), and C4Object::ClearPointers().

192 {
193  // clear pointers in all effects
194  C4Effect *pEff = this;
195  do
196  // command target lost: effect dead w/o callback
197  if (pEff->CommandTarget.getPropList() == pObj)
198  {
199  pEff->SetDead();
200  pEff->CommandTarget.Set0();
201  }
202  while ((pEff=pEff->pNext));
203 }
C4Effect * pNext
Definition: C4Effect.h:75
void Set0()
Definition: C4Value.h:336
C4Value CommandTarget
Definition: C4Effect.h:78
void SetDead()
Definition: C4Effect.cpp:205
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 156 of file C4PropList.h.

References C4Value::Set0().

Referenced by C4Object::AssignRemoval().

156 { while (FirstRef) FirstRef->Set0(); }
void Set0()
Definition: C4Value.h:336

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearShelve ( )
staticinherited

Definition at line 131 of file C4PropList.cpp.

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::Clear().

132 {
133  // cleanup shelve - used in game clear, un unsuccessful section load, etc.
134  ShelvedPropLists.clear();
135 }
static std::vector< C4PropListNumbered * > ShelvedPropLists
Definition: C4PropList.h:237

Here is the caller graph for this function:

void C4Effect::CompileFunc ( StdCompiler pComp,
C4PropList Owner,
C4ValueNumbers numbers 
)

Definition at line 530 of file C4Effect.cpp.

References C4Value::_getPropList(), CommandTarget, C4PropListNumbered::CompileFunc(), StdStrBuf::getData(), C4AulScriptEngine::GetGlobalConstant(), C4Value::getPropList(), C4PropList::GetPropListNumbered(), StdCompiler::hasNaming(), iInterval, iPriority, StdCompiler::isDeserializer(), StdCompiler::isSerializer(), C4PropList::IsStatic(), iTime, mkParAdapt(), mkPtrAdaptNoNull(), C4PropListNumbered::Number, pNext, StdCompiler::RCT_ID, C4PropListStatic::RefCompileFunc(), s, ScriptEngine, StdCompiler::SEP_END, StdCompiler::SEP_START, StdCompiler::Separator(), C4Value::Set0(), C4Value::SetObjectEnum(), StdCompiler::String(), Target, and StdCompiler::Value().

531 {
532  if (pComp->isDeserializer()) Target = Owner;
533  // read name
534  pComp->Separator(StdCompiler::SEP_START); // '('
535  // read priority
536  pComp->Value(iPriority); pComp->Separator();
537  // read time and intervall
538  pComp->Value(iTime); pComp->Separator();
539  pComp->Value(iInterval); pComp->Separator();
540  // read object number
541  // FIXME: replace with this when savegame compat breaks for other reasons
542  // pComp->Value(mkParAdapt(CommandTarget, numbers));
543  int32_t nptr = 0;
546  pComp->Value(nptr);
547  if (pComp->isDeserializer())
549  pComp->Separator();
550  // read ID
551  if (pComp->isSerializer())
552  {
554  if (p)
555  p->RefCompileFunc(pComp, numbers);
556  else
557  pComp->String(const_cast<char*>("None"), 5, StdCompiler::RCT_ID);
558  }
559  else
560  {
561  StdStrBuf s;
563  // An Object trumps a definition as command target
564  if (!nptr)
567  }
568  pComp->Separator();
569  // proplist
570  C4PropListNumbered::CompileFunc(pComp, numbers);
571  pComp->Separator(StdCompiler::SEP_END); // ')'
572  // is there a next effect?
573  bool fNext = !! pNext;
574  if (pComp->hasNaming())
575  {
576  if (fNext || pComp->isDeserializer())
577  fNext = pComp->Separator();
578  }
579  else
580  pComp->Value(fNext);
581  if (!fNext) return;
582  // read next
583  pComp->Value(mkParAdapt(mkPtrAdaptNoNull(pNext), Owner, numbers));
584  // denumeration and callback assignment will be done later
585 }
C4Effect * pNext
Definition: C4Effect.h:75
const char * getData() const
Definition: StdBuf.h:442
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
virtual bool hasNaming()
Definition: StdCompiler.h:58
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *numbers)
Definition: C4PropList.cpp:180
int32_t iInterval
Definition: C4Effect.h:73
bool GetGlobalConstant(const char *szName, C4Value *pTargetValue)
void Set0()
Definition: C4Value.h:336
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
void SetObjectEnum(int i)
Definition: C4Value.h:142
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped)=0
bool isSerializer()
Definition: StdCompiler.h:54
C4Value CommandTarget
Definition: C4Effect.h:78
int32_t iTime
Definition: C4Effect.h:73
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
Definition: StdAdaptors.h:606
void RefCompileFunc(StdCompiler *pComp, C4ValueNumbers *numbers) const
Definition: C4PropList.cpp:240
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458
C4PropList * _getPropList() const
Definition: C4Value.h:129
virtual C4PropListNumbered * GetPropListNumbered()
Definition: C4PropList.cpp:703
#define s
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

void C4PropListNumbered::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
)
inherited

Definition at line 180 of file C4PropList.cpp.

References C4Set< T >::Add(), C4PropList::CompileFunc(), StdCompiler::excCorrupt(), C4Set< T >::Get(), StdCompiler::isDeserializer(), C4PropListNumbered::Number, C4PropListNumbered::PropLists, StdCompiler::SEP_SEP2, StdCompiler::Separator(), and StdCompiler::Value().

Referenced by CompileFunc().

181 {
182  int32_t n = Number;
183  pComp->Value(n);
185  C4PropList::CompileFunc(pComp, numbers);
186  if (pComp->isDeserializer())
187  {
188  if (PropLists.Get(n))
189  {
190  pComp->excCorrupt("multiple PropLists with Number %d", n);
191  return;
192  }
193  // Once this proplist has a Number, it has to be in PropLists. See the destructor below.
194  Number = n;
195  PropLists.Add(this);
196  }
197 }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
Definition: C4PropList.cpp:397
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249
T * Add(T const &e)
T & Get(H e) const
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4PropList::Delete ( )
inlinevirtualinherited

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 90 of file C4PropList.h.

Referenced by C4ScriptHost::DeleteOwnedPropLists().

90 { return false; }

Here is the caller graph for this function:

void C4Effect::Denumerate ( C4ValueNumbers numbers)
overridevirtual

Reimplemented from C4PropList.

Definition at line 176 of file C4Effect.cpp.

References AssignCallbackFunctions(), CommandTarget, C4Value::Denumerate(), and pNext.

Referenced by C4GameScriptHost::Denumerate(), and C4Object::Denumerate().

177 {
178  // denum in all effects
179  C4Effect *pEff = this;
180  do
181  {
182  // command target
183  pEff->CommandTarget.Denumerate(numbers);
184  // assign any callback functions
185  pEff->AssignCallbackFunctions();
186  pEff->C4PropList::Denumerate(numbers);
187  }
188  while ((pEff=pEff->pNext));
189 }
C4Effect * pNext
Definition: C4Effect.h:75
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:251
void AssignCallbackFunctions()
Definition: C4Effect.cpp:27
C4Value CommandTarget
Definition: C4Effect.h:78

Here is the call graph for this function:

Here is the caller graph for this function:

C4Value C4Effect::DoCall ( C4PropList pObj,
const char *  szFn,
const C4Value rVal1,
const C4Value rVal2,
const C4Value rVal3,
const C4Value rVal4,
const C4Value rVal5,
const C4Value rVal6,
const C4Value rVal7 
)

Definition at line 409 of file C4Effect.cpp.

References C4PropList::C4Value, C4AulFunc::Exec(), FormatString(), GetCallbackScript(), C4PropList::GetFunc(), C4PropList::GetName(), and PSF_FxCustom.

Referenced by Check().

410 {
412  if (!p)
413  {
414  C4AulFunc * fn = GetFunc(szFn);
415  if (fn) return fn->Exec(this, &C4AulParSet(rVal1, rVal2, rVal3, rVal4, rVal5, rVal6, rVal7));
416  }
417  else
418  {
419  // old variant
420  // compose function name
421  C4AulFunc * fn = p->GetFunc(FormatString(PSF_FxCustom, GetName(), szFn).getData());
422  if (fn) return fn->Exec(p, &C4AulParSet(Obj(pObj), this, rVal1, rVal2, rVal3, rVal4, rVal5, rVal6, rVal7));
423  }
424  return C4Value();
425 }
#define PSF_FxCustom
Definition: C4GameScript.h:114
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
virtual const char * GetName() const
Definition: C4PropList.cpp:649
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::DoDamage ( int32_t &  riDamage,
int32_t  iDamageType,
int32_t  iCausePlr 
)

Definition at line 394 of file C4Effect.cpp.

References CallDamage(), IsDead(), pNext, C4PropList::Status, and Target.

Referenced by C4Object::DoDamage(), and C4Object::DoEnergy().

395 {
396  // ask all effects for damage adjustments
397  C4Effect *pEff = this;
398  do
399  {
400  if (!pEff->IsDead())
401  pEff->CallDamage(riDamage, iDamageType, iCausePlr);
402  if (Target && !Target->Status) return;
403  }
404  while ((pEff = pEff->pNext) && riDamage);
405 }
C4Effect * pNext
Definition: C4Effect.h:75
bool IsDead()
Definition: C4Effect.h:110
int32_t Status
Definition: C4PropList.h:168
C4PropList * Target
Definition: C4Effect.h:79
void CallDamage(int32_t &damage, int damagetype, int plr)
Definition: C4Effect.cpp:451

Here is the call graph for this function:

Here is the caller graph for this function:

Iterator C4PropList::end ( )
inlineinherited

Definition at line 206 of file C4PropList.h.

Referenced by C4ParticleProperties::Set().

206 { return Iterator(); }

Here is the caller graph for this function:

C4String * C4PropList::EnumerateOwnFuncs ( C4String prev = nullptr) const
inherited

Definition at line 940 of file C4PropList.cpp.

References C4Set< T >::First(), C4Set< T >::Get(), C4Value::getFunction(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

941 {
942  const C4Property * p = prev ? Properties.Next(&Properties.Get(prev)) : Properties.First();
943  while (p)
944  {
945  if (p->Value.getFunction())
946  return p->Key;
947  p = Properties.Next(p);
948  }
949  return nullptr;
950 }
C4Value Value
Definition: C4PropList.h:55
T & Get(H e) const
T const * Next(T const *p) const
C4String * Key
Definition: C4PropList.h:54
T const * First() const
C4AulFunc * getFunction() const
Definition: C4Value.h:119

Here is the call graph for this function:

void C4Effect::Execute ( C4Effect **  ppEffectList)
static

Definition at line 297 of file C4Effect.cpp.

References C4Fx_Execute_Kill, CallTimer(), iInterval, IsDead(), iTime, Kill(), pNext, C4PropList::Status, and Target.

Referenced by C4Game::Execute(), and C4Object::Execute().

298 {
299  // advance all effect timers first; then do execution
300  // this prevents a possible endless loop if timers register into the same effect list with interval 1 while it is being executed
301  for (C4Effect *pEffect = *ppEffectList; pEffect; pEffect = pEffect->pNext)
302  {
303  // ignore dead status; adjusting their time doesn't hurt
304  ++pEffect->iTime;
305  }
306  // get effect list
307  // execute all effects not marked as dead
308  C4Effect *pEffect = *ppEffectList, **ppPrevEffect=ppEffectList;
309  while (pEffect)
310  {
311  // effect dead?
312  if (pEffect->IsDead())
313  {
314  // delete it, then
315  C4Effect *pNextEffect = pEffect->pNext;
316  pEffect->pNext = nullptr;
317  delete pEffect;
318  // next effect
319  *ppPrevEffect = pEffect = pNextEffect;
320  }
321  else
322  {
323  // check timer execution
324  if (pEffect->iInterval && !(pEffect->iTime % pEffect->iInterval) && pEffect->iTime)
325  {
326  if (pEffect->CallTimer(pEffect->iTime) == C4Fx_Execute_Kill)
327  {
328  // safety: this class got deleted!
329  if (pEffect->Target && !pEffect->Target->Status) return;
330  // timer function decided to finish it
331  pEffect->Kill();
332  }
333  // safety: this class got deleted!
334  if (pEffect->Target && !pEffect->Target->Status) return;
335  }
336  // next effect
337  ppPrevEffect = &pEffect->pNext;
338  pEffect = pEffect->pNext;
339  }
340  }
341 }
C4Effect * pNext
Definition: C4Effect.h:75
bool IsDead()
Definition: C4Effect.h:110
int32_t iInterval
Definition: C4Effect.h:73
void Kill()
Definition: C4Effect.cpp:343
#define C4Fx_Execute_Kill
Definition: C4Effect.h:36
int32_t iTime
Definition: C4Effect.h:73
int32_t Status
Definition: C4PropList.h:168
C4PropList * Target
Definition: C4Effect.h:79
int CallTimer(int time)
Definition: C4Effect.cpp:443

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::FlipActive ( )
inline

Definition at line 111 of file C4Effect.h.

Referenced by TempRemoveUpperEffects().

111 { iPriority*=-1; } // alters activation status
int32_t iPriority
Definition: C4Effect.h:72

Here is the caller graph for this function:

void C4PropList::Freeze ( )
inlineinherited

Definition at line 128 of file C4PropList.h.

Referenced by C4PropList::FreezeAndMakeStaticRecursively().

128 { constant = true; }

Here is the caller graph for this function:

C4PropListStatic * C4PropList::FreezeAndMakeStaticRecursively ( std::vector< C4Value > *  prop_lists,
const C4PropListStatic parent = nullptr,
C4String key = nullptr 
)
inherited

Definition at line 303 of file C4PropList.cpp.

References C4VPropList(), C4PropList::Freeze(), C4PropList::FreezeAndMakeStaticRecursively(), C4PropListStatic::GetParent(), C4PropListStatic::GetParentKeyName(), C4PropList::GetPropertyByS(), C4Value::getPropList(), C4PropList::GetPrototype(), C4PropList::GetSortedLocalProperties(), C4PropList::IsStatic(), C4PropList::NewStatic(), C4Value::SetPropList(), and C4PropList::Status.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and C4AulScriptEngine::Link().

304 {
305  Freeze();
306  // Already static?
307  C4PropListStatic *this_static = IsStatic();
308  if (!this_static)
309  {
310  // Make self static by creating a copy and replacing all references
311  this_static = NewStatic(GetPrototype(), parent, key);
312  this_static->Properties.Swap(&Properties); // grab properties
313  this_static->Status = Status;
314  C4Value holder = C4VPropList(this);
315  while (FirstRef && FirstRef->NextRef)
316  {
317  C4Value *ref = FirstRef;
318  if (ref == &holder) ref = ref->NextRef;
319  ref->SetPropList(this_static);
320  }
321  // store reference
322  if (prop_lists)
323  {
324  prop_lists->push_back(C4VPropList(this_static));
325  }
326  // "this" should be deleted as holder goes out of scope
327  }
328  // Iterate over sorted list of elements to make static
329  // Must iterate over sorted list because the order must be defined, just in case it's a network game
330  // and a non-static child proplist is available through different paths it should still get the same name
331  auto prop_names = this_static->GetSortedLocalProperties(false);
332  for (auto prop_name : prop_names)
333  {
334  C4Value child_val;
335  this_static->GetPropertyByS(prop_name, &child_val);
336  C4PropList *child_proplist = child_val.getPropList();
337  if (child_proplist)
338  {
339  // Avoid infinite recursion: Only freeze into unfrozen children and "true" static children
340  C4PropListStatic *child_static = child_proplist->IsStatic();
341  if (!child_static || (child_static->GetParent() == this_static && child_static->GetParentKeyName() == prop_name))
342  {
343  child_proplist->FreezeAndMakeStaticRecursively(prop_lists, this_static, prop_name);
344  }
345  }
346  }
347  return this_static;
348 }
C4PropListStatic * FreezeAndMakeStaticRecursively(std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
Definition: C4PropList.cpp:303
void Freeze()
Definition: C4PropList.h:128
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
C4String * GetParentKeyName()
Definition: C4PropList.h:271
std::vector< C4String * > GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:576
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:245
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
int32_t Status
Definition: C4PropList.h:168
static C4PropListStatic * NewStatic(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.cpp:70
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
const C4PropListStatic * GetParent() const
Definition: C4PropList.h:270
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

C4Effect * C4Effect::Get ( const char *  szName,
int32_t  iIndex = 0,
int32_t  iMaxPriority = 0 
)

Definition at line 210 of file C4Effect.cpp.

References C4PropList::GetName(), iPriority, IsDead(), pNext, and SWildcardMatchEx().

Referenced by ClearAll(), Kill(), and TempRemoveUpperEffects().

211 {
212  // safety
213  if (!szName) return nullptr;
214  // check all effects
215  C4Effect *pEff = this;
216  do
217  {
218  // skip dead
219  if (pEff->IsDead()) continue;
220  // skip effects with too high priority
221  if (iMaxPriority && pEff->iPriority > iMaxPriority) continue;
222  // wildcard compare name
223  const char *szEffectName = pEff->GetName();
224  if (!SWildcardMatchEx(szEffectName, szName)) continue;
225  // effect name matches
226  // check index
227  if (iIndex--) continue;
228  // effect found
229  return pEff;
230  }
231  while ((pEff=pEff->pNext));
232  // nothing found
233  return nullptr;
234 }
C4Effect * pNext
Definition: C4Effect.h:75
bool IsDead()
Definition: C4Effect.h:110
virtual const char * GetName() const
Definition: C4PropList.cpp:649
bool SWildcardMatchEx(const char *szString, const char *szWildcard)
Definition: Standard.cpp:629
int32_t iPriority
Definition: C4Effect.h:72

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList * C4PropListNumbered::GetByNumber ( int32_t  iNumber)
staticinherited

Definition at line 75 of file C4PropList.cpp.

References C4Set< T >::Get(), and C4PropListNumbered::PropLists.

Referenced by C4Value::Denumerate(), and C4GameObjects::ObjectPointer().

76 {
77  return PropLists.Get(iNumber);
78 }
T & Get(H e) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList * C4Effect::GetCallbackScript ( )

Definition at line 40 of file C4Effect.cpp.

References C4Value::_getPropList(), and CommandTarget.

Referenced by AssignCallbackFunctions(), CallDamage(), CallEffect(), CallStart(), CallStop(), CallTimer(), ClearAll(), DoCall(), Init(), Kill(), and OnObjectChangedDef().

41 {
42  return CommandTarget._getPropList();
43 }
C4Value CommandTarget
Definition: C4Effect.h:78
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Effect::GetCount ( const char *  szMask,
int32_t  iMaxPriority = 0 
)

Definition at line 236 of file C4Effect.cpp.

References C4PropList::GetName(), iCnt, iPriority, IsDead(), pNext, and SWildcardMatchEx().

237 {
238  // count all matching effects
239  int32_t iCnt=0; C4Effect *pEff = this;
240  do if (!pEff->IsDead())
241  if (!szMask || SWildcardMatchEx(pEff->GetName(), szMask))
242  if (!iMaxPriority || pEff->iPriority <= iMaxPriority)
243  ++iCnt;
244  while ((pEff = pEff->pNext));
245  // return count
246  return iCnt;
247 }
C4Effect * pNext
Definition: C4Effect.h:75
bool IsDead()
Definition: C4Effect.h:110
int iCnt
Definition: TstC4NetIO.cpp:32
virtual const char * GetName() const
Definition: C4PropList.cpp:649
bool SWildcardMatchEx(const char *szString, const char *szWildcard)
Definition: Standard.cpp:629
int32_t iPriority
Definition: C4Effect.h:72

Here is the call graph for this function:

C4Def const * C4PropList::GetDef ( ) const
virtualinherited

Reimplemented in C4Def.

Definition at line 685 of file C4PropList.cpp.

References C4PropList::GetDef(), and C4PropList::GetPrototype().

Referenced by C4Value::_getDef(), ConstructionCheck(), C4Game::CreateObject(), C4Game::CreateObjectConstruction(), C4AulExec::DirectExec(), C4GameMessage::Draw(), C4Game::DrawPropListSpecImage(), C4AulExec::FnTranslate(), C4PropList::GetDef(), C4Value::getDef(), C4GameMessage::Init(), C4Object::Init(), C4FindObjectDef::IsImpossible(), C4PropList::operator==(), C4ScriptHost::Parse(), C4AulParse::Parse_Script(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), and C4ScriptGuiWindowProperty::Set().

686 {
687  if (GetPrototype()) return GetPrototype()->GetDef();
688  return nullptr;
689 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

C4Def * C4PropList::GetDef ( )
virtualinherited

Reimplemented in C4Def.

Definition at line 679 of file C4PropList.cpp.

References C4PropList::GetDef(), and C4PropList::GetPrototype().

680 {
681  if (GetPrototype()) return GetPrototype()->GetDef();
682  return nullptr;
683 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

C4Effect* C4Effect::GetEffect ( )
inlineoverridevirtual

Reimplemented from C4PropList.

Definition at line 137 of file C4Effect.h.

137 { return this; }
static int32_t C4PropListNumbered::GetEnumerationIndex ( )
inlinestaticinherited

Definition at line 225 of file C4PropList.h.

References C4PropListNumbered::EnumerationIndex.

Referenced by C4Game::NewObject(), C4EditCursor::PerformDuplication(), and C4ControlSyncCheck::Set().

225 { return EnumerationIndex; }
static int32_t EnumerationIndex
Definition: C4PropList.h:238

Here is the caller graph for this function:

C4AulFunc* C4PropList::GetFunc ( C4PropertyName  k) const
inlineinherited

Definition at line 105 of file C4PropList.h.

References C4StringTable::P, and Strings.

Referenced by AssignCallbackFunctions(), C4PropList::Call(), CallDamage(), C4Value::CompileFunc(), C4ScriptHost::CopyPropList(), DoCall(), C4PropList::GetFunc(), Init(), C4MapScriptHost::InitializeMap(), C4Object::PutAwayUnusedObject(), C4MaterialReaction::ResolveScriptFuncs(), C4MCOverlay::SetField(), C4AulCompiler::PreparseAstVisitor::visit(), and C4AulCompiler::CodegenAstVisitor::visit().

106  { return GetFunc(&Strings.P[k]); }
C4String P[P_LAST]
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4StringTable Strings
Definition: C4Globals.cpp:42

Here is the caller graph for this function:

C4AulFunc * C4PropList::GetFunc ( C4String k) const
inherited

Definition at line 803 of file C4PropList.cpp.

References C4Set< T >::Get(), C4PropList::GetFunc(), C4Value::getFunction(), C4PropList::GetPrototype(), C4Set< T >::Has(), and C4Property::Value.

804 {
805  assert(k);
806  if (Properties.Has(k))
807  {
808  return Properties.Get(k).Value.getFunction();
809  }
810  if (GetPrototype())
811  {
812  return GetPrototype()->GetFunc(k);
813  }
814  return nullptr;
815 }
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4AulFunc * getFunction() const
Definition: C4Value.h:119

Here is the call graph for this function:

C4AulFunc * C4PropList::GetFunc ( const char *  k) const
inherited

Definition at line 817 of file C4PropList.cpp.

References C4StringTable::FindString(), C4PropList::GetFunc(), s, and Strings.

818 {
819  assert(s);
820  if (s[0] == '~') ++s;
821  C4String * k = Strings.FindString(s);
822  // this string is entirely unused
823  if (!k)
824  return nullptr;
825  return GetFunc(k);
826 }
C4String * FindString(const char *strString) const
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4StringTable Strings
Definition: C4Globals.cpp:42
#define s

Here is the call graph for this function:

class C4MapScriptLayer * C4PropList::GetMapScriptLayer ( )
virtualinherited

Reimplemented in C4MapScriptLayer.

Definition at line 691 of file C4PropList.cpp.

References C4PropList::GetMapScriptLayer(), and C4PropList::GetPrototype().

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), FnParAlgo(), and C4PropList::GetMapScriptLayer().

692 {
693  if (GetPrototype()) return GetPrototype()->GetMapScriptLayer();
694  return nullptr;
695 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual class C4MapScriptLayer * GetMapScriptLayer()
Definition: C4PropList.cpp:691

Here is the call graph for this function:

Here is the caller graph for this function:

class C4MapScriptMap * C4PropList::GetMapScriptMap ( )
virtualinherited

Reimplemented in C4MapScriptMap.

Definition at line 697 of file C4PropList.cpp.

References C4PropList::GetMapScriptMap(), and C4PropList::GetPrototype().

Referenced by C4PropList::GetMapScriptMap().

698 {
699  if (GetPrototype()) return GetPrototype()->GetMapScriptMap();
700  return nullptr;
701 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual class C4MapScriptMap * GetMapScriptMap()
Definition: C4PropList.cpp:697

Here is the call graph for this function:

Here is the caller graph for this function:

const char * C4PropList::GetName ( ) const
virtualinherited

Reimplemented in C4PropListStatic.

Definition at line 649 of file C4PropList.cpp.

References C4String::GetCStr(), C4PropList::GetPropertyStr(), P_Name, and s.

Referenced by C4Object::ActivateMenu(), AssignCallbackFunctions(), C4Effect(), C4PropertyPath::C4PropertyPath(), C4Object::CanConcatPictureWith(), C4FindObjectAction::Check(), C4Game::CheckObjectEnumeration(), ClearAll(), ConstructionCheck(), DoCall(), C4EditCursor::DoContextMenu(), C4ObjectMenu::DoRefillInternal(), C4Object::Draw(), C4ScriptGuiWindow::Draw(), C4Game::DrawCrewOverheadText(), C4Object::ExecLife(), Get(), GetCount(), C4Object::GetDataString(), C4Object::GetInfoString(), Init(), Kill(), C4Object::Lift(), C4Game::NewObject(), ObjectComDig(), C4Object::Promote(), C4Object::Push(), C4Object::SetAction(), C4Object::SetOCF(), TempRemoveUpperEffects(), C4Object::UpdateOCF(), and C4EditCursor::UpdateStatusBar().

650 {
652  if (!s) return "";
653  return s->GetCStr();
654 }
const char * GetCStr() const
Definition: C4StringTable.h:49
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
#define s

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object * C4PropList::GetObject ( )
virtualinherited

Reimplemented in C4Object.

Definition at line 667 of file C4PropList.cpp.

References C4PropList::GetObject(), and C4PropList::GetPrototype().

Referenced by C4Value::_getObj(), C4EditCursor::AddToSelection(), C4PropertyPath::C4PropertyPath(), C4ScriptGuiWindowAction::ClearPointers(), ThisImpl< C4Object >::Conv(), C4GameMessage::Draw(), C4ScriptGuiWindowAction::ExecuteCommand(), FnGetEffectsFor(), C4Value::GetDataString(), C4Value::getObj(), C4PropList::GetObject(), C4GameMessage::Init(), Object(), C4GameObjects::ObjectPointer(), C4EditCursor::RemoveFromSelection(), and C4ScriptGuiWindowProperty::Set().

668 {
669  if (GetPrototype()) return GetPrototype()->GetObject();
670  return nullptr;
671 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object const * C4PropList::GetObject ( ) const
virtualinherited

Reimplemented in C4Object.

Definition at line 673 of file C4PropList.cpp.

References C4PropList::GetObject(), and C4PropList::GetPrototype().

674 {
675  if (GetPrototype()) return GetPrototype()->GetObject();
676  return nullptr;
677 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

C4ValueArray * C4Effect::GetProperties ( ) const
overridevirtual

Reimplemented from C4PropList.

Definition at line 654 of file C4Effect.cpp.

References a, C4VString(), C4PropList::GetProperties(), C4ValueArray::GetSize(), C4StringTable::P, P_CommandTarget, P_Interval, P_Name, P_Priority, P_Target, P_Time, C4ValueArray::SetSize(), and Strings.

655 {
657  int i;
658  i = a->GetSize();
659  a->SetSize(i + 5);
660  (*a)[i++] = C4VString(&::Strings.P[P_Name]);
661  (*a)[i++] = C4VString(&::Strings.P[P_Priority]);
662  (*a)[i++] = C4VString(&::Strings.P[P_Interval]);
663  (*a)[i++] = C4VString(&::Strings.P[P_CommandTarget]);
664  (*a)[i++] = C4VString(&::Strings.P[P_Target]);
665  (*a)[i++] = C4VString(&::Strings.P[P_Time]);
666  return a;
667 }
C4String P[P_LAST]
#define a
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:914
void SetSize(int32_t inSize)
int32_t GetSize() const
Definition: C4ValueArray.h:36
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246

Here is the call graph for this function:

bool C4PropList::GetProperty ( C4PropertyName  k,
C4Value pResult 
) const
inlineinherited

Definition at line 101 of file C4PropList.h.

References C4PropList::GetPropertyByS(), C4StringTable::P, and Strings.

Referenced by C4MapScriptAlgoFilter::C4MapScriptAlgoFilter(), C4MapScriptAlgoModifier::C4MapScriptAlgoModifier(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4FindObjectProcedure::Check(), C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), C4Object::DrawFaceImpl(), C4Object::DrawLine(), C4Object::ExecAction(), C4Object::GetAction(), C4Def::GetActionByName(), C4Object::GetDragImage(), C4Object::GetParallaxity(), C4MapScriptAlgo::GetXYProps(), C4GameMessage::Init(), C4Object::IsVisible(), C4ScriptUniform::Push(), C4Object::SetAction(), C4Object::SetActionByName(), and C4GraphicsOverlay::UpdateFacet().

102  { return GetPropertyByS(&Strings.P[k], pResult); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757

Here is the call graph for this function:

Here is the caller graph for this function:

C4ValueArray * C4PropList::GetPropertyArray ( C4PropertyName  n) const
inherited

Definition at line 789 of file C4PropList.cpp.

References C4Set< T >::Get(), C4Value::getArray(), C4PropList::GetPropertyArray(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4EditCursor::DoContextMenu(), C4PropList::GetPropertyArray(), and C4FoWLight::Update().

790 {
791  C4String * k = &Strings.P[n];
792  if (Properties.Has(k))
793  {
794  return Properties.Get(k).Value.getArray();
795  }
796  if (GetPrototype())
797  {
798  return GetPrototype()->GetPropertyArray(n);
799  }
800  return nullptr;
801 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4ValueArray * getArray() const
Definition: C4Value.h:118
C4ValueArray * GetPropertyArray(C4PropertyName n) const
Definition: C4PropList.cpp:789

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4PropList::GetPropertyBool ( C4PropertyName  n,
bool  default_val = false 
) const
inherited

Definition at line 872 of file C4PropList.cpp.

References C4Set< T >::Get(), C4Value::getBool(), C4PropList::GetPropertyBool(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4Object::ExecLife(), and C4PropList::GetPropertyBool().

873 {
874  C4String * k = &Strings.P[n];
875  if (Properties.Has(k))
876  {
877  return Properties.Get(k).Value.getBool();
878  }
879  if (GetPrototype())
880  {
881  return GetPrototype()->GetPropertyBool(n, default_val);
882  }
883  return default_val;
884 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
bool getBool() const
Definition: C4Value.h:113
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:872
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Effect::GetPropertyByS ( const C4String k,
C4Value pResult 
) const
overridevirtual

Reimplemented from C4PropList.

Definition at line 637 of file C4Effect.cpp.

References Abs(), C4PropList::C4Value, C4VInt(), CommandTarget, C4PropList::GetPropertyByS(), iInterval, iPriority, iTime, C4StringTable::P, P_CommandTarget, P_Interval, P_LAST, P_Name, P_Priority, P_Target, P_Time, Strings, and Target.

638 {
639  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
640  {
641  switch(k - &Strings.P[0])
642  {
643  case P_Name: return C4PropListNumbered::GetPropertyByS(k, pResult);
644  case P_Priority: *pResult = C4VInt(Abs(iPriority)); return true;
645  case P_Interval: *pResult = C4VInt(iInterval); return true;
646  case P_CommandTarget: *pResult = CommandTarget; return true;
647  case P_Target: *pResult = C4Value(Target); return true;
648  case P_Time: *pResult = C4VInt(iTime); return true;
649  }
650  }
651  return C4PropListNumbered::GetPropertyByS(k, pResult);
652 }
C4String P[P_LAST]
friend class C4Value
Definition: C4PropList.h:165
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
int32_t iInterval
Definition: C4Effect.h:73
C4Value CommandTarget
Definition: C4Effect.h:78
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
int32_t iTime
Definition: C4Effect.h:73
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
T Abs(T val)
Definition: Standard.h:42

Here is the call graph for this function:

int32_t C4PropList::GetPropertyInt ( C4PropertyName  k,
int32_t  default_val = 0 
) const
inherited

Definition at line 886 of file C4PropList.cpp.

References C4Set< T >::Get(), C4Value::getInt(), C4PropList::GetPropertyInt(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MouseControl::ButtonUpDragScript(), C4MapScriptAlgoEllipsis::C4MapScriptAlgoEllipsis(), C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4MapScriptAlgoOffset::C4MapScriptAlgoOffset(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRect::C4MapScriptAlgoRect(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MapScriptAlgoScale::C4MapScriptAlgoScale(), C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(), C4Object::Contact(), C4Object::ContactAction(), C4Object::DoBreath(), C4Object::DoEnergy(), C4Object::DoMovement(), C4MouseControl::DragNone(), C4Object::Draw(), C4Object::DrawActionFace(), C4Game::DrawPropListSpecImage(), C4Object::DrawTopFace(), C4Command::Enter(), C4Object::ExecAction(), C4Object::ExecLife(), C4Object::ExecMovement(), C4ValueProviderAction::Execute(), C4Command::Exit(), C4Command::FlightControl(), FnParAlgo(), C4SoundModifierList::Get(), C4SoundModifier::GetBoolProp(), C4SoundModifier::GetFloatProp(), C4Def::GetPlane(), C4PropList::GetPropertyInt(), C4Object::GetSolidMaskPlane(), C4Object::Init(), C4Object::IsVisible(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), ObjectComJump(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), C4Object::Push(), C4Command::Put(), C4Object::ResetProperty(), C4Object::SetAction(), C4Object::SetDir(), C4Object::SetOCF(), C4Object::SetPhase(), C4Object::SideBounds(), C4Command::Throw(), C4Object::UpdateActionFace(), C4MouseControl::UpdateCursorTarget(), C4GraphicsOverlay::UpdateFacet(), C4Object::UpdateFlipDir(), C4Object::UpdateOCF(), and C4Object::VerticalBounds().

887 {
888  C4String * k = &Strings.P[n];
889  if (Properties.Has(k))
890  {
891  return Properties.Get(k).Value.getInt();
892  }
893  if (GetPrototype())
894  {
895  return GetPrototype()->GetPropertyInt(n, default_val);
896  }
897  return default_val;
898 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
int32_t getInt() const
Definition: C4Value.h:112
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropertyName C4PropList::GetPropertyP ( C4PropertyName  k) const
inherited

Definition at line 855 of file C4PropList.cpp.

References C4Set< T >::Get(), C4PropList::GetPropertyP(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, P_LAST, Strings, and C4Property::Value.

Referenced by C4Object::ContactAction(), C4Object::ExecAction(), C4Object::ExecMovement(), C4Object::GetProcedure(), C4PropList::GetPropertyP(), ObjectComDrop(), C4Object::SetAction(), C4Object::SideBounds(), and C4Object::VerticalBounds().

856 {
857  C4String * k = &Strings.P[n];
858  if (Properties.Has(k))
859  {
860  C4String * v = Properties.Get(k).Value.getStr();
861  if (v >= &Strings.P[0] && v < &Strings.P[P_LAST])
862  return C4PropertyName(v - &Strings.P[0]);
863  return P_LAST;
864  }
865  if (GetPrototype())
866  {
867  return GetPrototype()->GetPropertyP(n);
868  }
869  return P_LAST;
870 }
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:855
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
C4String * getStr() const
Definition: C4Value.h:117
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4PropertyName

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList * C4PropList::GetPropertyPropList ( C4PropertyName  k) const
inherited

Definition at line 900 of file C4PropList.cpp.

References C4Set< T >::Get(), C4PropList::GetPropertyPropList(), C4Value::getPropList(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), C4Game::DrawPropListSpecImage(), C4PropList::GetPropertyPropList(), and C4GameMessage::Init().

901 {
902  C4String * k = &Strings.P[n];
903  if (Properties.Has(k))
904  {
905  return Properties.Get(k).Value.getPropList();
906  }
907  if (GetPrototype())
908  {
909  return GetPrototype()->GetPropertyPropList(n);
910  }
911  return nullptr;
912 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:900
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

C4String * C4PropList::GetPropertyStr ( C4PropertyName  k) const
inherited

Definition at line 775 of file C4PropList.cpp.

References C4Set< T >::Get(), C4PropList::GetPropertyStr(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4Game::DrawPropListSpecImage(), C4Object::ExecAction(), C4PropList::GetName(), C4PropListStatic::GetName(), C4PropList::GetPropertyStr(), C4Game::GetTranslatedString(), C4Object::SetAction(), C4Object::SetDir(), C4MouseControl::UpdateCursorTarget(), and C4GraphicsOverlay::UpdateFacet().

776 {
777  C4String * k = &Strings.P[n];
778  if (Properties.Has(k))
779  {
780  return Properties.Get(k).Value.getStr();
781  }
782  if (GetPrototype())
783  {
784  return GetPrototype()->GetPropertyStr(n);
785  }
786  return nullptr;
787 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
C4String * getStr() const
Definition: C4Value.h:117
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropListNumbered * C4PropListNumbered::GetPropListNumbered ( )
overridevirtualinherited

Reimplemented from C4PropList.

Definition at line 175 of file C4PropList.cpp.

176 {
177  return this;
178 }
C4PropList* C4PropList::GetPrototype ( ) const
inlineinherited
std::vector< C4String * > C4PropList::GetSortedLocalProperties ( bool  add_prototype = true) const
inherited

Definition at line 576 of file C4PropList.cpp.

References C4Set< T >::GetSortedListOfElementPointers(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and C4Game::GetTranslatedString().

577 {
578  // return property list without descending into prototype
579  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
580  std::vector< C4String * > result;
581  result.reserve(sorted_props.size() + add_prototype);
582  if (add_prototype) result.push_back(&::Strings.P[P_Prototype]); // implicit prototype for every prop list
583  for (auto p : sorted_props) result.push_back(p->Key);
584  return result;
585 }
C4String P[P_LAST]
std::list< const T * > GetSortedListOfElementPointers() const
C4StringTable Strings
Definition: C4Globals.cpp:42

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< C4String * > C4PropList::GetSortedLocalProperties ( const char *  prefix,
const C4PropList ignore_overridden 
) const
inherited

Definition at line 587 of file C4PropList.cpp.

References a, b, C4Set< T >::First(), C4String::GetCStr(), C4PropList::GetPrototype(), C4PropList::HasProperty(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

588 {
589  // return property list without descending into prototype
590  // ignore properties that have been overridden by proplist given in ignore_overridden or any of its prototypes up to and excluding this
591  std::vector< C4String * > result;
592  for (const C4Property *pp = Properties.First(); pp; pp = Properties.Next(pp))
593  if (pp->Key != &::Strings.P[P_Prototype])
594  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
595  {
596  // Override check
597  const C4PropList *check = ignore_overridden;
598  bool overridden = false;
599  if (check && check != this)
600  {
601  if (check->HasProperty(pp->Key)) { overridden = true; break; }
602  check = check->GetPrototype();
603  }
604  result.push_back(pp->Key);
605  }
606  // Sort
607  std::sort(result.begin(), result.end(), [](const C4String *a, const C4String *b) -> bool
608  {
609  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
610  });
611  return result;
612 }
C4String P[P_LAST]
#define b
const char * GetCStr() const
Definition: C4StringTable.h:49
#define a
T const * Next(T const *p) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
bool HasProperty(C4String *k) const
Definition: C4PropList.h:118
T const * First() const

Here is the call graph for this function:

std::vector< C4String * > C4PropList::GetSortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 632 of file C4PropList.cpp.

References a, b, C4String::GetCStr(), and C4PropList::GetUnsortedProperties().

633 {
634  struct sort_cmp {
635  bool operator() (const C4String *a, const C4String *b) const
636  {
637  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
638  }
639  };
640  // Return property list with descending into prototype
641  // But do not include Prototype property
642  std::vector< C4String * > result = GetUnsortedProperties(prefix, ignore_parent);
643  // Sort and remove duplicates
644  std::set< C4String *, sort_cmp > result_set(result.begin(), result.end());
645  result.assign(result_set.begin(), result_set.end());
646  return result;
647 }
#define b
const char * GetCStr() const
Definition: C4StringTable.h:49
#define a
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614

Here is the call graph for this function:

std::vector< C4String * > C4PropList::GetUnsortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 614 of file C4PropList.cpp.

References C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::GetSortedProperties(), and C4PropList::ThawRecursively().

615 {
616  // Return property list with descending into prototype
617  // But do not include Prototype property
618  std::vector< C4String * > result;
619  const C4PropList *p = this;
620  do
621  {
622  for (const C4Property *pp = p->Properties.First(); pp; pp = p->Properties.Next(pp))
623  if (pp->Key != &::Strings.P[P_Prototype])
624  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
625  result.push_back(pp->Key);
626  p = p->GetPrototype();
627  if (p == ignore_parent) break;
628  } while (p);
629  return result;
630 }
C4String P[P_LAST]
T const * Next(T const *p) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PropList::HasProperty ( C4String k) const
inlineinherited

Definition at line 118 of file C4PropList.h.

References C4Set< T >::Has().

Referenced by C4PropList::GetSortedLocalProperties(), C4MapScriptAlgo::GetXYProps(), C4AulCompiler::PreparseAstVisitor::visit(), and C4AulCompiler::ConstantResolver::visit().

118 { return Properties.Has(k); }
bool Has(H e) const

Here is the call graph for this function:

Here is the caller graph for this function:

C4Effect * C4Effect::Init ( C4PropList pForObj,
int32_t  iPrio,
const C4Value rVal1,
const C4Value rVal2,
const C4Value rVal3,
const C4Value rVal4 
)
protected

Definition at line 103 of file C4Effect.cpp.

References C4Fx_AnyFire, C4Fx_Effect_Annul, C4Fx_Effect_Deny, C4Fx_Start_Deny, C4PropList::Call(), CallStart(), Check(), GetCallbackScript(), C4PropList::GetFunc(), C4Value::getInt(), C4PropList::GetName(), iInterval, iPriority, IsDead(), P_Construction, P_Start, pFnStart, pNext, SetDead(), C4PropList::SetOnFire(), C4PropList::Status, Target, TempReaddUpperEffects(), TempRemoveUpperEffects(), and WildcardMatch().

Referenced by New().

104 {
105  Target = pForObj;
106  // ask all effects with higher priority first - except for prio 1 effects, which are considered out of the priority call chain (as per doc)
107  bool fRemoveUpper = (iPrio != 1);
108  // note that apart from denying the creation of this effect, higher priority effects may also remove themselves
109  // or do other things with the effect list
110  // (which does not quite make sense, because the effect might be denied by another effect)
111  // so the priority is assigned after this call, marking this effect dead before it's definitely valid
112  if (fRemoveUpper && pNext)
113  {
114  C4Effect * pEffect2 = pNext->Check(GetName(), iPrio, iInterval, rVal1, rVal2, rVal3, rVal4);
115  if (pEffect2)
116  {
117  // effect denied (iResult = -1), added to an effect (iResult = Number of that effect)
118  // or added to an effect that destroyed itself (iResult = -2)
119  if (pEffect2 != (C4Effect*)C4Fx_Effect_Deny && pEffect2 != (C4Effect*)C4Fx_Effect_Annul) return pEffect2;
120  // effect is still marked dead
121  return nullptr;
122  }
123  }
124  // init effect
125  // higher-priority effects must be deactivated temporarily, and then reactivated regarding the new effect
126  // higher-level effects should not be inserted during the process of removing or adding a lower-level effect
127  // because that would cause a wrong initialization order
128  // (hardly ever causing trouble, however...)
129  C4Effect *pLastRemovedEffect=nullptr;
130  C4AulFunc * pFn;
131  if (!GetCallbackScript())
132  {
133  Call(P_Construction, &C4AulParSet(rVal1, rVal2, rVal3, rVal4)).getInt();
134  if (pForObj && !pForObj->Status) return nullptr;
135  pFn = GetFunc(P_Start);
136  }
137  else
138  pFn = pFnStart;
139  if (fRemoveUpper && pNext && pFn)
140  TempRemoveUpperEffects(false, &pLastRemovedEffect);
141  // bad things may happen
142  if (pForObj && !pForObj->Status) return nullptr; // this will be invalid!
143  iPriority = iPrio; // validate effect now
144  if (CallStart(0, rVal1, rVal2, rVal3, rVal4) == C4Fx_Start_Deny)
145  // the effect denied to start: assume it hasn't, and mark it dead
146  SetDead();
147  if (fRemoveUpper && pNext && pFn)
148  TempReaddUpperEffects(pLastRemovedEffect);
149  if (pForObj && !pForObj->Status) return nullptr; // this will be invalid!
150  // Update OnFire cache
151  if (!IsDead() && pForObj && WildcardMatch(C4Fx_AnyFire, GetName()))
152  pForObj->SetOnFire(true);
153  return this;
154 }
C4Effect * pNext
Definition: C4Effect.h:75
int CallStart(int temporary, const C4Value &var1, const C4Value &var2, const C4Value &var3, const C4Value &var4)
Definition: C4Effect.cpp:427
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
bool IsDead()
Definition: C4Effect.h:110
int32_t iInterval
Definition: C4Effect.h:73
void TempReaddUpperEffects(C4Effect *pLastReaddEffect)
Definition: C4Effect.cpp:510
#define C4Fx_Effect_Deny
Definition: C4Effect.h:32
void TempRemoveUpperEffects(bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
Definition: C4Effect.cpp:485
C4Effect * Check(const char *szCheckEffect, int32_t iPrio, int32_t iTimer, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
Definition: C4Effect.cpp:249
virtual const char * GetName() const
Definition: C4PropList.cpp:649
#define C4Fx_AnyFire
Definition: C4Effect.h:151
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
void SetDead()
Definition: C4Effect.cpp:205
int32_t Status
Definition: C4PropList.h:168
C4AulFunc * pFnStart
Definition: C4Effect.h:82
int32_t getInt() const
Definition: C4Value.h:112
#define C4Fx_Start_Deny
Definition: C4Effect.h:39
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
#define C4Fx_Effect_Annul
Definition: C4Effect.h:33
virtual void SetOnFire(bool OnFire)
Definition: C4PropList.h:69
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Effect::IsActive ( )
inline

Definition at line 112 of file C4Effect.h.

Referenced by Kill(), and TempRemoveUpperEffects().

112 { return iPriority>0; } // returns whether effect is active
int32_t iPriority
Definition: C4Effect.h:72

Here is the caller graph for this function:

bool C4Effect::IsDead ( )
inline

Definition at line 110 of file C4Effect.h.

References iPriority.

Referenced by ClearAll(), DoDamage(), Execute(), Get(), GetCount(), Init(), and Kill().

110 { return !iPriority; } // return whether effect is to be removed
int32_t iPriority
Definition: C4Effect.h:72

Here is the caller graph for this function:

bool C4PropList::IsFrozen ( ) const
inlineinherited

Definition at line 131 of file C4PropList.h.

Referenced by C4PropList::ThawRecursively().

131 { return constant; }

Here is the caller graph for this function:

bool C4Effect::IsInactiveAndNotDead ( )
inline

Definition at line 113 of file C4Effect.h.

113 { return iPriority<0; } // as the name says
int32_t iPriority
Definition: C4Effect.h:72
bool C4PropListNumbered::IsNumbered ( ) const
inlineoverridevirtualinherited

Reimplemented from C4PropList.

Definition at line 220 of file C4PropList.h.

220 { return true; }
virtual class C4PropListStatic* C4PropList::IsStatic ( )
inlinevirtualinherited
const class C4PropListStatic* C4PropList::IsStatic ( ) const
inlineinherited

Definition at line 86 of file C4PropList.h.

References C4PropList::IsStatic().

Referenced by C4PropList::IsStatic().

86 { return const_cast<C4PropList*>(this)->IsStatic(); }
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::Kill ( )

Definition at line 343 of file C4Effect.cpp.

References C4Fx_AnyFire, C4Fx_Stop_Deny, C4FxCall_Normal, C4FxCall_TempAddForRemoval, C4PropList::C4Value, C4PropList::Call(), CallStart(), CallStop(), Get(), GetCallbackScript(), C4PropList::GetName(), iPriority, IsActive(), IsDead(), P_Destruction, SetDead(), C4PropList::SetOnFire(), Target, TempReaddUpperEffects(), TempRemoveUpperEffects(), and WildcardMatch().

Referenced by Check(), and Execute().

344 {
345  // active?
346  C4Effect *pLastRemovedEffect=nullptr;
347  if (IsActive())
348  // then temp remove all higher priority effects
349  TempRemoveUpperEffects(false, &pLastRemovedEffect);
350  else
351  // otherwise: temp reactivate before real removal
352  // this happens only if a lower priority effect removes an upper priority effect in its add- or removal-call
354  // remove this effect
355  int32_t iPrevPrio = iPriority; SetDead();
356  if (CallStop(C4FxCall_Normal, false) == C4Fx_Stop_Deny)
357  // effect denied to be removed: recover
358  iPriority = iPrevPrio;
359  // reactivate other effects
360  TempReaddUpperEffects(pLastRemovedEffect);
361  // Update OnFire cache
363  if (!Get(C4Fx_AnyFire))
364  Target->SetOnFire(false);
365  if (IsDead() && !GetCallbackScript())
367 }
int CallStart(int temporary, const C4Value &var1, const C4Value &var2, const C4Value &var3, const C4Value &var4)
Definition: C4Effect.cpp:427
bool IsDead()
Definition: C4Effect.h:110
friend class C4Value
Definition: C4PropList.h:165
#define C4FxCall_TempAddForRemoval
Definition: C4Effect.h:44
void TempReaddUpperEffects(C4Effect *pLastReaddEffect)
Definition: C4Effect.cpp:510
void TempRemoveUpperEffects(bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
Definition: C4Effect.cpp:485
bool IsActive()
Definition: C4Effect.h:112
#define C4FxCall_Normal
Definition: C4Effect.h:42
int CallStop(int reason, bool temporary)
Definition: C4Effect.cpp:435
virtual const char * GetName() const
Definition: C4PropList.cpp:649
#define C4Fx_AnyFire
Definition: C4Effect.h:151
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40
void SetDead()
Definition: C4Effect.cpp:205
C4Effect * Get(const char *szName, int32_t iIndex=0, int32_t iMaxPriority=0)
Definition: C4Effect.cpp:210
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
#define C4Fx_Stop_Deny
Definition: C4Effect.h:38
virtual void SetOnFire(bool OnFire)
Definition: C4PropList.h:69
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

C4Effect * C4Effect::New ( C4PropList pForObj,
C4Effect **  ppEffectList,
C4String szName,
int32_t  iPrio,
int32_t  iTimerInterval,
C4PropList pCmdTarget,
const C4Value rVal1,
const C4Value rVal2,
const C4Value rVal3,
const C4Value rVal4 
)
static

Definition at line 91 of file C4Effect.cpp.

References C4Effect(), and Init().

92 {
93  C4Effect * pEffect = new C4Effect(ppEffectList, szName, iPrio, iTimerInterval, pCmdTarget);
94  return pEffect->Init(pForObj, iPrio, rVal1, rVal2, rVal3, rVal4);
95 }
C4Effect * Init(C4PropList *pForObj, int32_t iPrio, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
Definition: C4Effect.cpp:103

Here is the call graph for this function:

C4Effect * C4Effect::New ( C4PropList pForObj,
C4Effect **  ppEffectList,
C4PropList prototype,
int32_t  iPrio,
int32_t  iTimerInterval,
const C4Value rVal1,
const C4Value rVal2,
const C4Value rVal3,
const C4Value rVal4 
)
static

Definition at line 97 of file C4Effect.cpp.

References C4Effect(), and Init().

98 {
99  C4Effect * pEffect = new C4Effect(ppEffectList, prototype, iPrio, iTimerInterval);
100  return pEffect->Init(pForObj, iPrio, rVal1, rVal2, rVal3, rVal4);
101 }
C4Effect * Init(C4PropList *pForObj, int32_t iPrio, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4)
Definition: C4Effect.cpp:103

Here is the call graph for this function:

C4PropList * C4PropList::New ( C4PropList prototype = nullptr)
staticinherited

Definition at line 64 of file C4PropList.cpp.

Referenced by CompileNewFunc(), FnPlaceVegetation(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), and C4AulCompiler::ConstexprEvaluator::visit().

65 {
66  C4PropList * r = new C4PropListScript(prototype);
67  return r;
68 }

Here is the caller graph for this function:

C4PropListStatic * C4PropList::NewStatic ( C4PropList prototype,
const C4PropListStatic parent,
C4String key 
)
staticinherited

Definition at line 70 of file C4PropList.cpp.

Referenced by C4PropListScen::C4PropListScen(), C4ScriptHost::CopyPropList(), C4PropList::FreezeAndMakeStaticRecursively(), C4ScenarioParameterDefs::RegisterScriptConstants(), and C4AulCompiler::ConstexprEvaluator::visit().

71 {
72  return new C4PropListStatic(prototype, parent, key);
73 }

Here is the caller graph for this function:

void C4Effect::OnObjectChangedDef ( C4PropList pObj)

Definition at line 471 of file C4Effect.cpp.

References GetCallbackScript(), pNext, and ReAssignCallbackFunctions().

Referenced by C4Object::ChangeDef().

472 {
473  // safety
474  if (!pObj) return;
475  // check all effects for reassignment
476  C4Effect *pCheck = this;
477  while (pCheck)
478  {
479  if (pCheck->GetCallbackScript() == pObj)
480  pCheck->ReAssignCallbackFunctions();
481  pCheck = pCheck->pNext;
482  }
483 }
C4Effect * pNext
Definition: C4Effect.h:75
void ReAssignCallbackFunctions()
Definition: C4Effect.h:127
C4PropList * GetCallbackScript()
Definition: C4Effect.cpp:40

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PropList::operator== ( const C4PropList b) const
inherited

Definition at line 379 of file C4PropList.cpp.

References C4Set< T >::First(), C4Set< T >::Get(), C4PropList::GetDef(), C4Set< T >::GetSize(), C4PropList::IsNumbered(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

380 {
381  // every numbered proplist has a unique number and is only identical to itself
382  if (this == &b) return true;
383  if (IsNumbered() || b.IsNumbered()) return false;
384  if (Properties.GetSize() != b.Properties.GetSize()) return false;
385  if (GetDef() != b.GetDef()) return false;
386  const C4Property * p = Properties.First();
387  while (p)
388  {
389  const C4Property & bp = b.Properties.Get(p->Key);
390  if (!bp) return false;
391  if (p->Value != bp.Value) return false;
392  p = Properties.Next(p);
393  }
394  return true;
395 }
C4Value Value
Definition: C4PropList.h:55
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
T & Get(H e) const
T const * Next(T const *p) const
unsigned int GetSize() const
C4String * Key
Definition: C4PropList.h:54
virtual bool IsNumbered() const
Definition: C4PropList.h:88
T const * First() const

Here is the call graph for this function:

void C4Effect::ReAssignAllCallbackFunctions ( )
inline

Definition at line 129 of file C4Effect.h.

References ReAssignAllCallbackFunctions(), and ReAssignCallbackFunctions().

Referenced by ReAssignAllCallbackFunctions(), C4AulScriptEngine::ReLink(), and C4Object::UpdateScriptPointers().

130  {
133  }
C4Effect * pNext
Definition: C4Effect.h:75
void ReAssignAllCallbackFunctions()
Definition: C4Effect.h:129
void ReAssignCallbackFunctions()
Definition: C4Effect.h:127

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::ReAssignCallbackFunctions ( )
inline

Definition at line 127 of file C4Effect.h.

References AssignCallbackFunctions().

Referenced by OnObjectChangedDef(), ReAssignAllCallbackFunctions(), and SetPropertyByS().

void AssignCallbackFunctions()
Definition: C4Effect.cpp:27

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::Register ( C4Effect **  ppEffectList,
int32_t  iPrio 
)

Definition at line 71 of file C4Effect.cpp.

References Abs(), iPriority, and pNext.

Referenced by C4Effect().

72 {
73  // get effect target
74  C4Effect *pCheck, *pPrev = *ppEffectList;
75  if (pPrev && Abs(pPrev->iPriority) < iPrio)
76  {
77  while ((pCheck = pPrev->pNext))
78  if (Abs(pCheck->iPriority) >= iPrio) break; else pPrev = pCheck;
79  // insert after previous
80  pNext = pPrev->pNext;
81  pPrev->pNext = this;
82  }
83  else
84  {
85  // insert as first effect
86  pNext = *ppEffectList;
87  *ppEffectList = this;
88  }
89 }
C4Effect * pNext
Definition: C4Effect.h:75
int32_t iPriority
Definition: C4Effect.h:72
T Abs(T val)
Definition: Standard.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::RemoveCyclicPrototypes ( )
inherited

Definition at line 430 of file C4PropList.cpp.

References C4Value::getPropList(), and C4Value::Set0().

Referenced by C4PropList::Denumerate().

431 {
432  // clear any cyclic prototype chains
433  // Use prototype.getPropList() instead of GetPrototype() because denumeration might not be completed yet
434  for(C4PropList * it = prototype.getPropList(); it; it = it->prototype.getPropList())
435  if(it == this)
436  {
437  prototype.Set0();
438  }
439 }
void Set0()
Definition: C4Value.h:336
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ResetEnumerationIndex ( )
staticinherited

Definition at line 99 of file C4PropList.cpp.

References C4PropListNumbered::EnumerationIndex, C4Set< T >::GetSize(), and C4PropListNumbered::PropLists.

Referenced by C4Game::Clear().

100 {
101  assert(!PropLists.GetSize());
102  EnumerationIndex = 0;
103 }
unsigned int GetSize() const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
static int32_t EnumerationIndex
Definition: C4PropList.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::ResetProperty ( C4String k)
overridevirtual

Reimplemented from C4PropList.

Definition at line 614 of file C4Effect.cpp.

References iInterval, iTime, C4StringTable::P, P_CommandTarget, P_Interval, P_LAST, P_Name, P_Priority, P_Prototype, P_Target, P_Time, C4PropList::ResetProperty(), and Strings.

615 {
616  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
617  {
618  switch(k - &Strings.P[0])
619  {
620  case P_Name:
621  throw C4AulExecError("effect: Name has to be a nonempty string");
622  case P_Priority:
623  throw C4AulExecError("effect: Priority is readonly");
624  case P_Interval: iInterval = 0; return;
625  case P_CommandTarget:
626  throw C4AulExecError("effect: CommandTarget is readonly");
627  case P_Target:
628  throw C4AulExecError("effect: Target is readonly");
629  case P_Time: iTime = 0; return;
630  case P_Prototype:
631  throw new C4AulExecError("effect: Prototype is readonly");
632  }
633  }
635 }
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:973
C4String P[P_LAST]
int32_t iInterval
Definition: C4Effect.h:73
C4StringTable Strings
Definition: C4Globals.cpp:42
int32_t iTime
Definition: C4Effect.h:73

Here is the call graph for this function:

void C4Effect::SetDead ( )

Definition at line 205 of file C4Effect.cpp.

References iPriority.

Referenced by ClearAll(), ClearPointers(), Init(), and Kill().

206 {
207  iPriority = 0;
208 }
int32_t iPriority
Definition: C4Effect.h:72

Here is the caller graph for this function:

void C4PropListNumbered::SetEnumerationIndex ( int32_t  iMaxObjectNumber)
staticinherited

Definition at line 93 of file C4PropList.cpp.

References C4PropListNumbered::EnumerationIndex.

Referenced by C4Game::CheckObjectEnumeration(), and C4GameObjects::PostLoad().

94 {
95  // update object enumeration index now, because calls like OnSynchronized might create objects
96  EnumerationIndex = std::max(EnumerationIndex, iMaxObjectNumber);
97 }
static int32_t EnumerationIndex
Definition: C4PropList.h:238

Here is the caller graph for this function:

void C4PropList::SetName ( const char *  NewName = nullptr)
virtualinherited

Reimplemented in C4Object.

Definition at line 656 of file C4PropList.cpp.

References C4VString(), C4StringTable::P, P_Name, C4PropList::ResetProperty(), C4PropList::SetProperty(), and Strings.

Referenced by c4_mapgen_handle_set_map_library(), C4MapScriptHost::InitFunctionMap(), and C4Object::SetName().

657 {
658  if (!NewName)
660  else
661  {
662  SetProperty(P_Name, C4VString(NewName));
663  }
664 }
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:973
C4String P[P_LAST]
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4PropList::SetOnFire ( bool  OnFire)
inlinevirtualinherited

Reimplemented in C4Object.

Definition at line 69 of file C4PropList.h.

Referenced by ClearAll(), Init(), Kill(), TempReaddUpperEffects(), and TempRemoveUpperEffects().

69 { }

Here is the caller graph for this function:

void C4PropList::SetProperty ( C4PropertyName  k,
const C4Value to 
)
inlineinherited

Definition at line 120 of file C4PropList.h.

References C4StringTable::P, C4PropList::SetPropertyByS(), and Strings.

Referenced by C4Game::AllocateTranslatedString(), C4Effect(), C4Object::ChangeDef(), C4Object::Init(), C4DefScriptHost::Parse(), C4ScriptHost::Preparse(), C4Object::SetAction(), C4PropList::SetName(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnLink(), and C4MapScriptLayer::UpdateSurfaceSize().

121  { SetPropertyByS(&Strings.P[k], to); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:952

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::SetPropertyByS ( C4String k,
const C4Value to 
)
overridevirtual

Reimplemented from C4PropList.

Definition at line 587 of file C4Effect.cpp.

References C4String::GetCStr(), C4Value::getInt(), C4Value::getStr(), iInterval, iTime, C4StringTable::P, P_CommandTarget, P_Interval, P_LAST, P_Name, P_Priority, P_Prototype, P_Target, P_Time, ReAssignCallbackFunctions(), C4PropList::SetPropertyByS(), and Strings.

588 {
589  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
590  {
591  switch(k - &Strings.P[0])
592  {
593  case P_Name:
594  if (!to.getStr() || !*to.getStr()->GetCStr())
595  throw C4AulExecError("effect: Name has to be a nonempty string");
598  return;
599  case P_Priority:
600  throw C4AulExecError("effect: Priority is readonly");
601  case P_Interval: iInterval = to.getInt(); return;
602  case P_CommandTarget:
603  throw C4AulExecError("effect: CommandTarget is readonly");
604  case P_Target:
605  throw C4AulExecError("effect: Target is readonly");
606  case P_Time: iTime = to.getInt(); return;
607  case P_Prototype:
608  throw new C4AulExecError("effect: Prototype is readonly");
609  }
610  }
612 }
C4String P[P_LAST]
C4String * getStr() const
Definition: C4Value.h:117
const char * GetCStr() const
Definition: C4StringTable.h:49
int32_t iInterval
Definition: C4Effect.h:73
void ReAssignCallbackFunctions()
Definition: C4Effect.h:127
C4StringTable Strings
Definition: C4Globals.cpp:42
int32_t iTime
Definition: C4Effect.h:73
int32_t getInt() const
Definition: C4Value.h:112
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:952

Here is the call graph for this function:

void C4PropListNumbered::ShelveNumberedPropLists ( )
staticinherited

Definition at line 105 of file C4PropList.cpp.

References C4PropListNumbered::ClearNumber(), C4Set< T >::First(), C4Set< T >::GetSize(), C4Set< T >::Next(), C4PropListNumbered::Number, C4PropListNumbered::PropLists, and C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::CompileFunc().

106 {
107  // unnumber all proplists and put them on the shelve. To be used on remaining objects before a savegame load.
108  assert(ShelvedPropLists.empty());
110  C4PropListNumbered *const* p_next = PropLists.First(), *const* p;
111  while ((p = p_next))
112  {
113  p_next = PropLists.Next(p);
114  C4PropListNumbered *pl = *p;
115  if (pl->Number != -1)
116  {
117  pl->ClearNumber();
118  ShelvedPropLists.push_back(pl);
119  }
120  }
121 }
static std::vector< C4PropListNumbered * > ShelvedPropLists
Definition: C4PropList.h:237
T const * Next(T const *p) const
unsigned int GetSize() const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::TempReaddUpperEffects ( C4Effect pLastReaddEffect)
protected

Definition at line 510 of file C4Effect.cpp.

References C4Fx_AnyFire, C4FxCall_Temp, C4PropList::C4Value, pNext, C4PropList::SetOnFire(), C4PropList::Status, Target, and WildcardMatch().

Referenced by Check(), Init(), and Kill().

511 {
512  // nothing to do? - this will also happen if TempRemoveUpperEffects did nothing due to priority==1
513  if (!pLastReaddEffect) return;
514  if (Target && !Target->Status) return; // this will be invalid!
515  // simply activate all following, inactive effects
516  for (C4Effect *pEff = pNext; pEff; pEff = pEff->pNext)
517  {
518  if (pEff->IsInactiveAndNotDead())
519  {
520  pEff->FlipActive();
521  if (pEff->iPriority!=1) pEff->CallStart(C4FxCall_Temp, C4Value(), C4Value(), C4Value(), C4Value());
522  if (Target && WildcardMatch(C4Fx_AnyFire, pEff->GetName()))
523  Target->SetOnFire(true);
524  }
525  // done?
526  if (pEff == pLastReaddEffect) break;
527  }
528 }
C4Effect * pNext
Definition: C4Effect.h:75
friend class C4Value
Definition: C4PropList.h:165
#define C4Fx_AnyFire
Definition: C4Effect.h:151
int32_t Status
Definition: C4PropList.h:168
#define C4FxCall_Temp
Definition: C4Effect.h:43
C4PropList * Target
Definition: C4Effect.h:79
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
virtual void SetOnFire(bool OnFire)
Definition: C4PropList.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Effect::TempRemoveUpperEffects ( bool  fTempRemoveThis,
C4Effect **  ppLastRemovedEffect 
)
protected

Definition at line 485 of file C4Effect.cpp.

References C4Fx_AnyFire, C4FxCall_Temp, CallStop(), FlipActive(), Get(), C4PropList::GetName(), iPriority, IsActive(), pNext, C4PropList::SetOnFire(), C4PropList::Status, Target, TempRemoveUpperEffects(), and WildcardMatch().

Referenced by Check(), Init(), Kill(), and TempRemoveUpperEffects().

486 {
487  if (Target && !Target->Status) return; // this will be invalid!
488  // priority=1: no callbacks
489  if (iPriority == 1) return;
490  // remove from high to low priority
491  // recursive implementation...
492  C4Effect *pEff = pNext;
493  while (pEff) if (pEff->IsActive()) break; else pEff = pEff->pNext;
494  // temp remove active effects with higher priority
495  if (pEff) pEff->TempRemoveUpperEffects(true, ppLastRemovedEffect);
496  // temp remove this
497  if (fTempRemoveThis)
498  {
499  FlipActive();
500  // Update OnFire cache
502  if (!Get(C4Fx_AnyFire))
503  Target->SetOnFire(false);
504  // temp callbacks only for higher priority effects
505  if (iPriority!=1) CallStop(C4FxCall_Temp, true);
506  if (!*ppLastRemovedEffect) *ppLastRemovedEffect = this;
507  }
508 }
C4Effect * pNext
Definition: C4Effect.h:75
void FlipActive()
Definition: C4Effect.h:111
void TempRemoveUpperEffects(bool fTempRemoveThis, C4Effect **ppLastRemovedEffect)
Definition: C4Effect.cpp:485
bool IsActive()
Definition: C4Effect.h:112
int CallStop(int reason, bool temporary)
Definition: C4Effect.cpp:435
virtual const char * GetName() const
Definition: C4PropList.cpp:649
#define C4Fx_AnyFire
Definition: C4Effect.h:151
int32_t Status
Definition: C4PropList.h:168
C4Effect * Get(const char *szName, int32_t iIndex=0, int32_t iMaxPriority=0)
Definition: C4Effect.cpp:210
#define C4FxCall_Temp
Definition: C4Effect.h:43
C4PropList * Target
Definition: C4Effect.h:79
int32_t iPriority
Definition: C4Effect.h:72
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
virtual void SetOnFire(bool OnFire)
Definition: C4PropList.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::Thaw ( )
inlineinherited

Definition at line 129 of file C4PropList.h.

Referenced by C4PropList::ThawRecursively(), and C4ScriptHost::UnlinkOwnedFunctions().

129 { constant = false; }

Here is the caller graph for this function:

void C4PropList::ThawRecursively ( )
inherited

Definition at line 283 of file C4PropList.cpp.

References C4PropList::GetPropertyByS(), C4Value::getPropList(), C4AulScriptEngine::GetPropList(), C4PropList::GetUnsortedProperties(), C4PropList::IsFrozen(), C4PropList::IsStatic(), s, ScriptEngine, C4PropList::Thaw(), and C4PropList::ThawRecursively().

Referenced by C4PropList::ThawRecursively(), and C4AulScriptEngine::UnLink().

284 {
285  //thaw self and all owned properties
286  Thaw();
288  //if (s) LogF("Thaw: %s", s->GetDataString().getData());
289  auto prop_names = GetUnsortedProperties(nullptr, ::ScriptEngine.GetPropList());
290  for (auto prop_name : prop_names)
291  {
292  C4Value child_val;
293  GetPropertyByS(prop_name, &child_val);
294  //LogF(" %s=%s", prop_name->GetCStr(), child_val.GetDataString(1).getData());
295  C4PropList *child_proplist = child_val.getPropList();
296  if (child_proplist && child_proplist->IsFrozen())
297  {
298  child_proplist->ThawRecursively();
299  }
300  }
301 }
void Thaw()
Definition: C4PropList.h:129
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
void ThawRecursively()
Definition: C4PropList.cpp:283
bool IsFrozen() const
Definition: C4PropList.h:131
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614
#define s
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

StdStrBuf C4PropList::ToJSON ( int  depth = 10,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 546 of file C4PropList.cpp.

References StdStrBuf::Append(), C4PropList::C4Value, C4Set< T >::GetSize(), C4Set< T >::GetSortedListOfElementPointers(), C4PropList::IsStatic(), and C4Value::ToJSON().

Referenced by C4Value::ToJSON().

547 {
548  if (depth <= 0 && Properties.GetSize())
549  {
550  throw new C4JSONSerializationError("maximum depth reached");
551  }
552  StdStrBuf DataString;
553  DataString = "{";
554  bool has_elements = false;
555  // Append prototype
556  if (prototype)
557  {
558  DataString.Append("Prototype:");
559  DataString.Append(prototype.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
560  has_elements = true;
561  }
562  // Append other properties
563  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
564  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
565  {
566  if (has_elements) DataString.Append(",");
567  DataString.Append(C4Value((*p)->Key).ToJSON());
568  DataString.Append(":");
569  DataString.Append((*p)->Value.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
570  has_elements = true;
571  }
572  DataString.Append("}");
573  return DataString;
574 }
std::list< const T * > GetSortedListOfElementPointers() const
friend class C4Value
Definition: C4PropList.h:165
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
StdStrBuf ToJSON(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::UnshelveNumberedPropLists ( )
staticinherited

Definition at line 123 of file C4PropList.cpp.

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::LoadScenarioSection(), and C4GameObjects::PostLoad().

124 {
125  // re-insert shelved proplists into main list and give them a number
126  for (auto & ShelvedPropList : ShelvedPropLists)
127  ShelvedPropList->AcquireNumber();
128  ShelvedPropLists.clear();
129 }
static std::vector< C4PropListNumbered * > ShelvedPropLists
Definition: C4PropList.h:237

Here is the caller graph for this function:

Friends And Related Function Documentation

template<class T , typename... P>
void CompileNewFunc ( T *&  ,
StdCompiler ,
P &&  ... 
)
friend

Member Data Documentation

C4Value C4Effect::CommandTarget
protected
int32_t C4PropListNumbered::EnumerationIndex = 0
staticprotectedinherited
int32_t C4Effect::iInterval
int32_t C4Effect::iPriority
int32_t C4Effect::iTime

Definition at line 73 of file C4Effect.h.

Referenced by C4Effect(), CompileFunc(), Execute(), GetPropertyByS(), ResetProperty(), and SetPropertyByS().

C4AulFunc* C4Effect::pFnDamage
protected

Definition at line 84 of file C4Effect.h.

Referenced by AssignCallbackFunctions(), and CallDamage().

C4AulFunc* C4Effect::pFnEffect
protected

Definition at line 83 of file C4Effect.h.

Referenced by AssignCallbackFunctions(), and CallEffect().

C4AulFunc* C4Effect::pFnStart
protected

Definition at line 82 of file C4Effect.h.

Referenced by AssignCallbackFunctions(), CallStart(), and Init().

C4AulFunc * C4Effect::pFnStop
protected

Definition at line 82 of file C4Effect.h.

Referenced by AssignCallbackFunctions(), and CallStop().

C4AulFunc* C4Effect::pFnTimer
protected

Definition at line 81 of file C4Effect.h.

Referenced by AssignCallbackFunctions(), and CallTimer().

std::vector< C4PropListNumbered * > C4PropListNumbered::ShelvedPropLists
staticprotectedinherited
int32_t C4PropList::Status {1}
inherited

Definition at line 168 of file C4PropList.h.

Referenced by C4Command::Acquire(), C4Command::Activate(), C4GameObjects::Add(), C4ObjectList::Add(), C4FoW::Add(), C4EditCursor::AddToSelection(), C4Object::AssignDeath(), C4ObjectList::AssignInfo(), C4Object::AssignRemoval(), C4Object::At(), C4PropList::Call(), C4Game::CastObjects(), C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), ClearAll(), C4ObjectList::ClearInfo(), C4Object::Collect(), C4Object::CompileFunc(), C4GameObjects::CrossCheck(), C4ObjectList::DeleteObjects(), C4ObjectList::Denumerate(), C4Landscape::P::DigMaterial2Objects(), C4Object::DirectComContents(), DoDamage(), C4Object::Draw(), C4Game::DrawCrewOverheadText(), C4Object::DrawSelectMark(), C4Object::DrawTopFace(), C4EditCursor::EMMoveObject(), C4Object::Enter(), C4Object::ExecAction(), C4SoundInstance::Execute(), Execute(), C4Object::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4FindObject::Find(), C4ObjectList::Find(), C4ObjectList::FindOther(), C4GameObjects::FixObjectOrder(), C4PropList::FreezeAndMakeStaticRecursively(), C4Object::GetArea(), C4EditCursor::GetCurrentSelectionPosition(), C4Object::GetEntranceArea(), C4Object::GetInfoString(), C4ObjectList::GetListID(), C4Object::GetMomentum(), C4ObjectList::GetObject(), C4Object::GrabInfo(), GrabLost(), C4GameObjects::GRBroadcast(), C4GameMessage::Init(), Init(), C4Object::IsMoveableBySolidMask(), C4GraphicsOverlay::IsValid(), C4Object::Lift(), C4ObjectList::ListIDCount(), C4Player::MakeCrewMember(), C4ObjectList::MassCount(), C4Object::MenuCommand(), C4GameMessageList::New(), C4Game::NewObject(), ObjectComGrab(), ObjectComUnGrab(), C4ObjectList::ObjectCount(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4GameObjects::PostLoad(), C4Object::Push(), C4GameObjects::Remove(), C4EditCursor::RemoveFromSelection(), C4AulScriptContext::ReturnDump(), C4GameObjects::SafeObjectPointer(), C4Object::SetAction(), C4Object::SetGraphics(), C4GameObjects::SetOCF(), C4Object::SetOCF(), C4Object::StatusActivate(), C4Object::StatusDeactivate(), TempReaddUpperEffects(), TempRemoveUpperEffects(), C4ObjectList::UpdateFaces(), C4ObjectList::UpdateGraphics(), C4Object::UpdateOCF(), C4Object::UpdatePos(), C4Object::UpdateSolidMask(), C4GameObjects::UpdateSolidMasks(), C4ObjectList::ValidateOwners(), and C4ObjectList::Write().


The documentation for this class was generated from the following files: