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