OpenClonk
C4Config Class Reference

#include <C4Config.h>

Collaboration diagram for C4Config:
[legend]

Public Member Functions

 C4Config ()
 
 ~C4Config ()
 
const char * GetSubkeyPath (const char *subkey)
 
void Default ()
 
bool Save ()
 
bool Load (const char *config_file=nullptr)
 
bool Init ()
 
bool Registered ()
 
const char * AtExePath (const char *filename)
 
const char * AtTempPath (const char *filename)
 
const char * AtTempUpdatePath (const char *filename)
 
const char * AtNetworkPath (const char *filename)
 
const char * AtScreenshotPath (const char *filename)
 
const char * AtUserDataPath (const char *filename)
 
const char * AtUserDataRelativePath (const char *filename)
 
const char * AtSystemDataPath (const char *filename)
 
const char * AtSystemDataRelativePath (const char *filename)
 
const char * AtRelativePath (const char *filename)
 
const char * GetRegistrationData (const char *field)
 
void ForceRelativePath (StdStrBuf *filename)
 
void CompileFunc (StdCompiler *compiler)
 
bool IsCorrupted ()
 
bool RemoveModule (const char *path, char *modules)
 
bool IsModule (const char *path, char *modules)
 
bool AddModule (const char *path, char *modules)
 
void GetConfigFileName (StdStrBuf &filename, const char *config_file)
 
void CleanupTempUpdateFolder ()
 
const char * MakeTempUpdateFolder ()
 

Static Public Member Functions

static void ExpandEnvironmentVariables (char *path, size_t max_length)
 

Public Attributes

C4ConfigGeneral General
 
C4ConfigDeveloper Developer
 
C4ConfigGraphics Graphics
 
C4ConfigSound Sound
 
C4ConfigNetwork Network
 
C4ConfigLobby Lobby
 
C4ConfigIRC IRC
 
C4ConfigGamepad Gamepads [C4ConfigMaxGamepads]
 
C4ConfigControls Controls
 
C4ConfigStartup Startup
 
C4ConfigSecurity Security
 
bool ConfigLoaded
 
StdStrBuf ConfigFilename
 

Detailed Description

Definition at line 249 of file C4Config.h.

Constructor & Destructor Documentation

◆ C4Config()

C4Config::C4Config ( )
default

Definition at line 286 of file C4Config.cpp.

287 {
288  Default();
289 }
void Default()
Definition: C4Config.cpp:296

References Default().

Here is the call graph for this function:

◆ ~C4Config()

C4Config::~C4Config ( )
default

Definition at line 291 of file C4Config.cpp.

292 {
293  ConfigLoaded = false;
294 }
bool ConfigLoaded
Definition: C4Config.h:266

References ConfigLoaded.

Member Function Documentation

◆ AddModule()

bool C4Config::AddModule ( const char *  path,
char *  modules 
)

Definition at line 868 of file C4Config.cpp.

869 {
870  return SAddModule(modules,path);
871 }
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:563

References SAddModule().

Here is the call graph for this function:

◆ AtExePath()

const char * C4Config::AtExePath ( const char *  filename)

Definition at line 579 of file C4Config.cpp.

580 {
581  SCopy(General.ExePath.getData(), AtPathFilename, _MAX_PATH);
582  SAppend(filename, AtPathFilename, _MAX_PATH);
583  return AtPathFilename;
584 }
#define _MAX_PATH
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
StdCopyStrBuf ExePath
Definition: C4Config.h:54
C4ConfigGeneral General
Definition: C4Config.h:255
const char * getData() const
Definition: StdBuf.h:442

References C4ConfigGeneral::ExePath, General, StdStrBuf::getData(), and SCopy().

Here is the call graph for this function:

◆ AtNetworkPath()

const char * C4Config::AtNetworkPath ( const char *  filename)

Definition at line 607 of file C4Config.cpp.

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 }
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:56
C4ConfigNetwork Network
Definition: C4Config.h:259
char WorkPath[CFG_MaxString+1]
Definition: C4Config.h:145

References General, SCopy(), and C4ConfigGeneral::UserDataPath.

Referenced by C4Network2::CreateDynamic(), C4Network2ResList::CreateNetworkFolder(), and C4Network2ResList::FindTempResFileName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtRelativePath()

const char * C4Config::AtRelativePath ( const char *  filename)

Definition at line 741 of file C4Config.cpp.

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 }
const char * GetRelativePathS(const char *strPath, const char *strRelativeTo)
Definition: StdFile.cpp:208
char SystemDataPath[CFG_MaxString+1]
Definition: C4Config.h:58

References General, GetRelativePathS(), C4ConfigGeneral::SystemDataPath, and C4ConfigGeneral::UserDataPath.

Referenced by C4ComponentHost::CopyFilePathFromGroup(), C4DefList::GetByPath(), C4Language::GetPackGroups(), C4GameLobby::MainDlg::OnClientAddPlayer(), C4StartupPlrPropertiesDlg::OnClosed(), C4StartupMainDlg::OnPlayerSelContextAdd(), C4StartupMainDlg::OnShown(), C4Shader::Refresh(), C4Game::ReloadFile(), C4Player::Save(), C4Network2Res::SetByFile(), C4Network2Res::SetByGroup(), and C4GameSave::WriteDescDefinitions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtScreenshotPath()

const char * C4Config::AtScreenshotPath ( const char *  filename)

Definition at line 615 of file C4Config.cpp.

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 }
#define DirectorySeparator
size_t SLen(const char *sptr)
Definition: Standard.h:74
void AppendBackslash(char *szFilename)
Definition: StdFile.cpp:254
bool CreatePath(const std::string &path)
Definition: StdFile.cpp:656
char ScreenshotPath[CFG_MaxString+1]
Definition: C4Config.h:59

References General, SCopy(), and C4ConfigGeneral::ScreenshotPath.

Referenced by C4GraphicsSystem::SaveScreenshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtSystemDataPath()

const char * C4Config::AtSystemDataPath ( const char *  filename)

Definition at line 593 of file C4Config.cpp.

594 {
595  SCopy(General.SystemDataPath, AtPathFilename, _MAX_PATH);
596  SAppend(filename, AtPathFilename, _MAX_PATH);
597  return AtPathFilename;
598 }

References General, SCopy(), and C4ConfigGeneral::SystemDataPath.

Referenced by C4MusicSystem::Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtSystemDataRelativePath()

const char * C4Config::AtSystemDataRelativePath ( const char *  filename)

Definition at line 735 of file C4Config.cpp.

736 {
737  // Specified file is located in SystemDataPath: return relative path
738  return GetRelativePathS(filename, General.SystemDataPath);
739 }

References General, GetRelativePathS(), and C4ConfigGeneral::SystemDataPath.

Here is the call graph for this function:

◆ AtTempPath()

const char * C4Config::AtTempPath ( const char *  filename)

Definition at line 600 of file C4Config.cpp.

601 {
602  SCopy(General.TempPath.getData(),AtPathFilename,_MAX_PATH);
603  SAppend(filename,AtPathFilename,_MAX_PATH);
604  return AtPathFilename;
605 }
StdCopyStrBuf TempPath
Definition: C4Config.h:55

References General, StdStrBuf::getData(), SCopy(), and C4ConfigGeneral::TempPath.

Referenced by C4ControlJoinPlayer::C4ControlJoinPlayer(), C4ControlReInitScenario::C4ControlReInitScenario(), C4StartupNetDlg::DoOK(), C4ScenarioSection::EnsureTempStore(), C4MusicFile::ExtractFile(), MakeTempUpdateFolder(), C4MusicFileSDL::Play(), C4PlayerInfoList::RecreatePlayerFiles(), C4MusicFile::RemTempFile(), C4Player::Save(), C4PXSSystem::Save(), C4PlayerList::Save(), C4Landscape::P::SaveDiffInternal(), C4Game::SaveGameTitle(), C4Landscape::P::SaveInternal(), C4Landscape::SaveMap(), C4Landscape::SaveTextures(), and C4ControlJoinPlayer::Strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtTempUpdatePath()

