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

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

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

Here is the call graph for this function:

C4MCCallbackArray::~C4MCCallbackArray ( )

Definition at line 91 of file C4MapCreatorS2.cpp.

References pMap.

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

Member Function Documentation

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

Definition at line 97 of file C4MapCreatorS2.cpp.

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

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

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

Here is the caller graph for this function:

void C4MCCallbackArray::Execute ( int32_t  iMapZoom)

Definition at line 122 of file C4MapCreatorS2.cpp.

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

123 {
124  // safety
125  if (!pSF || !pMap) return;
126  // pre-create parset
127  C4AulParSet Pars(0, 0, iMapZoom);
128  // call all funcs
129  int32_t iIndex=iWdt*iHgt;
130  while (iIndex--)
131  if (pMap[iIndex/8]&(1<<(iIndex%8)))
132  {
133  // set pars
134  Pars[0] = C4VInt((iIndex%iWdt) * iMapZoom - (iMapZoom/2));
135  Pars[1] = C4VInt((iIndex/iWdt) * iMapZoom - (iMapZoom/2));
136  // call
137  pSF->Exec(nullptr, &Pars);
138  }
139  // done
140 }
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: