OpenClonk
C4MapScriptMatTexMask Class Reference

#include <C4MapScript.h>

Public Member Functions

 C4MapScriptMatTexMask ()
 
 C4MapScriptMatTexMask (const C4Value &spec)
 
void Init (const C4Value &spec)
 
bool operator() (uint8_t fg, uint8_t bg) const
 

Detailed Description

Definition at line 33 of file C4MapScript.h.

Constructor & Destructor Documentation

◆ C4MapScriptMatTexMask() [1/2]

C4MapScriptMatTexMask::C4MapScriptMatTexMask ( )
inline

Definition at line 46 of file C4MapScript.h.

46 : sky_mask(C4M_MaxTexIndex + 1,false), tunnel_mask(C4M_MaxTexIndex + 1, false) { }
const int C4M_MaxTexIndex
Definition: C4Constants.h:51

◆ C4MapScriptMatTexMask() [2/2]

C4MapScriptMatTexMask::C4MapScriptMatTexMask ( const C4Value spec)
inline

Definition at line 47 of file C4MapScript.h.

47 : sky_mask(C4M_MaxTexIndex + 1, false), tunnel_mask(C4M_MaxTexIndex + 1, false) { Init(spec); }
void Init(const C4Value &spec)

References Init().

Here is the call graph for this function:

Member Function Documentation

◆ Init()

void C4MapScriptMatTexMask::Init ( const C4Value spec)

Definition at line 188 of file C4MapScript.cpp.

189 {
190  // Mask may be initialized by a simple string or by an array of strings, of which the effects are OR'ed
191  const C4ValueArray *arr = spec.getArray();
192  if (arr)
193  {
194  // Init by array
195  for (int32_t i=0; i<arr->GetSize(); ++i)
196  {
197  C4String *smask = arr->GetItem(i).getStr();
198  if (!smask) throw C4AulExecError(FormatString("MatTexMask expected string as %dth element in array.", (int)i).getData());
199  UnmaskSpec(smask);
200  }
201  }
202  else
203  {
204  // Init by string
205  C4String *smask = spec.getStr();
206  if (smask)
207  UnmaskSpec(smask);
208  else
209  {
210  if (spec) throw C4AulExecError("MatTexMask expected string or array of strings.");
211  // nil defaults to everything except index zero unmasked
212  sky_mask = std::vector<bool>(256, true);
213  tunnel_mask = std::vector<bool>(256, true);
214  sky_mask[0] = false;
215  tunnel_mask[0] = false;
216  }
217  }
218 }
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
const C4Value & GetItem(int32_t iElem) const
Definition: C4ValueArray.h:38
int32_t GetSize() const
Definition: C4ValueArray.h:36
C4ValueArray * getArray() const
Definition: C4Value.h:118
C4String * getStr() const
Definition: C4Value.h:117

References FormatString(), C4Value::getArray(), C4ValueArray::GetItem(), C4ValueArray::GetSize(), and C4Value::getStr().

Referenced by C4MapScriptAlgoFilter::C4MapScriptAlgoFilter(), and C4MapScriptMatTexMask().

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

◆ operator()()

bool C4MapScriptMatTexMask::operator() ( uint8_t  fg,
uint8_t  bg 
) const
inline

Definition at line 50 of file C4MapScript.h.

50 { if (bg == C4M_MaxTexIndex) return sky_mask[fg]; else return tunnel_mask[fg]; }

References C4M_MaxTexIndex.


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