OpenClonk
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;
70  int32_t MaxPlayer, MinPlayer, MaxPlayerLeague;
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 
130 
131 public:
132  bool IsMelee();
133  void Default();
134  void CompileFunc(StdCompiler *pComp, bool fSection);
135 };
136 
137 // Maximum map player extend factor
138 
139 const int32_t C4S_MaxMapPlayerExtend = 4;
140 
142 {
143 public:
145  int32_t Position[2];
154 public:
155  void Default();
156  bool EquipmentEqual(C4SPlrStart &rhs);
157  bool operator==(const C4SPlrStart& rhs);
158  void CompileFunc(StdCompiler *pComp);
159 };
160 
161 
163 {
164 public:
170  int32_t BottomOpen,TopOpen;
171  int32_t LeftOpen,RightOpen;
173  std::string SkyDef;
174  int32_t SkyDefFade[6];
175  bool NoScan;
177  // Dynamic map
178  C4SVal MapWdt,MapHgt,MapZoom;
179  C4SVal Amplitude,Phase,Period,Random;
183  std::string Material;
184  std::string Liquid;
185  bool KeepMapCreator; // set if the mapcreator will be needed in the scenario (for DrawDefMap)
186  int32_t SkyScrollMode; // sky scrolling mode for newgfx
187  int32_t MaterialZoom;
188  bool FlatChunkShapes; // if true, all material chunks are drawn flat
189  bool Secret; // hide map from observers (except in dev mode and the like)
190 public:
191  void Default();
192  void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum);
193  void CompileFunc(StdCompiler *pComp);
194 };
195 
197 {
198 public:
200  C4SVal StartSeason,YearSpeed;
202  bool NoGamma;
203 public:
204  void Default();
205  void CompileFunc(StdCompiler *pComp);
206 };
207 
209 {
210 public:
213 public:
214  void Default();
215  void CompileFunc(StdCompiler *pComp);
216 };
217 
219 {
220 public:
222 public:
223  void Default();
224  void CompileFunc(StdCompiler *pComp);
225 };
226 
228 {
229 public:
230  C4Scenario();
231 public:
240 public:
241  void SetExactLandscape();
242  void Clear();
243  void Default();
244  bool Load(C4Group &hGroup, bool fLoadSection = false, bool suppress_errors = false);
245  bool Save(C4Group &hGroup, bool fSaveSection=false);
246  void CompileFunc(StdCompiler *pComp, bool fSection);
247  int32_t GetMinPlayer(); // will try to determine the minimum player count for this scenario
248 };
249 
250 extern const char *C4ScenSect_Main;
251 
252 // ref to one scenario section
254 {
255 public:
256  C4ScenarioSection(const char *szName); // ctor
257  ~C4ScenarioSection(); // dtor
258 
259 public:
260  StdCopyStrBuf name; // section name
261  StdCopyStrBuf temp_filename; // filename of data file if in temp dir
262  StdCopyStrBuf filename; // filename of section in scenario file
263  bool fModified; // if set, the file is temp and contains runtime landscape and/or object data
264  class C4ScenarioObjectsScriptHost *pObjectScripts; // points to loaded script file for section Objects.c
265 
266  C4ScenarioSection *pNext; // next member of linked list
267 
268 public:
269  bool ScenarioLoad(const char *szFilename, bool is_temp_file); // called when scenario is loaded: extract to temp store
270  C4Group *GetGroupfile(C4Group &rGrp); // get group at section file (returns temp group, scenario subgroup or scenario group itself)
271  bool EnsureTempStore(bool fExtractLandscape, bool fExtractObjects); // make sure that a temp file is created, and nothing is modified within the main scenario file
272 };
273 
274 
275 
276 #endif // INC_C4Scenario
StdCopyStrBuf Mode
Definition: C4Scenario.h:121
C4IDList ValueOverloads
Definition: C4Scenario.h:109
C4IDList BuildKnowledge
Definition: C4Scenario.h:151
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:199
bool NetworkRuntimeJoin
Definition: C4Scenario.h:79
std::string Liquid
Definition: C4Scenario.h:184
void Default()
Definition: C4Scenario.cpp:55
std::string Material
Definition: C4Scenario.h:183
C4IDList Objects
Definition: C4Scenario.h:221
C4SDefinitions Definitions
Definition: C4Scenario.h:233
int32_t EnforcePosition
Definition: C4Scenario.h:146
int32_t MapPlayerExtend
Definition: C4Scenario.h:181
int32_t MaterialZoom
Definition: C4Scenario.h:187
C4SFilmMode
Definition: C4Scenario.h:53
bool LandscapePushPull
Definition: C4Scenario.h:110
C4SEnvironment Environment
Definition: C4Scenario.h:239
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:153
std::string MissionAccess
Definition: C4Scenario.h:76
C4SVal YearSpeed
Definition: C4Scenario.h:200
C4IDList ReadyCrew
Definition: C4Scenario.h:147
bool Replay
Definition: C4Scenario.h:72
C4SLandscape Landscape
Definition: C4Scenario.h:236
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:176
std::string Title
Definition: C4Scenario.h:64
C4IDList Vegetation
Definition: C4Scenario.h:167
const int C4S_MaxPlayer
Definition: C4Constants.h:53
void CompileFunc(StdCompiler *pComp)
Definition: C4Scenario.cpp:60
C4SVal Wind
Definition: C4Scenario.h:201
#define _MAX_PATH
int32_t TopOpen
Definition: C4Scenario.h:170
StdCopyStrBuf filename
Definition: C4Scenario.h:262
int32_t SkyScrollMode
Definition: C4Scenario.h:186
bool NoGamma
Definition: C4Scenario.h:202
bool ExactLandscape
Definition: C4Scenario.h:165
C4SVal InEarthLevel
Definition: C4Scenario.h:168
int32_t AutoScanSideOpen
Definition: C4Scenario.h:172
C4IDList SkipDefs
Definition: C4Scenario.h:94
bool SaveGame
Definition: C4Scenario.h:71
C4SVal MapZoom
Definition: C4Scenario.h:178
C4SVal Wealth
Definition: C4Scenario.h:144
bool NetworkGame
Definition: C4Scenario.h:78
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 operator==(const C4SVal &rhs) const
Definition: C4Scenario.h:39
C4SAnimals Animals
Definition: C4Scenario.h:237
C4IDList EarthNest
Definition: C4Scenario.h:212
C4IDList ReadyBase
Definition: C4Scenario.h:148
bool FlatChunkShapes
Definition: C4Scenario.h:188
C4SVal Random
Definition: C4Scenario.h:179
bool LandscapeInsertThrust
Definition: C4Scenario.h:111
C4IDList ReadyVehic
Definition: C4Scenario.h:149
StdCopyStrBuf name
Definition: C4Scenario.h:260
C4IDList InEarth
Definition: C4Scenario.h:169
C4IDList FreeLife
Definition: C4Scenario.h:211
int32_t RightOpen
Definition: C4Scenario.h:171
std::string Font
Definition: C4Scenario.h:66
bool Secret
Definition: C4Scenario.h:77
C4SGame Game
Definition: C4Scenario.h:234
class C4ScenarioObjectsScriptHost * pObjectScripts
Definition: C4Scenario.h:264
const char * C4ScenSect_Main
bool EvaluateOnAbort
Definition: C4Scenario.h:129
C4IDList ReadyMaterial
Definition: C4Scenario.h:150
int32_t Difficulty
Definition: C4Scenario.h:67
void SetConstant(int32_t val)
Definition: C4Scenario.cpp:41
C4SHead Head
Definition: C4Scenario.h:232
C4SVal VegLevel
Definition: C4Scenario.h:166
std::string Engine
Definition: C4Scenario.h:75
C4NameList Layers
Definition: C4Scenario.h:182
C4ScenarioSection * pNext
Definition: C4Scenario.h:266
int32_t Std
Definition: C4Scenario.h:31
bool KeepMapCreator
Definition: C4Scenario.h:185
int32_t Rnd
Definition: C4Scenario.h:31
C4SWeather Weather
Definition: C4Scenario.h:238
bool NoInitialize
Definition: C4Scenario.h:69
std::string SkyDef
Definition: C4Scenario.h:173
StdCopyStrBuf temp_filename
Definition: C4Scenario.h:261
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
int32_t Evaluate()
Definition: C4Scenario.cpp:50
C4SVal LiquidLevel
Definition: C4Scenario.h:180
int32_t RandomSeed
Definition: C4Scenario.h:74
bool FoWEnabled
Definition: C4Scenario.h:125
int32_t Film
Definition: C4Scenario.h:73
const int32_t C4S_MaxMapPlayerExtend
Definition: C4Scenario.h:139
C4IDList BaseMaterial
Definition: C4Scenario.h:152
int32_t Min
Definition: C4Scenario.h:31