OpenClonk
C4PropListNumbered Class Reference

#include <C4PropList.h>

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

Public Member Functions

 ~C4PropListNumbered () 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 C4EffectGetEffect ()
 
virtual class C4MapScriptLayerGetMapScriptLayer ()
 
virtual class C4MapScriptMapGetMapScriptMap ()
 
C4PropListGetPrototype () const
 
void RemoveCyclicPrototypes ()
 
virtual class C4PropListStaticIsStatic ()
 
const class C4PropListStaticIsStatic () const
 
virtual bool Delete ()
 
virtual bool GetPropertyByS (const C4String *k, C4Value *pResult) const
 
virtual C4ValueArrayGetProperties () const
 
virtual void SetPropertyByS (C4String *k, const C4Value &to)
 
virtual void ResetProperty (C4String *k)
 
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)
 
virtual void Denumerate (C4ValueNumbers *)
 
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 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 Number {-1}
 
int32_t Status {1}
 

Protected Member Functions

 C4PropListNumbered (C4PropList *prototype=nullptr)
 
void AcquireNumber ()
 
void ClearNumber ()
 
void ClearRefs ()
 

Static Protected Attributes

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

Friends

class C4Game
 
class C4GameObjects
 

Detailed Description

Definition at line 213 of file C4PropList.h.

Constructor & Destructor Documentation

◆ ~C4PropListNumbered()

C4PropListNumbered::~C4PropListNumbered ( )
override

Definition at line 199 of file C4PropList.cpp.

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

200 {
201  if (Number != -1)
202  PropLists.Remove(this);
203  else
204  Log("removing numbered proplist without number");
205 }
void Remove(H e)
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
Here is the call graph for this function:

◆ C4PropListNumbered()

C4PropListNumbered::C4PropListNumbered ( C4PropList prototype = nullptr)
protected

Definition at line 151 of file C4PropList.cpp.

151  : C4PropList(prototype)
152 {
153 }
C4PropList(C4PropList *prototype=nullptr)
Definition: C4PropList.cpp:275

Member Function Documentation

◆ AcquireNumber()

void C4PropListNumbered::AcquireNumber ( )
protected

Definition at line 155 of file C4PropList.cpp.

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

Referenced by C4Effect::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:

◆ AppendDataString()

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 C4PropList::IsFrozen().

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 }
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
std::list< const T * > GetSortedListOfElementPointers() const
unsigned int GetSize() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 1026 of file C4PropList.cpp.

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

Referenced by C4PropList::begin(), C4ParticleProperties::Set(), C4Object::ShiftContents(), and C4ScriptGuiWindow::~C4ScriptGuiWindow().

