All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MapScriptAlgo.cpp File Reference
#include "C4Include.h"
#include "landscape/C4MapScript.h"
#include "lib/C4Random.h"
Include dependency graph for C4MapScriptAlgo.cpp:

Go to the source code of this file.


C4MapScriptAlgoFnParAlgo (C4PropList *algo_par)
int32_t QuerySeededRandomField (int32_t seed, int32_t x, int32_t y, int32_t scale)

Function Documentation

C4MapScriptAlgo* FnParAlgo ( C4PropList algo_par)

Definition at line 490 of file C4MapScriptAlgo.cpp.

References FormatString(), C4PropList::GetMapScriptLayer(), C4PropList::GetPropertyInt(), MAPALGO_And, MAPALGO_Border, MAPALGO_Ellipsis, MAPALGO_Filter, MAPALGO_Layer, MAPALGO_Lines, MAPALGO_Not, MAPALGO_Offset, MAPALGO_Or, MAPALGO_Polygon, MAPALGO_Rect, MAPALGO_RndChecker, MAPALGO_Rotate, MAPALGO_Scale, MAPALGO_Turbulence, MAPALGO_Xor, and P_Algo.

Referenced by C4MapScriptAlgoModifier::C4MapScriptAlgoModifier().

491 {
492  // Convert script function parameter to internal C4MapScriptAlgo class. Also resolve all parameters and nested child algos.
493  if (!algo_par) return nullptr;
494  // if algo is a layer, take that directly
495  C4MapScriptLayer *algo_layer = algo_par->GetMapScriptLayer();
496  if (algo_layer) return new C4MapScriptAlgoLayer(algo_layer);
497  // otherwise, determine by proplist parameter "algo"
498  switch (algo_par->GetPropertyInt(P_Algo))
499  {
500  case MAPALGO_Layer: return new C4MapScriptAlgoLayer(algo_par);
501  case MAPALGO_RndChecker: return new C4MapScriptAlgoRndChecker(algo_par);
502  case MAPALGO_And: return new C4MapScriptAlgoAnd(algo_par);
503  case MAPALGO_Or: return new C4MapScriptAlgoOr(algo_par);
504  case MAPALGO_Xor: return new C4MapScriptAlgoXor(algo_par);
505  case MAPALGO_Not: return new C4MapScriptAlgoNot(algo_par);
506  case MAPALGO_Offset: return new C4MapScriptAlgoOffset(algo_par);
507  case MAPALGO_Scale: return new C4MapScriptAlgoScale(algo_par);
508  case MAPALGO_Rotate: return new C4MapScriptAlgoRotate(algo_par);
509  case MAPALGO_Rect: return new C4MapScriptAlgoRect(algo_par);
510  case MAPALGO_Ellipsis: return new C4MapScriptAlgoEllipsis(algo_par);
511  case MAPALGO_Polygon: return new C4MapScriptAlgoPolygon(algo_par);
512  case MAPALGO_Lines: return new C4MapScriptAlgoLines(algo_par);
513  case MAPALGO_Turbulence: return new C4MapScriptAlgoTurbulence(algo_par);
514  case MAPALGO_Border: return new C4MapScriptAlgoBorder(algo_par);
515  case MAPALGO_Filter: return new C4MapScriptAlgoFilter(algo_par);
516  default:
517  throw C4AulExecError(FormatString("got invalid algo: %d", algo_par->GetPropertyInt(P_Algo)).getData());
518  }
519  return nullptr;
520 }
virtual class C4MapScriptLayer * GetMapScriptLayer()
Definition: C4PropList.cpp:687
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:882
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:

int32_t QuerySeededRandomField ( int32_t  seed,
int32_t  x,
int32_t  y,
int32_t  scale 

Definition at line 94 of file C4MapScriptAlgo.cpp.

Referenced by C4MapScriptAlgoRndChecker::operator()(), and C4MapScriptAlgoTurbulence::operator()().

95 {
96  return modD((((seed ^ (x*214013))*214013) ^ (y*214013)), scale);
97 }

Here is the caller graph for this function: