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

#include <C4MapCreatorS2.h>

Collaboration diagram for C4MCCallbackArray:
[legend]

Public Member Functions

 C4MCCallbackArray (C4AulFunc *pSFunc, C4MapCreatorS2 *pMapCreator)
 
 ~C4MCCallbackArray ()
 
void EnablePixel (int32_t iX, int32_t iY)
 
void Execute (int32_t iMapZoom)
 

Protected Attributes

C4MapCreatorS2pMapCreator
 
BYTEpMap
 
int32_t iWdt
 
int32_t iHgt
 
C4AulFuncpSF
 
C4MCCallbackArraypNext
 

Friends

class C4MCCallbackArrayList
 

Detailed Description

Definition at line 105 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

C4MCCallbackArray::C4MCCallbackArray ( C4AulFunc pSFunc,
C4MapCreatorS2 pMapCreator 
)

Definition at line 80 of file C4MapCreatorS2.cpp.

References C4MCCallbackArrayList::Add(), C4MapCreatorS2::CallbackArrays, pMap, pNext, and pSF.

81 {
82  // store fn
83  pSF = pSFunc;
84  // zero fields
85  pMap=nullptr; pNext=nullptr;
86  // store and add in map creator
87  if ((this->pMapCreator=pMapCreator))
88  pMapCreator->CallbackArrays.Add(this);
89  // done
90 }
C4MCCallbackArrayList CallbackArrays
C4MCCallbackArray * pNext
void Add(C4MCCallbackArray *pNewArray)

Here is the call graph for this function:

C4MCCallbackArray::~C4MCCallbackArray ( )

Definition at line 92 of file C4MapCreatorS2.cpp.

References pMap.

93 {
94  // clear map, if present
95  if (pMap) delete [] pMap;
96 }

Member Function Documentation

void C4MCCallbackArray::EnablePixel ( int32_t  iX,
int32_t  iY 
)

Definition at line 98 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Hgt, iHgt, iSize, iWdt, C4MapCreatorS2::pCurrentMap, pMap, pMapCreator, and C4MCOverlay::Wdt.

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

99 {
100  // array not yet created? then do that now!
101  if (!pMap)
102  {
103  // safety
104  if (!pMapCreator) return;
105  // get current map size
106  C4MCMap *pCurrMap = pMapCreator->pCurrentMap;
107  if (!pCurrMap) return;
108  iWdt = pCurrMap->Wdt; iHgt = pCurrMap->Hgt;
109  // create bitmap
110  int32_t iSize=(iWdt*iHgt+7)/8;
111  pMap = new BYTE[iSize];
112  memset(pMap, 0, iSize);
113  // done
114  }
115  // safety: do not set outside map!
116  if (iX<0 || iY<0 || iX>=iWdt || iY>=iHgt) return;
117  // set in map
118  int32_t iIndex = iX + iY*iWdt;
119  pMap[iIndex/8] |= 1<<(iIndex%8);
120  // done
121 }
uint8_t BYTE
C4MapCreatorS2 * pMapCreator
C4MCMap * pCurrentMap
int iSize
Definition: TstC4NetIO.cpp:32

Here is the caller graph for this function:

void C4MCCallbackArray::Execute ( int32_t  iMapZoom)

Definition at line 123 of file C4MapCreatorS2.cpp.

References C4VInt(), C4AulFunc::Exec(), iHgt, iWdt, pMap, and pSF.

124 {
125  // safety
126  if (!pSF || !pMap) return;
127  // pre-create parset
128  C4AulParSet Pars(0, 0, iMapZoom);
129  // call all funcs
130  int32_t iIndex=iWdt*iHgt;
131  while (iIndex--)
132  if (pMap[iIndex/8]&(1<<(iIndex%8)))
133  {
134  // set pars
135  Pars[0] = C4VInt((iIndex%iWdt) * iMapZoom - (iMapZoom/2));
136  Pars[1] = C4VInt((iIndex/iWdt) * iMapZoom - (iMapZoom/2));
137  // call
138  pSF->Exec(nullptr, &Pars);
139  }
140  // done
141 }
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73

Here is the call graph for this function:

Friends And Related Function Documentation

friend class C4MCCallbackArrayList
friend

Definition at line 123 of file C4MapCreatorS2.h.

Member Data Documentation

int32_t C4MCCallbackArray::iHgt
protected

Definition at line 114 of file C4MapCreatorS2.h.

Referenced by EnablePixel(), and Execute().

int32_t C4MCCallbackArray::iWdt
protected

Definition at line 114 of file C4MapCreatorS2.h.

Referenced by EnablePixel(), and Execute().

BYTE* C4MCCallbackArray::pMap
protected

Definition at line 113 of file C4MapCreatorS2.h.

Referenced by C4MCCallbackArray(), EnablePixel(), Execute(), and ~C4MCCallbackArray().

C4MapCreatorS2* C4MCCallbackArray::pMapCreator
protected

Definition at line 112 of file C4MapCreatorS2.h.

Referenced by EnablePixel().

C4AulFunc* C4MCCallbackArray::pSF
protected

Definition at line 115 of file C4MapCreatorS2.h.

Referenced by C4MCCallbackArray(), and Execute().


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