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 188 of file C4MapScript.cpp.

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

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

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 }
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:270

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: