OpenClonk
C4MapCreatorS2 Class Reference

#include <C4MapCreatorS2.h>

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

Public Member Functions

 C4MapCreatorS2 (C4SLandscape *pLandscape, C4TextureMap *pTexMap, C4MaterialMap *pMatMap, int iPlayerCount)
 
 ~C4MapCreatorS2 () override
 
void Default ()
 
void Clear ()
 
bool ReadFile (const char *szFilename, C4Group *pGrp)
 
bool ReadScript (const char *szScript)
 
C4MCMapGetMap (const char *szMapName)
 
bool Render (const char *szMapName, CSurface8 *&sfcMap, CSurface8 *&sfcMapBkg)
 
BYTERenderBuf (const char *szMapName, int32_t &sfcWdt, int32_t &sfcHgt)
 
void SetC4SLandscape (C4SLandscape *pLandscape)
 
void ExecuteCallbacks (int32_t iMapZoom)
 
virtual C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode)
 
void Reg2Owner (C4MCNode *pOwner)
 
virtual C4MCNodeType Type ()
 
virtual C4MCOverlayOverlay ()
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

bool GlobalScope () override
 
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 ()
 

Protected Attributes

C4SLandscapeLandscape
 
C4TextureMapTexMap
 
C4MaterialMapMatMap
 
C4MCMap DefaultMap
 
C4MCOverlay DefaultOverlay
 
C4MCPoint DefaultPoint
 
C4MCMappCurrentMap
 
C4MCCallbackArrayList CallbackArrays
 
int PlayerCount
 

Friends

class C4MCOverlay
 
class C4MCMap
 
class C4MCParser
 
class C4MCCallbackArray
 

Detailed Description

Definition at line 297 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

◆ C4MapCreatorS2()

C4MapCreatorS2::C4MapCreatorS2 ( C4SLandscape pLandscape,
C4TextureMap pTexMap,
C4MaterialMap pMatMap,
int  iPlayerCount 
)

Definition at line 759 of file C4MapCreatorS2.cpp.

759  : C4MCNode(nullptr)
760 {
761  // me r b creator
762  MapCreator=this;
763  // store members
764  Landscape=pLandscape; TexMap=pTexMap; MatMap=pMatMap;
765  PlayerCount=iPlayerCount;
766  // set engine field for default stuff
767  DefaultMap.MapCreator=this;
770  // default to landscape settings
771  Default();
772 }
C4MapCreatorS2 * MapCreator
C4MCNode(C4MCNode *pOwner=nullptr)
C4MCPoint DefaultPoint
C4MaterialMap * MatMap
C4MCOverlay DefaultOverlay
C4TextureMap * TexMap
C4SLandscape * Landscape

References Default(), DefaultMap, DefaultOverlay, DefaultPoint, Landscape, C4MCNode::MapCreator, MatMap, PlayerCount, and TexMap.

Here is the call graph for this function:

◆ ~C4MapCreatorS2()

C4MapCreatorS2::~C4MapCreatorS2 ( )
override

Definition at line 774 of file C4MapCreatorS2.cpp.

