OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 ()
 
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 ()
 
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 ( C4SLandscape pLandscape,
C4TextureMap pTexMap,
C4MaterialMap pMatMap,
int  iPlayerCount 
)

Definition at line 758 of file C4MapCreatorS2.cpp.

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

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

Here is the call graph for this function:

C4MapCreatorS2::~C4MapCreatorS2 ( )

Definition at line 773 of file C4MapCreatorS2.cpp.

References Clear().

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

Here is the call graph for this function:

Member Function Documentation

void C4MapCreatorS2::Clear ( )

Definition at line 788 of file C4MapCreatorS2.cpp.

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

Referenced by ~C4MapCreatorS2().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 156 of file C4MapCreatorS2.h.

References C4MCNode::C4MCNode().

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

Here is the call graph for this function:

void C4MapCreatorS2::Default ( )

Definition at line 779 of file C4MapCreatorS2.cpp.

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

Referenced by C4MapCreatorS2(), and Clear().

780 {
781  // default templates
785  pCurrentMap=nullptr;
786 }
C4MCOverlay DefaultOverlay
C4MCPoint DefaultPoint
void Default()
C4MCMap * pCurrentMap

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4MCNode::Evaluate ( )
inlineprotectedvirtualinherited

Reimplemented in C4MCPoint, and C4MCOverlay.

Definition at line 170 of file C4MapCreatorS2.h.

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

170 { } // called when all fields are initialized

Here is the caller graph for this function:

void C4MapCreatorS2::ExecuteCallbacks ( int32_t  iMapZoom)
inline

Definition at line 332 of file C4MapCreatorS2.h.

References C4MCCallbackArrayList::Execute().

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

Here is the call graph for this function:

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

Definition at line 830 of file C4MapCreatorS2.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 254 of file C4MapCreatorS2.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MapCreatorS2::GlobalScope ( )
inlineprotectedvirtual

Reimplemented from C4MCNode.

Definition at line 329 of file C4MapCreatorS2.h.

329 { return true; } // it's the global node
int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 274 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

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

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

Here is the caller graph for this function:

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

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

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

Here is the caller graph for this function:

C4MCOverlay * C4MCNode::OwnerOverlay ( )
inherited

Definition at line 245 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Overlay(), and C4MCNode::Owner.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 798 of file C4MapCreatorS2.cpp.

References C4MCParser, and C4MCParserErr::show().

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

Here is the call graph for this function:

bool C4MapCreatorS2::ReadScript ( const char *  szScript)

Definition at line 814 of file C4MapCreatorS2.cpp.

References C4MCParser, and C4MCParserErr::show().

Referenced by C4Landscape::DrawMap().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::ReEvaluate ( )
protectedinherited

Definition at line 293 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0, C4MCNode::Evaluate(), and C4MCNode::Next.

Referenced by C4MCMap::SetSize().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::Reg2Owner ( C4MCNode pOwner)
inherited

Definition at line 215 of file C4MapCreatorS2.cpp.

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

Referenced by C4MCNode::C4MCNode().

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

Here is the caller graph for this function:

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

Definition at line 854 of file C4MapCreatorS2.cpp.

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

Referenced by C4Landscape::DrawMap().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 885 of file C4MapCreatorS2.cpp.

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

Referenced by c4_mapgen_handle_new().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MapCreatorS2::SetC4SLandscape ( C4SLandscape pLandscape)
inline

Definition at line 315 of file C4MapCreatorS2.h.

References Landscape.

316  { Landscape=pLandscape; }
C4SLandscape * Landscape
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 268 of file C4MapCreatorS2.cpp.

Referenced by C4MCOverlay::SetField().

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

Here is the caller graph for this function:

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator
const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 282 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

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

Here is the caller graph for this function:

virtual C4MCNodeType C4MCNode::Type ( )
inlinevirtualinherited

Reimplemented in C4MCMap, C4MCPoint, and C4MCOverlay.

Definition at line 186 of file C4MapCreatorS2.h.

References MCN_Node.

Referenced by AlgoPolygon(), and GetMap().

186 { return MCN_Node; } // get node type

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4MCCallbackArray
friend

Definition at line 337 of file C4MapCreatorS2.h.

friend class C4MCMap
friend

Definition at line 335 of file C4MapCreatorS2.h.

friend class C4MCOverlay
friend

Definition at line 334 of file C4MapCreatorS2.h.

friend class C4MCParser
friend

Definition at line 336 of file C4MapCreatorS2.h.

Referenced by ReadFile(), and ReadScript().

Member Data Documentation

C4MCCallbackArrayList C4MapCreatorS2::CallbackArrays
protected

Definition at line 326 of file C4MapCreatorS2.h.

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

C4MCNode * C4MCNode::ChildL
inherited
C4MCMap C4MapCreatorS2::DefaultMap
protected

Definition at line 322 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

C4MCOverlay C4MapCreatorS2::DefaultOverlay
protected

Definition at line 323 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

C4MCPoint C4MapCreatorS2::DefaultPoint
protected

Definition at line 324 of file C4MapCreatorS2.h.

Referenced by C4MapCreatorS2(), and Default().

C4SLandscape* C4MapCreatorS2::Landscape
protected

Definition at line 319 of file C4MapCreatorS2.h.

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

C4MaterialMap* C4MapCreatorS2::MatMap
protected

Definition at line 321 of file C4MapCreatorS2.h.

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

char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

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

C4MCMap* C4MapCreatorS2::pCurrentMap
protected

Definition at line 325 of file C4MapCreatorS2.h.

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

int C4MapCreatorS2::PlayerCount
protected

Definition at line 327 of file C4MapCreatorS2.h.

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

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: