OpenClonk
C4Config.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  * Copyright (c) 1998-2000, Matthes Bender
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-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 
17 /* Game configuration as stored in registry */
18 
19 #include "C4Include.h"
21 #include "config/C4Config.h"
22 
23 #include "C4Version.h"
24 #include "c4group/C4Components.h"
25 #include "network/C4Network2.h"
26 
27 #include "platform/C4Window.h"
28 #include "platform/StdRegistry.h"
29 
30 #ifdef HAVE_SYS_STAT_H
31 #include <sys/stat.h>
32 #endif
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h>
35 #endif
36 
37 #ifdef USE_CONSOLE
38 #define DONCOFF 0
39 #else
40 #define DONCOFF 1
41 #endif
42 
43 #include "game/C4Application.h"
44 
46 {
47  // For those without the ability to intuitively guess what the falses and trues mean:
48  // its mkNamingAdapt(field, name, default, fPrefillDefault, fStoreDefault)
49  // where fStoreDefault writes out the value to the config even if it's the same as the default.
50 #define s mkStringAdaptM
51  compiler->Value(mkNamingAdapt(s(Name), "Name", "" ));
52  compiler->Value(mkNamingAdapt(s(Language), "Language", "", false, true));
53  compiler->Value(mkNamingAdapt(s(LanguageEx), "LanguageEx", "", false, true));
54  compiler->Value(mkNamingAdapt(s(Participants), "Participants", "" ));
55 
56  // deliberately not grandfathering UserPath setting, since it was written to config by default
57  compiler->Value(mkNamingAdapt(s(ConfigUserPath), "UserDataPath", "", false, true));
58  compiler->Value(mkNamingAdapt(s(ModsDataPath), "ModsDataPath", "", false, true));
59  // assimilate old data
60  compiler->Value(mkNamingAdapt(s(Adopt.PlayerPath), "PlayerPath", ""));
61 
62  // temporary path only set during updates
63  compiler->Value(mkNamingAdapt(s(TempUpdatePath), "TempUpdatePath", ""));
64 
65  compiler->Value(mkNamingAdapt(s(MissionAccess), "MissionAccess", "", false, true));
66  compiler->Value(mkNamingAdapt(FPS, "FPS", 0 ));
67  compiler->Value(mkNamingAdapt(DefRec, "DefRec", 0 ));
68  compiler->Value(mkNamingAdapt(ScreenshotFolder, "ScreenshotFolder", "Screenshots", false, true));
69  compiler->Value(mkNamingAdapt(ModsFolder, "ModsFolder", "mods", false, true));
70  compiler->Value(mkNamingAdapt(ScrollSmooth, "ScrollSmooth", 4 ));
71  compiler->Value(mkNamingAdapt(AlwaysDebug, "DebugMode", 0 ));
72  compiler->Value(mkNamingAdapt(OpenScenarioInGameMode, "OpenScenarioInGameMode", 0 ));
73 #ifdef _WIN32
74  compiler->Value(mkNamingAdapt(MMTimer, "MMTimer", 1 ));
75 #endif
76  compiler->Value(mkNamingAdapt(s(RXFontName), "FontName", C4DEFAULT_FONT_NAME, false, true));
77  compiler->Value(mkNamingAdapt(RXFontSize, "FontSize", 14, false, true));
78  compiler->Value(mkNamingAdapt(GamepadEnabled, "GamepadEnabled", true ));
79  compiler->Value(mkNamingAdapt(FirstStart, "FirstStart", true ));
80  compiler->Value(mkNamingAdapt(ConfigResetSafety, "ConfigResetSafety", static_cast<int32_t>(ConfigResetSafetyVal) ));
81 }
82 
84 {
85  compiler->Value(mkNamingAdapt(AutoFileReload, "AutoFileReload", 1 , false, true));
86  compiler->Value(mkNamingAdapt(s(TodoFilename), "TodoFilename", "{SCENARIO}/TODO.txt", false, true));
87  compiler->Value(mkNamingAdapt(s(AltTodoFilename), "AltTodoFilename2", "{USERPATH}/TODO.txt", false, true));
88  compiler->Value(mkNamingAdapt(MaxScriptMRU, "MaxScriptMRU", 30 , false, false));
89  compiler->Value(mkNamingAdapt(DebugShapeTextures, "DebugShapeTextures", 0 , false, true));
90  compiler->Value(mkNamingAdapt(ShowHelp, "ShowHelp", true , false, false));
91  for (int32_t i = 0; i < CFG_MaxEditorMRU; ++i)
92  {
93  compiler->Value(mkNamingAdapt(s(RecentlyEditedSzenarios[i]), FormatString("EditorMRU%02d", (int)i).getData(), "", false, false));
94  }
95 }
96 
98 {
99  if (!filename || !*filename)
100  {
101  return;
102  }
103  // Put given scenario first in list by moving all other scenarios down
104  // Check how many scenarios to move down the list. Stop moving down when the given scenario is in the list
105  int32_t move_down_num;
106  for (move_down_num = 0; move_down_num < CFG_MaxEditorMRU - 1; ++move_down_num)
107  {
108  if (!strncmp(filename, RecentlyEditedSzenarios[move_down_num], CFG_MaxString))
109  {
110  break;
111  }
112  }
113  // Move them down
114  for (int32_t i = move_down_num; i > 0; --i)
115  {
117  }
118  // Put current scenario in
119  strncpy(RecentlyEditedSzenarios[0], filename, CFG_MaxString);
120 }
121 
123 {
124  compiler->Value(mkNamingAdapt(ResX, "ResolutionX", -1 ,false, true));
125  compiler->Value(mkNamingAdapt(ResY, "ResolutionY", -1 ,false, true));
126  compiler->Value(mkNamingAdapt(WindowX, "WindowX", 800 ,false, true));
127  compiler->Value(mkNamingAdapt(WindowY, "WindowY", 600 ,false, true));
128  compiler->Value(mkNamingAdapt(RefreshRate, "RefreshRate", 0 ));
129  compiler->Value(mkNamingAdapt(SplitscreenDividers, "SplitscreenDividers", 1 ));
130  compiler->Value(mkNamingAdapt(ShowStartupMessages, "ShowStartupMessages", 1 ,false, true));
131  compiler->Value(mkNamingAdapt(VerboseObjectLoading, "VerboseObjectLoading", 0 ));
132  compiler->Value(mkNamingAdapt(MenuTransparency, "MenuTransparency", 1 ,false, true));
133  compiler->Value(mkNamingAdapt(UpperBoard, "UpperBoard", 1 ,false, true));
134  compiler->Value(mkNamingAdapt(ShowClock, "ShowClock", 0 ,false, true));
135  compiler->Value(mkNamingAdapt(ShowCrewNames, "ShowCrewNames", 1 ,false, true));
136  compiler->Value(mkNamingAdapt(ShowCrewCNames, "ShowCrewCNames", 0 ,false, true));
137  compiler->Value(mkNamingAdapt(Windowed, "Windowed", 0 ,false, true));
138  compiler->Value(mkNamingAdapt(PXSGfx, "PXSGfx" , 1 ));
139  compiler->Value(mkNamingAdapt(Gamma, "Gamma" , 100 ));
140  compiler->Value(mkNamingAdapt(Monitor, "Monitor", 0 )); // 0 = D3DADAPTER_DEFAULT
141  compiler->Value(mkNamingAdapt(MaxRefreshDelay, "MaxRefreshDelay", 30 ));
142  compiler->Value(mkNamingAdapt(NoOffscreenBlits, "NoOffscreenBlits", 1 ));
143  compiler->Value(mkNamingAdapt(MultiSampling, "MultiSampling", 4 ));
144  compiler->Value(mkNamingAdapt(AutoFrameSkip, "AutoFrameSkip", 1 ));
145  compiler->Value(mkNamingAdapt(MouseCursorSize, "MouseCursorSize", 50 ));
146 }
147 
149 {
150  compiler->Value(mkNamingAdapt(RXSound, "Sound", DONCOFF ,false, true));
151  compiler->Value(mkNamingAdapt(RXMusic, "Music", DONCOFF ,false, true));
152  compiler->Value(mkNamingAdapt(FEMusic, "MenuMusic", DONCOFF ,false, true));
153  compiler->Value(mkNamingAdapt(FESamples, "MenuSound", DONCOFF ,false, true));
154  compiler->Value(mkNamingAdapt(Verbose, "Verbose", 0 ));
155  compiler->Value(mkNamingAdapt(MusicVolume, "MusicVolume2", 40 ,false, true));
156  compiler->Value(mkNamingAdapt(SoundVolume, "SoundVolume", 100 ,false, true));
157 }
158 
160 {
161  compiler->Value(mkNamingAdapt(ControlRate, "ControlRate", 3 ,false, true));
162  compiler->Value(mkNamingAdapt(ControlPreSend, "ControlPreSend", -1 ));
163  compiler->Value(mkNamingAdapt(s(WorkPath), "WorkPath", "Network" ,false, true));
164  compiler->Value(mkNamingAdapt(Lobby, "Lobby", 0 ));
165  compiler->Value(mkNamingAdapt(NoRuntimeJoin, "NoRuntimeJoin", 1 ,false, true));
166  compiler->Value(mkNamingAdapt(NoReferenceRequest, "NoReferenceRequest", 0 ));
167  compiler->Value(mkNamingAdapt(MaxResSearchRecursion, "MaxResSearchRecursion",1 ,false, true));
168  compiler->Value(mkNamingAdapt(Comment, "Comment", "" ,false, true));
169  compiler->Value(mkNamingAdapt(PortTCP, "PortTCP", C4NetStdPortTCP ,false, true));
170  compiler->Value(mkNamingAdapt(PortUDP, "PortUDP", C4NetStdPortUDP ,false, true));
171  compiler->Value(mkNamingAdapt(EnableUPnP, "EnableUPnP", 1 , false, true));
172  compiler->Value(mkNamingAdapt(PortDiscovery, "PortDiscovery", C4NetStdPortDiscovery ,false, true));
173  compiler->Value(mkNamingAdapt(PortRefServer, "PortRefServer", C4NetStdPortRefServer ,false, true));
174  compiler->Value(mkNamingAdapt(ControlMode, "ControlMode", 0 ));
175  compiler->Value(mkNamingAdapt(Nick, "Nick", "" ,false, true));
176  compiler->Value(mkNamingAdapt(MaxLoadFileSize, "MaxLoadFileSize", 5*1024*1024 ,false, true));
177 
178  compiler->Value(mkNamingAdapt(MasterServerSignUp, "MasterServerSignUp", 1 ));
179  compiler->Value(mkNamingAdapt(MasterServerActive, "MasterServerActive", 0 ));
180  compiler->Value(mkNamingAdapt(MasterKeepPeriod, "MasterKeepPeriod", 60 ));
181  compiler->Value(mkNamingAdapt(MasterReferencePeriod, "MasterReferencePeriod",120 ));
182  compiler->Value(mkNamingAdapt(LeagueServerSignUp, "LeagueServerSignUp", 0 ));
183  compiler->Value(mkNamingAdapt(UseAlternateServer, "UseAlternateServer", 0 ));
184  compiler->Value(mkNamingAdapt(s(AlternateServerAddress),"AlternateServerAddress", "https://league.openclonk.org/league.php"));
185  compiler->Value(mkNamingAdapt(UseAlternateModDatabaseServer, "UseAlternateModDatabaseServer", 0));
186  compiler->Value(mkNamingAdapt(s(AlternateModDatabaseServerAddress), "AlternateModDatabaseServerAddress", "https://mods.openclonk.org/api/"));
187  compiler->Value(mkNamingAdapt(s(LastPassword), "LastPassword", "Wipf" ));
188 #ifdef WITH_AUTOMATIC_UPDATE
189  compiler->Value(mkNamingAdapt(s(UpdateServerAddress), "UpdateServerAddress", "https://www.openclonk.org/update/"));
190  compiler->Value(mkNamingAdapt(AutomaticUpdate, "AutomaticUpdate", 0 ,false, true));
191  compiler->Value(mkNamingAdapt(LastUpdateTime, "LastUpdateTime", 0 ));
192 #endif
193  compiler->Value(mkNamingAdapt(AsyncMaxWait, "AsyncMaxWait", 2 ));
194  compiler->Value(mkNamingAdapt(PacketLogging, "PacketLogging", 0 ));
195 
196 
197  compiler->Value(mkNamingAdapt(s(PuncherAddress), "PuncherAddress", "netpuncher.openclonk.org:11115"));
198  compiler->Value(mkNamingAdapt(mkParAdapt(LastLeagueServer, StdCompiler::RCT_All), "LastLeagueServer", "" ));
199  compiler->Value(mkNamingAdapt(mkParAdapt(LastLeaguePlayerName, StdCompiler::RCT_All), "LastLeaguePlayerName", "" ));
200  compiler->Value(mkNamingAdapt(mkParAdapt(LastLeagueAccount, StdCompiler::RCT_All), "LastLeagueAccount", "" ));
201  compiler->Value(mkNamingAdapt(mkParAdapt(LastLeagueLoginToken, StdCompiler::RCT_All), "LastLeagueLoginToken", "" ));
202 }
203 
205 {
206  compiler->Value(mkNamingAdapt(AllowPlayerSave, "AllowPlayerSave", 0 ,false, false));
207  compiler->Value(mkNamingAdapt(CountdownTime, "CountdownTime", 5 ,false, false));
208 }
209 
211 {
212  compiler->Value(mkNamingAdapt(s(Server), "Server", "irc.euirc.net", false, true));
213  compiler->Value(mkNamingAdapt(s(Nick), "Nick", "" , false, true));
214  compiler->Value(mkNamingAdapt(s(RealName), "RealName", "" , false, true));
215  compiler->Value(mkNamingAdapt(s(Channel), "Channel", "#openclonk" , false, true));
216  compiler->Value(mkNamingAdapt(AllowAllChannels, "AllowAllChannels", 0 , false, true));
217 }
218 
220 {
221  compiler->Value(mkNamingAdapt(WasRegistered, "WasRegistered", 0 ));
222 #ifdef _WIN32
223  compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", R"(%APPDATA%\)" C4ENGINENAME, false, true));
224 #elif defined(__linux__)
225  compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", "$HOME/.clonk/" C4ENGINENICK, false, true));
226 #elif defined(__APPLE__)
227  compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", "$HOME/Library/Application Support/" C4ENGINENAME, false, true));
228 #endif
229 }
230 
231 void C4ConfigGamepad::CompileFunc(StdCompiler *compiler, bool buttons_only)
232 {
233  /* The defaults here are for a Logitech Dual Action under Linux-SDL. Better than nothing, I guess. */
234  if (!buttons_only)
235  {
236  for (int i = 0; i < 6; ++i)
237  {
238  compiler->Value(mkNamingAdapt(AxisMin[i], FormatString("Axis%dMin", i).getData(), 0u));
239  compiler->Value(mkNamingAdapt(AxisMax[i], FormatString("Axis%dMax", i).getData(), 0u));
240  compiler->Value(mkNamingAdapt(AxisCalibrated[i], FormatString("Axis%dCalibrated", i).getData(), false));
241  }
242  }
243  compiler->Value(mkNamingAdapt(Button[0], "Button1", -1 ));
244  compiler->Value(mkNamingAdapt(Button[1], "Button2", -1 ));
245  compiler->Value(mkNamingAdapt(Button[2], "Button3", -1 ));
246  compiler->Value(mkNamingAdapt(Button[3], "Button4", -1 ));
247  compiler->Value(mkNamingAdapt(Button[4], "Button5", -1 ));
248  compiler->Value(mkNamingAdapt(Button[5], "Button6", -1 ));
249  compiler->Value(mkNamingAdapt(Button[6], "Button7", -1 ));
250  compiler->Value(mkNamingAdapt(Button[7], "Button8", -1 ));
251  compiler->Value(mkNamingAdapt(Button[8], "Button9", -1 ));
252  compiler->Value(mkNamingAdapt(Button[9], "Button10", -1 ));
253  compiler->Value(mkNamingAdapt(Button[10], "Button11", -1 ));
254  compiler->Value(mkNamingAdapt(Button[11], "Button12", -1 ));
255 }
256 
258 {
259  // loads an empty config for the buttons
260  StdCompilerNull Comp; Comp.Compile(mkParAdapt(*this, true));
261 }
262 
264 {
265  // loads an empty config for the gamepad config
266  StdCompilerNull Comp; Comp.Compile(mkParAdapt(*this, false));
267 }
268 
270 {
271 #ifndef USE_CONSOLE
272  if (compiler->isSerializer())
273  {
274  // The registry compiler is broken with arrays. It doesn't delete extra items if the config got shorter
275  // Solve it by defaulting the array before writing to it.
276  compiler->Default("UserSets");
277  }
278  compiler->Value(mkNamingAdapt(UserSets, "UserSets", C4PlayerControlAssignmentSets()));
279  compiler->Value(mkNamingAdapt(MouseAutoScroll, "MouseAutoScroll", 0 /* change default 33 to enable */ ));
280  compiler->Value(mkNamingAdapt(GamepadGuiControl, "GamepadGuiControl", 0, false, true));
281 #endif
282 }
283 
284 #undef s
285 
287 {
288  Default();
289 }
290 
292 {
293  ConfigLoaded = false;
294 }
295 
297 {
298  // force default values
299  StdCompilerNull Comp; Comp.Compile(*this);
300  ConfigLoaded = false;
301 }
302 
303 void C4Config::GetConfigFileName(StdStrBuf &filename, const char *config_file)
304 {
305  if (config_file)
306  {
307  // Config filename is specified
308  filename.Ref(config_file);
309  }
310  else
311  {
312  // Config filename from home
313  StdStrBuf home(getenv("HOME"));
314  if (home)
315  {
316  home += "/";
317  }
318  filename.Copy(home);
319 #ifdef __APPLE__
320  filename += "Library/Preferences/" C4ENGINEID ".config";
321 #else
322  filename += ".clonk/" C4ENGINENICK "/config";
323 #endif
324  }
325 }
326 
327 bool C4Config::Load(const char *config_file)
328 {
329  try
330  {
331 #ifdef _WIN32
332  // Windows: Default load from registry, if no explicit config file is specified
333  if (!config_file)
334  {
335  StdCompilerConfigRead CfgRead(HKEY_CURRENT_USER, "Software\\" C4CFG_Company "\\" C4ENGINENAME);
336  CfgRead.Compile(*this);
337  }
338  else
339 #endif
340  {
341  // Nonwindows or explicit config file: Determine filename to load config from
342  StdStrBuf filename;
343  GetConfigFileName(filename, config_file);
344 
345  // Load config file into buf
346  StdStrBuf buf;
347  buf.LoadFromFile(filename.getData());
348 
349  if (buf.isNull())
350  {
351  // Config file not present?
352 #ifdef __linux__
353  if (!config_file)
354  {
355  StdStrBuf filename(getenv("HOME"));
356  if (filename)
357  {
358  filename += "/";
359  }
360  filename += ".clonk/" C4ENGINENICK;
361  CreatePath(filename.getData());
362  }
363 #endif
364  // Buggy StdCompiler crashes when compiling a Null-StdStrBuf
365  buf.Ref(" ");
366  }
367 
368  // Read config from buffer
369  StdCompilerINIRead IniRead;
370  IniRead.setInput(buf);
371  IniRead.Compile(*this);
372  }
373  }
374  catch (StdCompiler::Exception *pExc)
375  {
376  // Configuration file syntax error?
377  LogF("Error loading configuration: %s"/*LoadResStr("IDS_ERR_CONFREAD") - restbl not yet loaded*/, pExc->Msg.getData());
378  delete pExc;
379  return false;
380  }
381 
382  // Config postinit
384 #ifdef HAVE_WINSOCK
385  // Setup WS manually, so c4group doesn't depend on C4NetIO
386  WSADATA wsadata;
387  bool fWinSock = !WSAStartup(WINSOCK_VERSION, &wsadata);
388 #endif
389  if (SEqual(Network.Nick.getData(), "Unknown"))
390  {
391  char LocalName[25+1];
392  *LocalName = 0;
393  gethostname(LocalName, 25);
394  if (*LocalName)
395  {
396  Network.Nick.Copy(LocalName);
397  }
398  }
399 #ifdef HAVE_WINSOCK
400  if (fWinSock)
401  {
402  WSACleanup();
403  }
404 #endif
406  // Warning against invalid ports
408  {
409  Log("Warning: Network TCP port and reference server port both set to same value - increasing reference server port!");
411  if (Config.Network.PortRefServer >= 65536)
412  {
414  }
415  }
417  {
418  Log("Warning: Network UDP port and LAN game discovery port both set to same value - increasing discovery port!");
420  if (Config.Network.PortDiscovery >= 65536)
421  {
423  }
424  }
425  // Empty nick already defaults to GetRegistrationData("Nick") or
426  // Network.LocalName at relevant places.
427  ConfigLoaded = true;
428  if (config_file)
429  {
430  ConfigFilename.Copy(config_file);
431  }
432  else
433  {
435  }
436  return true;
437 }
438 
440 {
441  try
442  {
443 #ifdef _WIN32
444  if (!ConfigFilename.getLength())
445  {
446  // Windows: Default save to registry, if it wasn't loaded from file
447  StdCompilerConfigWrite CfgWrite(HKEY_CURRENT_USER, "Software\\" C4CFG_Company "\\" C4ENGINENAME);
448  CfgWrite.Decompile(*this);
449  }
450  else
451 #endif
452  {
453  StdStrBuf filename;
455  StdCompilerINIWrite IniWrite;
456  IniWrite.Decompile(*this);
457  IniWrite.getOutput().SaveToFile(filename.getData());
458  }
459  }
460  catch (StdCompiler::Exception *exception)
461  {
462  LogF(LoadResStr("IDS_ERR_CONFSAVE"), exception->Msg.getData());
463  delete exception;
464  return false;
465  }
466  return true;
467 }
468 
470 {
471 #ifdef _WIN32
472  // Exe path
473  wchar_t apath[CFG_MaxString];
474  if (GetModuleFileNameW(nullptr, apath, CFG_MaxString))
475  {
476  ExePath = StdStrBuf(apath);
480  }
481 
482  // Temp path
483  GetTempPathW(CFG_MaxString,apath);
484  TempPath = StdStrBuf(apath);
485  if (TempPath[0])
486  {
488  }
489 #elif defined(PROC_SELF_EXE)
490  ExePath.SetLength(1024);
491  ssize_t l = readlink(PROC_SELF_EXE, ExePath.getMData(), 1024);
492  if (l < -1)
493  {
494  ExePath.Ref(".");
495  }
496  else
497  {
498  ExePath.SetLength(l);
501  }
502  const char * t = getenv("TMPDIR");
503  if (t)
504  {
505  TempPath = t;
507  }
508  else
509  {
510  TempPath = "/tmp/";
511  }
512 #else
513  // Mac: Just use the working directory as ExePath.
516  TempPath = "/tmp/";
517 #endif
518 
519  // Find system-wide data path
520 #if defined(_WIN32)
521  // Use ExePath: on windows, everything is installed to one directory
523 #elif defined(__APPLE__)
524  SCopy(::Application.GetGameDataPath().c_str(), SystemDataPath);
525 #elif defined(WITH_AUTOMATIC_UPDATE) && defined(WITH_APPDIR_INSTALLATION)
526  // AppDir: layout like normal unix installation, but relative to executable.
527  auto str = FormatString("%s%s", ExePath.getMData(), OC_SYSTEM_DATA_DIR);
528  SCopy(str.getMData(), SystemDataPath);
529 #elif defined(WITH_AUTOMATIC_UPDATE)
530  // WITH_AUTOMATIC_UPDATE builds are our tarball releases and
531  // development snapshots, i.e. where the game data is at the
532  // same location as the executable.
534 #elif defined(OC_SYSTEM_DATA_DIR)
535  SCopy(OC_SYSTEM_DATA_DIR, SystemDataPath);
536 #else
537 #error Please define OC_SYSTEM_DATA_DIR!
538 #endif
540 
541  // Find user-specific data path
542  if (ConfigUserPath[0])
543  {
545  }
546  else
547  {
548 #if defined(_WIN32)
549  SCopy(R"(%APPDATA%\)" C4ENGINENAME, UserDataPath);
550 #elif defined(__APPLE__)
551  SCopy("$HOME/Library/Application Support/" C4ENGINENAME, UserDataPath);
552 #else
553  SCopy("$HOME/.clonk/" C4ENGINENICK, UserDataPath);
554 #endif
555  }
558 
559  // Screenshot path
561  if (ScreenshotFolder.getLength() + std::strlen(ScreenshotPath) + 1 <= CFG_MaxString)
562  {
565  }
566  // Mods path
568  if (ModsFolder.getLength() + std::strlen(ModsDataPath) + 1 <= CFG_MaxString)
569  {
572  }
573  // Create user path if it doesn't already exist
575 }
576 
577 static char AtPathFilename[_MAX_PATH_LEN];
578 
579 const char* C4Config::AtExePath(const char *filename)
580 {
581  SCopy(General.ExePath.getData(), AtPathFilename, _MAX_PATH);
582  SAppend(filename, AtPathFilename, _MAX_PATH);
583  return AtPathFilename;
584 }
585 
586 const char* C4Config::AtUserDataPath(const char *filename)
587 {
588  SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH);
589  SAppend(filename, AtPathFilename, _MAX_PATH);
590  return AtPathFilename;
591 }
592 
593 const char* C4Config::AtSystemDataPath(const char *filename)
594 {
595  SCopy(General.SystemDataPath, AtPathFilename, _MAX_PATH);
596  SAppend(filename, AtPathFilename, _MAX_PATH);
597  return AtPathFilename;
598 }
599 
600 const char* C4Config::AtTempPath(const char *filename)
601 {
602  SCopy(General.TempPath.getData(),AtPathFilename,_MAX_PATH);
603  SAppend(filename,AtPathFilename,_MAX_PATH);
604  return AtPathFilename;
605 }
606 
607 const char* C4Config::AtNetworkPath(const char *filename)
608 {
609  SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH);
610  SAppend(Network.WorkPath, AtPathFilename, _MAX_PATH);
611  SAppend(filename, AtPathFilename, _MAX_PATH);
612  return AtPathFilename;
613 }
614 
615 const char *C4Config::AtScreenshotPath(const char *filename)
616 {
617  int len;
618  SCopy(General.ScreenshotPath, AtPathFilename, _MAX_PATH);
619  if ((len = SLen(AtPathFilename)))
620  {
621  if (AtPathFilename[len-1] == DirectorySeparator)
622  {
623  AtPathFilename[len-1] = '\0';
624  }
625  }
626  if (!CreatePath(AtPathFilename))
627  {
628  SCopy(General.UserDataPath,AtPathFilename,_MAX_PATH);
629  }
630  AppendBackslash(AtPathFilename);
631  SAppend(filename, AtPathFilename, _MAX_PATH);
632  return AtPathFilename;
633 }
634 
635 
636 bool C4ConfigGeneral::CreateSaveFolder(const char *directory, const char *language_title)
637 {
638  // Create directory if needed
639  if (!CreatePath(directory))
640  {
641  return false;
642  }
643  // Create title component if needed
644  char language[3]; SCopy(Config.General.Language, language, 2);
645  StdStrBuf title_file; title_file.Format("%s%c%s", directory, DirectorySeparator, C4CFN_WriteTitle);
646  StdStrBuf title_data; title_data.Format("%s:%s", language, language_title);
647 
648  CStdFile file;
649  if (!FileExists(title_file.getData()))
650  {
651  if (!file.Create(title_file.getData()) || !file.WriteString(title_data.getData()) || !file.Close())
652  {
653  return false;
654  }
655  }
656  // Save folder seems okay
657  return true;
658 }
659 
660 
662 {
663  // Alternate (configurable) league server
664  if (UseAlternateServer)
665  {
666  return AlternateServerAddress;
667  }
668  // Standard (hardcoded) official league server
669  else
670  {
671  return "https://league.openclonk.org/league.php";
672  }
673 }
674 
676 {
677  // Alternate (configurable) mod database server
680  // Standard (hardcoded) official mod database server
681  else
682  return "https://mods.openclonk.org/api/";
683 }
684 
686 {
687  // check for port collisions
688  if (PortTCP != -1 && PortTCP == PortRefServer)
689  {
690  LogSilentF("Network: TCP Port collision, setting defaults");
693  }
694  if (PortUDP != -1 && PortUDP == PortDiscovery)
695  {
696  LogSilentF("Network: UDP Port collision, setting defaults");
699  }
700 }
701 
702 void C4ConfigNetwork::SetLeagueLoginData(const char *server_name, const char *player_name, const char *account, const char *login_token)
703 {
704  // ideally, there would be a list to store multiple logins
705  // however, we don't really support multiplayer at one computer at the moment anyway
706  LastLeagueServer.Copy(server_name);
707  LastLeaguePlayerName.Copy(player_name);
708  LastLeagueAccount.Copy(account);
709  LastLeagueLoginToken.Copy(login_token);
710 }
711 
712 bool C4ConfigNetwork::GetLeagueLoginData(const char *server_name, const char *player_name, StdStrBuf *account, StdStrBuf *login_token) const
713 {
714  // check if last login matches and store if desired
715  if (LastLeagueServer == server_name && LastLeaguePlayerName == player_name)
716  {
717  account->Copy(LastLeagueAccount);
718  login_token->Copy(LastLeagueLoginToken);
719  return true;
720  }
721  return false;
722 }
723 
725 {
726  UserSets.Clear();
727 }
728 
729 const char* C4Config::AtUserDataRelativePath(const char *filename)
730 {
731  // Specified file is located in UserDataPath: return relative path
732  return GetRelativePathS(filename, General.UserDataPath);
733 }
734 
735 const char* C4Config::AtSystemDataRelativePath(const char *filename)
736 {
737  // Specified file is located in SystemDataPath: return relative path
738  return GetRelativePathS(filename, General.SystemDataPath);
739 }
740 
741 const char* C4Config::AtRelativePath(const char *filename)
742 {
743  const char *path = GetRelativePathS(filename, General.UserDataPath);
744  if (path == filename)
745  {
746  return GetRelativePathS(filename, General.SystemDataPath);
747  }
748  return path;
749 }
750 
752 {
753  assert(filename);
754  // Specified file is located in SystemDataPath?
755  const char *relative = GetRelativePathS(filename->getData(), General.SystemDataPath);
756  if (relative != filename->getData())
757  {
758  // return relative path
759  StdStrBuf temp; temp.Copy(relative);
760  filename->Take(std::move(temp));
761  }
762  else
763  {
764  // not in ExePath: Is it a global path?
765  if (IsGlobalPath(filename->getData()))
766  {
767  // then shorten it (e.g. C:\Temp\Missions.ocf\Goldmine.ocs to Missions.ocf\Goldmine.ocs)
768  StdStrBuf temp; temp.Copy(GetC4Filename(filename->getData()));
769  filename->Take(std::move(temp));
770  }
771  }
772 }
773 
775 {
776  // No language defined: default to German or English by system language
777  if (!Language[0])
778  {
779  if (IsGermanSystem())
780  {
781  SCopy("DE - Deutsch", Language);
782  }
783  else
784  {
785  SCopy("US - English", Language);
786  }
787  }
788  // No fallback sequence defined: use primary language list
789  if (!LanguageEx[0])
790  {
792  }
793 }
794 
796 {
797  // Dummy function: to be overloaded in C4Config
798  return true;
799 }
800 
802 {
803  return true;
804 }
805 
806 const char* C4Config::GetSubkeyPath(const char *subkey)
807 {
808  static char key[1024 + 1];
809 #ifdef _WIN32
810  sprintf(key, R"(Software\%s\%s\%s)", C4CFG_Company, C4ENGINENAME, subkey);
811 #else
812  sprintf(key, "%s", subkey);
813 #endif
814  return key;
815 }
816 
817 int C4ConfigGeneral::GetLanguageSequence(const char *source, char *target)
818 {
819  // Copy a condensed list of language codes from the source list to the target string,
820  // skipping any whitespace or long language descriptions. Language sequences are
821  // comma separated.
822  int count = 0;
823  char language[2 + 1];
824  for (int i = 0; SCopySegment(source, i, language, ',', 2, true); i++)
825  {
826  if (language[0])
827  {
828  if (target[0]) SAppendChar(',', target);
829  SAppend(language, target);
830  count++;
831  }
832  }
833  return count;
834 }
835 
837 {
838  compiler->Value(mkNamingAdapt(HideMsgGfxEngineChange, "HideMsgGfxEngineChange", 0));
839  compiler->Value(mkNamingAdapt(HideMsgGfxBitDepthChange, "HideMsgGfxBitDepthChange", 0));
840  compiler->Value(mkNamingAdapt(HideMsgMMTimerChange, "HideMsgMMTimerChange", 0));
841  compiler->Value(mkNamingAdapt(HideMsgStartDedicated, "HideMsgStartDedicated", 0));
842  compiler->Value(mkNamingAdapt(HideMsgPlrTakeOver, "HideMsgPlrTakeOver", 0));
843  compiler->Value(mkNamingAdapt(HideMsgPlrNoTakeOver, "HideMsgPlrNoTakeOver", 0));
844  compiler->Value(mkNamingAdapt(HideMsgNoOfficialLeague, "HideMsgNoOfficialLeague", 0));
845  compiler->Value(mkNamingAdapt(HideMsgIRCDangerous, "HideMsgIRCDangerous", 0));
846  compiler->Value(mkNamingAdapt(AlphabeticalSorting, "AlphabeticalSorting", 0));
847  compiler->Value(mkNamingAdapt(LastPortraitFolderIdx, "LastPortraitFolderIdx", 0));
848 }
849 
851 {
852  compiler->Value(mkNamingAdapt(General, "General" ));
853  compiler->Value(mkNamingAdapt(Controls, "Controls" ));
854  for (int i=0; i<C4ConfigMaxGamepads; ++i)
855  {
856  compiler->Value(mkNamingAdapt(Gamepads[i], FormatString("Gamepad%d", i).getData()));
857  }
858  compiler->Value(mkNamingAdapt(Graphics, "Graphics" ));
859  compiler->Value(mkNamingAdapt(Sound, "Sound" ));
860  compiler->Value(mkNamingAdapt(Network, "Network" ));
861  compiler->Value(mkNamingAdapt(Lobby, "Lobby" ));
862  compiler->Value(mkNamingAdapt(IRC, "IRC" ));
863  compiler->Value(mkNamingAdapt(Developer, "Developer" ));
864  compiler->Value(mkNamingAdapt(Startup, "Startup" ));
865  compiler->Value(mkNamingAdapt(Security, "Security" ));
866 }
867 
868 bool C4Config::AddModule(const char *path, char *modules)
869 {
870  return SAddModule(modules,path);
871 }
872 
873 bool C4Config::IsModule(const char *path, char *modules)
874 {
875  return SIsModule(modules,path);
876 }
877 
878 bool C4Config::RemoveModule(const char *path, char *modules)
879 {
880  return SRemoveModule(modules,path);
881 }
882 
883 void C4Config::ExpandEnvironmentVariables(char *path, size_t max_length)
884 {
885 #ifdef _WIN32
886  wchar_t buf[_MAX_PATH_LEN];
887  ExpandEnvironmentStringsW(GetWideChar(path), buf, _MAX_PATH);
888  SCopy(StdStrBuf(buf).getData(), path, max_length);
889 #else // __linux__ or __APPLE___
890  StdStrBuf home(getenv("HOME"));
891  char* rest;
892  if (home && (rest = const_cast<char *>(SSearch(path, "$HOME"))) && (std::strlen(path) - 5 + home.getLength() <= max_length))
893  {
894  // String replace... there might be a more elegant way to do this.
895  memmove(rest + home.getLength() - SLen("$HOME"), rest, SLen(rest) + 1);
896  strncpy(rest - SLen("$HOME"), home.getData(), home.getLength());
897  }
898 #endif
899 }
900 
902 {
903  // Get rid of update path present from before update
904  if (*General.TempUpdatePath)
905  {
907  *General.TempUpdatePath = '\0';
908  }
909 }
910 
912 {
913  // just pick a temp name
914  StdStrBuf temp_name;
915  temp_name.Copy(AtTempPath("update"));
916  MakeTempFilename(&temp_name);
917  SCopy(temp_name.getData(), General.TempUpdatePath);
919  return General.TempUpdatePath;
920 }
921 
922 const char *C4Config::AtTempUpdatePath(const char *filename)
923 {
924  SCopy(General.TempUpdatePath,AtPathFilename,_MAX_PATH-1);
925  AppendBackslash(AtPathFilename);
926  SAppend(filename,AtPathFilename,_MAX_PATH);
927  return AtPathFilename;
928 }
929 
bool IsGermanSystem()
Definition: C4AppMac.mm:193
#define C4CFN_WriteTitle
Definition: C4Components.h:83
#define DONCOFF
Definition: C4Config.cpp:40
#define s
C4Config Config
Definition: C4Config.cpp:930
@ CFG_MaxEditorMRU
Definition: C4Config.h:28
@ CFG_MaxString
Definition: C4Config.h:28
#define C4DEFAULT_FONT_NAME
Definition: C4Config.h:27
const int C4ConfigMaxGamepads
Definition: C4Config.h:217
C4Application Application
Definition: C4Globals.cpp:44
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
bool LogSilentF(const char *strMessage,...)
Definition: C4Log.cpp:272
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
const int16_t C4NetStdPortRefServer
Definition: C4Network2.h:32
const int16_t C4NetStdPortDiscovery
Definition: C4Network2.h:31
const int16_t C4NetStdPortUDP
Definition: C4Network2.h:30
const int16_t C4NetStdPortTCP
Definition: C4Network2.h:29
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
#define DirectorySeparator
#define _MAX_PATH
#define _MAX_PATH_LEN
ptrdiff_t ssize_t
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:369
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
Definition: Standard.cpp:547
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:279
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
bool SRemoveModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:588
void SAppendChar(char cChar, char *szStr)
Definition: Standard.cpp:271
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:563
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
#define sprintf
Definition: Standard.h:162
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
size_t SLen(const char *sptr)
Definition: Standard.h:74
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:833
const char * GetC4Filename(const char *szPath)
Definition: StdFile.cpp:68
const char * GetRelativePathS(const char *strPath, const char *strRelativeTo)
Definition: StdFile.cpp:208
bool TruncatePath(char *szPath)
Definition: StdFile.cpp:237
bool GetParentPath(const char *szFilename, char *szBuffer)
Definition: StdFile.cpp:186
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:320
void AppendBackslash(char *szFilename)
Definition: StdFile.cpp:254
bool IsGlobalPath(const char *szPath)
Definition: StdFile.cpp:224
bool CreatePath(const std::string &path)
Definition: StdFile.cpp:656
const char * GetWorkingDirectory()
Definition: StdFile.cpp:627
bool FileExists(const char *szFileName)
int32_t MouseAutoScroll
Definition: C4Config.h:234
C4PlayerControlAssignmentSets UserSets
Definition: C4Config.h:235
int32_t GamepadGuiControl
Definition: C4Config.h:233
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:269
char RecentlyEditedSzenarios[CFG_MaxEditorMRU][CFG_MaxString+1]
Definition: C4Config.h:90
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:83
char AltTodoFilename[CFG_MaxString+1]
Definition: C4Config.h:86
void AddRecentlyEditedScenario(const char *filename)
Definition: C4Config.cpp:97
int32_t MaxScriptMRU
Definition: C4Config.h:87
int32_t AutoFileReload
Definition: C4Config.h:84
char TodoFilename[CFG_MaxString+1]
Definition: C4Config.h:85
int32_t DebugShapeTextures
Definition: C4Config.h:88
bool AxisCalibrated[6]
Definition: C4Config.h:224
void CompileFunc(StdCompiler *compiler, bool buttons_only=false)
Definition: C4Config.cpp:231
uint32_t AxisMax[6]
Definition: C4Config.h:223
uint32_t AxisMin[6]
Definition: C4Config.h:223
int32_t Button[C4MaxKey]
Definition: C4Config.h:222
void ResetButtons()
Definition: C4Config.cpp:257
StdCopyStrBuf ExePath
Definition: C4Config.h:54
char Participants[CFG_MaxString+1]
Definition: C4Config.h:39
char ConfigUserPath[CFG_MaxString+1]
Definition: C4Config.h:44
char SystemDataPath[CFG_MaxString+1]
Definition: C4Config.h:58
char Name[CFG_MaxString+1]
Definition: C4Config.h:36
int32_t ScrollSmooth
Definition: C4Config.h:51
StdStrBuf ScreenshotFolder
Definition: C4Config.h:45
StdCopyStrBuf TempPath
Definition: C4Config.h:55
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:38
@ ConfigResetSafetyVal
Definition: C4Config.h:34
void DeterminePaths()
Definition: C4Config.cpp:469
int32_t FPS
Definition: C4Config.h:48
char Language[CFG_MaxString+1]
Definition: C4Config.h:37
bool GamepadEnabled
Definition: C4Config.h:61
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:56
void DefaultLanguage()
Definition: C4Config.cpp:774
int32_t DefRec
Definition: C4Config.h:49
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:45
int32_t OpenScenarioInGameMode
Definition: C4Config.h:41
int32_t AlwaysDebug
Definition: C4Config.h:40
char TempUpdatePath[CFG_MaxString+1]
Definition: C4Config.h:60
int32_t ConfigResetSafety
Definition: C4Config.h:52
int32_t MMTimer
Definition: C4Config.h:50
char ModsDataPath[CFG_MaxString+1]
Definition: C4Config.h:57
StdStrBuf ModsFolder
Definition: C4Config.h:46
char MissionAccess[CFG_MaxString+1]
Definition: C4Config.h:47
char RXFontName[CFG_MaxString+1]
Definition: C4Config.h:42
bool FirstStart
Definition: C4Config.h:62
bool CreateSaveFolder(const char *directory, const char *language_title)
Definition: C4Config.cpp:636
int32_t RXFontSize
Definition: C4Config.h:43
char ScreenshotPath[CFG_MaxString+1]
Definition: C4Config.h:59
static int GetLanguageSequence(const char *source, char *target)
Definition: C4Config.cpp:817
int32_t ResX
Definition: C4Config.h:104
int32_t Gamma
Definition: C4Config.h:111
int32_t ResY
Definition: C4Config.h:104
int32_t RefreshRate
Definition: C4Config.h:106
int32_t AutoFrameSkip
Definition: C4Config.h:116
int32_t WindowY
Definition: C4Config.h:105
int32_t VerboseObjectLoading
Definition: C4Config.h:100
int32_t WindowX
Definition: C4Config.h:105
int32_t MenuTransparency
Definition: C4Config.h:101
int32_t MultiSampling
Definition: C4Config.h:115
int32_t MaxRefreshDelay
Definition: C4Config.h:113
int32_t PXSGfx
Definition: C4Config.h:110
int32_t NoOffscreenBlits
Definition: C4Config.h:114
int32_t Windowed
Definition: C4Config.h:107
int32_t SplitscreenDividers
Definition: C4Config.h:98
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:122
int32_t UpperBoard
Definition: C4Config.h:102
int32_t ShowCrewNames
Definition: C4Config.h:108
int32_t ShowStartupMessages
Definition: C4Config.h:99
int32_t ShowCrewCNames
Definition: C4Config.h:109
int32_t MouseCursorSize
Definition: C4Config.h:118
int32_t ShowClock
Definition: C4Config.h:103
int32_t Monitor
Definition: C4Config.h:112
const char * AtSystemDataRelativePath(const char *filename)
Definition: C4Config.cpp:735
const char * AtSystemDataPath(const char *filename)
Definition: C4Config.cpp:593
C4ConfigGeneral General
Definition: C4Config.h:255
C4ConfigNetwork Network
Definition: C4Config.h:259
C4ConfigStartup Startup
Definition: C4Config.h:264
bool Registered()
Definition: C4Config.cpp:795
void ForceRelativePath(StdStrBuf *filename)
Definition: C4Config.cpp:751
bool AddModule(const char *path, char *modules)
Definition: C4Config.cpp:868
const char * AtRelativePath(const char *filename)
Definition: C4Config.cpp:741
bool IsModule(const char *path, char *modules)
Definition: C4Config.cpp:873
const char * AtExePath(const char *filename)
Definition: C4Config.cpp:579
void CleanupTempUpdateFolder()
Definition: C4Config.cpp:901
bool RemoveModule(const char *path, char *modules)
Definition: C4Config.cpp:878
C4ConfigIRC IRC
Definition: C4Config.h:261
const char * AtTempPath(const char *filename)
Definition: C4Config.cpp:600
const char * AtUserDataPath(const char *filename)
Definition: C4Config.cpp:586
C4ConfigGamepad Gamepads[C4ConfigMaxGamepads]
Definition: C4Config.h:262
const char * MakeTempUpdateFolder()
Definition: C4Config.cpp:911
bool Save()
Definition: C4Config.cpp:439
bool Init()
Definition: C4Config.cpp:801
const char * GetSubkeyPath(const char *subkey)
Definition: C4Config.cpp:806
C4ConfigSecurity Security
Definition: C4Config.h:265
const char * AtTempUpdatePath(const char *filename)
Definition: C4Config.cpp:922
C4ConfigLobby Lobby
Definition: C4Config.h:260
static void ExpandEnvironmentVariables(char *path, size_t max_length)
Definition: C4Config.cpp:883
C4ConfigControls Controls
Definition: C4Config.h:263
bool Load(const char *config_file=nullptr)
Definition: C4Config.cpp:327
void GetConfigFileName(StdStrBuf &filename, const char *config_file)
Definition: C4Config.cpp:303
const char * AtScreenshotPath(const char *filename)
Definition: C4Config.cpp:615
StdStrBuf ConfigFilename
Definition: C4Config.h:267
void Default()
Definition: C4Config.cpp:296
const char * AtUserDataRelativePath(const char *filename)
Definition: C4Config.cpp:729
const char * AtNetworkPath(const char *filename)
Definition: C4Config.cpp:607
C4ConfigDeveloper Developer
Definition: C4Config.h:256
bool ConfigLoaded
Definition: C4Config.h:266
C4ConfigGraphics Graphics
Definition: C4Config.h:257
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:850
C4ConfigSound Sound
Definition: C4Config.h:258
int32_t AllowAllChannels
Definition: C4Config.h:214
char Channel[CFG_MaxString+1]
Definition: C4Config.h:212
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:210
char Nick[CFG_MaxString+1]
Definition: C4Config.h:210
char RealName[CFG_MaxString+1]
Definition: C4Config.h:211
char Server[CFG_MaxString+1]
Definition: C4Config.h:209
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:204
int32_t AllowPlayerSave
Definition: C4Config.h:202
int32_t CountdownTime
Definition: C4Config.h:201
int32_t MasterServerActive
Definition: C4Config.h:148
int32_t UseAlternateModDatabaseServer
Definition: C4Config.h:163
int32_t AsyncMaxWait
Definition: C4Config.h:170
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:159
ValidatedStdCopyStrBuf< C4InVal::VAL_Comment > Comment
Definition: C4Config.h:146
char WorkPath[CFG_MaxString+1]
Definition: C4Config.h:145
bool GetLeagueLoginData(const char *server_name, const char *player_name, StdStrBuf *account, StdStrBuf *login_token) const
Definition: C4Config.cpp:712
int32_t MasterServerSignUp
Definition: C4Config.h:147
const char * GetModDatabaseServerAddress()
Definition: C4Config.cpp:675
int32_t MasterKeepPeriod
Definition: C4Config.h:149
int32_t MasterReferencePeriod
Definition: C4Config.h:150
StdCopyStrBuf LastLeagueServer
Definition: C4Config.h:161
int32_t MaxResSearchRecursion
Definition: C4Config.h:144
int32_t PortUDP
Definition: C4Config.h:153
StdCopyStrBuf LastLeagueLoginToken
Definition: C4Config.h:161
void CheckPortsForCollisions()
Definition: C4Config.cpp:685
int32_t MaxLoadFileSize
Definition: C4Config.h:157
const char * GetLeagueServerAddress()
Definition: C4Config.cpp:661
char AlternateModDatabaseServerAddress[CFG_MaxString+1]
Definition: C4Config.h:164
int32_t NoReferenceRequest
Definition: C4Config.h:143
char LastPassword[CFG_MaxString+1]
Definition: C4Config.h:158
int32_t ControlPreSend
Definition: C4Config.h:140
int32_t ControlRate
Definition: C4Config.h:139
void SetLeagueLoginData(const char *server_name, const char *player_name, const char *account, const char *login_token)
Definition: C4Config.cpp:702
int32_t PacketLogging
Definition: C4Config.h:171
int32_t EnableUPnP
Definition: C4Config.h:154
char PuncherAddress[CFG_MaxString+1]
Definition: C4Config.h:160
int32_t LeagueServerSignUp
Definition: C4Config.h:151
int32_t PortRefServer
Definition: C4Config.h:153
StdCopyStrBuf LastLeagueAccount
Definition: C4Config.h:161
int32_t PortDiscovery
Definition: C4Config.h:153
int32_t UseAlternateServer
Definition: C4Config.h:152
char AlternateServerAddress[CFG_MaxString+1]
Definition: C4Config.h:159
int32_t NoRuntimeJoin
Definition: C4Config.h:142
StdCopyStrBuf LastLeaguePlayerName
Definition: C4Config.h:161
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Nick
Definition: C4Config.h:156
int32_t PortTCP
Definition: C4Config.h:153
int32_t ControlMode
Definition: C4Config.h:155
int32_t Lobby
Definition: C4Config.h:141
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:219
char KeyPath[CFG_MaxString+1]
Definition: C4Config.h:244
int32_t WasRegistered
Definition: C4Config.h:245
int32_t RXSound
Definition: C4Config.h:126
int32_t FEMusic
Definition: C4Config.h:128
int32_t FESamples
Definition: C4Config.h:129
int32_t Verbose
Definition: C4Config.h:130
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:148
int32_t SoundVolume
Definition: C4Config.h:132
int32_t MusicVolume
Definition: C4Config.h:131
int32_t RXMusic
Definition: C4Config.h:127
int32_t HideMsgStartDedicated
Definition: C4Config.h:188
int32_t HideMsgGfxBitDepthChange
Definition: C4Config.h:186
int32_t HideMsgIRCDangerous
Definition: C4Config.h:192
int32_t HideMsgPlrNoTakeOver
Definition: C4Config.h:190
int32_t AlphabeticalSorting
Definition: C4Config.h:193
int32_t LastPortraitFolderIdx
Definition: C4Config.h:194
int32_t HideMsgNoOfficialLeague
Definition: C4Config.h:191
int32_t HideMsgPlrTakeOver
Definition: C4Config.h:189
void CompileFunc(StdCompiler *compiler)
Definition: C4Config.cpp:836
int32_t HideMsgMMTimerChange
Definition: C4Config.h:187
int32_t HideMsgGfxEngineChange
Definition: C4Config.h:185
bool Close(StdBuf **ppMemory=nullptr)
Definition: CStdFile.cpp:151
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false)
Definition: CStdFile.cpp:49
bool WriteString(const char *szStr)
Definition: CStdFile.cpp:264
void Decompile(const T &rStruct)
Definition: StdCompiler.h:178
virtual bool Default(const char *szName)
Definition: StdCompiler.h:88
void Value(const T &rStruct)
Definition: StdCompiler.h:161
bool isSerializer()
Definition: StdCompiler.h:54
void Compile(T &&rStruct)
Definition: StdCompiler.h:173
void setInput(const InT &In)
Definition: StdCompiler.h:630
void SetLength(size_t iLength)
Definition: StdBuf.h:509
void Ref(const char *pnData)
Definition: StdBuf.h:455
const char * getData() const
Definition: StdBuf.h:442
char * getMData()
Definition: StdBuf.h:443
void AppendBackslash()
Definition: StdBuf.cpp:248
bool isNull() const
Definition: StdBuf.h:441
void Copy()
Definition: StdBuf.h:467
bool LoadFromFile(const char *szFile)
Definition: StdBuf.cpp:73
bool SaveToFile(const char *szFile) const
Definition: StdBuf.cpp:94
void Clear()
Definition: StdBuf.h:466
size_t getLength() const
Definition: StdBuf.h:445
void Take(char *pnData)
Definition: StdBuf.h:457
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174