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) override
 
bool RenderTo (BYTE *pToBuf, BYTE *pToBufBkg, int32_t iPitch)
 
void SetSize (int32_t iWdt, int32_t iHgt)
 
C4MCNodeType Type () override
 
bool SetOp (C4MCTokenType eOp) override
 
C4MCAlgorithmGetAlgo (const char *szName)
 
bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType) override
 
void Evaluate () override
 
C4MCOverlayOverlay () override
 
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 696 of file C4MapCreatorS2.cpp.

Referenced by clone().

696  : C4MCOverlay(pOwner)
697 {
698 
699 }
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 701 of file C4MapCreatorS2.cpp.

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

Member Function Documentation

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

Definition at line 516 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().

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

References C4MCNode::Child0.

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

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

Here is the caller graph for this function:

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

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 706 of file C4MapCreatorS2.cpp.

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

Referenced by C4MapCreatorS2::Default().

707 {
708  // inherited
710  // size by landscape def
712 }
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 ( )
overridevirtualinherited

Reimplemented from C4MCNode.

Definition at line 458 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.

459 {
460  // inherited
462  // get mat color
463  if (Inside<int32_t>(Material,0,MapCreator->MatMap->Num-1))
464  {
466  if(MatClr == 0 || !Sub)
467  MatClrBkg = 0;
468  else
470  }
471  else
472  {
473  MatClr=0;
474  MatClrBkg=0;
475  }
476 
477  // calc size
478  if (Owner)
479  {
480  C4MCOverlay *pOwnrOvrl;
481  if ((pOwnrOvrl=OwnerOverlay()))
482  {
483  int32_t iOwnerWdt=pOwnrOvrl->Wdt; int32_t iOwnerHgt=pOwnrOvrl->Hgt;
484  X = RX.Evaluate(iOwnerWdt) + pOwnrOvrl->X;
485  Y = RY.Evaluate(iOwnerHgt) + pOwnrOvrl->Y;
486  Wdt = RWdt.Evaluate(iOwnerWdt);
487  Hgt = RHgt.Evaluate(iOwnerHgt);
488  OffX = ROffX.Evaluate(iOwnerWdt);
489  OffY = ROffY.Evaluate(iOwnerHgt);
490  }
491  }
492  // calc seed
493  if (!(Seed=FixedSeed))
494  {
495  int32_t r1=Random(32768);
496  int32_t r2=Random(65536);
497  Seed=(r1<<16) | r2;
498  }
499 }
int_bool ROffY
C4MaterialMap * MatMap
C4MCOverlay * OwnerOverlay()
uint32_t Random()
Definition: C4Random.cpp:43
C4Material * Map
Definition: C4Material.h:169
int_bool RHgt
C4TextureMap * TexMap
int32_t MTunnel
Definition: C4Material.cpp:36
virtual void Evaluate()
int_bool ROffX
C4MCNode * Owner
char Name[C4M_MaxName+1]
Definition: C4Material.h:89
int_bool RWdt
int32_t FixedSeed
int32_t Num
Definition: C4Material.h:168
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:235
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:441
C4MapCreatorS2 * MapCreator
int32_t Material

Here is the call graph for this function:

C4MCOverlay * C4MCOverlay::FirstOfChain ( )
inherited

Definition at line 501 of file C4MapCreatorS2.cpp.

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

Referenced by PreparePeek().

502 {
503  // run backwards until nullptr, non-overlay or overlay without operator is found
504  C4MCOverlay *pOvrl=this;
505  C4MCOverlay *pPrevO;
506  while (pOvrl->Prev)
507  {
508  if (!(pPrevO=pOvrl->Prev->Overlay())) break;
509  if (pPrevO->Op == MCT_NONE) break;
510  pOvrl=pPrevO;
511  }
512  // done
513  return pOvrl;
514 }
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 446 of file C4MapCreatorS2.cpp.

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

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

447 {
448  // search map
449  for (C4MCAlgorithm *pAlgo = &C4MCAlgoMap[0]; pAlgo->Function; pAlgo++)
450  // check name
451  if (SEqual(pAlgo->Identifier, szName))
452  // success!
453  return pAlgo;
454  // nothing found
455  return nullptr;
456 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
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 255 of file C4MapCreatorS2.cpp.

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

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

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 }
C4MCNode * GetNodeByName(const char *szName)
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
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 275 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

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

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

Here is the caller graph for this function:

C4MCOverlay* C4MCOverlay::Overlay ( )
inlineoverridevirtualinherited

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 246 of file C4MapCreatorS2.cpp.

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

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

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
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 622 of file C4MapCreatorS2.cpp.

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

Referenced by AlgoBorder().

623 {
624  // start with this one
625  C4MCOverlay *pOvrl=this; bool fLastSetC=false; C4MCTokenType eLastOp=MCT_NONE; BYTE Crap;
626  // loop through op chain
627  while (true)
628  {
629  fLastSetC=pOvrl->RenderPix(iX, iY, Crap, Crap, eLastOp, fLastSetC, false);
630  eLastOp=pOvrl->Op;
631  if (!pOvrl->Op) break;
632  // must be another overlay, since there's an operator
633  // hopefully, the preparser will catch all the other crap
634  pOvrl=pOvrl->Next->Overlay();
635  }
636  // return result
637  return fLastSetC;
638 }
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 294 of file C4MapCreatorS2.cpp.

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

Referenced by SetSize().

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()
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 216 of file C4MapCreatorS2.cpp.

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

Referenced by C4MCNode::C4MCNode().

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

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

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

Reimplemented from C4MCNode.

Definition at line 372 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.

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

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 748 of file C4MapCreatorS2.cpp.

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

Referenced by C4Landscape::DrawDefMap().

749 {
750  // store new size
751  Wdt=iWdt; Hgt=iHgt;
752  // update relative values
754 }
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 283 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

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

Here is the caller graph for this function:

C4MCNodeType C4MCMap::Type ( )
inlineoverridevirtual

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: