OpenClonk
C4Scenario Class Reference

#include <C4Scenario.h>

Collaboration diagram for C4Scenario:
[legend]

Public Member Functions

 C4Scenario ()
 
void SetExactLandscape ()
 
void Clear ()
 
void Default ()
 
bool Load (C4Group &hGroup, bool fLoadSection=false, bool suppress_errors=false)
 
bool Save (C4Group &hGroup, bool fSaveSection=false)
 
void CompileFunc (StdCompiler *pComp, bool fSection)
 
int32_t GetMinPlayer ()
 

Public Attributes

C4SHead Head
 
C4SDefinitions Definitions
 
C4SGame Game
 
C4SPlrStart PlrStart [C4S_MaxPlayer]
 
C4SLandscape Landscape
 
C4SAnimals Animals
 
C4SWeather Weather
 
C4SEnvironment Environment
 

Detailed Description

Definition at line 227 of file C4Scenario.h.

Constructor & Destructor Documentation

◆ C4Scenario()

C4Scenario::C4Scenario ( )

Definition at line 73 of file C4Scenario.cpp.

74 {
75  Default();
76 }
void Default()
Definition: C4Scenario.cpp:78

References Default().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4Scenario::Clear ( )

Definition at line 410 of file C4Scenario.cpp.

411 {
412 
413 }

Referenced by C4Game::Clear().

Here is the caller graph for this function:

◆ CompileFunc()

void C4Scenario::CompileFunc ( StdCompiler pComp,
bool  fSection 
)

Definition at line 128 of file C4Scenario.cpp.

129 {
130  pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head"));
131  if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions"));
132  pComp->Value(mkNamingAdapt(mkParAdapt(Game, fSection), "Game"));
133  for (int32_t i = 0; i < C4S_MaxPlayer; i++)
134  pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData()));
135  pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
136  pComp->Value(mkNamingAdapt(Animals, "Animals"));
137  pComp->Value(mkNamingAdapt(Weather, "Weather"));
138  pComp->Value(mkNamingAdapt(Environment, "Environment"));
139 }
const int C4S_MaxPlayer
Definition: C4Constants.h:53
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4SGame Game
Definition: C4Scenario.h:234
C4SWeather Weather
Definition: C4Scenario.h:238
C4SEnvironment Environment
Definition: C4Scenario.h:239
C4SLandscape Landscape
Definition: C4Scenario.h:236
C4SAnimals Animals
Definition: C4Scenario.h:237
C4SHead Head
Definition: C4Scenario.h:232
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:235
C4SDefinitions Definitions
Definition: C4Scenario.h:233
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References Animals, C4S_MaxPlayer, Definitions, Environment, FormatString(), Game, Head, Landscape, mkNamingAdapt(), mkParAdapt(), PlrStart, StdCompiler::Value(), and Weather.

Here is the call graph for this function:

◆ Default()

void C4Scenario::Default ( )

Definition at line 78 of file C4Scenario.cpp.

79 {
80  int32_t cnt;
81  Head.Default();
83  Game.Default();
84  for (cnt=0; cnt<C4S_MaxPlayer; cnt++) PlrStart[cnt].Default();
86  Animals.Default();
87  Weather.Default();
90 }
void Default()
Definition: C4Scenario.cpp:381
C4SRealism Realism
Definition: C4Scenario.h:127
void Default()
Definition: C4Scenario.cpp:215
void Default()
Definition: C4Scenario.cpp:159
void Default()
Definition: C4Scenario.cpp:286
void Default()
Definition: C4Scenario.cpp:403
void Default()
Definition: C4Scenario.cpp:363

References Animals, C4S_MaxPlayer, C4SHead::Default(), C4SDefinitions::Default(), C4SRealism::Default(), C4SGame::Default(), C4SLandscape::Default(), C4SWeather::Default(), C4SAnimals::Default(), C4SEnvironment::Default(), Definitions, Environment, Game, Head, Landscape, PlrStart, C4SGame::Realism, and Weather.

