OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameParameters.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 /* Game parameters - game data that is valid before the game is started */
17 
18 #ifndef C4GAMEPARAMETERS_H
19 #define C4GAMEPARAMETERS_H
20 
21 #include "object/C4IDList.h"
22 #include "control/C4PlayerInfo.h"
23 #include "control/C4Teams.h"
24 #include "object/C4InfoCore.h"
25 
26 class C4GameRes
27 {
28  friend class C4GameResList;
29 public:
30  C4GameRes();
31  C4GameRes(const C4GameRes &Res);
32  ~C4GameRes();
33 
34  C4GameRes &operator = (const C4GameRes &Res);
35 
36 private:
37  C4Network2ResType eType;
38  StdCopyStrBuf File;
39  const C4Network2ResCore *pResCore;
40  C4Network2Res::Ref pNetRes;
41 
42 public:
43  C4Network2ResType getType() const { return eType; }
44  const char *getFile() const { return File.getData(); }
45  bool isPresent() const { return !! File; }
46  const C4Network2ResCore *getResCore() const { return pResCore; }
47  C4Network2Res::Ref getNetRes() const { return pNetRes; }
48 
49  void SetFile(C4Network2ResType eType, const char *szFile);
50  void SetResCore(C4Network2ResCore *pResCore);
51  void SetNetRes(C4Network2Res::Ref pRes);
52 
53  bool Publish(C4Network2ResList *pResList);
54  bool Load(C4Network2ResList *pResList);
55  bool InitNetwork(C4Network2ResList *pResList);
56 
57  void CalcHash();
58 
59  void Clear();
60 
61  void CompileFunc(StdCompiler *pComp);
62 };
63 
65 {
66 private:
67  C4GameRes **pResList;
68  int32_t iResCount, iResCapacity;
69 
70 public:
71  C4GameResList() : pResList(nullptr), iResCount(0), iResCapacity(0) {}
73 
75 
76  int32_t getResCount() const { return iResCount; }
77 
79 
80  void Clear();
81  bool Load(C4Group &hGroup, C4Scenario *pScenario, const char * szDefinitionFilenames); // host: create res cores by definition filenames
82 
83  C4GameRes *CreateByFile(C4Network2ResType eType, const char *szFile);
85  bool InitNetwork(C4Network2ResList *pNetResList);
86 
87  void CalcHashes();
88 
89  bool RetrieveFiles(); // client: make sure all definition files are loaded
90 
91  void CompileFunc(StdCompiler *pComp);
92 
93 protected:
94  void Add(C4GameRes *pRes);
95  void LoadFoldersWithLocalDefs(const char *szPath);
96 };
97 
99 {
100 public:
103 
104  // League (empty if it's not a league game)
108 
109  // Maximum player count allowed
110  int32_t MaxPlayers;
111 
112  // Original network game? Also set in replays of network games for sync safety
114 
115  // Originally hosted in editor (also in replays from editor)
116  bool IsEditor;
117 
118  // Control rate
119  int32_t ControlRate;
120 
121  // Automatic frame skip enabled for this game?
123 
124  // Allow debug mode?
126 
127  // Active rules and goals
130 
131  // Game resources
134 
135  // Clients
137 
138  // Players & Teams
142 
143  // Custom scenario parameters
145 
146  bool isLeague() const { return !!LeagueAddress.getLength(); }
147  bool doStreaming() const { return !!StreamAddress.getLength(); }
148  const char* getLeague() { return League.getData(); }
150  void EnforceLeagueRules(class C4Scenario *pScenario);
151 
152  void Clear();
153  bool Load(C4Group &hGroup, C4Scenario *pDefault, const char *szGameText, C4LangStringTable *pLang, const char *DefinitionFilenames, C4ScenarioParameters *pStartupScenarioParameters);
154  bool InitNetwork(C4Network2ResList *pResList);
155  bool Save(C4Group &hGroup, C4Scenario *pDefault);
156 
157  void CompileFunc(StdCompiler *pComp, C4Scenario *pScenario = nullptr);
158 };
159 
160 #endif // C4GAMEPARAMETERS_H
C4Network2ResType
Definition: C4Network2Res.h:40
const char * getData() const
Definition: StdBuf.h:450
bool InitNetwork(C4Network2ResList *pNetResList)
void CompileFunc(StdCompiler *pComp, C4Scenario *pScenario=nullptr)
void CompileFunc(StdCompiler *pComp)
bool Load(C4Group &hGroup, C4Scenario *pScenario, const char *szDefinitionFilenames)
C4GameRes * iterRes(C4GameRes *pLast, C4Network2ResType eType=NRT_Null)
C4GameRes & operator=(const C4GameRes &Res)
void EnforceLeagueRules(class C4Scenario *pScenario)
bool Load(C4Group &hGroup, C4Scenario *pDefault, const char *szGameText, C4LangStringTable *pLang, const char *DefinitionFilenames, C4ScenarioParameters *pStartupScenarioParameters)
StdCopyStrBuf League
bool InitNetwork(C4Network2ResList *pResList)
const char * getLeague()
C4ClientList Clients
const C4Network2ResCore * getResCore() const
bool Publish(C4Network2ResList *pResList)
void SetResCore(C4Network2ResCore *pResCore)
C4GameRes * CreateByFile(C4Network2ResType eType, const char *szFile)
bool InitNetwork(C4Network2ResList *pResList)
C4ScenarioParameters ScenarioParameters
StdStrBuf GetGameGoalString() const
C4GameResList GameRes
bool Save(C4Group &hGroup, C4Scenario *pDefault)
C4PlayerInfoList RestorePlayerInfos
C4GameResList & operator=(const C4GameResList &List)
bool doStreaming() const
C4PlayerInfoList PlayerInfos
void CompileFunc(StdCompiler *pComp)
const char * getFile() const
void SetNetRes(C4Network2Res::Ref pRes)
bool isLeague() const
C4Network2Res::Ref getNetRes() const
C4Network2ResType getType() const
StdCopyStrBuf StreamAddress
size_t getLength() const
Definition: StdBuf.h:453
void LoadFoldersWithLocalDefs(const char *szPath)
bool Load(C4Network2ResList *pResList)
void Add(C4GameRes *pRes)
bool isPresent() const
StdCopyStrBuf LeagueAddress
C4GameRes * CreateByNetRes(C4Network2Res::Ref pNetRes)
int32_t getResCount() const
void SetFile(C4Network2ResType eType, const char *szFile)