OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 225 of file C4Scenario.h.

Constructor & Destructor Documentation

C4Scenario::C4Scenario ( )

Definition at line 73 of file C4Scenario.cpp.

References Default().

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

Here is the call graph for this function:

Member Function Documentation

void C4Scenario::Clear ( )

Definition at line 408 of file C4Scenario.cpp.

Referenced by C4Game::Clear().

409 {
410 
411 }

Here is the caller graph for this function:

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

Definition at line 128 of file C4Scenario.cpp.

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

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 }
C4SDefinitions Definitions
Definition: C4Scenario.h:231
C4SEnvironment Environment
Definition: C4Scenario.h:237
C4SLandscape Landscape
Definition: C4Scenario.h:234
const int C4S_MaxPlayer
Definition: C4Constants.h:53
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:171
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4SAnimals Animals
Definition: C4Scenario.h:235
C4SGame Game
Definition: C4Scenario.h:232
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
C4SHead Head
Definition: C4Scenario.h:230
C4SWeather Weather
Definition: C4Scenario.h:236
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

void C4Scenario::Default ( )

Definition at line 78 of file C4Scenario.cpp.

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().

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:361
C4SDefinitions Definitions
Definition: C4Scenario.h:231
void Default()
Definition: C4Scenario.cpp:379
C4SEnvironment Environment
Definition: C4Scenario.h:237
C4SLandscape Landscape
Definition: C4Scenario.h:234
const int C4S_MaxPlayer
Definition: C4Constants.h:53
void Default()
Definition: C4Scenario.cpp:78
void Default()
Definition: C4Scenario.cpp:284
void Default()
Definition: C4Scenario.cpp:159
C4SRealism Realism
Definition: C4Scenario.h:127
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4SAnimals Animals
Definition: C4Scenario.h:235
void Default()
Definition: C4Scenario.cpp:215
void Default()
Definition: C4Scenario.cpp:401
C4SGame Game
Definition: C4Scenario.h:232
C4SHead Head
Definition: C4Scenario.h:230
C4SWeather Weather
Definition: C4Scenario.h:236

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Scenario::GetMinPlayer ( )

Definition at line 141 of file C4Scenario.cpp.

References Head, and C4SHead::MinPlayer.

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

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
C4SHead Head
Definition: C4Scenario.h:230

Here is the caller graph for this function:

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

Definition at line 92 of file C4Scenario.cpp.

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

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

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 }
void Default()
Definition: C4Scenario.cpp:78
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932
#define C4CFN_ScenarioCore
Definition: C4Components.h:42
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 114 of file C4Scenario.cpp.

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

Referenced by C4Game::LoadScenarioSection().

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 }
void Take(char *pnData)
Definition: StdBuf.h:465
#define C4CFN_ScenarioCore
Definition: C4Components.h:42
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Scenario::SetExactLandscape ( )

Definition at line 413 of file C4Scenario.cpp.

References C4SLandscape::ExactLandscape, and Landscape.

Referenced by C4Game::LoadScenarioSection().

414 {
415  if (Landscape.ExactLandscape) return;
416  // Set landscape
418 }
C4SLandscape Landscape
Definition: C4Scenario.h:234
bool ExactLandscape
Definition: C4Scenario.h:163

Here is the caller graph for this function:

Member Data Documentation

C4SAnimals C4Scenario::Animals

Definition at line 235 of file C4Scenario.h.

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

C4SDefinitions C4Scenario::Definitions
C4SEnvironment C4Scenario::Environment

Definition at line 237 of file C4Scenario.h.

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

C4SWeather C4Scenario::Weather

Definition at line 236 of file C4Scenario.h.

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


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