Referenced by C4Scenario(), C4Game::Default(), and Load().

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

◆ GetMinPlayer()

int32_t C4Scenario::GetMinPlayer ( )

Definition at line 141 of file C4Scenario.cpp.

142 {
143  // MinPlayer is specified.
144  if (Head.MinPlayer != 0)
145  return Head.MinPlayer;
146  // Otherwise/unknown: need at least one.
147  return 1;
148 }
int32_t MinPlayer
Definition: C4Scenario.h:70

References Head, and C4SHead::MinPlayer.

Referenced by C4GameLobby::Countdown::OnSec1Timer().

Here is the caller graph for this function:

◆ Load()

bool C4Scenario::Load ( C4Group hGroup,
bool  fLoadSection = false,
bool  suppress_errors = false 
)

Definition at line 92 of file C4Scenario.cpp.

93 {
94  StdStrBuf Buf;
95  if (!hGroup.LoadEntryString(C4CFN_ScenarioCore,&Buf)) return false;
96  if (!fLoadSection) Default();
97  if (suppress_errors)
98  {
99  if (!CompileFromBuf_Log<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), Buf, C4CFN_ScenarioCore))
100  {
101  return false;
102  }
103  }
104  else
105  {
106  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), Buf, C4CFN_ScenarioCore))
107  {
108  return false;
109  }
110  }
111  return true;
112 }
#define C4CFN_ScenarioCore
Definition: C4Components.h:42
bool LoadEntryString(const char *entry_name, StdStrBuf *buffer)
Definition: C4Group.cpp:2430

References C4CFN_ScenarioCore, Default(), C4Group::LoadEntryString(), and mkParAdapt().

Referenced by C4Game::LoadScenarioSection(), C4Game::OpenScenario(), and C4Playback::StreamToRecord().

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

◆ Save()

bool C4Scenario::Save ( C4Group hGroup,
bool  fSaveSection = false 
)

Definition at line 114 of file C4Scenario.cpp.

115 {
116  StdStrBuf Buf;
117  try
118  {
119  Buf.Take(DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection)));
120  }
121  catch (StdCompiler::Exception *)
122  { return false; }
123  if (!hGroup.Add(C4CFN_ScenarioCore,Buf,false,true))
124  { return false; }
125  return true;
126 }
bool Add(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1621
void Take(char *pnData)
Definition: StdBuf.h:457

References C4Group::Add(), C4CFN_ScenarioCore, mkParAdapt(), and StdStrBuf::Take().

Referenced by C4Game::LoadScenarioSection().

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

◆ SetExactLandscape()

void C4Scenario::SetExactLandscape ( )

Definition at line 415 of file C4Scenario.cpp.

416 {
417  if (Landscape.ExactLandscape) return;
418  // Set landscape
419  Landscape.ExactLandscape = true;
420 }
bool ExactLandscape
Definition: C4Scenario.h:165

References C4SLandscape::ExactLandscape, and Landscape.

Referenced by C4Game::LoadScenarioSection().

Here is the caller graph for this function:

Member Data Documentation

◆ Animals

C4SAnimals C4Scenario::Animals

Definition at line 237 of file C4Scenario.h.

Referenced by CompileFunc(), Default(), and C4Game::InitAnimals().

◆ Definitions

C4SDefinitions C4Scenario::Definitions

◆ Environment

C4SEnvironment C4Scenario::Environment

Definition at line 239 of file C4Scenario.h.

Referenced by CompileFunc(), Default(), and C4Game::InitEnvironment().

◆ Game

◆ Head

◆ Landscape

◆ PlrStart

◆ Weather

C4SWeather C4Scenario::Weather

Definition at line 238 of file C4Scenario.h.

Referenced by CompileFunc(), Default(), C4Weather::Execute(), and C4Weather::Init().


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