1027 {
1028  C4PropList::Iterator iter;
1029 
1030  if (GetPrototype())
1031  {
1032  iter = GetPrototype()->begin();
1033  }
1034  else
1035  {
1036  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1037  }
1038  iter.Reserve(Properties.GetSize());
1039 
1040  const C4Property * p = Properties.First();
1041  while (p)
1042  {
1043  iter.AddProperty(p);
1044  p = Properties.Next(p);
1045  }
1046 
1047  iter.Init();
1048  return iter;
1049 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * Next(T const *p) const
Iterator begin()
T const * First() const
unsigned int GetSize() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Call() [1/3]

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

Definition at line 110 of file C4PropList.h.

References C4ScriptGuiWindowActionID::Call, C4PropList::GetPropertyBool(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), C4PropList::GetPropertyPropList(), C4StringTable::P, and Strings.

Referenced by C4Command::Acquire(), C4Object::ActivateMenu(), C4ControlPlayerSelect::C4ControlPlayerSelect(), C4Command::Call(), C4GameScriptHost::Call(), C4Effect::CallEffect(), C4Command::CallFailed(), C4Effect::CallStart(), C4Effect::CallStop(), C4Effect::CallTimer(), C4FindObjectFunc::Check(), C4Effect::ClearAll(), C4Object::Collect(), C4SortObjectFunc::CompareGetValue(), C4Control::CompileFunc(), C4Object::Contact(), C4GameObjects::CrossCheck(), C4Landscape::P::DigMaterial2Objects(), C4Object::DoMovement(), C4ObjectMenu::DoRefillInternal(), C4ControlPlayerMouse::DragDrop(), C4Object::Enter(), C4RoundResults::EvaluateGame(), C4RoundResults::EvaluateGoals(), C4ScriptGuiWindowAction::ExecuteCommand(), C4PlayerControl::ExecuteControlPacket(), C4Object::Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), C4Object::GetValue(), GrabLost(), C4GameObjects::GRBroadcast(), C4Landscape::Incinerate(), C4Effect::Init(), C4Player::Init(), C4ControlPlayerAction::InitPlayerControl(), C4ObjectMenu::IsCloseDenied(), C4Effect::Kill(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4GameObjects::OnSynchronized(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4Game::SaveData(), C4GUI::FrameDecoration::SetByDef(), C4Player::SetObjectCrewStatus(), C4DefList::Synchronize(), C4Command::Transfer(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

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 call graph for this function:
Here is the caller graph for this function:

◆ Call() [2/3]

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 }
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
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
Here is the call graph for this function:

◆ Call() [3/3]

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 }
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
friend class C4Value
Definition: C4PropList.h:165
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173
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
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
#define s
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:

◆ CheckPropList()

bool C4PropListNumbered::CheckPropList ( C4PropList pObj)
static

Definition at line 80 of file C4PropList.cpp.

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
T const * First() const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
Here is the caller graph for this function:

◆ Clear()

void C4PropList::Clear ( )
inlineinherited

Definition at line 66 of file C4PropList.h.

Referenced by C4ExtraScriptHost::Clear(), C4AulScriptEngine::Clear(), C4Def::Clear(), ClearNumberedPropLists(), C4Set< C4String *>::CompileFunc(), C4ScriptHost::DeleteOwnedPropLists(), C4MapScriptHost::InitFunctionMap(), C4Def::~C4Def(), and C4MapScriptHost::~C4MapScriptHost().

66 { constant = false; Properties.Clear(); prototype.Set0(); }
void Set0()
Definition: C4Value.h:336
void Clear()
Here is the caller graph for this function:

◆ ClearNumber()

void C4PropListNumbered::ClearNumber ( )
protected

Definition at line 165 of file C4PropList.cpp.

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

Referenced by 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:

◆ ClearNumberedPropLists()

void C4PropListNumbered::ClearNumberedPropLists ( )
static

Definition at line 137 of file C4PropList.cpp.

References C4PropList::Clear().

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 }
T const * Next(T const *p) const
void Clear()
Definition: C4PropList.h:66
T const * First() 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:

◆ ClearRefs()

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 156 of file C4PropList.h.

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

◆ ClearShelve()

void C4PropListNumbered::ClearShelve ( )
static

Definition at line 131 of file C4PropList.cpp.

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:

◆ CompileFunc()

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

Definition at line 180 of file C4PropList.cpp.

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

Referenced by C4Effect::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:

◆ Delete()

virtual bool C4PropList::Delete ( )
inlinevirtualinherited

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 90 of file C4PropList.h.

Referenced by C4AulScriptEngine::Clear(), and C4ScriptHost::DeleteOwnedPropLists().

90 { return false; }
Here is the caller graph for this function:

◆ Denumerate()

void C4PropList::Denumerate ( C4ValueNumbers numbers)
virtualinherited

Reimplemented in C4Object, C4AulScriptEngine, and C4Effect.

Definition at line 350 of file C4PropList.cpp.

References C4Value::Denumerate(), C4Set< T >::First(), C4Set< T >::Next(), C4PropList::RemoveCyclicPrototypes(), and C4Property::Value.

Referenced by C4AulScriptEngine::Denumerate(), C4Value::Denumerate(), C4Object::Denumerate(), and C4PropList::IsFrozen().

351 {
352  const C4Property * p = Properties.First();
353  while (p)
354  {
355  const_cast<C4Value &>(p->Value).Denumerate(numbers);
356  p = Properties.Next(p);
357  }
358  prototype.Denumerate(numbers);
360 }
void RemoveCyclicPrototypes()
Definition: C4PropList.cpp:430
C4Value Value
Definition: C4PropList.h:55
T const * Next(T const *p) const
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:350
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:251
T const * First() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

Iterator C4PropList::end ( )
inlineinherited

Definition at line 206 of file C4PropList.h.

References CompileNewFunc().

Referenced by C4ParticleProperties::Set(), and C4ScriptGuiWindow::~C4ScriptGuiWindow().

