OpenClonk
C4SVal Class Reference

#include <C4Scenario.h>

Public Member Functions

 C4SVal (int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100)
 
void Default ()
 
void Set (int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100)
 
void SetConstant (int32_t val)
 
int32_t Evaluate ()
 
void CompileFunc (StdCompiler *pComp)
 
bool operator== (const C4SVal &rhs) const
 

Public Attributes

int32_t Std
 
int32_t Rnd
 
int32_t Min
 
int32_t Max
 

Detailed Description

Definition at line 26 of file C4Scenario.h.

Constructor & Destructor Documentation

◆ C4SVal()

C4SVal::C4SVal ( int32_t  std = 0,
int32_t  rnd = 0,
int32_t  min = 0,
int32_t  max = 100 
)

Definition at line 31 of file C4Scenario.cpp.

32  : Std(std), Rnd(rnd), Min(min), Max(max)
33 {
34 }
int32_t Max
Definition: C4Scenario.h:31
int32_t Rnd
Definition: C4Scenario.h:31
int32_t Std
Definition: C4Scenario.h:31
int32_t Min
Definition: C4Scenario.h:31

Member Function Documentation

◆ CompileFunc()

void C4SVal::CompileFunc ( StdCompiler pComp)

Definition at line 60 of file C4Scenario.cpp.

61 {
62  pComp->Value(mkDefaultAdapt(Std, 0));
63  if (!pComp->Separator()) return;
64  pComp->Value(mkDefaultAdapt(Rnd, 0));
65  if (!pComp->Separator()) return;
66  pComp->Value(mkDefaultAdapt(Min, 0));
67  if (!pComp->Separator()) return;
68  pComp->Value(mkDefaultAdapt(Max, 100));
69 }
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References Max, Min, mkDefaultAdapt(), Rnd, StdCompiler::Separator(), Std, and StdCompiler::Value().

Here is the call graph for this function:

◆ Default()

void C4SVal::Default ( )

Definition at line 55 of file C4Scenario.cpp.

56 {
57  Set();
58 }
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100)
Definition: C4Scenario.cpp:36

References Set().

Referenced by C4SLandscape::Default().

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

◆ Evaluate()

int32_t C4SVal::Evaluate ( )

Definition at line 50 of file C4Scenario.cpp.

51 {
52  return Clamp<int32_t>(Std+Random(2*Rnd+1)-Rnd,Min,Max);
53 }
uint32_t Random()
Definition: C4Random.cpp:43

References Max, Min, Random(), Rnd, and Std.

Referenced by C4MapCreator::Create(), C4Weather::Execute(), C4SLandscape::GetMapSize(), C4Weather::Init(), C4Game::InitInEarth(), C4Game::InitVegetation(), C4Landscape::ScenarioInit(), and C4Player::ScenarioInit().

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

◆ operator==()

bool C4SVal::operator== ( const C4SVal rhs) const
inline

Definition at line 39 of file C4Scenario.h.

40  {
41  return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max;
42  }

References Max, Min, Rnd, and Std.

◆ Set()

void C4SVal::Set ( int32_t  std = 0,
int32_t  rnd = 0,
int32_t  min = 0,
int32_t  max = 100 
)

Definition at line 36 of file C4Scenario.cpp.

37 {
38  Std=std; Rnd=rnd; Min=min; Max=max;
39 }

References Max, Min, Rnd, and Std.

Referenced by c4_mapgen_handle_new(), c4_mapgen_handle_new_script(), Default(), C4SPlrStart::Default(), C4SLandscape::Default(), C4SWeather::Default(), and C4Landscape::DrawMap().

Here is the caller graph for this function:

◆ SetConstant()

void C4SVal::SetConstant ( int32_t  val)

Definition at line 41 of file C4Scenario.cpp.

42 {
43  // Set to constant value and ensure limits allow it
44  Std = val;
45  Rnd = 0;
46  Min = std::min<int32_t>(Min, val);
47  Max = std::max<int32_t>(Max, val);
48 }

References Max, Min, Rnd, and Std.

Member Data Documentation

◆ Max

◆ Min

int32_t C4SVal::Min

Definition at line 31 of file C4Scenario.h.

Referenced by CompileFunc(), Evaluate(), C4Weather::Execute(), operator==(), Set(), and SetConstant().

◆ Rnd

int32_t C4SVal::Rnd

Definition at line 31 of file C4Scenario.h.

Referenced by CompileFunc(), Evaluate(), operator==(), Set(), and SetConstant().

◆ Std

int32_t C4SVal::Std

Definition at line 31 of file C4Scenario.h.

Referenced by CompileFunc(), Evaluate(), operator==(), Set(), and SetConstant().


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