All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Go to the documentation of this file.
1 /*
2  * OpenClonk,
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH,
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  */
18 /* Game configuration as stored in registry */
20 #ifndef INC_C4Config
21 #define INC_C4Config
23 #include "config/C4Constants.h"
24 #include "lib/C4InputValidation.h"
26 #include <list>
28 #define C4DEFAULT_FONT_NAME "Endeavour"
29 enum { CFG_MaxString = 1024, CFG_MaxEditorMRU = 8 };
32 {
33 public:
34  enum { ConfigResetSafetyVal = 42 };
37  char Language[CFG_MaxString+1]; // entered by user in frontend options (may contain comma separated list or long language descriptions)
38  char LanguageEx[CFG_MaxString+1]; // full fallback list composed by frontend options (condensed comma separated list)
40  int32_t AlwaysDebug; // if set: turns on debugmode whenever engine is started
41  int32_t OpenScenarioInGameMode; // When the program arguments include a scenario path, open the game regularly
43  int32_t RXFontSize;
47  int32_t FPS;
48  int32_t DefRec;
49  int32_t MMTimer; // use multimedia-timers
50  int32_t ScrollSmooth; // view movement smoothing
51  int32_t ConfigResetSafety; // safety value: If this value is screwed, the config got corrupted and must be reset
52  // Determined at run-time
60  bool FirstStart;
61  int32_t DebugRec;
62  // if defined, the external file is used for debugrec writing. Otherwise read/check
63  int32_t DebugRecWrite;
64  // if defined, an external file is used for debugrec writing (replays only)
67 public:
68  static int GetLanguageSequence(const char *strSource, char *strTarget);
69  void DefaultLanguage();
70  bool CreateSaveFolder(const char *strDirectory, const char *strLanguageTitle);
71  void DeterminePaths();
72  void CompileFunc(StdCompiler *pComp);
74 private:
75  struct
76  {
77  char PlayerPath[CFG_MaxString+1];
78  } Adopt;
79 };
82 {
83 public:
84  int32_t AutoFileReload;
87  int32_t MaxScriptMRU; // maximum number of remembered elements in recently used scripts
88  int32_t DebugShapeTextures; // if nonzero, show messages about loaded shape textures
89  bool ShowHelp; // show help buttons and descriptions in editor
91  void CompileFunc(StdCompiler *pComp);
92  void AddRecentlyEditedScenario(const char *fn);
93 };
96 {
97 public:
102  int32_t UpperBoard;
103  int32_t ShowClock;
104  int32_t ResX,ResY;
105  int32_t WindowX,WindowY;
106  int32_t RefreshRate; // monitor vertical refresh rate
107  int32_t Windowed; // 0: fullscreen, 1: windowed, 2: fullscreen in game, windowed in menu
108  int32_t ShowCrewNames; // show player name above clonks?
109  int32_t ShowCrewCNames; // show clonk names above clonks?
110  int32_t PXSGfx; // show PXS-graphics (instead of sole pixels)
111  int32_t Gamma; // gamma value
112  int32_t Currency; // default wealth symbolseb
113  int32_t Monitor; // monitor index to play on
114  int32_t MaxRefreshDelay; // minimum time after which graphics should be refreshed (ms)
115  int32_t NoOffscreenBlits; // if set, all blits to non-primary-surfaces are emulated
116  int32_t MultiSampling; // multisampling samples
117  int32_t AutoFrameSkip; // if true, gfx frames are skipped when they would slow down the game
118  int32_t DebugOpenGL; // if true, enables OpenGL debugging
119  int32_t MouseCursorSize; // size in pixels
121  void CompileFunc(StdCompiler *pComp);
122 };
125 {
126 public:
127  int32_t RXSound;
128  int32_t RXMusic;
129  int32_t FEMusic;
130  int32_t FESamples;
131  int32_t Verbose; // show music files names
132  int32_t MusicVolume;
133  int32_t SoundVolume;
134  void CompileFunc(StdCompiler *pComp);
135 };
138 {
139 public:
140  int32_t ControlRate;
141  int32_t ControlPreSend;
142  int32_t Lobby;
143  int32_t NoRuntimeJoin;
155  int32_t EnableUPnP;
156  int32_t ControlMode;
164  char UpdateServerAddress[CFG_MaxString+1];
165  int32_t AutomaticUpdate;
166  int32_t LastUpdateTime;
167 #endif
168  int32_t AsyncMaxWait;
169  int32_t PacketLogging;
170 public:
171  void CompileFunc(StdCompiler *pComp);
172  const char *GetLeagueServerAddress();
174  void SetLeagueLoginData(const char *szServer, const char *szPlayerName, const char *szAccount, const char *szLoginToken);
175  bool GetLeagueLoginData(const char *szServer, const char *szPlayerName, StdStrBuf *pAccount, StdStrBuf *pLoginToken) const;
176 };
179 {
180 public:
181  // config for do-not-show-this-msg-again-messages
190  int32_t AlphabeticalSorting; // if set, Folder.txt-sorting is ignored in scenario selection
192  void CompileFunc(StdCompiler *pComp);
193 };
196 {
197 public:
198  int32_t CountdownTime;
199  int32_t AllowPlayerSave; // whether save-to-disk function is enabled for player resources
200  void CompileFunc(StdCompiler *pComp);
201 };
204 {
205 public:
210  void CompileFunc(StdCompiler *pComp);
212 };
214 const int C4ConfigMaxGamepads = 4;
217 {
218 public:
219  int32_t Button[C4MaxKey];
220  uint32_t AxisMin[6], AxisMax[6];
221  bool AxisCalibrated[6];
222  void CompileFunc(StdCompiler *pComp, bool fButtonsOnly=false);
223  void ResetButtons(); // reset all buttons to default
224  void Reset(); // reset all buttons and axis calibration to default
225 };
228 {
229 public:
231  int32_t MouseAutoScroll; // auto scroll strength
234  void CompileFunc(StdCompiler *pComp);
235  void ResetKeys(); // reset all keys to default
236 };
239 {
240 public:
241  char KeyPath[CFG_MaxString + 1]; // absolute path; environment variables are stored and only expanded upon evaluation
242  int32_t WasRegistered;
243  void CompileFunc(StdCompiler *pComp);
244 };
246 class C4Config
247 {
248 public:
249  C4Config();
250  ~C4Config();
251 public:
263  bool fConfigLoaded; // true if config has been successfully loaded
264  StdStrBuf ConfigFilename; // set for configs loaded from a nondefault config file
265 public:
266  const char* GetSubkeyPath(const char *strSubkey);
267  void Default();
268  bool Save();
269  bool Load(const char *szConfigFile = nullptr);
270  bool Init();
271  bool Registered();
272  const char *AtExePath(const char *szFilename);
273  const char *AtTempPath(const char *szFilename);
274  const char *AtTempUpdatePath(const char *szFilename);
275  const char *AtNetworkPath(const char *szFilename);
276  const char *AtScreenshotPath(const char *szFilename);
277  const char *AtUserDataPath(const char *szFilename);
278  const char *AtUserDataRelativePath(const char *szFilename);
279  const char *AtSystemDataPath(const char *szFilename);
280  const char *AtSystemDataRelativePath(const char *szFilename);
281  const char *AtRelativePath(const char *szFilename); // Returns ASDRP or AUDRP depending on location
282  const char *GetRegistrationData(const char* strField) { return ""; }
283  void ForceRelativePath(StdStrBuf *sFilename); // try AtRelativePath; force GetC4Filename if not possible
284  void CompileFunc(StdCompiler *pComp);
285  bool IsCorrupted() { return (General.ConfigResetSafety != C4ConfigGeneral::ConfigResetSafetyVal) || !Graphics.ResX; }
286  bool RemoveModule(const char *szPath, char *szModules);
287  bool IsModule(const char *szPath, char *szModules);
288  bool AddModule(const char *szPath, char *szModules);
289  void GetConfigFileName(StdStrBuf &filename, const char *szConfigFile);
291  const char *MakeTempUpdateFolder();
293  static void ExpandEnvironmentVariables(char *strPath, size_t iMaxLen);
294 };
296 extern C4Config Config;
298 #endif // INC_C4Config
int32_t MouseAutoScroll
Definition: C4Config.h:231
int32_t OpenScenarioInGameMode
Definition: C4Config.h:41
int32_t RefreshRate
Definition: C4Config.h:106
void Default()
Definition: C4Config.cpp:287
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:143
int32_t MaxResSearchRecursion
Definition: C4Config.h:145
int32_t DebugOpenGL
Definition: C4Config.h:118
int32_t AlphabeticalSorting
Definition: C4Config.h:190
void DefaultLanguage()
Definition: C4Config.cpp:691
int32_t MultiSampling
Definition: C4Config.h:116
C4ConfigStartup Startup
Definition: C4Config.h:261
int32_t LastPortraitFolderIdx
Definition: C4Config.h:191
char Server[CFG_MaxString+1]
Definition: C4Config.h:206
int32_t PortDiscovery
Definition: C4Config.h:154
int32_t MenuTransparency
Definition: C4Config.h:101
int32_t VerboseObjectLoading
Definition: C4Config.h:100
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:212
int32_t AllowPlayerSave
Definition: C4Config.h:199
static int GetLanguageSequence(const char *strSource, char *strTarget)
Definition: C4Config.cpp:728
char MissionAccess[CFG_MaxString+1]
Definition: C4Config.h:46
int32_t FPS
Definition: C4Config.h:47
C4ConfigGeneral General
Definition: C4Config.h:252
int32_t FEMusic
Definition: C4Config.h:129
StdCopyStrBuf LastLeagueLoginToken
Definition: C4Config.h:162
const char * GetSubkeyPath(const char *strSubkey)
Definition: C4Config.cpp:717
int32_t PacketLogging
Definition: C4Config.h:169
int32_t Button[C4MaxKey]
Definition: C4Config.h:219
const char * AtUserDataRelativePath(const char *szFilename)
Definition: C4Config.cpp:648
int32_t RXSound
Definition: C4Config.h:127
int32_t Windowed
Definition: C4Config.h:107
int32_t PortRefServer
Definition: C4Config.h:154
void ResetButtons()
Definition: C4Config.cpp:250
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:203
int32_t MaxLoadFileSize
Definition: C4Config.h:158
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:745
ValidatedStdCopyStrBuf< C4InVal::VAL_Comment > Comment
Definition: C4Config.h:147
const char * AtSystemDataRelativePath(const char *szFilename)
Definition: C4Config.cpp:654
int32_t HideMsgIRCDangerous
Definition: C4Config.h:189
char PuncherAddress[CFG_MaxString+1]
Definition: C4Config.h:161
int32_t ShowCrewNames
Definition: C4Config.h:108
bool CreateSaveFolder(const char *strDirectory, const char *strLanguageTitle)
Definition: C4Config.cpp:576
void SetLeagueLoginData(const char *szServer, const char *szPlayerName, const char *szAccount, const char *szLoginToken)
Definition: C4Config.cpp:621
void CleanupTempUpdateFolder()
Definition: C4Config.cpp:808
StdStrBuf ScreenshotFolder
Definition: C4Config.h:45
int32_t MouseCursorSize
Definition: C4Config.h:119
char DebugRecExternalFile[_MAX_PATH+1]
Definition: C4Config.h:65
int32_t HideMsgPlrNoTakeOver
Definition: C4Config.h:187
bool GamepadEnabled
Definition: C4Config.h:59
int32_t HideMsgMMTimerChange
Definition: C4Config.h:184
int32_t ControlRate
Definition: C4Config.h:140
void DeterminePaths()
Definition: C4Config.cpp:434
#define _MAX_PATH
bool IsCorrupted()
Definition: C4Config.h:285
char ScreenshotPath[CFG_MaxString+1]
Definition: C4Config.h:57
int32_t SoundVolume
Definition: C4Config.h:133
int32_t DebugShapeTextures
Definition: C4Config.h:88
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:52
void AddRecentlyEditedScenario(const char *fn)
Definition: C4Config.cpp:100
bool RemoveModule(const char *szPath, char *szModules)
Definition: C4Config.cpp:785
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Nick
Definition: C4Config.h:157
int32_t HideMsgGfxBitDepthChange
Definition: C4Config.h:183
const char * GetRegistrationData(const char *strField)
Definition: C4Config.h:282
const char * AtTempUpdatePath(const char *szFilename)
Definition: C4Config.cpp:829
int32_t UpperBoard
Definition: C4Config.h:102
C4Config Config
Definition: C4Config.cpp:837
C4ConfigGraphics Graphics
Definition: C4Config.h:254
char RealName[CFG_MaxString+1]
Definition: C4Config.h:208
char ConfigUserPath[CFG_MaxString+1]
Definition: C4Config.h:44
int32_t NoReferenceRequest
Definition: C4Config.h:144
int32_t ShowCrewCNames
Definition: C4Config.h:109
char TodoFilename[CFG_MaxString+1]
Definition: C4Config.h:85
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:759
StdStrBuf ConfigFilename
Definition: C4Config.h:264
char Participants[CFG_MaxString+1]
Definition: C4Config.h:39
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:55
int32_t Verbose
Definition: C4Config.h:131
C4ConfigLobby Lobby
Definition: C4Config.h:257
void CheckPortsForCollisions()
Definition: C4Config.cpp:604
int32_t ConfigResetSafety
Definition: C4Config.h:51
int32_t DefRec
Definition: C4Config.h:48
const char * AtNetworkPath(const char *szFilename)
Definition: C4Config.cpp:551
int32_t MaxRefreshDelay
Definition: C4Config.h:114
int32_t AutoFileReload
Definition: C4Config.h:84
int32_t HideMsgGfxEngineChange
Definition: C4Config.h:182
char LastPassword[CFG_MaxString+1]
Definition: C4Config.h:159
Definition: C4Config.h:258
uint32_t AxisMin[6]
Definition: C4Config.h:220
int32_t WindowX
Definition: C4Config.h:105
C4ConfigNetwork Network
Definition: C4Config.h:256
char AlternateServerAddress[CFG_MaxString+1]
Definition: C4Config.h:160
int32_t NoOffscreenBlits
Definition: C4Config.h:115
int32_t MaxScriptMRU
Definition: C4Config.h:87
C4ConfigDeveloper Developer
Definition: C4Config.h:253
StdCopyStrBuf LastLeaguePlayerName
Definition: C4Config.h:162
char SystemDataPath[CFG_MaxString+1]
Definition: C4Config.h:56
const char * AtSystemDataPath(const char *szFilename)
Definition: C4Config.cpp:537
int32_t HideMsgNoOfficialLeague
Definition: C4Config.h:188
int32_t HideMsgStartDedicated
Definition: C4Config.h:185
int32_t CountdownTime
Definition: C4Config.h:198
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:38
static void ExpandEnvironmentVariables(char *strPath, size_t iMaxLen)
Definition: C4Config.cpp:790
int32_t PXSGfx
Definition: C4Config.h:110
char WorkPath[CFG_MaxString+1]
Definition: C4Config.h:146
int32_t HideMsgPlrTakeOver
Definition: C4Config.h:186
bool IsModule(const char *szPath, char *szModules)
Definition: C4Config.cpp:780
int32_t MasterKeepPeriod
Definition: C4Config.h:150
bool FirstStart
Definition: C4Config.h:60
char Language[CFG_MaxString+1]
Definition: C4Config.h:37
char Name[CFG_MaxString+1]
Definition: C4Config.h:36
int32_t ControlPreSend
Definition: C4Config.h:141
int32_t LeagueServerSignUp
Definition: C4Config.h:152
int32_t MasterServerSignUp
Definition: C4Config.h:148
char RecentlyEditedSzenarios[CFG_MaxEditorMRU][CFG_MaxString+1]
Definition: C4Config.h:90
char Nick[CFG_MaxString+1]
Definition: C4Config.h:207
int32_t MasterReferencePeriod
Definition: C4Config.h:151
char TempUpdatePath[CFG_MaxString+1]
Definition: C4Config.h:58
void CompileFunc(StdCompiler *pComp, bool fButtonsOnly=false)
Definition: C4Config.cpp:224
int32_t GamepadGuiControl
Definition: C4Config.h:230
bool AxisCalibrated[6]
Definition: C4Config.h:221
int32_t Monitor
Definition: C4Config.h:113
int32_t WindowY
Definition: C4Config.h:105
char RXFontName[CFG_MaxString+1]
Definition: C4Config.h:42
int32_t SplitscreenDividers
Definition: C4Config.h:98
StdCopyStrBuf TempPath
Definition: C4Config.h:54
bool AddModule(const char *szPath, char *szModules)
Definition: C4Config.cpp:775
C4ConfigControls Controls
Definition: C4Config.h:260
const char * AtScreenshotPath(const char *szFilename)
Definition: C4Config.cpp:559
StdCopyStrBuf LastLeagueAccount
Definition: C4Config.h:162
int32_t RXFontSize
Definition: C4Config.h:43
int32_t MMTimer
Definition: C4Config.h:49
int32_t AlwaysDebug
Definition: C4Config.h:40
int32_t ResX
Definition: C4Config.h:104
const int C4MaxKey
Definition: C4Constants.h:30
char Channel[CFG_MaxString+1]
Definition: C4Config.h:209
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:530
int32_t ControlMode
Definition: C4Config.h:156
int32_t ResY
Definition: C4Config.h:104
void ForceRelativePath(StdStrBuf *sFilename)
Definition: C4Config.cpp:668
bool Registered()
Definition: C4Config.cpp:706
int32_t Gamma
Definition: C4Config.h:111
int32_t Currency
Definition: C4Config.h:112
bool GetLeagueLoginData(const char *szServer, const char *szPlayerName, StdStrBuf *pAccount, StdStrBuf *pLoginToken) const
Definition: C4Config.cpp:631
int32_t DebugRecWrite
Definition: C4Config.h:63
bool Save()
Definition: C4Config.cpp:404
int32_t NoRuntimeJoin
Definition: C4Config.h:143
bool fConfigLoaded
Definition: C4Config.h:263
C4ConfigSecurity Security
Definition: C4Config.h:262
int32_t AsyncMaxWait
Definition: C4Config.h:168
int32_t MasterServerActive
Definition: C4Config.h:149
char AltTodoFilename[CFG_MaxString+1]
Definition: C4Config.h:86
bool Load(const char *szConfigFile=nullptr)
Definition: C4Config.cpp:315
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:116
StdCopyStrBuf ExePath
Definition: C4Config.h:53
int32_t FESamples
Definition: C4Config.h:130
int32_t DebugRec
Definition: C4Config.h:61
int32_t Lobby
Definition: C4Config.h:142
int32_t MusicVolume
Definition: C4Config.h:132
C4PlayerControlAssignmentSets UserSets
Definition: C4Config.h:232
char KeyPath[CFG_MaxString+1]
Definition: C4Config.h:241
const char * AtTempPath(const char *szFilename)
Definition: C4Config.cpp:544
bool Init()
Definition: C4Config.cpp:712
const char * AtExePath(const char *szFilename)
Definition: C4Config.cpp:523
int32_t EnableUPnP
Definition: C4Config.h:155
void GetConfigFileName(StdStrBuf &filename, const char *szConfigFile)
Definition: C4Config.cpp:294
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:154
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:660
C4ConfigGamepad Gamepads[C4ConfigMaxGamepads]
Definition: C4Config.h:259
int32_t WasRegistered
Definition: C4Config.h:242
uint32_t AxisMax[6]
Definition: C4Config.h:220
int32_t UseAlternateServer
Definition: C4Config.h:153
C4ConfigSound Sound
Definition: C4Config.h:255
const char * GetLeagueServerAddress()
Definition: C4Config.cpp:594
int32_t AutoFrameSkip
Definition: C4Config.h:117
int32_t AllowAllChannels
Definition: C4Config.h:211
int32_t PortTCP
Definition: C4Config.h:154
StdCopyStrBuf LastLeagueServer
Definition: C4Config.h:162
const int C4ConfigMaxGamepads
Definition: C4Config.h:214
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:262
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:88
int32_t ScrollSmooth
Definition: C4Config.h:50
int32_t ShowClock
Definition: C4Config.h:103
void CompileFunc(StdCompiler *pComp)
Definition: C4Config.cpp:197
int32_t ShowStartupMessages
Definition: C4Config.h:99
int32_t PortUDP
Definition: C4Config.h:154
int32_t RXMusic
Definition: C4Config.h:128
const char * MakeTempUpdateFolder()
Definition: C4Config.cpp:818