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