775 {
776  // clear fields
777  Clear();
778 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4MapCreatorS2::Clear ( )

Definition at line 789 of file C4MapCreatorS2.cpp.

790 {
791  // clear nodes
792  C4MCNode::Clear();
793  // clear callbacks
795  // defaults templates
796  Default();
797 }
C4MCCallbackArrayList CallbackArrays

References CallbackArrays, C4MCCallbackArrayList::Clear(), C4MCNode::Clear(), and Default().

Referenced by ~C4MapCreatorS2().

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

◆ clone()

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

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 156 of file C4MapCreatorS2.h.

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

References C4MCNode::C4MCNode().

Here is the call graph for this function:

◆ Default()

void C4MapCreatorS2::Default ( )

Definition at line 780 of file C4MapCreatorS2.cpp.

781 {
782  // default templates
786  pCurrentMap=nullptr;
787 }
void Default()
C4MCMap * pCurrentMap

References C4MCOverlay::Default(), C4MCPoint::Default(), C4MCMap::Default(), DefaultMap, DefaultOverlay, DefaultPoint, and pCurrentMap.

Referenced by C4MapCreatorS2(), and Clear().

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

◆ Evaluate()

virtual void C4MCNode::Evaluate ( )
inlineprotectedvirtualinherited

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 C4MCNode::ReEvaluate().

Here is the caller graph for this function:

◆ ExecuteCallbacks()

void C4MapCreatorS2::ExecuteCallbacks ( int32_t  iMapZoom)
inline

Definition at line 332 of file C4MapCreatorS2.h.

332 { CallbackArrays.Execute(iMapZoom); }
void Execute(int32_t iMapZoom)

References CallbackArrays, and C4MCCallbackArrayList::Execute().

Here is the call graph for this function:

◆ GetMap()

C4MCMap * C4MapCreatorS2::GetMap ( const char *  szMapName)

Definition at line 831 of file C4MapCreatorS2.cpp.

832 {
833  C4MCMap *pMap=nullptr; C4MCNode *pNode;
834  // get map
835  if (szMapName && *szMapName)
836  {
837  // by name...
838  if ((pNode = GetNodeByName(szMapName)))
839  if (pNode->Type() == MCN_Map)
840  pMap = (C4MCMap *) pNode;
841  }
842  else
843  {
844  // or simply last map entry
845  for (pNode = ChildL; pNode; pNode=pNode->Prev)
846  if (pNode->Type() == MCN_Map)
847  {
848  pMap = (C4MCMap *) pNode;
849  break;
850  }
851  }
852  return pMap;
853 }
@ MCN_Map
C4MCNode * ChildL
C4MCNode * GetNodeByName(const char *szName)
virtual C4MCNodeType Type()
C4MCNode * Prev

References C4MCNode::ChildL, C4MCNode::GetNodeByName(), MCN_Map, C4MCNode::Prev, and C4MCNode::Type().

Referenced by c4_mapgen_handle_new(), Render(), and RenderBuf().

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

◆ GetNodeByName()

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

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 * Owner

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

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

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

◆ GlobalScope()

bool C4MapCreatorS2::GlobalScope ( )
inlineoverrideprotectedvirtual

Reimplemented from C4MCNode.

Definition at line 329 of file C4MapCreatorS2.h.

329 { return true; } // it's the global node

◆ IntPar()

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

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

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

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

◆ ReadFile()

bool C4MapCreatorS2::ReadFile ( const char *  szFilename,
C4Group pGrp 
)

Definition at line 799 of file C4MapCreatorS2.cpp.

800 {
801  // create parser and read file
802  try
803  {
804  C4MCParser(this).ParseFile(szFilename, pGrp);
805  }
806  catch (C4MCParserErr err)
807  {
808  err.show();
809  return false;
810  }
811  // success
812  return true;
813 }
friend class C4MCParser

References C4MCParser, and C4MCParserErr::show().

Here is the call graph for this function:

◆ ReadScript()

bool C4MapCreatorS2::ReadScript ( const char *  szScript)

Definition at line 815 of file C4MapCreatorS2.cpp.

816 {
817  // create parser and read
818  try
819  {
820  C4MCParser(this).Parse(szScript);
821  }
822  catch (C4MCParserErr err)
823  {
824  err.show();
825  return false;
826  }
827  // success
828  return true;
829 }

References C4MCParser, and C4MCParserErr::show().

Referenced by C4Landscape::DrawMap().

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

◆ ReEvaluate()

void C4MCNode::ReEvaluate ( )
protectedinherited

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 }
C4MCNode * Next
virtual void Evaluate()
C4MCNode * Child0

References C4MCNode::Child0, C4MCNode::Evaluate(), and C4MCNode::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)
inherited

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 }

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

Referenced by C4MCNode::C4MCNode().

Here is the caller graph for this function:

◆ Render()

bool C4MapCreatorS2::Render ( const char *  szMapName,
CSurface8 *&  sfcMap,
CSurface8 *&  sfcMapBkg 
)

Definition at line 855 of file C4MapCreatorS2.cpp.

856 {
857  assert(sfcMap == nullptr);
858  assert(sfcMapBkg == nullptr);
859 
860  // get map
861  C4MCMap *pMap=GetMap(szMapName);
862  if (!pMap) return false;
863 
864  // get size
865  int32_t sfcWdt, sfcHgt;
866  sfcWdt=pMap->Wdt; sfcHgt=pMap->Hgt;
867  if (!sfcWdt || !sfcHgt) return false;
868 
869  // create surfaces
870  sfcMap = new CSurface8(sfcWdt, sfcHgt);
871  sfcMapBkg = new CSurface8(sfcWdt, sfcHgt);
872  assert(sfcMap->Pitch == sfcMapBkg->Pitch);
873 
874  // render map to surface
875  pMap->RenderTo(sfcMap->Bits, sfcMapBkg->Bits, sfcMap->Pitch);
876 
877  // success
878  return true;
879 }
bool RenderTo(BYTE *pToBuf, BYTE *pToBufBkg, int32_t iPitch)
C4MCMap * GetMap(const char *szMapName)
int Pitch
Definition: CSurface8.h:28
BYTE * Bits
Definition: CSurface8.h:30