const char * C4Config::AtTempUpdatePath ( const char *  filename)

Definition at line 922 of file C4Config.cpp.

923 {
924  SCopy(General.TempUpdatePath,AtPathFilename,_MAX_PATH-1);
925  AppendBackslash(AtPathFilename);
926  SAppend(filename,AtPathFilename,_MAX_PATH);
927  return AtPathFilename;
928 }
char TempUpdatePath[CFG_MaxString+1]
Definition: C4Config.h:60

References General, SCopy(), and C4ConfigGeneral::TempUpdatePath.

Here is the call graph for this function:

◆ AtUserDataPath()

const char * C4Config::AtUserDataPath ( const char *  filename)

Definition at line 586 of file C4Config.cpp.

587 {
588  SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH);
589  SAppend(filename, AtPathFilename, _MAX_PATH);
590  return AtPathFilename;
591 }

References General, SCopy(), and C4ConfigGeneral::UserDataPath.

Referenced by C4MainMenu::ActivateSavegame(), C4StartupPlrSelDlg::CheckPlayerName(), C4MusicSystem::Init(), C4Player::Init(), C4StartupPlrSelDlg::PlayerListItem::Load(), C4MusicSystem::LoadMoreMusic(), C4StartupPlrPropertiesDlg::OnClosed(), OpenExtraLogs(), OpenLog(), C4MessageInput::ProcessCommand(), C4Game::QuickSave(), C4Record::Start(), and C4StartupPlrSelDlg::PlayerListItem::UpdateCore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AtUserDataRelativePath()

const char * C4Config::AtUserDataRelativePath ( const char *  filename)

Definition at line 729 of file C4Config.cpp.

730 {
731  // Specified file is located in UserDataPath: return relative path
732  return GetRelativePathS(filename, General.UserDataPath);
733 }

References General, GetRelativePathS(), and C4ConfigGeneral::UserDataPath.

Referenced by C4GraphicsSystem::SaveScreenshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CleanupTempUpdateFolder()

void C4Config::CleanupTempUpdateFolder ( )

Definition at line 901 of file C4Config.cpp.

902 {
903  // Get rid of update path present from before update
904  if (*General.TempUpdatePath)
905  {
907  *General.TempUpdatePath = '\0';
908  }
909 }
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:833

References EraseItem(), General, and C4ConfigGeneral::TempUpdatePath.

Referenced by C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void C4Config::CompileFunc ( StdCompiler compiler)

Definition at line 850 of file C4Config.cpp.

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 }
const int C4ConfigMaxGamepads
Definition: C4Config.h:217
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4ConfigStartup Startup
Definition: C4Config.h:264
C4ConfigIRC IRC
Definition: C4Config.h:261
C4ConfigGamepad Gamepads[C4ConfigMaxGamepads]
Definition: C4Config.h:262
C4ConfigSecurity Security
Definition: C4Config.h:265
C4ConfigLobby Lobby
Definition: C4Config.h:260
C4ConfigControls Controls
Definition: C4Config.h:263
C4ConfigDeveloper Developer
Definition: C4Config.h:256
C4ConfigGraphics Graphics
Definition: C4Config.h:257
C4ConfigSound Sound
Definition: C4Config.h:258
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References C4ConfigMaxGamepads, Controls, Developer, FormatString(), Gamepads, General, Graphics, IRC, Lobby, mkNamingAdapt(), Network, Security, Sound, Startup, and StdCompiler::Value().

Here is the call graph for this function:

◆ Default()

void C4Config::Default ( )

Definition at line 296 of file C4Config.cpp.

297 {
298  // force default values
299  StdCompilerNull Comp; Comp.Compile(*this);
300  ConfigLoaded = false;
301 }
void Compile(T &&rStruct)
Definition: StdCompiler.h:173