206 { return Iterator(); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnumerateOwnFuncs()

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

Definition at line 959 of file C4PropList.cpp.

References C4Value::getFunction(), C4Property::Key, and C4Property::Value.

Referenced by C4AulExec::DirectExec(), and C4PropList::GetFunc().

960 {
961  const C4Property * p = prev ? Properties.Next(&Properties.Get(prev)) : Properties.First();
962  while (p)
963  {
964  if (p->Value.getFunction())
965  return p->Key;
966  p = Properties.Next(p);
967  }
968  return nullptr;
969 }
C4Value Value
Definition: C4PropList.h:55
T & Get(H e) const
T const * Next(T const *p) const
C4AulFunc * getFunction() const
Definition: C4Value.h:119
T const * First() const
C4String * Key
Definition: C4PropList.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Freeze()

void C4PropList::Freeze ( )
inlineinherited

Definition at line 128 of file C4PropList.h.

Referenced by C4ScriptLibrary::C4ScriptLibrary(), and C4PropList::FreezeAndMakeStaticRecursively().

128 { constant = true; }
Here is the caller graph for this function:

◆ FreezeAndMakeStaticRecursively()

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(), C4PropList::IsFrozen(), 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
C4PropList * getPropList() const
Definition: C4Value.h:116
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
C4String * GetParentKeyName()
Definition: C4PropList.h:271
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:245
int32_t Status
Definition: C4PropList.h:168
static C4PropListStatic * NewStatic(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.cpp:70
std::vector< C4String *> GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:576
const C4PropListStatic * GetParent() const
Definition: C4PropList.h:270
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
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:

◆ GetByNumber()

C4PropList * C4PropListNumbered::GetByNumber ( int32_t  iNumber)
static

Definition at line 75 of file C4PropList.cpp.

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 caller graph for this function:

◆ GetDef() [1/2]

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(), C4VObj(), ConstructionCheck(), C4Game::CreateObject(), C4Game::CreateObjectConstruction(), C4AulExec::DirectExec(), C4GameMessage::Draw(), C4Game::DrawPropListSpecImage(), C4AulExec::FnTranslate(), C4PropList::GetDef(), C4Value::getDef(), C4GameMessage::Init(), C4Object::Init(), 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 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDef() [2/2]

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 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
Here is the call graph for this function:

◆ GetEffect()

C4Effect * C4PropList::GetEffect ( )
virtualinherited

Reimplemented in C4Effect.

Definition at line 709 of file C4PropList.cpp.

References a, b, C4PropList::GetEffect(), C4PropList::GetPrototype(), and C4Set< T >::Hash().

Referenced by C4ValueConv< C4Effect * >::_FromC4V(), C4VObj(), and C4PropList::GetEffect().

710 {
711  if (GetPrototype()) return GetPrototype()->GetEffect();
712  return nullptr;
713 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Effect * GetEffect()
Definition: C4PropList.cpp:709
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEnumerationIndex()

static int32_t C4PropListNumbered::GetEnumerationIndex ( )
inlinestatic

Definition at line 225 of file C4PropList.h.

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:

◆ GetFunc() [1/3]

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

Definition at line 105 of file C4PropList.h.

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

Referenced by C4Effect::AssignCallbackFunctions(), C4PropList::Call(), C4Effect::CallDamage(), C4AulExec::ClearPointers(), C4Value::CompileFunc(), C4ScriptHost::CopyPropList(), C4AulExec::DirectExec(), C4Effect::DoCall(), C4PropList::GetFunc(), C4AulScriptEngine::GetFunctionNames(), C4Effect::Init(), C4MapScriptHost::InitializeMap(), C4MaterialReaction::ResolveScriptFuncs(), C4MCOverlay::SetField(), and C4AulCompiler::PreparseAstVisitor::visit().

106  { return GetFunc(&Strings.P[k]); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFunc() [2/3]

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

Definition at line 803 of file C4PropList.cpp.

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

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
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4AulFunc * getFunction() const
Definition: C4Value.h:119
bool Has(H e) const
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
Here is the call graph for this function:

◆ GetFunc() [3/3]

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 }
C4StringTable Strings
Definition: C4Globals.cpp:42
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4String * FindString(const char *strString) const
#define s
Here is the call graph for this function:

◆ GetMapScriptLayer()

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:

◆ GetMapScriptMap()

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:

◆ GetName()

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(), C4Effect::AssignCallbackFunctions(), C4ControlEMDrawTool::C4ControlEMDrawTool(), C4Effect::C4Effect(), C4PropertyPath::C4PropertyPath(), C4Object::CanConcatPictureWith(), C4FindObjectAction::Check(), C4Game::CheckObjectEnumeration(), C4Effect::ClearAll(), C4Control::CompileFunc(), ConstructionCheck(), C4Effect::DoCall(), C4EditCursor::DoContextMenu(), C4ObjectMenu::DoRefillInternal(), C4Object::Draw(), C4Game::DrawCrewOverheadText(), C4Effect::Get(), C4Effect::GetCount(), GetTextColorForBackground(), C4Value::GetTypeEx(), C4Effect::Init(), C4Effect::Kill(), C4Game::NewObject(), ObjectComDig(), C4Object::SetAction(), and C4Effect::TempRemoveUpperEffects().

650 {
652  if (!s) return "";
653  return s->GetCStr();
654 }
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
const char * GetCStr() const
Definition: C4StringTable.h:49
#define s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetObject() [1/2]

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(), C4VObj(), C4AulExec::ClearPointers(), C4GameMessage::Draw(), C4Value::getObj(), C4PropList::GetObject(), C4GameMessage::Init(), Object(), C4GameObjects::ObjectPointer(), C4AulDebug::OnLog(), C4EditCursor::RemoveFromSelection(), and C4ScriptGuiWindowProperty::Set().

668 {
669  if (GetPrototype()) return GetPrototype()->GetObject();
670  return nullptr;
671 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetObject() [2/2]

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 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
Here is the call graph for this function:

◆ GetProperties()

C4ValueArray * C4PropList::GetProperties ( ) const
virtualinherited

Reimplemented in C4Object, and C4Effect.

Definition at line 914 of file C4PropList.cpp.

References a, C4V_String, C4VString(), C4PropList::GetProperties(), C4PropList::GetPrototype(), C4ValueArray::GetSize(), C4Property::Key, and C4ValueArray::SetSize().

Referenced by C4ScriptGuiWindow::CreateFromPropList(), C4AulScriptEngine::GetFunctionNames(), C4PropList::GetProperties(), C4Effect::GetProperties(), C4Object::GetProperties(), and C4ScriptGuiWindowProperty::Set().

915 {
916  C4ValueArray * a;
917  int i = 0;
918  const bool hasInheritedProperties = GetPrototype() != nullptr;
919  if (hasInheritedProperties)
920  {
921  a = GetPrototype()->GetProperties();
922  i = a->GetSize();
923  a->SetSize(i + Properties.GetSize());
924  }
925  else
926  {
927  a = new C4ValueArray(Properties.GetSize());
928  i = 0;
929  }
930  const C4Property * p = Properties.First();
931  while (p)
932  {
933  C4String *newPropertyName = p->Key;
934  assert(newPropertyName != nullptr && "Proplist key is nullpointer");
935  // Do we need to check for duplicate property names?
936  bool skipProperty = false;
937  if (hasInheritedProperties)
938  {
939  for (size_t j = 0; j < i; ++j)
940  {
941  if ((*a)[j].getStr() != newPropertyName) continue;
942  skipProperty = true;
943  break;
944  }
945  }
946  if (!skipProperty)
947  {
948  (*a)[i++] = C4VString(newPropertyName);
949  assert(((*a)[i - 1].GetType() == C4V_String) && "Proplist key is non-string");
950  }
951  p = Properties.Next(p);
952  }
953  // We might have added less properties than initially intended.
954  if (hasInheritedProperties)
955  a->SetSize(i);
956  return a;
957 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * Next(T const *p) const
#define a
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:914
void SetSize(int32_t inSize)
T const * First() const
int32_t GetSize() const
Definition: C4ValueArray.h:36
unsigned int GetSize() const
C4String * Key
Definition: C4PropList.h:54
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProperty()

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

Definition at line 101 of file C4PropList.h.

Referenced by C4MapScriptAlgoFilter::C4MapScriptAlgoFilter(), C4MapScriptAlgoModifier::C4MapScriptAlgoModifier(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4FindObjectProcedure::Check(), C4PropertyCollection::Clear(), C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), GetTextColorForBackground(), C4MapScriptAlgo::GetXYProps(), C4GameMessage::Init(), C4ScriptUniform::Push(), 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 caller graph for this function:

◆ GetPropertyArray()

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

Definition at line 789 of file C4PropList.cpp.

References C4PropList::GetPropertyArray(), C4PropList::GetPrototype(), C4StringTable::P, and Strings.

Referenced by C4EditCursor::DoContextMenu(), C4PropList::GetPropertyArray(), GetTextColorForBackground(), 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
C4ValueArray * GetPropertyArray(C4PropertyName n) const
Definition: C4PropList.cpp:789
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4ValueArray * getArray() const
Definition: C4Value.h:118
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyBool()

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

Definition at line 872 of file C4PropList.cpp.

References C4PropList::GetPropertyBool(), C4PropList::GetPrototype(), C4StringTable::P, and Strings.

Referenced by C4PropList::Call(), C4PropList::GetPropertyBool(), and GetTextColorForBackground().

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
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:872
bool getBool() const
Definition: C4Value.h:113
bool Has(H e) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyByS()

bool C4PropList::GetPropertyByS ( const C4String k,
C4Value pResult 
) const
virtualinherited

Reimplemented in C4Object, and C4Effect.

Definition at line 757 of file C4PropList.cpp.

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

Referenced by C4PropertyCollection::Clear(), C4Value::CompileFunc(), C4ScriptGuiWindow::CreateFromPropList(), C4PropList::FreezeAndMakeStaticRecursively(), C4Def::GetActionByName(), C4DefList::GetAllDefs(), C4PropList::GetPropertyByS(), C4Effect::GetPropertyByS(), C4Object::GetPropertyByS(), GetTextColorForBackground(), C4Game::GetTranslatedString(), C4ValueArraySortPropertycomp::operator()(), C4ScriptGuiWindowProperty::Set(), C4Object::SetActionByName(), C4PropList::ThawRecursively(), C4ScriptHost::UnlinkOwnedFunctions(), C4GraphicsOverlay::UpdateFacet(), and C4AulCompiler::ConstexprEvaluator::visit().

758 {
759  if (Properties.Has(k))
760  {
761  *pResult = Properties.Get(k).Value;
762  return true;
763  }
764  else if (k == &Strings.P[P_Prototype])
765  {
766  *pResult = prototype;
767  return true;
768  }
769  else if(GetPrototype())
770  return GetPrototype()->GetPropertyByS(k, pResult);
771  else
772  return false;
773 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
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:

◆ GetPropertyInt()

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

Definition at line 886 of file C4PropList.cpp.

References C4PropList::GetPropertyInt(), C4PropList::GetPrototype(), C4StringTable::P, and Strings.

Referenced by C4MouseControl::ButtonUpDragScript(), C4MapScriptAlgoEllipsis::C4MapScriptAlgoEllipsis(), C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4MapScriptAlgoOffset::C4MapScriptAlgoOffset(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRect::C4MapScriptAlgoRect(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MapScriptAlgoScale::C4MapScriptAlgoScale(), C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(), C4PropList::Call(), C4GUI::FrameDecoration::Clear(), C4Object::Contact(), C4Object::ContactAction(), C4Object::DoMovement(), C4MouseControl::DragNone(), C4Object::Draw(), C4Object::DrawActionFace(), C4Game::DrawPropListSpecImage(), C4Object::DrawTopFace(), C4Command::Enter(), C4Object::ExecMovement(), C4ValueProviderAction::Execute(), C4Command::Exit(), C4Command::FlightControl(), FnParAlgo(), C4SoundModifierList::Get(), C4SoundModifier::GetBoolProp(), C4SoundModifier::GetFloatProp(), C4Def::GetPlane(), C4PropList::GetPropertyInt(), GetTextColorForBackground(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), ObjectComJump(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), C4Command::Put(), C4Object::SetAction(), C4Object::SetDir(), C4Object::SetOCF(), C4Object::SetPhase(), C4Object::SideBounds(), C4DefList::Synchronize(), C4Command::Throw(), C4Object::UpdateActionFace(), C4MouseControl::UpdateCursorTarget(), C4GraphicsOverlay::UpdateFacet(), C4Object::UpdateFlipDir(), C4Object::UpdateOCF(), C4Object::VerticalBounds(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().

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
int32_t getInt() const
Definition: C4Value.h:112
T & Get(H e) const
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyP()

C4PropertyName C4PropList::GetPropertyP ( C4PropertyName  k) const
inherited

Definition at line 855 of file C4PropList.cpp.

References C4PropList::GetPropertyP(), C4PropList::GetPrototype(), C4StringTable::P, P_LAST, and Strings.

Referenced by C4PropList::Call(), C4Object::ContactAction(), 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 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
C4String * getStr() const
Definition: C4Value.h:117
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:855
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropertyName
bool Has(H e) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyPropList()

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

Definition at line 900 of file C4PropList.cpp.

References C4PropList::GetPropertyPropList(), C4PropList::GetPrototype(), C4StringTable::P, and Strings.

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), C4PropList::Call(), 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
T & Get(H e) const
C4PropList * getPropList() const
Definition: C4Value.h:116
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:900
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyStr()

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

Definition at line 775 of file C4PropList.cpp.

References C4PropList::GetPropertyStr(), C4PropList::GetPrototype(), C4StringTable::P, and Strings.

Referenced by C4Game::DrawPropListSpecImage(), C4Object::ExecAction(), C4PropList::GetName(), C4PropListStatic::GetName(), C4PropList::GetPropertyStr(), GetTextColorForBackground(), 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
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropListNumbered()

C4PropListNumbered * C4PropListNumbered::GetPropListNumbered ( )
overridevirtual

Reimplemented from C4PropList.

Definition at line 175 of file C4PropList.cpp.

176 {
177  return this;
178 }

◆ GetPrototype()

C4PropList* C4PropList::GetPrototype ( ) const
inlineinherited

◆ GetSortedLocalProperties() [1/2]

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 C4PropertyCollection::Clear(), C4PropList::FreezeAndMakeStaticRecursively(), C4Game::GetTranslatedString(), and C4PropList::IsFrozen().

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]
C4StringTable Strings
Definition: C4Globals.cpp:42
std::list< const T * > GetSortedListOfElementPointers() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSortedLocalProperties() [2/2]

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
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * Next(T const *p) const
#define a
const char * GetCStr() const
Definition: C4StringTable.h:49
C4StringTable Strings
Definition: C4Globals.cpp:42
T const * First() const
bool HasProperty(C4String *k) const
Definition: C4PropList.h:118
Here is the call graph for this function:

◆ GetSortedProperties()

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().

Referenced by C4PropList::IsFrozen().

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
#define a
const char * GetCStr() const
Definition: C4StringTable.h:49
std::vector< C4String *> GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUnsortedProperties()

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(), C4PropList::IsFrozen(), 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]
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * Next(T const *p) const
C4StringTable Strings
Definition: C4Globals.cpp:42
T const * First() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasProperty()

bool C4PropList::HasProperty ( C4String k) const
inlineinherited

Definition at line 118 of file C4PropList.h.

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

118 { return Properties.Has(k); }
bool Has(H e) const
Here is the caller graph for this function:

◆ IsFrozen()

bool C4PropList::IsFrozen ( ) const
inlineinherited

Definition at line 131 of file C4PropList.h.

References C4PropList::AppendDataString(), b, C4PropList::C4PropList(), C4Property::CompileFunc(), C4PropList::Denumerate(), C4PropList::FreezeAndMakeStaticRecursively(), C4PropList::GetSortedLocalProperties(), C4PropList::GetSortedProperties(), C4PropList::GetUnsortedProperties(), operator==(), C4PropList::ToJSON(), and C4PropList::~C4PropList().

Referenced by C4PropertyCollection::Clear(), C4AulExec::ClearPointers(), and C4PropList::ThawRecursively().

131 { return constant; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsNumbered()

bool C4PropListNumbered::IsNumbered ( ) const
inlineoverridevirtual

Reimplemented from C4PropList.

Definition at line 220 of file C4PropList.h.

220 { return true; }

◆ IsStatic() [1/2]

virtual class C4PropListStatic* C4PropList::IsStatic ( )
inlinevirtualinherited

◆ IsStatic() [2/2]

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:

◆ New()

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

Definition at line 64 of file C4PropList.cpp.

Referenced by C4AulExec::ClearPointers(), CompileNewFunc(), FnPlaceVegetation(), C4PropList::SetProperty(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), C4AulCompiler::ConstexprEvaluator::visit(), and C4ScriptGuiWindow::~C4ScriptGuiWindow().

65 {
66  C4PropList * r = new C4PropListScript(prototype);
67  return r;
68 }
Here is the caller graph for this function:

◆ NewStatic()

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(), C4PropList::SetProperty(), and C4AulCompiler::ConstexprEvaluator::visit().

71 {
72  return new C4PropListStatic(prototype, parent, key);
73 }
Here is the caller graph for this function:

◆ operator==()

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 bool IsNumbered() const
Definition: C4PropList.h:88
T & Get(H e) const
T const * Next(T const *p) const
T const * First() const
unsigned int GetSize() const
C4String * Key
Definition: C4PropList.h:54
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
Here is the call graph for this function:

◆ RemoveCyclicPrototypes()

void C4PropList::RemoveCyclicPrototypes ( )
inherited

Definition at line 430 of file C4PropList.cpp.

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

Referenced by C4PropList::Denumerate(), and C4PropList::GetPrototype().

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 }
C4PropList * getPropList() const
Definition: C4Value.h:116
void Set0()
Definition: C4Value.h:336
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetEnumerationIndex()

void C4PropListNumbered::ResetEnumerationIndex ( )
static

Definition at line 99 of file C4PropList.cpp.

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 caller graph for this function:

◆ ResetProperty()

void C4PropList::ResetProperty ( C4String k)
virtualinherited

Reimplemented in C4Object, and C4Effect.

Definition at line 992 of file C4PropList.cpp.

References C4Property::Key, C4StringTable::P, P_Prototype, and Strings.

Referenced by C4Effect::ResetProperty(), C4Object::ResetProperty(), C4PropList::SetName(), and C4ScriptHost::UnlinkOwnedFunctions().

993 {
994  if (k == &Strings.P[P_Prototype])
995  prototype.Set0();
996  else
997  Properties.Remove(k);
998 }
C4String P[P_LAST]
void Set0()
Definition: C4Value.h:336
C4StringTable Strings
Definition: C4Globals.cpp:42
void Remove(H e)
Here is the caller graph for this function:

◆ SetEnumerationIndex()

void C4PropListNumbered::SetEnumerationIndex ( int32_t  iMaxObjectNumber)
static

Definition at line 93 of file C4PropList.cpp.

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:

◆ SetName()

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:992
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:

◆ SetOnFire()

virtual void C4PropList::SetOnFire ( bool  OnFire)
inlinevirtualinherited

Reimplemented in C4Object.

Definition at line 69 of file C4PropList.h.

References C4MapScriptLayer::GetMapScriptLayer(), and C4MapScriptMap::GetMapScriptMap().

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

69 { }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetProperty()

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

Definition at line 120 of file C4PropList.h.

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

Referenced by C4Game::AllocateTranslatedString(), C4Effect::C4Effect(), C4ScriptHost::Preparse(), 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:971
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPropertyByS()

void C4PropList::SetPropertyByS ( C4String k,
const C4Value to 
)
virtualinherited

Reimplemented in C4Object, C4PropListScen, and C4Effect.

Definition at line 971 of file C4PropList.cpp.

References C4Value::getPropList(), C4PropList::GetPrototype(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4AulDefFunc::C4AulDefFunc(), C4PropListScen::C4PropListScen(), C4AulExec::ClearPointers(), C4ScriptHost::CopyPropList(), C4PropList::SetProperty(), C4Effect::SetPropertyByS(), C4PropListScen::SetPropertyByS(), C4Object::SetPropertyByS(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnlinkOwnedFunctions(), C4AulCompiler::PreparseAstVisitor::visit(), C4AulCompiler::ConstexprEvaluator::visit(), C4AulCompiler::ConstantResolver::visit(), and C4ScriptGuiWindow::~C4ScriptGuiWindow().

972 {
973  assert(!constant);
974  if (k == &Strings.P[P_Prototype])
975  {
976  C4PropList * newpt = to.getPropList();
977  for(C4PropList * it = newpt; it; it = it->GetPrototype())
978  if(it == this)
979  throw C4AulExecError("Trying to create cyclic prototype structure");
980  prototype.SetPropList(newpt);
981  }
982  else if (Properties.Has(k))
983  {
984  Properties.Get(k).Value = to;
985  }
986  else
987  {
988  Properties.Add(C4Property(k, to));
989  }
990 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
T * Add(T const &e)
T & Get(H e) const
C4PropList * getPropList() const
Definition: C4Value.h:116
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4StringTable Strings
Definition: C4Globals.cpp:42
bool Has(H e) const
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShelveNumberedPropLists()

void C4PropListNumbered::ShelveNumberedPropLists ( )
static

Definition at line 105 of file C4PropList.cpp.

References ClearNumber(), and Number.

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
T const * First() const
unsigned int GetSize() 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:

◆ Thaw()

void C4PropList::Thaw ( )
inlineinherited

Definition at line 129 of file C4PropList.h.

References C4PropList::ThawRecursively().

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

129 { constant = false; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThawRecursively()

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::Thaw(), 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
C4PropList * getPropList() const
Definition: C4Value.h:116
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
void ThawRecursively()
Definition: C4PropList.cpp:283
bool IsFrozen() const
Definition: C4PropList.h:131
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
std::vector< C4String *> GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614
#define s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToJSON()

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 C4PropList::IsFrozen(), and 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 }
friend class C4Value
Definition: C4PropList.h:165
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
std::list< const T * > GetSortedListOfElementPointers() const
unsigned int GetSize() const
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:

◆ UnshelveNumberedPropLists()

void C4PropListNumbered::UnshelveNumberedPropLists ( )
static

Definition at line 123 of file C4PropList.cpp.

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

◆ C4Game

friend class C4Game
friend

Definition at line 239 of file C4PropList.h.

◆ C4GameObjects

friend class C4GameObjects
friend

Definition at line 240 of file C4PropList.h.

Member Data Documentation

◆ EnumerationIndex

int32_t C4PropListNumbered::EnumerationIndex = 0
staticprotected

Definition at line 238 of file C4PropList.h.

Referenced by AcquireNumber(), and C4Game::CompileFunc().

◆ Number

◆ PropLists

C4Set< C4PropListNumbered * > C4PropListNumbered::PropLists
staticprotected

◆ ShelvedPropLists

std::vector< C4PropListNumbered * > C4PropListNumbered::ShelvedPropLists
staticprotected

Definition at line 237 of file C4PropList.h.

◆ Status

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(), C4ObjectList::AssignInfo(), C4PropList::Call(), C4Game::CastObjects(), C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Effect::ClearAll(), C4ObjectList::ClearInfo(), C4AulExec::ClearPointers(), C4Object::Collect(), C4GameObjects::CrossCheck(), C4ObjectList::DeleteObjects(), C4ObjectList::Denumerate(), C4Landscape::P::DigMaterial2Objects(), C4Object::DirectComContents(), C4Effect::DoDamage(), C4Game::DrawCrewOverheadText(), C4EditCursor::EMMoveObject(), C4Object::Enter(), C4SoundInstance::Execute(), C4Effect::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4FindObject::Find(), C4ObjectList::Find(), C4FindObject::FindMany(), C4ObjectList::FindOther(), C4GameObjects::FixObjectOrder(), C4PropList::FreezeAndMakeStaticRecursively(), C4EditCursor::GetCurrentSelectionPosition(), C4ObjectList::GetListID(), C4ObjectList::GetObject(), GetTextColorForBackground(), C4Object::GrabInfo(), GrabLost(), C4GameObjects::GRBroadcast(), C4GameMessage::Init(), C4Effect::Init(), C4ObjectList::ListIDCount(), C4Player::MakeCrewMember(), C4ObjectList::MassCount(), C4GameMessageList::New(), C4Game::NewObject(), ObjectComGrab(), ObjectComUnGrab(), C4ObjectList::ObjectCount(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4GameObjects::PostLoad(), C4GameObjects::Remove(), C4EditCursor::RemoveFromSelection(), C4GameObjects::SafeObjectPointer(), C4Object::SetAction(), C4GameObjects::SetOCF(), C4Effect::TempReaddUpperEffects(), C4Effect::TempRemoveUpperEffects(), C4ObjectList::UpdateFaces(), C4ObjectList::UpdateGraphics(), C4GameObjects::UpdateSolidMasks(), C4ObjectList::ValidateOwners(), C4ObjectList::Write(), and C4ControlEMMoveObject::~C4ControlEMMoveObject().


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