23 #include "C4Version.h"
30 #ifdef HAVE_SYS_STAT_H
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h>
50 #define s mkStringAdaptM
99 if (!filename || !*filename)
105 int32_t move_down_num;
106 for (move_down_num = 0; move_down_num <
CFG_MaxEditorMRU - 1; ++move_down_num)
114 for (int32_t i = move_down_num; i > 0; --i)
188 #ifdef WITH_AUTOMATIC_UPDATE
189 compiler->
Value(
mkNamingAdapt(
s(UpdateServerAddress),
"UpdateServerAddress",
"https://www.openclonk.org/update/"));
224 #elif defined(__linux__)
226 #elif defined(__APPLE__)
236 for (
int i = 0; i < 6; ++i)
308 filename.
Ref(config_file);
320 filename +=
"Library/Preferences/" C4ENGINEID
".config";
322 filename +=
".clonk/" C4ENGINENICK
"/config";
335 StdCompilerConfigRead CfgRead(HKEY_CURRENT_USER,
"Software\\" C4CFG_Company
"\\" C4ENGINENAME);
336 CfgRead.Compile(*
this);
360 filename +=
".clonk/" C4ENGINENICK;
387 bool fWinSock = !WSAStartup(WINSOCK_VERSION, &wsadata);
391 char LocalName[25+1];
393 gethostname(LocalName, 25);
409 Log(
"Warning: Network TCP port and reference server port both set to same value - increasing reference server port!");
418 Log(
"Warning: Network UDP port and LAN game discovery port both set to same value - increasing discovery port!");
447 StdCompilerConfigWrite CfgWrite(HKEY_CURRENT_USER,
"Software\\" C4CFG_Company
"\\" C4ENGINENAME);
448 CfgWrite.Decompile(*
this);
489 #elif defined(PROC_SELF_EXE)
502 const char * t = getenv(
"TMPDIR");
523 #elif defined(__APPLE__)
525 #elif defined(WITH_AUTOMATIC_UPDATE) && defined(WITH_APPDIR_INSTALLATION)
529 #elif defined(WITH_AUTOMATIC_UPDATE)
534 #elif defined(OC_SYSTEM_DATA_DIR)
537 #error Please define OC_SYSTEM_DATA_DIR!
550 #elif defined(__APPLE__)
583 return AtPathFilename;
590 return AtPathFilename;
597 return AtPathFilename;
604 return AtPathFilename;
612 return AtPathFilename;
619 if ((len =
SLen(AtPathFilename)))
623 AtPathFilename[len-1] =
'\0';
632 return AtPathFilename;
646 StdStrBuf title_data; title_data.
Format(
"%s:%s", language, language_title);
671 return "https://league.openclonk.org/league.php";
682 return "https://mods.openclonk.org/api/";
690 LogSilentF(
"Network: TCP Port collision, setting defaults");
696 LogSilentF(
"Network: UDP Port collision, setting defaults");
744 if (path == filename)
756 if (relative != filename->
getData())
760 filename->
Take(std::move(temp));
769 filename->
Take(std::move(temp));
808 static char key[1024 + 1];
810 sprintf(key, R
"(Software\%s\%s\%s)", C4CFG_Company, C4ENGINENAME, subkey);
823 char language[2 + 1];
824 for (
int i = 0;
SCopySegment(source, i, language,
',', 2,
true); i++)
892 if (home && (rest =
const_cast<char *
>(
SSearch(path,
"$HOME"))) && (std::strlen(path) - 5 + home.
getLength() <= max_length))
927 return AtPathFilename;
#define C4DEFAULT_FONT_NAME
const int C4ConfigMaxGamepads
C4Application Application
const char * LoadResStr(const char *id)
bool Log(const char *szMessage)
bool LogSilentF(const char *strMessage,...)
bool LogF(const char *strMessage,...)
const int16_t C4NetStdPortRefServer
const int16_t C4NetStdPortDiscovery
const int16_t C4NetStdPortUDP
const int16_t C4NetStdPortTCP
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
const char * SSearch(const char *szString, const char *szIndex)
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
bool SRemoveModule(char *szList, const char *szModule, bool fCaseSensitive)
void SAppendChar(char cChar, char *szStr)
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
void SAppend(const char *szSource, char *szTarget, int iMaxL)
bool SEqual(const char *szStr1, const char *szStr2)
size_t SLen(const char *sptr)
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
StdStrBuf FormatString(const char *szFmt,...)
bool EraseItem(const char *szItemName)
const char * GetC4Filename(const char *szPath)
const char * GetRelativePathS(const char *strPath, const char *strRelativeTo)
bool TruncatePath(char *szPath)
bool GetParentPath(const char *szFilename, char *szBuffer)
void MakeTempFilename(char *szFilename)
void AppendBackslash(char *szFilename)
bool IsGlobalPath(const char *szPath)
bool CreatePath(const std::string &path)
const char * GetWorkingDirectory()
bool FileExists(const char *szFileName)
C4PlayerControlAssignmentSets UserSets
int32_t GamepadGuiControl
void CompileFunc(StdCompiler *compiler)
char RecentlyEditedSzenarios[CFG_MaxEditorMRU][CFG_MaxString+1]
void CompileFunc(StdCompiler *compiler)
char AltTodoFilename[CFG_MaxString+1]
void AddRecentlyEditedScenario(const char *filename)
char TodoFilename[CFG_MaxString+1]
int32_t DebugShapeTextures
void CompileFunc(StdCompiler *compiler, bool buttons_only=false)
char Participants[CFG_MaxString+1]
char ConfigUserPath[CFG_MaxString+1]
char SystemDataPath[CFG_MaxString+1]
char Name[CFG_MaxString+1]
StdStrBuf ScreenshotFolder
char LanguageEx[CFG_MaxString+1]
char Language[CFG_MaxString+1]
char UserDataPath[CFG_MaxString+1]
void CompileFunc(StdCompiler *compiler)
int32_t OpenScenarioInGameMode
char TempUpdatePath[CFG_MaxString+1]
int32_t ConfigResetSafety
char ModsDataPath[CFG_MaxString+1]
char MissionAccess[CFG_MaxString+1]
char RXFontName[CFG_MaxString+1]
bool CreateSaveFolder(const char *directory, const char *language_title)
char ScreenshotPath[CFG_MaxString+1]
static int GetLanguageSequence(const char *source, char *target)
int32_t VerboseObjectLoading
int32_t SplitscreenDividers
void CompileFunc(StdCompiler *compiler)
int32_t ShowStartupMessages
const char * AtSystemDataRelativePath(const char *filename)
const char * AtSystemDataPath(const char *filename)
void ForceRelativePath(StdStrBuf *filename)
bool AddModule(const char *path, char *modules)
const char * AtRelativePath(const char *filename)
bool IsModule(const char *path, char *modules)
const char * AtExePath(const char *filename)
void CleanupTempUpdateFolder()
bool RemoveModule(const char *path, char *modules)
const char * AtTempPath(const char *filename)
const char * AtUserDataPath(const char *filename)
C4ConfigGamepad Gamepads[C4ConfigMaxGamepads]
const char * MakeTempUpdateFolder()
const char * GetSubkeyPath(const char *subkey)
C4ConfigSecurity Security
const char * AtTempUpdatePath(const char *filename)
static void ExpandEnvironmentVariables(char *path, size_t max_length)
C4ConfigControls Controls
bool Load(const char *config_file=nullptr)
void GetConfigFileName(StdStrBuf &filename, const char *config_file)
const char * AtScreenshotPath(const char *filename)
const char * AtUserDataRelativePath(const char *filename)
const char * AtNetworkPath(const char *filename)
C4ConfigDeveloper Developer
C4ConfigGraphics Graphics
void CompileFunc(StdCompiler *compiler)
char Channel[CFG_MaxString+1]
void CompileFunc(StdCompiler *compiler)
char Nick[CFG_MaxString+1]
char RealName[CFG_MaxString+1]
char Server[CFG_MaxString+1]
void CompileFunc(StdCompiler *compiler)
int32_t MasterServerActive
int32_t UseAlternateModDatabaseServer
void CompileFunc(StdCompiler *compiler)
ValidatedStdCopyStrBuf< C4InVal::VAL_Comment > Comment
char WorkPath[CFG_MaxString+1]
bool GetLeagueLoginData(const char *server_name, const char *player_name, StdStrBuf *account, StdStrBuf *login_token) const
int32_t MasterServerSignUp
const char * GetModDatabaseServerAddress()
int32_t MasterReferencePeriod
StdCopyStrBuf LastLeagueServer
int32_t MaxResSearchRecursion
StdCopyStrBuf LastLeagueLoginToken
void CheckPortsForCollisions()
const char * GetLeagueServerAddress()
char AlternateModDatabaseServerAddress[CFG_MaxString+1]
int32_t NoReferenceRequest
char LastPassword[CFG_MaxString+1]
void SetLeagueLoginData(const char *server_name, const char *player_name, const char *account, const char *login_token)
char PuncherAddress[CFG_MaxString+1]
int32_t LeagueServerSignUp
StdCopyStrBuf LastLeagueAccount
int32_t UseAlternateServer
char AlternateServerAddress[CFG_MaxString+1]
StdCopyStrBuf LastLeaguePlayerName
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Nick
void CompileFunc(StdCompiler *compiler)
char KeyPath[CFG_MaxString+1]
void CompileFunc(StdCompiler *compiler)
int32_t HideMsgStartDedicated
int32_t HideMsgGfxBitDepthChange
int32_t HideMsgIRCDangerous
int32_t HideMsgPlrNoTakeOver
int32_t AlphabeticalSorting
int32_t LastPortraitFolderIdx
int32_t HideMsgNoOfficialLeague
int32_t HideMsgPlrTakeOver
void CompileFunc(StdCompiler *compiler)
int32_t HideMsgMMTimerChange
int32_t HideMsgGfxEngineChange
bool Close(StdBuf **ppMemory=nullptr)
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false)
bool WriteString(const char *szStr)
void Decompile(const T &rStruct)
virtual bool Default(const char *szName)
void Value(const T &rStruct)
void Compile(T &&rStruct)
void setInput(const InT &In)
void SetLength(size_t iLength)
void Ref(const char *pnData)
const char * getData() const
bool LoadFromFile(const char *szFile)
bool SaveToFile(const char *szFile) const
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O