References StdCompiler::Compile(), and ConfigLoaded.

Referenced by C4Config(), and C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExpandEnvironmentVariables()

void C4Config::ExpandEnvironmentVariables ( char *  path,
size_t  max_length 
)
static

Definition at line 883 of file C4Config.cpp.

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 }
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
#define _MAX_PATH_LEN
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:369

References _MAX_PATH, _MAX_PATH_LEN, StdStrBuf::getData(), StdStrBuf::getLength(), GetWideChar(), SCopy(), SLen(), and SSearch().

Referenced by C4ConfigGeneral::DeterminePaths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ForceRelativePath()

void C4Config::ForceRelativePath ( StdStrBuf filename)

Definition at line 751 of file C4Config.cpp.

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 }
const char * GetC4Filename(const char *szPath)
Definition: StdFile.cpp:68
bool IsGlobalPath(const char *szPath)
Definition: StdFile.cpp:224
void Copy()
Definition: StdBuf.h:467
void Take(char *pnData)
Definition: StdBuf.h:457

References StdStrBuf::Copy(), General, GetC4Filename(), StdStrBuf::getData(), GetRelativePathS(), IsGlobalPath(), C4ConfigGeneral::SystemDataPath, and StdStrBuf::Take().

Here is the call graph for this function:

◆ GetConfigFileName()

void C4Config::GetConfigFileName ( StdStrBuf filename,
const char *  config_file 
)

Definition at line 303 of file C4Config.cpp.

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 }
void Ref(const char *pnData)
Definition: StdBuf.h:455

References StdStrBuf::Copy(), and StdStrBuf::Ref().

Referenced by Load(), and Save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRegistrationData()

const char* C4Config::GetRegistrationData ( const char *  field)
inline

Definition at line 285 of file C4Config.h.

285 { return ""; }

Referenced by C4ClientPlayerInfos::C4ClientPlayerInfos(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupOptionsDlg::SaveConfig(), and C4ClientCore::SetLocal().

Here is the caller graph for this function:

◆ GetSubkeyPath()

const char * C4Config::GetSubkeyPath ( const char *  subkey)

Definition at line 806 of file C4Config.cpp.

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 }
#define sprintf
Definition: Standard.h:162

References sprintf.

Referenced by ConsoleDlgProc(), C4GUI::DialogWindow::Init(), C4ViewportWindow::Init(), C4Game::PreInit(), and PropertyDlgProc().

Here is the caller graph for this function:

◆ Init()

bool C4Config::Init ( )

Definition at line 801 of file C4Config.cpp.

802 {
803  return true;
804 }

Referenced by C4Application::DoInit().

Here is the caller graph for this function:

◆ IsCorrupted()

bool C4Config::IsCorrupted ( )
inline

Definition at line 288 of file C4Config.h.

References C4ConfigGeneral::ConfigResetSafety, C4ConfigGeneral::ConfigResetSafetyVal, General, Graphics, and C4ConfigGraphics::ResX.

Referenced by C4Application::DoInit().

Here is the caller graph for this function:

◆ IsModule()

bool C4Config::IsModule ( const char *  path,
char *  modules 
)

Definition at line 873 of file C4Config.cpp.

874 {
875  return SIsModule(modules,path);
876 }
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
Definition: Standard.cpp:547

References SIsModule().

Here is the call graph for this function:

◆ Load()

bool C4Config::Load ( const char *  config_file = nullptr)

Definition at line 327 of file C4Config.cpp.

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 }
C4Config Config
Definition: C4Config.cpp:930
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
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
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
void DeterminePaths()
Definition: C4Config.cpp:469
void DefaultLanguage()
Definition: C4Config.cpp:774
void GetConfigFileName(StdStrBuf &filename, const char *config_file)
Definition: C4Config.cpp:303
StdStrBuf ConfigFilename
Definition: C4Config.h:267
int32_t PortUDP
Definition: C4Config.h:153
int32_t PortRefServer
Definition: C4Config.h:153
int32_t PortDiscovery
Definition: C4Config.h:153
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Nick
Definition: C4Config.h:156
int32_t PortTCP
Definition: C4Config.h:153
void setInput(const InT &In)
Definition: StdCompiler.h:630
bool isNull() const
Definition: StdBuf.h:441
bool LoadFromFile(const char *szFile)
Definition: StdBuf.cpp:73
void Clear()
Definition: StdBuf.h:466

