OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 31 of file C4MapScript.h.

Constructor & Destructor Documentation

C4MapScriptMatTexMask::C4MapScriptMatTexMask ( )
inline

Definition at line 44 of file C4MapScript.h.

44 : sky_mask(C4M_MaxTexIndex + 1,false), tunnel_mask(C4M_MaxTexIndex + 1, false) { }
const int C4M_MaxTexIndex
Definition: C4Constants.h:51
C4MapScriptMatTexMask::C4MapScriptMatTexMask ( const C4Value spec)
inline

Definition at line 45 of file C4MapScript.h.

References Init().

45 : sky_mask(C4M_MaxTexIndex + 1, false), tunnel_mask(C4M_MaxTexIndex + 1, false) { Init(spec); }
const int C4M_MaxTexIndex
Definition: C4Constants.h:51
void Init(const C4Value &spec)

Here is the call graph for this function:

Member Function Documentation

void C4MapScriptMatTexMask::Init ( const C4Value spec)

Definition at line 187 of file C4MapScript.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 48 of file C4MapScript.h.

References C4M_MaxTexIndex.

48 { if (bg == C4M_MaxTexIndex) return sky_mask[fg]; else return tunnel_mask[fg]; }
const int C4M_MaxTexIndex
Definition: C4Constants.h:51

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