OpenClonk
C4MCOverlay Class Reference

#include <C4MapCreatorS2.h>

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

Public Member Functions

 C4MCOverlay (C4MCNode *pOwner=nullptr)
 
 C4MCOverlay (C4MCParser *pParser, C4MCNode *pOwner, C4MCOverlay &rTemplate, bool fClone)
 
C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode) 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)
 
C4MCNodeType Type () override
 
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 194 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

◆ C4MCOverlay() [1/2]

C4MCOverlay::C4MCOverlay ( C4MCNode pOwner = nullptr)

Definition at line 306 of file C4MapCreatorS2.cpp.

306  : C4MCNode(pOwner)
307 {
308  // zero members
309  X=Y=Wdt=Hgt=OffX=OffY=0;
310  Material=MNone;
311  *Texture=0;
312  Op=MCT_NONE;
313  MatClr=0;
314  MatClrBkg=0;
315  Algorithm=nullptr;
316  Sub=false;
317  ZoomX=ZoomY=0;
318  FixedSeed=Seed=0;
319 // Alpha=Beta=0;
322  pEvaluateFunc=pDrawFunc=nullptr;
323 }
const int32_t MNone
Definition: C4Constants.h:177
@ MCT_NONE
C4MCNode(C4MCNode *pOwner=nullptr)
int32_t Material
C4MCCallbackArray * pEvaluateFunc
char Texture[C4M_MaxName+1]
C4MCTokenType Op
C4MCCallbackArray * pDrawFunc
int32_t Rotate
int32_t FixedSeed
int32_t Lambda
int32_t Turbulence
C4MCAlgorithm * Algorithm

References Algorithm, FixedSeed, Group, Hgt, Invert, Lambda, LooseBounds, Mask, MatClr, MatClrBkg, Material, MCT_NONE, MNone, OffX, OffY, Op, pDrawFunc, pEvaluateFunc, Rotate, Seed, Sub, Texture, Turbulence, Wdt, X, Y, ZoomX, and ZoomY.

Referenced by clone().

Here is the caller graph for this function:

◆ C4MCOverlay() [2/2]

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

Definition at line 325 of file C4MapCreatorS2.cpp.

325  : C4MCNode(pParser, pOwner, rTemplate, fClone)
326 {
327  // copy fields
328  X=rTemplate.X; Y=rTemplate.Y; Wdt=rTemplate.Wdt; Hgt=rTemplate.Hgt;
329  RX=rTemplate.RX; RY=rTemplate.RY; RWdt=rTemplate.RWdt; RHgt=rTemplate.RHgt;
330  OffX=rTemplate.OffX; OffY=rTemplate.OffY; ROffX=rTemplate.ROffX; ROffY=rTemplate.ROffY;
331  Material=rTemplate.Material;
332  SCopy(rTemplate.Texture, Texture, C4MaxName);
333  Algorithm=rTemplate.Algorithm;
334  Sub=rTemplate.Sub;
335  ZoomX=rTemplate.ZoomX; ZoomY=rTemplate.ZoomY;
336  MatClr=rTemplate.MatClr;
337  MatClrBkg=rTemplate.MatClrBkg;
338  Seed=rTemplate.Seed;
339  Alpha=rTemplate.Alpha; Beta=rTemplate.Beta; Turbulence=rTemplate.Turbulence; Lambda=rTemplate.Lambda;
340  Rotate=rTemplate.Rotate;
341  Invert=rTemplate.Invert; LooseBounds=rTemplate.LooseBounds; Group=rTemplate.Group; Mask=rTemplate.Mask;
342  FixedSeed=rTemplate.FixedSeed;
343  pEvaluateFunc=rTemplate.pEvaluateFunc;
344  pDrawFunc=rTemplate.pDrawFunc;
345  // zero non-template-fields
346  if (fClone) Op=rTemplate.Op; else Op=MCT_NONE;
347 }
const unsigned int C4MaxName
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
int_bool Beta
int_bool RWdt
int_bool Alpha
int_bool ROffX
int_bool ROffY
int_bool RHgt

References Algorithm, Alpha, Beta, C4MaxName, FixedSeed, Group, Hgt, Invert, Lambda, LooseBounds, Mask, MatClr, MatClrBkg, Material, MCT_NONE, OffX, OffY, Op, pDrawFunc, pEvaluateFunc, RHgt, ROffX, ROffY, Rotate, RWdt, RX, RY, SCopy(), Seed, Sub, Texture, Turbulence, Wdt, X, Y, ZoomX, and ZoomY.

Here is the call graph for this function:

Member Function Documentation

◆ CheckMask()

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

Definition at line 516 of file C4MapCreatorS2.cpp.

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:930
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Real Cos(const C4Real &fAngle)
Definition: C4Real.h:266
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
C4Real C4REAL10(int x)
Definition: C4Real.h:269
C4Real Sin(const C4Real &fAngle)
Definition: C4Real.h:265
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
@ RCT_MCT2
Definition: C4Record.h:73
@ RCT_MCT1
Definition: C4Record.h:72
int x
Definition: C4Record.h:185
int Rotate
Definition: C4Record.h:180
int x
Definition: C4Record.h:180
int y
Definition: C4Record.h:180
int Turbulence
Definition: C4Record.h:180
int y
Definition: C4Record.h:185
int32_t DebugRec
Definition: C4Config.h:63
C4ConfigGeneral General
Definition: C4Config.h:255
Definition: C4Real.h:59
bool(* Function)(C4MCOverlay *, int32_t, int32_t)

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

Referenced by RenderPix().

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

◆ Clear()

void C4MCNode::Clear ( )
inherited

Definition at line 240 of file C4MapCreatorS2.cpp.

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

References C4MCNode::Child0.

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

Here is the caller graph for this function:

◆ clone()

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

Reimplemented from C4MCNode.

Reimplemented in C4MCMap.

Definition at line 200 of file C4MapCreatorS2.h.

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

References C4MCOverlay().

Here is the call graph for this function:

◆ Default()

void C4MCOverlay::Default ( )
protected

Definition at line 349 of file C4MapCreatorS2.cpp.

350 {
351  // default algo
353  // no mat (sky) default
354  Material=MNone;
355  *Texture=0;
356  // but if mat is set, assume it sub
357  Sub=true;
358  // full size
359  OffX=OffY=X=Y=0;
360  ROffX.Set(0,true); ROffY.Set(0,true); RX.Set(0,true); RY.Set(0,true);
362  RWdt.Set(C4MC_SizeRes,true); RHgt.Set(C4MC_SizeRes,true);
363  // def zoom
365  // def values
366  Alpha.Set(0,false); Beta.Set(0,false); Turbulence=Lambda=Rotate=0; Invert=LooseBounds=Group=Mask=false;
367  FixedSeed=0;
368  // script funcs
369  pEvaluateFunc=pDrawFunc=nullptr;
370 }
#define C4MC_DefAlgo
#define C4MC_SizeRes
#define C4MC_ZoomRes
void Set(int32_t value, bool percent)
C4MCAlgorithm * GetAlgo(const char *szName)

References Algorithm, Alpha, Beta, C4MC_DefAlgo, C4MC_SizeRes, C4MC_ZoomRes, FixedSeed, GetAlgo(), Group, Hgt, Invert, Lambda, LooseBounds, Mask, Material, MNone, OffX, OffY, pDrawFunc, pEvaluateFunc, RHgt, ROffX, ROffY, Rotate, RWdt, RX, RY, C4MCNode::int_bool::Set(), Sub, Texture, Turbulence, Wdt, X, Y, ZoomX, and ZoomY.

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

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

◆ Evaluate()

void C4MCOverlay::Evaluate ( )
overridevirtual

Reimplemented from C4MCNode.