References C4NetStdPortDiscovery, C4NetStdPortRefServer, StdStrBuf::Clear(), StdCompiler::Compile(), Config, ConfigFilename, ConfigLoaded, StdStrBuf::Copy(), CreatePath(), C4ConfigGeneral::DefaultLanguage(), C4ConfigGeneral::DeterminePaths(), General, GetConfigFileName(), StdStrBuf::getData(), StdStrBuf::isNull(), StdStrBuf::LoadFromFile(), Log(), LogF(), StdCompiler::Exception::Msg, Network, C4ConfigNetwork::Nick, C4ConfigNetwork::PortDiscovery, C4ConfigNetwork::PortRefServer, C4ConfigNetwork::PortTCP, C4ConfigNetwork::PortUDP, StdStrBuf::Ref(), SEqual(), and StdCompilerINIRead::setInput().

Referenced by C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeTempUpdateFolder()

const char * C4Config::MakeTempUpdateFolder ( )

Definition at line 911 of file C4Config.cpp.

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 }
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:320
const char * AtTempPath(const char *filename)
Definition: C4Config.cpp:600

References AtTempPath(), StdStrBuf::Copy(), CreatePath(), General, StdStrBuf::getData(), MakeTempFilename(), SCopy(), and C4ConfigGeneral::TempUpdatePath.

Here is the call graph for this function:

◆ Registered()

bool C4Config::Registered ( )

Definition at line 795 of file C4Config.cpp.

796 {
797  // Dummy function: to be overloaded in C4Config
798  return true;
799 }

◆ RemoveModule()

bool C4Config::RemoveModule ( const char *  path,
char *  modules 
)

Definition at line 878 of file C4Config.cpp.

879 {
880  return SRemoveModule(modules,path);
881 }
bool SRemoveModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:588

References SRemoveModule().

Here is the call graph for this function:

◆ Save()

bool C4Config::Save ( )

Definition at line 439 of file C4Config.cpp.

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 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Decompile(const T &rStruct)
Definition: StdCompiler.h:178
bool SaveToFile(const char *szFile) const
Definition: StdBuf.cpp:94
size_t getLength() const
Definition: StdBuf.h:445

References ConfigFilename, StdCompiler::Decompile(), GetConfigFileName(), StdStrBuf::getData(), StdStrBuf::getLength(), StdCompilerINIWrite::getOutput(), LoadResStr(), LogF(), StdCompiler::Exception::Msg, and StdStrBuf::SaveToFile().

Referenced by C4Game::DoGameOver(), C4Application::DoInit(), C4Application::Quit(), and C4StartupOptionsDlg::SaveConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ConfigFilename

StdStrBuf C4Config::ConfigFilename

Definition at line 267 of file C4Config.h.

Referenced by Load(), and Save().

◆ ConfigLoaded

bool C4Config::ConfigLoaded

Definition at line 266 of file C4Config.h.

Referenced by Default(), Load(), C4Application::Quit(), and ~C4Config().

◆ Controls

◆ Developer

◆ Gamepads

C4ConfigGamepad C4Config::Gamepads[C4ConfigMaxGamepads]

Definition at line 262 of file C4Config.h.

Referenced by CompileFunc().

◆ General

C4ConfigGeneral C4Config::General

Definition at line 255 of file C4Config.h.

Referenced by C4Landscape::_SetPix2(), C4MainMenu::ActivateDisplay(), C4MainMenu::ActivateNewPlayer(), C4LSectors::Add(), C4Viewport::AdjustPosition(), C4Object::AssignRemoval(), AtExePath(), AtNetworkPath(), AtRelativePath(), AtScreenshotPath(), AtSystemDataPath(), AtSystemDataRelativePath(), AtTempPath(), AtTempUpdatePath(), AtUserDataPath(), AtUserDataRelativePath(), C4PortraitSelDlg::C4PortraitSelDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4ScenarioListLoader::Scenario::CanOpen(), C4MassMover::Cease(), C4Playback::Check(), C4MCOverlay::CheckMask(), C4StartupPlrSelDlg::CheckPlayerName(), CleanupTempUpdateFolder(), C4Playback::Clear(), CompileFunc(), C4MassMoverSet::Create(), C4ScenarioListLoader::Entry::CreateEntryForFile(), C4MapFolderData::CreateGUIElements(), C4ConfigGeneral::CreateSaveFolder(), C4GameControl::DbgRec(), C4PXS::Deactivate(), C4AulExec::DirectExec(), C4Application::DoInit(), C4ScenarioListLoader::SubFolder::DoLoadContents(), C4Landscape::P::DoScan(), C4UpperBoard::Draw(), C4Game::DropFile(), C4Game::ExecObjects(), C4Game::Execute(), C4PXS::Execute(), C4Object::Execute(), C4Playback::ExecuteControl(), C4PlayerControl::ExecuteControlPacket(), C4Landscape::P::ExecuteScan(), ForceRelativePath(), C4Game::GetTranslatedString(), C4Reloc::Init(), C4Game::Init(), C4Player::InitControl(), C4Game::InitDefs(), C4GraphicsResource::InitFonts(), C4StartupGraphics::InitFonts(), C4Game::InitScriptEngine(), IsCorrupted(), C4StartupScenSelDlg::KeyCheat2(), C4MapFolderData::Load(), C4DefList::Load(), C4ScenarioListLoader::Entry::Load(), Load(), C4Game::LoadAdditionalSystemGroup(), C4ScenarioListLoader::Scenario::LoadCustomPre(), MakeTempUpdateFolder(), C4MainMenu::MenuCommand(), C4StartupPlrSelDlg::PlayerListItem::MoveFilename(), C4Game::NewObject(), C4StartupNetDlg::OnBtnRecord(), C4GameOptionButtons::OnBtnRecord(), C4StartupPlrPropertiesDlg::OnClosed(), C4StartupPlrSelDlg::OnDelBtnConfirm(), C4StartupMainDlg::OnPlayerSelContextAdd(), C4StartupMainDlg::OnPlayerSelContextAddPlr(), C4StartupMainDlg::OnPlayerSelContextRemove(), C4StartupMainDlg::OnPlayerSelContextRemovePlr(), C4StartupMainDlg::OnShown(), C4Playback::Open(), C4Game::OpenScenario(), C4Application::ParseCommandLine(), C4Application::PreInit(), C4MessageInput::ProcessCommand(), C4HTTPClient::Query(), C4Game::QuickSave(), RecordRandom(), C4Game::ReloadDef(), C4Game::ReloadFile(), C4LSectors::Remove(), C4GameControl::RequestRuntimeRecord(), RestartApplication(), C4Shape::Rotate(), C4GameSave::SaveDesc(), C4ScenarioSection::ScenarioLoad(), C4Network2Res::SetByCore(), C4Application::SetGameFont(), C4ClientCore::SetLocal(), C4Object::SetOCF(), C4ScenarioListLoader::Entry::SetTitleInGroup(), C4Record::Start(), C4Record::Stop(), C4LSectors::Update(), C4Game::UpdateLanguage(), C4Object::UpdateOCF(), and C4StartupMainDlg::UpdateParticipants().

◆ Graphics

◆ IRC

◆ Lobby

C4ConfigLobby C4Config::Lobby

◆ Network

◆ Security

C4ConfigSecurity C4Config::Security

Definition at line 265 of file C4Config.h.

Referenced by CompileFunc().

◆ Sound

◆ Startup


The documentation for this class was generated from the following files: