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

#include <C4MapCreatorS2.h>

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

Public Member Functions

 C4MCMap (C4MCNode *pOwner=nullptr)
 
 C4MCMap (C4MCParser *pParser, C4MCNode *pOwner, C4MCMap &rTemplate, bool fClone)
 
C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode)
 
bool RenderTo (BYTE *pToBuf, BYTE *pToBufBkg, int32_t iPitch)
 
void SetSize (int32_t iWdt, int32_t iHgt)
 
C4MCNodeType Type ()
 
bool SetOp (C4MCTokenType eOp)
 
C4MCAlgorithmGetAlgo (const char *szName)
 
bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
void Evaluate ()
 
C4MCOverlayOverlay ()
 
C4MCOverlayFirstOfChain ()
 
bool CheckMask (int32_t iX, int32_t iY)
 
bool RenderPix (int32_t iX, int32_t iY, BYTE &rPix, BYTE &rPixBkg, C4MCTokenType eLastOp=MCT_NONE, bool fLastSet=false, bool fDraw=true, C4MCOverlay **ppPixelSetOverlay=nullptr)
 
bool PeekPix (int32_t iX, int32_t iY)
 
bool InBounds (int32_t iX, int32_t iY)
 
void Clear ()
 
void Reg2Owner (C4MCNode *pOwner)
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

int32_t Seed
 
int32_t FixedSeed
 
int32_t X
 
int32_t Y
 
int32_t Wdt
 
int32_t Hgt
 
int32_t OffX
 
int32_t OffY
 
int_bool RX
 
int_bool RY
 
int_bool RWdt
 
int_bool RHgt
 
int_bool ROffX
 
int_bool ROffY
 
int32_t Material
 
bool Sub
 
char Texture [C4M_MaxName+1]
 
BYTE MatClr
 
BYTE MatClrBkg
 
C4MCTokenType Op
 
C4MCAlgorithmAlgorithm
 
int32_t Turbulence
 
int32_t Lambda
 
int32_t Rotate
 
int_bool Alpha
 
int_bool Beta
 
int32_t ZoomX
 
int32_t ZoomY
 
bool Invert
 
bool LooseBounds
 
bool Group
 
bool Mask
 
C4MCCallbackArraypEvaluateFunc
 
C4MCCallbackArraypDrawFunc
 
C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

void Default ()
 
virtual bool GlobalScope ()
 
C4MCNodeGetNodeByName (const char *szName)
 
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)
 
void ReEvaluate ()
 

Friends

class C4MapCreatorS2
 
class C4MCParser
 

Detailed Description

Definition at line 274 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

C4MCMap::C4MCMap ( C4MCNode pOwner = nullptr)

Definition at line 695 of file C4MapCreatorS2.cpp.

Referenced by clone().

695  : C4MCOverlay(pOwner)
696 {
697 
698 }
C4MCOverlay(C4MCNode *pOwner=nullptr)

Here is the caller graph for this function:

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

Definition at line 700 of file C4MapCreatorS2.cpp.

700  : C4MCOverlay(pParser, pOwner, rTemplate, fClone)
701 {
702 
703 }
C4MCOverlay(C4MCNode *pOwner=nullptr)

Member Function Documentation

bool C4MCOverlay::CheckMask ( int32_t  iX,
int32_t  iY 
)
inherited

Definition at line 515 of file C4MapCreatorS2.cpp.

References AddDbgRec(), C4MCOverlay::Algorithm, C4REAL10(), Config, Cos(), C4ConfigGeneral::DebugRec, fixtoi(), C4MCAlgorithm::Function, C4Config::General, C4MCOverlay::Hgt, C4MCOverlay::Invert, itofix(), C4MCOverlay::Lambda, C4MCOverlay::LooseBounds, C4MCOverlay::OffX, C4MCOverlay::OffY, RCT_MCT1, RCT_MCT2, C4RCTrf::Rotate, C4MCOverlay::Rotate, C4MCOverlay::Seed, Sin(), C4RCTrf::Turbulence, C4MCOverlay::Turbulence, C4MCOverlay::Wdt, C4RCTrf::x, C4RCPos::x, C4MCOverlay::X, C4RCTrf::y, C4RCPos::y, C4MCOverlay::Y, C4MCOverlay::ZoomX, and C4MCOverlay::ZoomY.

Referenced by C4MCOverlay::RenderPix().

516 {
517  // bounds match?
518  if (!LooseBounds) if (iX<X || iY<Y || iX>=X+Wdt || iY>=Y+Hgt) return false;
519  if (Config.General.DebugRec)
520  {
521  C4RCTrf rc;
522  rc.x=iX; rc.y=iY; rc.Rotate=Rotate; rc.Turbulence=Turbulence;
523  AddDbgRec(RCT_MCT1, &rc, sizeof(rc));
524  }
525  C4Real dX=itofix(iX); C4Real dY=itofix(iY);
526  // apply turbulence
527  if (Turbulence)
528  {
529  const C4Real Rad2Grad = itofix(3754936, 65536);
530  int32_t j=3;
531  for (int32_t i=10; i<=Turbulence; i*=10)
532  {
533  int32_t Seed2; Seed2=Seed;
534  for (int32_t l=0; l<Lambda+1; ++l)
535  {
536  for (C4Real d=itofix(2); d<6; d+=C4REAL10(15))
537  {
538  dX += Sin(((dX / 7 + itofix(Seed2) / ZoomX + dY) / j + d) * Rad2Grad) * j / 2;
539  dY += Cos(((dY / 7 + itofix(Seed2) / ZoomY + dX) / j - d) * Rad2Grad) * j / 2;
540  }
541  Seed2 = (Seed * (Seed2<<3) + 0x4465) & 0xffff;
542  }
543  j+=3;
544  }
545  }
546  // apply rotation
547  if (Rotate)
548  {
549  C4Real dXo(dX), dYo(dY);
550  dX = dXo*Cos(itofix(Rotate)) - dYo*Sin(itofix(Rotate));
551  dY = dYo*Cos(itofix(Rotate)) + dXo*Sin(itofix(Rotate));
552  }
553  if (Rotate || Turbulence)
554  { iX=fixtoi(dX, ZoomX); iY=fixtoi(dY, ZoomY); }
555  else
556  { iX*=ZoomX; iY*=ZoomY; }
557  if (Config.General.DebugRec)
558  {
559  C4RCPos rc2;
560  rc2.x=iX; rc2.y=iY;
561  AddDbgRec(RCT_MCT2, &rc2, sizeof(rc2));
562  }
563  // apply offset
564  iX-=OffX*ZoomX; iY-=OffY*ZoomY;
565  // check bounds, if loose
566  if (LooseBounds) if (iX<X*ZoomX || iY<Y*ZoomY || iX>=(X+Wdt)*ZoomX || iY>=(Y+Hgt)*ZoomY) return Invert;
567  // query algorithm
568  return (Algorithm->Function) (this, iX, iY)^Invert;
569 }
C4Config Config
Definition: C4Config.cpp:837
int x
Definition: C4Record.h:180
C4ConfigGeneral General
Definition: C4Config.h:252
int32_t Turbulence
int y
Definition: C4Record.h:180
Definition: C4Real.h:58
int Rotate
Definition: C4Record.h:180
int Turbulence
Definition: C4Record.h:180
C4Real C4REAL10(int x)
Definition: C4Real.h:269
int y
Definition: C4Record.h:185
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:36
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
int32_t Lambda
int32_t Rotate
bool(* Function)(C4MCOverlay *, int32_t, int32_t)
int32_t DebugRec
Definition: C4Config.h:61
C4MCAlgorithm * Algorithm
C4Real Sin(const C4Real &fAngle)
Definition: C4Real.h:265
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
int x
Definition: C4Record.h:185
C4Real Cos(const C4Real &fAngle)
Definition: C4Real.h:266

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::Clear ( )
inherited

Definition at line 239 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0.

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

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

Here is the caller graph for this function:

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

Reimplemented from C4MCOverlay.

Definition at line 280 of file C4MapCreatorS2.h.

References C4MCMap().

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

Here is the call graph for this function:

void C4MCMap::Default ( )
protected

Definition at line 705 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Default(), C4SLandscape::GetMapSize(), C4MCOverlay::Hgt, C4MapCreatorS2::Landscape, C4MCNode::MapCreator, C4MapCreatorS2::PlayerCount, and C4MCOverlay::Wdt.