References CSurface8::Bits, GetMap(), C4MCOverlay::Hgt, CSurface8::Pitch, C4MCMap::RenderTo(), and C4MCOverlay::Wdt.

Referenced by C4Landscape::DrawMap().

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

◆ RenderBuf()

BYTE * C4MapCreatorS2::RenderBuf ( const char *  szMapName,
int32_t &  sfcWdt,
int32_t &  sfcHgt 
)

Definition at line 886 of file C4MapCreatorS2.cpp.

887 {
888  // get map
889  C4MCMap *pMap=GetMap(szMapName);
890  if (!pMap) return nullptr;
891 
892  // get size
893  sfcWdt=pMap->Wdt; sfcHgt=pMap->Hgt;
894  if (!sfcWdt || !sfcHgt) return nullptr;
895  int dwSfcWdt = sfcWdt;
896  DWordAlign(dwSfcWdt);
897  sfcWdt = dwSfcWdt;
898 
899  // create buffer
900  BYTE *buf=new BYTE[sfcWdt*sfcHgt];
901 
902  // render and return it
903  pMap->RenderTo(buf, nullptr, sfcWdt);
904  return buf;
905 }
uint8_t BYTE

References GetMap(), C4MCOverlay::Hgt, and C4MCOverlay::Wdt.

Referenced by c4_mapgen_handle_new().

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

◆ SetC4SLandscape()

void C4MapCreatorS2::SetC4SLandscape ( C4SLandscape pLandscape)
inline

Definition at line 315 of file C4MapCreatorS2.h.

316  { Landscape=pLandscape; }

References Landscape.

◆ SetField()

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

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)
inlineprotectedvirtualinherited

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 
)
protectedinherited

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

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

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4MCCallbackArray

friend class C4MCCallbackArray
friend

Definition at line 337 of file C4MapCreatorS2.h.

◆ C4MCMap

friend class C4MCMap
friend

Definition at line 335 of file C4MapCreatorS2.h.

◆ C4MCOverlay

friend class C4MCOverlay
friend

Definition at line 334 of file C4MapCreatorS2.h.

◆ C4MCParser

friend class C4MCParser
friend

Definition at line 336 of file C4MapCreatorS2.h.

Referenced by ReadFile(), and ReadScript().

Member Data Documentation

◆ CallbackArrays

C4MCCallbackArrayList C4MapCreatorS2::CallbackArrays
protected

Definition at line 326 of file C4MapCreatorS2.h.

Referenced by C4MCCallbackArray::C4MCCallbackArray(), Clear(), and ExecuteCallbacks().

◆ Child0

◆ ChildL

C4MCNode * C4MCNode::ChildL
inherited

◆ DefaultMap

C4MCMap C4MapCreatorS2::DefaultMap
protected

Definition at line 322 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

◆ DefaultOverlay

C4MCOverlay C4MapCreatorS2::DefaultOverlay
protected

Definition at line 323 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

◆ DefaultPoint

C4MCPoint C4MapCreatorS2::DefaultPoint
protected

Definition at line 324 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

◆ Landscape

C4SLandscape* C4MapCreatorS2::Landscape
protected

Definition at line 319 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), C4MCMap::Default(), and SetC4SLandscape().

◆ MapCreator

◆ MatMap

C4MaterialMap* C4MapCreatorS2::MatMap
protected

Definition at line 321 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), C4MCOverlay::Evaluate(), and C4MCOverlay::SetField().

◆ Name

char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), and C4MCNode::C4MCNode().

◆ Next

◆ Owner

◆ pCurrentMap

C4MCMap* C4MapCreatorS2::pCurrentMap
protected

Definition at line 325 of file C4MapCreatorS2.h.

Referenced by Default(), C4MCCallbackArray::EnablePixel(), and C4MCMap::RenderTo().

◆ PlayerCount

int C4MapCreatorS2::PlayerCount
protected

Definition at line 327 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and C4MCMap::Default().

◆ Prev

◆ TexMap

C4TextureMap* C4MapCreatorS2::TexMap
protected

Definition at line 320 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), C4MCOverlay::Evaluate(), and C4MCOverlay::SetField().


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