OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Scenario.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Core component of a scenario file */
19 
20 #ifndef INC_C4Scenario
21 #define INC_C4Scenario
22 
23 #include "lib/C4NameList.h"
24 #include "object/C4IDList.h"
25 
26 class C4SVal
27 {
28 public:
29  C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
30 public:
31  int32_t Std,Rnd,Min,Max;
32 public:
33  void Default();
34  void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
35  void SetConstant(int32_t val);
36  int32_t Evaluate();
37  void CompileFunc(StdCompiler *pComp);
38 public:
39  inline bool operator==(const C4SVal &rhs) const
40  {
41  return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max;
42  }
43 };
44 
45 #define C4S_SECTIONLOAD 1 /* parts of the C4S that are modifyable for different landcape sections */
46 
47 // flags for section reloading
48 #define C4S_SAVE_LANDSCAPE 1
49 #define C4S_SAVE_OBJECTS 2
50 #define C4S_KEEP_EFFECTS 4
51 #define C4S_REINIT_SCENARIO 8
52 
54 {
58 };
59 
60 class C4SHead
61 {
62 public:
63  int32_t C4XVer[2];
64  std::string Title;
65  std::string Loader;
66  std::string Font; // scenario specific font; may be 0
67  int32_t Difficulty;
68  int32_t Icon;
71  bool SaveGame;
72  bool Replay;
73  int32_t Film;
74  int32_t RandomSeed;
75  std::string Engine; // Relative filename of engine to be used for this scenario
76  std::string MissionAccess;
77  bool Secret; // if true, scenario is invisible if MissionAccess has not been granted
80  StdCopyStrBuf Origin; // original oath and filename to scenario (for records and savegames)
81 public:
82  void Default();
83  void CompileFunc(StdCompiler *pComp, bool fSection);
84 };
85 
86 
87 const int32_t C4S_MaxDefinitions = 10;
88 
90 {
91 public:
92  bool LocalOnly;
95  void SetModules(const char *szList, const char *szRelativeToPath=nullptr, const char *szRelativeToPath2=nullptr);
96  bool GetModules(StdStrBuf *psOutModules) const;
97  std::list<const char *> GetModulesAsList() const; // get definitions as string pointers into this structure
98  void Default();
99  void CompileFunc(StdCompiler *pComp);
100 
101 private:
102  char Definition[C4S_MaxDefinitions][_MAX_PATH+1];
103 };
104 
105 
107 {
108 public:
110  bool LandscapePushPull; // Use new experimental push-pull-algorithms
111  bool LandscapeInsertThrust; // Inserted material may thrust material of lower density aside
112 
113 public:
114  void Default();
115 };
116 
117 
118 class C4SGame
119 {
120 public:
121  StdCopyStrBuf Mode; // Game mode used by league to determine correct evaluation
124 
126 
128 
129 public:
130  bool IsMelee();
131  void Default();
132  void CompileFunc(StdCompiler *pComp, bool fSection);
133 };
134 
135 // Maximum map player extend factor
136 
137 const int32_t C4S_MaxMapPlayerExtend = 4;
138 
140 {
141 public:
143  int32_t Position[2];
152 public:
153  void Default();
154  bool EquipmentEqual(C4SPlrStart &rhs);
155  bool operator==(const C4SPlrStart& rhs);
156  void CompileFunc(StdCompiler *pComp);
157 };
158 
159 
161 {
162 public:
171  std::string SkyDef;
172  int32_t SkyDefFade[6];
173  bool NoScan;
175  // Dynamic map
181  std::string Material;
182  std::string Liquid;
183  bool KeepMapCreator; // set if the mapcreator will be needed in the scenario (for DrawDefMap)
184  int32_t SkyScrollMode; // sky scrolling mode for newgfx
185  int32_t MaterialZoom;
186  bool FlatChunkShapes; // if true, all material chunks are drawn flat
187  bool Secret; // hide map from observers (except in dev mode and the like)
188 public:
189  void Default();
190  void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum);
191  void CompileFunc(StdCompiler *pComp);
192 };
193 
195 {
196 public:
200  bool NoGamma;
201 public:
202  void Default();
203  void CompileFunc(StdCompiler *pComp);
204 };
205 
207 {
208 public:
211 public:
212  void Default();
213  void CompileFunc(StdCompiler *pComp);
214 };
215 
217 {
218 public:
220 public:
221  void Default();
222  void CompileFunc(StdCompiler *pComp);
223 };
224 
226 {
227 public:
228  C4Scenario();
229 public:
238 public:
239  void SetExactLandscape();
240  void Clear();
241  void Default();
242  bool Load(C4Group &hGroup, bool fLoadSection = false, bool suppress_errors = false);
243  bool Save(C4Group &hGroup, bool fSaveSection=false);
244  void CompileFunc(StdCompiler *pComp, bool fSection);
245  int32_t GetMinPlayer(); // will try to determine the minimum player count for this scenario
246 };
247 
248 extern const char *C4ScenSect_Main;
249 
250 // ref to one scenario section
252 {
253 public:
254  C4ScenarioSection(const char *szName); // ctor
255  ~C4ScenarioSection(); // dtor
256 
257 public:
258  StdCopyStrBuf name; // section name
259  StdCopyStrBuf temp_filename; // filename of data file if in temp dir
260  StdCopyStrBuf filename; // filename of section in scenario file
261  bool fModified; // if set, the file is temp and contains runtime landscape and/or object data
262  class C4ScenarioObjectsScriptHost *pObjectScripts; // points to loaded script file for section Objects.c
263 
264  C4ScenarioSection *pNext; // next member of linked list
265 
266 public:
267  bool ScenarioLoad(const char *szFilename, bool is_temp_file); // called when scenario is loaded: extract to temp store
268  C4Group *GetGroupfile(C4Group &rGrp); // get group at section file (returns temp group, scenario subgroup or scenario group itself)
269  bool EnsureTempStore(bool fExtractLandscape, bool fExtractObjects); // make sure that a temp file is created, and nothing is modified within the main scenario file
270 };
271 
272 
273 
274 #endif // INC_C4Scenario
StdCopyStrBuf Mode
Definition: C4Scenario.h:121
C4IDList ValueOverloads
Definition: C4Scenario.h:109
C4IDList BuildKnowledge
Definition: C4Scenario.h:149
StdCopyStrBuf Origin
Definition: C4Scenario.h:80
int32_t Max
Definition: C4Scenario.h:31
int32_t Icon
Definition: C4Scenario.h:68
C4SVal Climate
Definition: C4Scenario.h:197
bool NetworkRuntimeJoin
Definition: C4Scenario.h:79
std::string Liquid
Definition: C4Scenario.h:182
void Default()
Definition: C4Scenario.cpp:55
std::string Material
Definition: C4Scenario.h:181
C4IDList Objects
Definition: C4Scenario.h:219
void Default()
Definition: C4Scenario.cpp:361
C4SVal StartSeason
Definition: C4Scenario.h:198
C4SDefinitions Definitions
Definition: C4Scenario.h:231
bool operator==(const C4SPlrStart &rhs)
Definition: C4Scenario.cpp:256
int32_t EnforcePosition
Definition: C4Scenario.h:144
void Default()
Definition: C4Scenario.cpp:379
int32_t MapPlayerExtend
Definition: C4Scenario.h:179
bool Save(C4Group &hGroup, bool fSaveSection=false)
Definition: C4Scenario.cpp:114
C4ScenarioSection(const char *szName)
void SetExactLandscape()
Definition: C4Scenario.cpp:413
int32_t MaterialZoom
Definition: C4Scenario.h:185
C4SFilmMode
Definition: C4Scenario.h:53
bool IsMelee()
Definition: C4Scenario.cpp:510
bool LandscapePushPull
Definition: C4Scenario.h:110
C4SEnvironment Environment
Definition: C4Scenario.h:237
C4IDList Goals
Definition: C4Scenario.h:122
int32_t MinPlayer
Definition: C4Scenario.h:70
std::string Loader
Definition: C4Scenario.h:65
C4IDList BaseProduction
Definition: C4Scenario.h:151
std::string MissionAccess
Definition: C4Scenario.h:76
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:500
void Clear()
Definition: C4Scenario.cpp:408
C4SVal YearSpeed
Definition: C4Scenario.h:198
C4IDList ReadyCrew
Definition: C4Scenario.h:145
bool Replay
Definition: C4Scenario.h:72
void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum)
Definition: C4Scenario.cpp:317
C4SLandscape Landscape
Definition: C4Scenario.h:234
C4IDList Rules
Definition: C4Scenario.h:123
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100)
Definition: C4Scenario.cpp:36
C4SVal Gravity
Definition: C4Scenario.h:174
std::string Title
Definition: C4Scenario.h:64
C4IDList Vegetation
Definition: C4Scenario.h:165
const int C4S_MaxPlayer
Definition: C4Constants.h:53
C4SVal MapWdt
Definition: C4Scenario.h:176
bool GetModules(StdStrBuf *psOutModules) const
Definition: C4Scenario.cpp:420
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:60
C4SVal Wind
Definition: C4Scenario.h:199
#define _MAX_PATH
void Default()
Definition: C4Scenario.cpp:78
int32_t GetMinPlayer()
Definition: C4Scenario.cpp:141
int32_t TopOpen
Definition: C4Scenario.h:168
StdCopyStrBuf filename
Definition: C4Scenario.h:260
int32_t SkyScrollMode
Definition: C4Scenario.h:184
bool NoGamma
Definition: C4Scenario.h:200
bool ExactLandscape
Definition: C4Scenario.h:163
void CompileFunc(StdCompiler *pComp, bool fSection)
Definition: C4Scenario.cpp:128
C4SVal InEarthLevel
Definition: C4Scenario.h:166
C4IDList SkipDefs
Definition: C4Scenario.h:94
bool SaveGame
Definition: C4Scenario.h:71
C4SVal MapZoom
Definition: C4Scenario.h:176
C4SVal Period
Definition: C4Scenario.h:177
bool operator==(const C4SVal &rhs) const
Definition: C4Scenario.h:39
C4SVal Wealth
Definition: C4Scenario.h:142
void Default()
Definition: C4Scenario.cpp:237
int32_t BottomOpen
Definition: C4Scenario.h:168
bool Load(C4Group &hGroup, bool fLoadSection=false, bool suppress_errors=false)
Definition: C4Scenario.cpp:92
int32_t MaxPlayer
Definition: C4Scenario.h:70
int32_t C4XVer[2]
Definition: C4Scenario.h:63
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:268
int32_t LeftOpen
Definition: C4Scenario.h:169
C4Group * GetGroupfile(C4Group &rGrp)
void Default()
Definition: C4Scenario.cpp:284
bool NetworkGame
Definition: C4Scenario.h:78
int32_t SkyDefFade[6]
Definition: C4Scenario.h:172
void Default()
Definition: C4Scenario.cpp:159
C4SRealism Realism
Definition: C4Scenario.h:127
bool AllowUserChange
Definition: C4Scenario.h:93
C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100)
Definition: C4Scenario.cpp:31
bool ScenarioLoad(const char *szFilename, bool is_temp_file)
std::list< const char * > GetModulesAsList() const
Definition: C4Scenario.cpp:444
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:370
C4SVal Phase
Definition: C4Scenario.h:177
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4SAnimals Animals
Definition: C4Scenario.h:235
C4IDList EarthNest
Definition: C4Scenario.h:210
C4IDList ReadyBase
Definition: C4Scenario.h:146
bool FlatChunkShapes
Definition: C4Scenario.h:186
bool EnsureTempStore(bool fExtractLandscape, bool fExtractObjects)
C4SVal Random
Definition: C4Scenario.h:177
bool LandscapeInsertThrust
Definition: C4Scenario.h:111
C4IDList ReadyVehic
Definition: C4Scenario.h:147
StdCopyStrBuf name
Definition: C4Scenario.h:258
void Default()
Definition: C4Scenario.cpp:215
C4IDList InEarth
Definition: C4Scenario.h:167
C4SVal MapHgt
Definition: C4Scenario.h:176
C4IDList FreeLife
Definition: C4Scenario.h:209
void SetModules(const char *szList, const char *szRelativeToPath=nullptr, const char *szRelativeToPath2=nullptr)
Definition: C4Scenario.cpp:462
int32_t RightOpen
Definition: C4Scenario.h:169
std::string Font
Definition: C4Scenario.h:66
void Default()
Definition: C4Scenario.cpp:401
bool Secret
Definition: C4Scenario.h:77
C4SGame Game
Definition: C4Scenario.h:232
class C4ScenarioObjectsScriptHost * pObjectScripts
Definition: C4Scenario.h:262
const char * C4ScenSect_Main
int32_t Position[2]
Definition: C4Scenario.h:143
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:326
C4IDList ReadyMaterial
Definition: C4Scenario.h:148
int32_t Difficulty
Definition: C4Scenario.h:67
void CompileFunc(StdCompiler *pComp, bool fSection)
Definition: C4Scenario.cpp:222
void SetConstant(int32_t val)
Definition: C4Scenario.cpp:41
C4SVal Amplitude
Definition: C4Scenario.h:177
C4SHead Head
Definition: C4Scenario.h:230
C4SVal VegLevel
Definition: C4Scenario.h:164
std::string Engine
Definition: C4Scenario.h:75
C4NameList Layers
Definition: C4Scenario.h:180
C4ScenarioSection * pNext
Definition: C4Scenario.h:264
int32_t Std
Definition: C4Scenario.h:31
bool KeepMapCreator
Definition: C4Scenario.h:183
int32_t Rnd
Definition: C4Scenario.h:31
C4SWeather Weather
Definition: C4Scenario.h:236
bool NoInitialize
Definition: C4Scenario.h:69
std::string SkyDef
Definition: C4Scenario.h:171
StdCopyStrBuf temp_filename
Definition: C4Scenario.h:259
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
bool EquipmentEqual(C4SPlrStart &rhs)
Definition: C4Scenario.cpp:251
void CompileFunc(StdCompiler *pComp, bool fSection)
Definition: C4Scenario.cpp:180
int32_t Evaluate()
Definition: C4Scenario.cpp:50
int32_t MaxPlayerLeague
Definition: C4Scenario.h:70
C4SVal LiquidLevel
Definition: C4Scenario.h:178
bool AutoScanSideOpen
Definition: C4Scenario.h:170
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:396
int32_t RandomSeed
Definition: C4Scenario.h:74
bool FoWEnabled
Definition: C4Scenario.h:125
int32_t Film
Definition: C4Scenario.h:73
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:385
const int32_t C4S_MaxMapPlayerExtend
Definition: C4Scenario.h:137
C4IDList BaseMaterial
Definition: C4Scenario.h:150
int32_t Min
Definition: C4Scenario.h:31