OpenClonk
C4MCNode Class Reference

#include <C4MapCreatorS2.h>

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

Classes

class  int_bool
 

Public Member Functions

 C4MCNode (C4MCNode *pOwner=nullptr)
 
 C4MCNode (C4MCParser *pParser, C4MCNode *pOwner, C4MCNode &rTemplate, bool fClone)
 
virtual ~C4MCNode ()
 
virtual C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode)
 
void Clear ()
 
void Reg2Owner (C4MCNode *pOwner)
 
virtual C4MCNodeType Type ()
 
virtual C4MCOverlayOverlay ()
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

virtual bool GlobalScope ()
 
virtual bool SetOp (C4MCTokenType eOp)
 
C4MCNodeGetNodeByName (const char *szName)
 
virtual bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
int32_t IntPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
const char * StrPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
virtual void Evaluate ()
 
void ReEvaluate ()
 

Friends

class C4MCParser
 

Detailed Description

Definition at line 144 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

◆ C4MCNode() [1/2]

C4MCNode::C4MCNode ( C4MCNode pOwner = nullptr)

Definition at line 184 of file C4MapCreatorS2.cpp.

185 {
186  // reg to owner
187  Reg2Owner(pOwner);
188  // no name
189  *Name=0;
190 }
char Name[C4MaxName]
void Reg2Owner(C4MCNode *pOwner)

References Name, and Reg2Owner().

Referenced by clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4MCNode() [2/2]

C4MCNode::C4MCNode ( C4MCParser pParser,
C4MCNode pOwner,
C4MCNode rTemplate,
bool  fClone 
)

Definition at line 192 of file C4MapCreatorS2.cpp.

193 {
194  // Make sure the template is not used recursively within itself
195  for(C4MCNode* pParent = pOwner; pParent != nullptr; pParent = pParent->Owner)
196  if(pParent == &rTemplate)
197  throw C4MCParserErr(pParser, C4MCErr_NoRecTemplate, rTemplate.Name);
198  // set owner and stuff
199  Reg2Owner(pOwner);
200  // copy children from template
201  for (C4MCNode *pChild=rTemplate.Child0; pChild; pChild=pChild->Next)
202  pChild->clone(pParser, this);
203  // no name
204  *Name=0;
205 }
#define C4MCErr_NoRecTemplate
C4MCNode * Owner
C4MCNode * Next
C4MCNode * Child0

References C4MCErr_NoRecTemplate, Child0, Name, Next, Owner, and Reg2Owner().

Here is the call graph for this function:

◆ ~C4MCNode()

C4MCNode::~C4MCNode ( )
virtual

Definition at line 207 of file C4MapCreatorS2.cpp.

208 {
209  // clear
210  Clear();
211  // remove from list
212  if (Prev) Prev->Next = Next; else if (Owner) Owner->Child0 = Next;
213  if (Next) Next->Prev = Prev; else if (Owner) Owner->ChildL = Prev;
214 }
C4MCNode * ChildL
C4MCNode * Prev

References Child0, ChildL, Clear(), Next, Owner, and Prev.

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4MCNode::Clear ( )

Definition at line 240 of file C4MapCreatorS2.cpp.

241 {
242  // delete all children; they'll unreg themselves
243  while (Child0) delete Child0;
244 }

References Child0.

Referenced by C4MapCreatorS2::Clear(), and ~C4MCNode().

Here is the caller graph for this function:

◆ clone()

virtual C4MCNode* C4MCNode::clone ( C4MCParser pParser,
C4MCNode pToNode 
)
inlinevirtual

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 156 of file C4MapCreatorS2.h.

156 { return new C4MCNode(pParser, pToNode, *this, true); }
C4MCNode(C4MCNode *pOwner=nullptr)

References C4MCNode().

Here is the call graph for this function:

◆ Evaluate()

virtual void C4MCNode::Evaluate ( )
inlineprotectedvirtual

Reimplemented in C4MCPoint, and C4MCOverlay.

Definition at line 170 of file C4MapCreatorS2.h.

170 { } // called when all fields are initialized

Referenced by C4MCOverlay::Evaluate(), C4MCPoint::Evaluate(), and ReEvaluate().

Here is the caller graph for this function:

◆ GetNodeByName()

C4MCNode * C4MCNode::GetNodeByName ( const char *  szName)
protected

Definition at line 255 of file C4MapCreatorS2.cpp.

