OpenClonk
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() [1/2]

C4MCMap::C4MCMap ( C4MCNode pOwner = nullptr)

Definition at line 696 of file C4MapCreatorS2.cpp.

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

Referenced by clone().

Here is the caller graph for this function:

◆ C4MCMap() [2/2]

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 }

Member Function Documentation

◆ CheckMask()

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

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
int32_t Rotate
int32_t Lambda
int32_t Turbulence
C4MCAlgorithm * Algorithm
bool(* Function)(C4MCOverlay *, int32_t, int32_t)

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

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* C4MCMap::clone ( C4MCParser pParser,
C4MCNode pToNode 
)
inlineoverridevirtual

Reimplemented from C4MCOverlay.

Definition at line 280 of file C4MapCreatorS2.h.

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

References C4MCMap().

Here is the call graph for this function:

◆ Default()

void C4MCMap::Default ( )
protected

Definition at line 706 of file C4MapCreatorS2.cpp.

707 {
708  // inherited
710  // size by landscape def
712 }
C4MapCreatorS2 * MapCreator
C4SLandscape * Landscape
void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum)
Definition: C4Scenario.cpp:319

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

Referenced by C4MapCreatorS2::Default().

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

◆ Evaluate()

void C4MCOverlay::Evaluate ( )
overridevirtualinherited

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
virtual void Evaluate()
int32_t Material
char Texture[C4M_MaxName+1]
int_bool RWdt
int32_t FixedSeed
int_bool ROffX
int_bool ROffY
int_bool RHgt
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(), 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.

Here is the call graph for this function:

◆ FirstOfChain()

C4MCOverlay * C4MCOverlay::FirstOfChain ( )
inherited

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

References MCT_NONE, C4MCOverlay::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)
inherited

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 C4MCOverlay::Default(), and C4MCOverlay::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 
)
inlineinherited

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 C4MCOverlay::Hgt, C4MCOverlay::Wdt, C4MCOverlay::X, and C4MCOverlay::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 C4MCOverlay::SetField(), and C4MCPoint::SetField().

Here is the caller graph for this function:

◆ Overlay()

C4MCOverlay* C4MCOverlay::Overlay ( )
inlineoverridevirtualinherited

Reimplemented from C4MCNode.

Definition at line 232 of file C4MapCreatorS2.h.

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

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

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

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

◆ PeekPix()

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

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, C4MCOverlay::Op, C4MCNode::Overlay(), and C4MCOverlay::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 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 
)
inherited

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)
C4MCCallbackArray * pEvaluateFunc
bool CheckMask(int32_t iX, int32_t iY)

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

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

◆ RenderTo()

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

Definition at line 714 of file C4MapCreatorS2.cpp.

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 }
C4MCCallbackArray * pDrawFunc
C4MCMap * pCurrentMap

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

Referenced by C4MapCreatorS2::Render().

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

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
const int32_t MNone
Definition: C4Constants.h:177
#define C4MCErr_AlgoNotFound
#define C4MCErr_TexNotFound
#define C4MCErr_SFuncNotFound
#define C4MCErr_MatNotFound
#define C4MC_ZoomRes
C4GameScriptHost GameScript
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
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)
C4MCAlgorithm * GetAlgo(const char *szName)
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(), 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.

Here is the call graph for this function:

◆ SetOp()

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

References C4MCOverlay::Op.

◆ SetSize()

void C4MCMap::SetSize ( int32_t  iWdt,
int32_t  iHgt 
)

Definition at line 748 of file C4MapCreatorS2.cpp.

749 {
750  // store new size
751  Wdt=iWdt; Hgt=iHgt;
752  // update relative values
754 }
void ReEvaluate()

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

Referenced by C4Landscape::DrawDefMap().

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

◆ StrPar()

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

Definition at line 283 of file C4MapCreatorS2.cpp.

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

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

Here is the caller graph for this function:

◆ Type()

C4MCNodeType C4MCMap::Type ( )
inlineoverridevirtual

Reimplemented from C4MCOverlay.

Definition at line 290 of file C4MapCreatorS2.h.

290 { return MCN_Map; } // get node type
@ MCN_Map

References MCN_Map.

Friends And Related Function Documentation

◆ C4MapCreatorS2

friend class C4MapCreatorS2
friend

Definition at line 292 of file C4MapCreatorS2.h.

◆ C4MCParser

friend class C4MCParser
friend

Definition at line 293 of file C4MapCreatorS2.h.

Member Data Documentation

◆ Algorithm

C4MCAlgorithm* C4MCOverlay::Algorithm
inherited

◆ Alpha

int_bool C4MCOverlay::Alpha
inherited

Definition at line 218 of file C4MapCreatorS2.h.

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

◆ Beta

int_bool C4MCOverlay::Beta
inherited

Definition at line 218 of file C4MapCreatorS2.h.

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

◆ Child0

◆ ChildL

C4MCNode * C4MCNode::ChildL
inherited

◆ FixedSeed

int32_t C4MCOverlay::FixedSeed
inherited

◆ Group

bool C4MCOverlay::Group
inherited

◆ Hgt

◆ Invert

bool C4MCOverlay::Invert
inherited

◆ Lambda

int32_t C4MCOverlay::Lambda
inherited

◆ LooseBounds

bool C4MCOverlay::LooseBounds
inherited

◆ MapCreator

◆ Mask

bool C4MCOverlay::Mask
inherited

◆ MatClr

BYTE C4MCOverlay::MatClr
inherited

◆ MatClrBkg

BYTE C4MCOverlay::MatClrBkg
inherited

◆ Material

int32_t C4MCOverlay::Material
inherited

◆ Name

char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

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

◆ Next

◆ OffX

int32_t C4MCOverlay::OffX
inherited

◆ OffY

int32_t C4MCOverlay::OffY
inherited

◆ Op

◆ Owner

◆ pDrawFunc

C4MCCallbackArray* C4MCOverlay::pDrawFunc
inherited

Definition at line 222 of file C4MapCreatorS2.h.

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

◆ pEvaluateFunc

C4MCCallbackArray* C4MCOverlay::pEvaluateFunc
inherited

◆ Prev

◆ RHgt

int_bool C4MCOverlay::RHgt
inherited

◆ ROffX

int_bool C4MCOverlay::ROffX
inherited

◆ ROffY

int_bool C4MCOverlay::ROffY
inherited

◆ Rotate

int32_t C4MCOverlay::Rotate
inherited

◆ RWdt

int_bool C4MCOverlay::RWdt
inherited

◆ RX

int_bool C4MCOverlay::RX
inherited

◆ RY

int_bool C4MCOverlay::RY
inherited

◆ Seed

int32_t C4MCOverlay::Seed
inherited

◆ Sub

bool C4MCOverlay::Sub
inherited

◆ Texture

char C4MCOverlay::Texture[C4M_MaxName+1]
inherited

◆ Turbulence

int32_t C4MCOverlay::Turbulence
inherited

◆ Wdt

◆ X

◆ Y

◆ ZoomX

int32_t C4MCOverlay::ZoomX
inherited

◆ ZoomY

int32_t C4MCOverlay::ZoomY
inherited

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