Definition at line 458 of file C4MapCreatorS2.cpp.

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 }
int32_t MTunnel
Definition: C4Material.cpp:36
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:235
uint32_t Random()
Definition: C4Random.cpp:43
int32_t Evaluate(int32_t relative_to)
C4MCOverlay * OwnerOverlay()
C4MCNode * Owner
C4MapCreatorS2 * MapCreator
virtual void Evaluate()
C4MaterialMap * MatMap
C4TextureMap * TexMap
char Name[C4M_MaxName+1]
Definition: C4Material.h:89
int32_t Num
Definition: C4Material.h:168
C4Material * Map
Definition: C4Material.h:169
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture=nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:441

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

Here is the call graph for this function:

◆ FirstOfChain()

C4MCOverlay * C4MCOverlay::FirstOfChain ( )

Definition at line 501 of file C4MapCreatorS2.cpp.

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 }
virtual C4MCOverlay * Overlay()
C4MCNode * Prev

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

Referenced by PreparePeek().

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

◆ GetAlgo()

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

Definition at line 446 of file C4MapCreatorS2.cpp.

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 }
C4MCAlgorithm C4MCAlgoMap[]
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93

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

Referenced by Default(), and SetField().

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 }
C4MCNode * ChildL
C4MCNode * GetNodeByName(const char *szName)

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

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

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

◆ GlobalScope()

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

◆ InBounds()

bool C4MCOverlay::InBounds ( int32_t  iX,
int32_t  iY 
)
inline

Definition at line 238 of file C4MapCreatorS2.h.

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

References Hgt, Wdt, X, and Y.

Referenced by AlgoBorder().

Here is the caller graph for this function:

◆ 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 SetField(), and C4MCPoint::SetField().

Here is the caller graph for this function:

◆ Overlay()

C4MCOverlay* C4MCOverlay::Overlay ( )
inlineoverridevirtual

Reimplemented from C4MCNode.

Definition at line 232 of file C4MapCreatorS2.h.

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

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

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 Overlay(), and C4MCNode::Owner.

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

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

◆ PeekPix()

bool C4MCOverlay::PeekPix ( int32_t  iX,
int32_t  iY 
)

Definition at line 622 of file C4MapCreatorS2.cpp.

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 }
C4MCTokenType
uint8_t BYTE
C4MCNode * Next
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)

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

Referenced by AlgoBorder().

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 }

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:

◆ RenderPix()

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 
)

Definition at line 572 of file C4MapCreatorS2.cpp.

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 }
@ MCT_OR
@ MCT_AND
@ MCT_XOR
void EnablePixel(int32_t iX, int32_t iY)
bool CheckMask(int32_t iX, int32_t iY)

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

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

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

◆ SetField()

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

Reimplemented from C4MCNode.