256 {
257  // search local list (backwards: last node has highest priority)
258  for (C4MCNode *pChild=ChildL; pChild; pChild=pChild->Prev)
259  // name match?
260  if (SEqual(pChild->Name, szName))
261  // yeah, success!
262  return pChild;
263  // search owner, if present
264  if (Owner) return Owner->GetNodeByName(szName);
265  // nothing found
266  return nullptr;
267 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4MCNode * GetNodeByName(const char *szName)

References ChildL, GetNodeByName(), Owner, Prev, and SEqual().

Referenced by C4MapCreatorS2::GetMap(), and GetNodeByName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GlobalScope()

virtual bool C4MCNode::GlobalScope ( )
inlineprotectedvirtual

Reimplemented in C4MapCreatorS2.

Definition at line 162 of file C4MapCreatorS2.h.

162 { return false; } // whether node is a global scope

◆ IntPar()

int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protected

Definition at line 275 of file C4MapCreatorS2.cpp.

276 {
277  // check if int32_t
278  if (ValType == MCT_INT || ValType == MCT_PERCENT || ValType == MCT_PX)
279  return iVal;
280  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
281 }
#define C4MCErr_FieldValInvalid
@ MCT_INT
@ MCT_PX
@ MCT_PERCENT

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

Referenced by C4MCOverlay::SetField(), and C4MCPoint::SetField().

Here is the caller graph for this function:

◆ Overlay()

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtual

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

187 { return nullptr; } // return overlay, if this is one

Referenced by C4MCOverlay::FirstOfChain(), and C4MCOverlay::PeekPix().

Here is the caller graph for this function:

◆ OwnerOverlay()

C4MCOverlay * C4MCNode::OwnerOverlay ( )

Definition at line 246 of file C4MapCreatorS2.cpp.

247 {
248  for (C4MCNode *pOwnr=Owner; pOwnr; pOwnr=pOwnr->Owner)
249  if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay())
250  return pOwnrOvrl;
251  // no overlay-owner
252  return nullptr;
253 }
C4MCOverlay * Overlay() override

References C4MCOverlay::Overlay(), and Owner.

Referenced by C4MCOverlay::Evaluate(), C4MCPoint::Evaluate(), and PreparePeek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReEvaluate()

void C4MCNode::ReEvaluate ( )
protected

Definition at line 294 of file C4MapCreatorS2.cpp.

295 {
296  // evaluate ourselves
297  Evaluate();
298  // evaluate children
299  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
300  pChild->ReEvaluate();
301 }
virtual void Evaluate()

References Child0, Evaluate(), and Next.

Referenced by C4MCMap::SetSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reg2Owner()

void C4MCNode::Reg2Owner ( C4MCNode pOwner)

Definition at line 216 of file C4MapCreatorS2.cpp.

217 {
218  // init list
219  Child0=ChildL=nullptr;
220  // owner?
221  if ((Owner=pOwner))
222  {
223  // link into it
224  if ((Prev = Owner->ChildL))
225  Prev->Next = this;
226  else
227  Owner->Child0 = this;
228  Owner->ChildL = this;
229  MapCreator=pOwner->MapCreator;
230  }
231  else
232  {
233  Prev=nullptr;
234  MapCreator=nullptr;
235  }
236  // we're always last entry
237  Next=nullptr;
238 }
C4MapCreatorS2 * MapCreator

References Child0, ChildL, MapCreator, Next, Owner, and Prev.

Referenced by C4MCNode().

Here is the caller graph for this function:

◆ SetField()

bool C4MCNode::SetField ( C4MCParser pParser,
const char *  szField,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedvirtual

Reimplemented in C4MCPoint, and C4MCOverlay.

Definition at line 269 of file C4MapCreatorS2.cpp.

270 {
271  // no fields in base class
272  return false;
273 }

Referenced by C4MCOverlay::SetField().

Here is the caller graph for this function:

◆ SetOp()

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtual

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator

◆ StrPar()

const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protected

Definition at line 283 of file C4MapCreatorS2.cpp.

284 {
285  // check if identifier
286  if (ValType != MCT_IDTF)
287  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
288  return szSVal;
289 }
@ MCT_IDTF

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

Here is the caller graph for this function:

◆ Type()

virtual C4MCNodeType C4MCNode::Type ( )
inlinevirtual

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 186 of file C4MapCreatorS2.h.

186 { return MCN_Node; } // get node type
@ MCN_Node

References MCN_Node.

Referenced by AlgoPolygon(), and C4MapCreatorS2::GetMap().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4MCParser

friend class C4MCParser
friend

Definition at line 190 of file C4MapCreatorS2.h.

Member Data Documentation

◆ Child0

C4MCNode * C4MCNode::Child0

◆ ChildL

C4MCNode * C4MCNode::ChildL

Definition at line 147 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2::GetMap(), GetNodeByName(), Reg2Owner(), and ~C4MCNode().

◆ MapCreator

◆ Name

char C4MCNode::Name[C4MaxName]

Definition at line 149 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), and C4MCNode().

◆ Next

C4MCNode * C4MCNode::Next

◆ Owner

◆ Prev


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