OpenClonk
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.

Functions

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

Function Documentation

◆ FnParAlgo()

C4MapScriptAlgo* FnParAlgo ( C4PropList algo_par)

Definition at line 541 of file C4MapScriptAlgo.cpp.

542 {
543  // Convert script function parameter to internal C4MapScriptAlgo class. Also resolve all parameters and nested child algos.
544  if (!algo_par) return nullptr;
545 
546  C4MapScriptAlgo *inner = FnParAlgoInner(algo_par);
547 
548  // if the Material property is set, use that material:
549  C4String *material = algo_par->GetPropertyStr(P_Material);
550  if (material) { // set inner material by wrapping with SetMaterial algo.
551  uint8_t fg = 0, bg = 0;
552  if (!FnParTexCol(material, fg, bg))
553  throw C4AulExecError("Invalid Material in map script algorithm.");
554  return new C4MapScriptAlgoSetMaterial(inner, fg, bg);
555  }
556 
557  return inner; // otherwise, just return the original algo
558 }
bool FnParTexCol(C4String *mattex, uint8_t &fg, uint8_t &bg)
Definition: C4MapScript.cpp:48
@ P_Material
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:744

Referenced by C4MapScriptAlgoModifier::C4MapScriptAlgoModifier().

Here is the caller graph for this function:

◆ QuerySeededRandomField()

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

Definition at line 94 of file C4MapScriptAlgo.cpp.

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