Definition at line 372 of file C4MapCreatorS2.cpp.

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 }
const int C4M_MaxName
Definition: C4Constants.h:49
#define C4MCErr_AlgoNotFound
#define C4MCErr_TexNotFound
#define C4MCErr_SFuncNotFound
#define C4MCErr_MatNotFound
C4GameScriptHost GameScript
C4Value ScenPropList
Definition: C4ScriptHost.h:164
virtual bool SetField(C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
const char * StrPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
int32_t IntPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:365
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:109
bool CheckTexture(const char *szTexture)
Definition: C4Texture.cpp:485
C4PropList * _getPropList() const
Definition: C4Value.h:129

References C4Value::_getPropList(), C4M_MaxName, C4MC_ZoomRes, C4MCErr_AlgoNotFound, C4MCErr_MatNotFound, C4MCErr_SFuncNotFound, C4MCErr_TexNotFound, C4TextureMap::CheckTexture(), GameScript, C4MaterialMap::Get(), 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.

Here is the call graph for this function:

◆ SetOp()

bool C4MCOverlay::SetOp ( C4MCTokenType  eOp)
inlineoverridevirtual

Reimplemented from C4MCNode.

Definition at line 224 of file C4MapCreatorS2.h.

224 { Op=eOp; return true; } // set following operator

References Op.

◆ 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 SetField().

Here is the caller graph for this function:

◆ Type()

C4MCNodeType C4MCOverlay::Type ( )
inlineoverridevirtual

Reimplemented from C4MCNode.

Reimplemented in C4MCMap.

Definition at line 241 of file C4MapCreatorS2.h.

241 { return MCN_Overlay; } // get node type
@ MCN_Overlay

References MCN_Overlay.

Friends And Related Function Documentation

◆ C4MapCreatorS2

friend class C4MapCreatorS2
friend

Definition at line 243 of file C4MapCreatorS2.h.

◆ C4MCParser

friend class C4MCParser
friend

Definition at line 244 of file C4MapCreatorS2.h.

Member Data Documentation

◆ Algorithm

C4MCAlgorithm* C4MCOverlay::Algorithm

Definition at line 216 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ Alpha

int_bool C4MCOverlay::Alpha

Definition at line 218 of file C4MapCreatorS2.h.

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

◆ Beta

int_bool C4MCOverlay::Beta

Definition at line 218 of file C4MapCreatorS2.h.

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

◆ Child0

◆ ChildL

C4MCNode * C4MCNode::ChildL
inherited

◆ FixedSeed

int32_t C4MCOverlay::FixedSeed

Definition at line 207 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Group

bool C4MCOverlay::Group

Definition at line 220 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and RenderPix().

◆ Hgt

◆ Invert

bool C4MCOverlay::Invert

Definition at line 220 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ Lambda

int32_t C4MCOverlay::Lambda

Definition at line 217 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ LooseBounds

bool C4MCOverlay::LooseBounds

Definition at line 220 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ MapCreator

◆ Mask

bool C4MCOverlay::Mask

Definition at line 220 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and RenderPix().

◆ MatClr

BYTE C4MCOverlay::MatClr

Definition at line 213 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Evaluate(), and RenderPix().

◆ MatClrBkg

BYTE C4MCOverlay::MatClrBkg

Definition at line 214 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Evaluate(), and RenderPix().

◆ Material

int32_t C4MCOverlay::Material

Definition at line 210 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Name

char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

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

◆ Next

C4MCNode * C4MCNode::Next
inherited

◆ OffX

int32_t C4MCOverlay::OffX

Definition at line 208 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), Default(), and Evaluate().

◆ OffY

int32_t C4MCOverlay::OffY

Definition at line 208 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), Default(), and Evaluate().

◆ Op

C4MCTokenType C4MCOverlay::Op

Definition at line 215 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), FirstOfChain(), PeekPix(), RenderPix(), and SetOp().

◆ Owner

◆ pDrawFunc

C4MCCallbackArray* C4MCOverlay::pDrawFunc

Definition at line 222 of file C4MapCreatorS2.h.

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

◆ pEvaluateFunc

C4MCCallbackArray* C4MCOverlay::pEvaluateFunc

Definition at line 221 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and RenderPix().

◆ Prev

◆ RHgt

int_bool C4MCOverlay::RHgt

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ ROffX

int_bool C4MCOverlay::ROffX

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ ROffY

int_bool C4MCOverlay::ROffY

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Rotate

int32_t C4MCOverlay::Rotate

Definition at line 217 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ RWdt

int_bool C4MCOverlay::RWdt

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ RX

int_bool C4MCOverlay::RX

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ RY

int_bool C4MCOverlay::RY

Definition at line 209 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Seed

int32_t C4MCOverlay::Seed

Definition at line 206 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Evaluate().

◆ Sub

bool C4MCOverlay::Sub

Definition at line 211 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Texture

char C4MCOverlay::Texture[C4M_MaxName+1]

Definition at line 212 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), Default(), and Evaluate().

◆ Turbulence

int32_t C4MCOverlay::Turbulence

Definition at line 217 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay(), CheckMask(), and Default().

◆ Wdt

◆ X

int32_t C4MCOverlay::X

◆ Y

int32_t C4MCOverlay::Y

◆ ZoomX

int32_t C4MCOverlay::ZoomX

Definition at line 219 of file C4MapCreatorS2.h.

Referenced by AlgoMandel(), C4MCOverlay(), CheckMask(), and Default().

◆ ZoomY

int32_t C4MCOverlay::ZoomY

Definition at line 219 of file C4MapCreatorS2.h.

Referenced by AlgoMandel(), C4MCOverlay(), CheckMask(), and Default().


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