Referenced by C4MapCreatorS2::Default().

706 {
707  // inherited
709  // size by landscape def
711 }
C4SLandscape * Landscape
void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum)
Definition: C4Scenario.cpp:317
C4MapCreatorS2 * MapCreator

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCOverlay::Evaluate ( )
virtualinherited

Reimplemented from C4MCNode.

Definition at line 457 of file C4MapCreatorS2.cpp.

References C4MCNode::Evaluate(), C4MCNode::int_bool::Evaluate(), C4MCOverlay::FixedSeed, C4TextureMap::GetIndexMatTex(), C4MCOverlay::Hgt, C4MaterialMap::Map, C4MCNode::MapCreator, Mat2PixColDefault(), C4MCOverlay::MatClr, C4MCOverlay::MatClrBkg, C4MCOverlay::Material, C4MapCreatorS2::MatMap, MTunnel, C4MaterialCore::Name, C4MaterialMap::Num, C4MCOverlay::OffX, C4MCOverlay::OffY, C4MCNode::Owner, C4MCNode::OwnerOverlay(), Random(), C4MCOverlay::RHgt, C4MCOverlay::ROffX, C4MCOverlay::ROffY, C4MCOverlay::RWdt, C4MCOverlay::RX, C4MCOverlay::RY, C4MCOverlay::Seed, C4MCOverlay::Sub, C4MapCreatorS2::TexMap, C4MCOverlay::Texture, C4MCOverlay::Wdt, C4MCOverlay::X, and C4MCOverlay::Y.

458 {
459  // inherited
461  // get mat color
462  if (Inside<int32_t>(Material,0,MapCreator->MatMap->Num-1))
463  {
465  if(MatClr == 0 || !Sub)
466  MatClrBkg = 0;
467  else
469  }
470  else
471  {
472  MatClr=0;
473  MatClrBkg=0;
474  }
475 
476  // calc size
477  if (Owner)
478  {
479  C4MCOverlay *pOwnrOvrl;
480  if ((pOwnrOvrl=OwnerOverlay()))
481  {
482  int32_t iOwnerWdt=pOwnrOvrl->Wdt; int32_t iOwnerHgt=pOwnrOvrl->Hgt;
483  X = RX.Evaluate(iOwnerWdt) + pOwnrOvrl->X;
484  Y = RY.Evaluate(iOwnerHgt) + pOwnrOvrl->Y;
485  Wdt = RWdt.Evaluate(iOwnerWdt);
486  Hgt = RHgt.Evaluate(iOwnerHgt);
487  OffX = ROffX.Evaluate(iOwnerWdt);
488  OffY = ROffY.Evaluate(iOwnerHgt);
489  }
490  }
491  // calc seed
492  if (!(Seed=FixedSeed))
493  {
494  int32_t r1=Random(32768);
495  int32_t r2=Random(65536);
496  Seed=(r1<<16) | r2;
497  }
498 }
int_bool ROffY
C4MaterialMap * MatMap
C4MCOverlay * OwnerOverlay()
uint32_t Random()
Definition: C4Random.cpp:43
C4Material * Map
Definition: C4Material.h:171
int_bool RHgt
C4TextureMap * TexMap
int32_t MTunnel
Definition: C4Material.cpp:37
virtual void Evaluate()
int_bool ROffX
C4MCNode * Owner
char Name[C4M_MaxName+1]
Definition: C4Material.h:91
int_bool RWdt
int32_t FixedSeed
int32_t Num
Definition: C4Material.h:170
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:237
int32_t Evaluate(int32_t relative_to)
char Texture[C4M_MaxName+1]
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture=nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:450
C4MapCreatorS2 * MapCreator
int32_t Material

Here is the call graph for this function:

C4MCOverlay * C4MCOverlay::FirstOfChain ( )
inherited

Definition at line 500 of file C4MapCreatorS2.cpp.

References MCT_NONE, C4MCOverlay::Op, C4MCNode::Overlay(), and C4MCNode::Prev.

Referenced by PreparePeek().

501 {
502  // run backwards until nullptr, non-overlay or overlay without operator is found
503  C4MCOverlay *pOvrl=this;
504  C4MCOverlay *pPrevO;
505  while (pOvrl->Prev)
506  {
507  if (!(pPrevO=pOvrl->Prev->Overlay())) break;
508  if (pPrevO->Op == MCT_NONE) break;
509  pOvrl=pPrevO;
510  }
511  // done
512  return pOvrl;
513 }
C4MCTokenType Op
virtual C4MCOverlay * Overlay()
C4MCNode * Prev

Here is the call graph for this function:

Here is the caller graph for this function:

C4MCAlgorithm * C4MCOverlay::GetAlgo ( const char *  szName)
inherited

Definition at line 445 of file C4MapCreatorS2.cpp.

References C4MCAlgoMap, C4MCAlgorithm::Function, and SEqual().

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

446 {
447  // search map
448  for (C4MCAlgorithm *pAlgo = &C4MCAlgoMap[0]; pAlgo->Function; pAlgo++)
449  // check name
450  if (SEqual(pAlgo->Identifier, szName))
451  // success!
452  return pAlgo;
453  // nothing found
454  return nullptr;
455 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
C4MCAlgorithm C4MCAlgoMap[]
bool(* Function)(C4MCOverlay *, int32_t, int32_t)

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

virtual bool C4MCNode::GlobalScope ( )
inlineprotectedvirtualinherited

Reimplemented in C4MapCreatorS2.

Definition at line 162 of file C4MapCreatorS2.h.

162 { return false; } // whether node is a global scope
bool C4MCOverlay::InBounds ( int32_t  iX,
int32_t  iY 
)
inlineinherited

Definition at line 238 of file C4MapCreatorS2.h.

References C4MCOverlay::Hgt.

Referenced by AlgoBorder().

238 { return iX>=X && iY>=Y && iX<X+Wdt && iY<Y+Hgt; } // return whether point iX/iY is inside bounds

Here is the caller graph for this function:

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:

C4MCOverlay* C4MCOverlay::Overlay ( )
inlinevirtualinherited

Reimplemented from C4MCNode.

Definition at line 232 of file C4MapCreatorS2.h.

Referenced by C4MCNode::OwnerOverlay(), and C4MCOverlay::RenderPix().

232 { return this; } // this is an overlay

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 C4MCOverlay::PeekPix ( int32_t  iX,
int32_t  iY 
)
inherited

Definition at line 621 of file C4MapCreatorS2.cpp.

References MCT_NONE, C4MCNode::Next, C4MCOverlay::Op, C4MCNode::Overlay(), and C4MCOverlay::RenderPix().

Referenced by AlgoBorder().

622 {
623  // start with this one
624  C4MCOverlay *pOvrl=this; bool fLastSetC=false; C4MCTokenType eLastOp=MCT_NONE; BYTE Crap;
625  // loop through op chain
626  while (1)
627  {
628  fLastSetC=pOvrl->RenderPix(iX, iY, Crap, Crap, eLastOp, fLastSetC, false);
629  eLastOp=pOvrl->Op;
630  if (!pOvrl->Op) break;
631  // must be another overlay, since there's an operator
632  // hopefully, the preparser will catch all the other crap
633  pOvrl=pOvrl->Next->Overlay();
634  }
635  // return result
636  return fLastSetC;
637 }
uint8_t BYTE
C4MCTokenType Op
bool RenderPix(int32_t iX, int32_t iY, BYTE &rPix, BYTE &rPixBkg, C4MCTokenType eLastOp=MCT_NONE, bool fLastSet=false, bool fDraw=true, C4MCOverlay **ppPixelSetOverlay=nullptr)
C4MCNode * Next
virtual C4MCOverlay * Overlay()
C4MCTokenType

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 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 C4MCOverlay::RenderPix ( int32_t  iX,
int32_t  iY,
BYTE rPix,
BYTE rPixBkg,
C4MCTokenType  eLastOp = MCT_NONE,
bool  fLastSet = false,
bool  fDraw = true,
C4MCOverlay **  ppPixelSetOverlay = nullptr 
)
inherited

Definition at line 571 of file C4MapCreatorS2.cpp.

References C4MCOverlay::CheckMask(), C4MCNode::Child0, C4MCCallbackArray::EnablePixel(), C4MCOverlay::Group, C4MCOverlay::Mask, C4MCOverlay::MatClr, C4MCOverlay::MatClrBkg, MCT_AND, MCT_NONE, MCT_OR, MCT_XOR, C4MCNode::Next, C4MCOverlay::Op, C4MCOverlay::Overlay(), and C4MCOverlay::pEvaluateFunc.

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

572 {
573  // algo match?
574  bool SetThis=CheckMask(iX, iY);
575  bool DoSet;
576  // exec last op
577  switch (eLastOp)
578  {
579  case MCT_AND: // and
580  DoSet=SetThis&&fLastSet;
581  break;
582  case MCT_OR: // or
583  DoSet=SetThis||fLastSet;
584  break;
585  case MCT_XOR: // xor
586  DoSet=SetThis^fLastSet;
587  break;
588  default: // no op
589  DoSet=SetThis;
590  break;
591  }
592 
593  // set pix to local value and exec children, if no operator is following
594  if ((DoSet && fDraw && Op == MCT_NONE) || Group)
595  {
596  // groups don't set a pixel value, if they're associated with an operator
597  fDraw &= !Group || (Op == MCT_NONE);
598  if (fDraw && DoSet && !Mask)
599  {
600  rPix=MatClr;
601  rPixBkg=MatClrBkg;
602  if (ppPixelSetOverlay) *ppPixelSetOverlay = this;
603  }
604  bool fLastSetC=false; eLastOp=MCT_NONE;
605  // evaluate children overlays, if this was painted, too
606  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
607  if (C4MCOverlay *pOvrl=pChild->Overlay())
608  {
609  fLastSetC=pOvrl->RenderPix(iX, iY, rPix, rPixBkg, eLastOp, fLastSetC, fDraw, ppPixelSetOverlay);
610  if (Group && (pOvrl->Op == MCT_NONE))
611  DoSet |= fLastSetC;
612  eLastOp=pOvrl->Op;
613  }
614  // add evaluation-callback
615  if (pEvaluateFunc && DoSet && fDraw) pEvaluateFunc->EnablePixel(iX, iY);
616  }
617  // done
618  return DoSet;
619 }
C4MCOverlay * Overlay()
C4MCTokenType Op
bool CheckMask(int32_t iX, int32_t iY)
C4MCNode * Child0
C4MCNode * Next
C4MCCallbackArray * pEvaluateFunc
void EnablePixel(int32_t iX, int32_t iY)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MCMap::RenderTo ( BYTE pToBuf,
BYTE pToBufBkg,
int32_t  iPitch 
)

Definition at line 713 of file C4MapCreatorS2.cpp.

References C4MCCallbackArray::EnablePixel(), C4MCOverlay::Hgt, C4MCNode::MapCreator, MCT_NONE, C4MapCreatorS2::pCurrentMap, C4MCOverlay::pDrawFunc, C4MCOverlay::RenderPix(), and C4MCOverlay::Wdt.

Referenced by C4MapCreatorS2::Render(), and C4MapCreatorS2::RenderBuf().

714 {
715  // set current render target
716  if (MapCreator) MapCreator->pCurrentMap=this;
717  // draw pixel by pixel
718  for (int32_t iY=0; iY<Hgt; iY++)
719  {
720  for (int32_t iX=0; iX<Wdt; iX++)
721  {
722  // default to sky
723  BYTE dummyPix;
724  *pToBuf=0;
725  if (pToBufBkg) *pToBufBkg=0;
726  // render pixel value
727  C4MCOverlay *pRenderedOverlay = nullptr;
728  RenderPix(iX, iY, *pToBuf, pToBufBkg ? *pToBufBkg : dummyPix, MCT_NONE, false, true, &pRenderedOverlay);
729  // add draw-callback for rendered overlay
730  if (pRenderedOverlay)
731  if (pRenderedOverlay->pDrawFunc)
732  pRenderedOverlay->pDrawFunc->EnablePixel(iX, iY);
733  // next pixel
734  pToBuf++;
735  if (pToBufBkg) pToBufBkg++;
736  }
737  // next line
738  pToBuf+=iPitch-Wdt;
739  if (pToBufBkg) pToBufBkg+=iPitch-Wdt;
740  }
741  // reset render target
742  if (MapCreator) MapCreator->pCurrentMap=nullptr;
743  // success
744  return true;
745 }
uint8_t BYTE
C4MCCallbackArray * pDrawFunc
bool RenderPix(int32_t iX, int32_t iY, BYTE &rPix, BYTE &rPixBkg, C4MCTokenType eLastOp=MCT_NONE, bool fLastSet=false, bool fDraw=true, C4MCOverlay **ppPixelSetOverlay=nullptr)
C4MCMap * pCurrentMap
void EnablePixel(int32_t iX, int32_t iY)
C4MapCreatorS2 * MapCreator

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from C4MCNode.

Definition at line 371 of file C4MapCreatorS2.cpp.

References C4Value::_getPropList(), C4M_MaxName, C4MC_ZoomRes, C4MCErr_AlgoNotFound, C4MCErr_MatNotFound, C4MCErr_SFuncNotFound, C4MCErr_TexNotFound, C4TextureMap::CheckTexture(), GameScript, C4MaterialMap::Get(), C4MCOverlay::GetAlgo(), C4PropList::GetFunc(), C4MCNode::IntPar(), C4MCNode::MapCreator, C4MapCreatorS2::MatMap, MCT_INT, MCT_PERCENT, MNone, C4GameScriptHost::ScenPropList, SCopy(), SEqual(), C4MCNode::SetField(), C4MCNode::StrPar(), and C4MapCreatorS2::TexMap.

372 {
373  int32_t iMat; C4MCAlgorithm *pAlgo;
374  // inherited fields
375  if (C4MCNode::SetField(pParser, szField, szSVal, iVal, ValType)) return true;
376  //local fields
377  for (C4MCNodeAttr *pAttr=&C4MCOvrlMap[0]; *pAttr->Name; pAttr++)
378  if (SEqual(szField, pAttr->Name))
379  {
380  // field was found, get offset to store in
381  MemberAdapter<C4MCOverlay> Target(*this, pAttr->Offset);
382  // store according to field type
383  switch (pAttr->Type)
384  {
385  case C4MCV_Integer:
386  // simply store
387  Target.As<int32_t>() = IntPar;
388  break;
389  case C4MCV_Percent:
390  Target.As<int_bool>().Set(IntPar, ValType == MCT_PERCENT || ValType == MCT_INT);
391  break;
392  case C4MCV_Pixels:
393  Target.As<int_bool>().Set(IntPar, ValType == MCT_PERCENT);
394  break;
395  case C4MCV_Material:
396  // get material by string
397  iMat = MapCreator->MatMap->Get(StrPar);
398  // check validity
399  if (iMat == MNone) throw C4MCParserErr(pParser, C4MCErr_MatNotFound, StrPar);
400  // store
401  Target.As<int32_t>() = iMat;
402  break;
403  case C4MCV_Texture:
404  // check validity
406  throw C4MCParserErr(pParser, C4MCErr_TexNotFound, StrPar);
407  // store
408  SCopy(StrPar, Target.As<char [C4M_MaxName + 1]>(), C4M_MaxName);
409  break;
410  case C4MCV_Algorithm:
411  // get algo
412  pAlgo=GetAlgo(StrPar);
413  // check validity
414  if (!pAlgo) throw C4MCParserErr(pParser, C4MCErr_AlgoNotFound, StrPar);
415  // store
416  Target.As<C4MCAlgorithm *>()=pAlgo;
417  break;
418  case C4MCV_Boolean:
419  // store whether value is not zero
420  Target.As<bool>()=IntPar!=0;
421  break;
422  case C4MCV_Zoom:
423  // store calculated zoom
424  Target.As<int32_t>()=Clamp<int32_t>(C4MC_ZoomRes-IntPar,1,C4MC_ZoomRes*2);
425  break;
426  case C4MCV_ScriptFunc:
427  {
428  // get script func of main script
430  if (!pSFunc) throw C4MCParserErr(pParser, C4MCErr_SFuncNotFound, StrPar);
431  // add to main
432  Target.As<C4MCCallbackArray*>() = new C4MCCallbackArray(pSFunc, MapCreator);
433  }
434  default:
435  // TODO
436  break;
437  }
438  // done
439  return true;
440  }
441  // nothing found :(
442  return false;
443 }
#define C4MC_ZoomRes
C4MaterialMap * MatMap
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const char * StrPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
C4MCAlgorithm * GetAlgo(const char *szName)
C4GameScriptHost GameScript
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:107
C4TextureMap * TexMap
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
const int C4M_MaxName
Definition: C4Constants.h:49
#define C4MCErr_MatNotFound
bool CheckTexture(const char *szTexture)
Definition: C4Texture.cpp:494
const int32_t MNone
Definition: C4Constants.h:178
C4Value ScenPropList
Definition: C4ScriptHost.h:163
#define C4MCErr_TexNotFound
#define C4MCErr_AlgoNotFound
virtual bool SetField(C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:362
int32_t IntPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
C4PropList * _getPropList() const
Definition: C4Value.h:129
C4MapCreatorS2 * MapCreator
#define C4MCErr_SFuncNotFound

Here is the call graph for this function:

bool C4MCOverlay::SetOp ( C4MCTokenType  eOp)
inlinevirtualinherited

Reimplemented from C4MCNode.

Definition at line 224 of file C4MapCreatorS2.h.

224 { Op=eOp; return true; } // set following operator
C4MCTokenType Op
void C4MCMap::SetSize ( int32_t  iWdt,
int32_t  iHgt 
)

Definition at line 747 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Hgt, C4MCNode::MapCreator, C4MCNode::ReEvaluate(), and C4MCOverlay::Wdt.

Referenced by C4Landscape::DrawDefMap().

748 {
749  // store new size
750  Wdt=iWdt; Hgt=iHgt;
751  // update relative values
753 }
void ReEvaluate()
C4MapCreatorS2 * MapCreator

Here is the call graph for this function:

Here is the caller graph for this function:

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:

C4MCNodeType C4MCMap::Type ( )
inlinevirtual

Reimplemented from C4MCOverlay.

Definition at line 290 of file C4MapCreatorS2.h.

References MCN_Map.

290 { return MCN_Map; } // get node type

Friends And Related Function Documentation

friend class C4MapCreatorS2
friend

Definition at line 292 of file C4MapCreatorS2.h.

friend class C4MCParser
friend

Definition at line 293 of file C4MapCreatorS2.h.

Member Data Documentation

C4MCAlgorithm* C4MCOverlay::Algorithm
inherited
int_bool C4MCOverlay::Alpha
inherited

Definition at line 218 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), C4MCOverlay::C4MCOverlay(), and C4MCOverlay::Default().

int_bool C4MCOverlay::Beta
inherited

Definition at line 218 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), C4MCOverlay::C4MCOverlay(), and C4MCOverlay::Default().

C4MCNode * C4MCNode::ChildL
inherited
int32_t C4MCOverlay::FixedSeed
inherited
bool C4MCOverlay::Group
inherited
bool C4MCOverlay::Invert
inherited
int32_t C4MCOverlay::Lambda
inherited
bool C4MCOverlay::LooseBounds
inherited
bool C4MCOverlay::Mask
inherited
BYTE C4MCOverlay::MatClr
inherited
BYTE C4MCOverlay::MatClrBkg
inherited
int32_t C4MCOverlay::Material
inherited
char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

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

int32_t C4MCOverlay::OffX
inherited
int32_t C4MCOverlay::OffY
inherited
C4MCCallbackArray* C4MCOverlay::pDrawFunc
inherited

Definition at line 222 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay::C4MCOverlay(), C4MCOverlay::Default(), and RenderTo().

C4MCCallbackArray* C4MCOverlay::pEvaluateFunc
inherited
int_bool C4MCOverlay::RHgt
inherited
int_bool C4MCOverlay::ROffX
inherited
int_bool C4MCOverlay::ROffY
inherited
int32_t C4MCOverlay::Rotate
inherited
int_bool C4MCOverlay::RWdt
inherited
int_bool C4MCOverlay::RX
inherited
int_bool C4MCOverlay::RY
inherited
int32_t C4MCOverlay::Seed
inherited
bool C4MCOverlay::Sub
inherited
char C4MCOverlay::Texture[C4M_MaxName+1]
inherited
int32_t C4MCOverlay::Turbulence
inherited
int32_t C4MCOverlay::X
inherited
int32_t C4MCOverlay::Y
inherited
int32_t C4MCOverlay::ZoomX
inherited
int32_t C4MCOverlay::ZoomY
inherited

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