2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2011-04-13 18:22:10 +00:00
|
|
|
#ifndef ENGINE_SHARED_CONFIG_H
|
|
|
|
#define ENGINE_SHARED_CONFIG_H
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2020-10-07 06:06:26 +00:00
|
|
|
#include <base/detect.h>
|
2021-01-10 12:47:07 +00:00
|
|
|
#include <engine/config.h>
|
2020-10-07 06:06:26 +00:00
|
|
|
|
2015-07-22 16:23:40 +00:00
|
|
|
#define CONFIG_FILE "settings_ddnet.cfg"
|
2015-08-12 11:49:16 +00:00
|
|
|
#define AUTOEXEC_FILE "autoexec.cfg"
|
|
|
|
#define AUTOEXEC_CLIENT_FILE "autoexec_client.cfg"
|
|
|
|
#define AUTOEXEC_SERVER_FILE "autoexec_server.cfg"
|
2015-07-22 16:23:40 +00:00
|
|
|
|
2021-01-10 12:47:07 +00:00
|
|
|
class CConfig
|
2011-04-13 18:37:12 +00:00
|
|
|
{
|
2021-01-10 12:47:07 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Save, Desc) int m_##Name;
|
|
|
|
#define MACRO_CONFIG_COL(Name, ScriptName, Def, Save, Desc) unsigned m_##Name;
|
|
|
|
#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Save, Desc) char m_##Name[Len]; // Flawfinder: ignore
|
|
|
|
#include "config_variables.h"
|
|
|
|
#undef MACRO_CONFIG_INT
|
|
|
|
#undef MACRO_CONFIG_COL
|
|
|
|
#undef MACRO_CONFIG_STR
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2021-01-10 12:47:07 +00:00
|
|
|
extern CConfig g_Config;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CFGFLAG_SAVE = 1 << 0,
|
|
|
|
CFGFLAG_CLIENT = 1 << 1,
|
|
|
|
CFGFLAG_SERVER = 1 << 2,
|
|
|
|
CFGFLAG_STORE = 1 << 3,
|
|
|
|
CFGFLAG_MASTER = 1 << 4,
|
|
|
|
CFGFLAG_ECON = 1 << 5,
|
2020-10-11 13:59:57 +00:00
|
|
|
// DDRace
|
2020-10-17 15:29:33 +00:00
|
|
|
|
2020-10-11 14:27:28 +00:00
|
|
|
CMDFLAG_TEST = 1 << 6,
|
2020-09-26 19:41:58 +00:00
|
|
|
CFGFLAG_CHAT = 1 << 7,
|
|
|
|
CFGFLAG_GAME = 1 << 8,
|
|
|
|
CFGFLAG_NONTEEHISTORIC = 1 << 9,
|
|
|
|
CFGFLAG_COLLIGHT = 1 << 10,
|
|
|
|
CFGFLAG_COLALPHA = 1 << 11,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2021-01-10 12:47:07 +00:00
|
|
|
class CConfigManager : public IConfigManager
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_CALLBACKS = 16
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CCallback
|
|
|
|
{
|
|
|
|
SAVECALLBACKFUNC m_pfnFunc;
|
|
|
|
void *m_pUserData;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IStorage *m_pStorage;
|
|
|
|
IOHANDLE m_ConfigFile;
|
|
|
|
bool m_Failed;
|
|
|
|
CCallback m_aCallbacks[MAX_CALLBACKS];
|
|
|
|
int m_NumCallbacks;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CConfigManager();
|
|
|
|
|
|
|
|
virtual void Init();
|
|
|
|
virtual void Reset();
|
2021-12-27 00:13:09 +00:00
|
|
|
virtual void Reset(const char *pScriptName);
|
2021-01-10 12:47:07 +00:00
|
|
|
virtual bool Save();
|
|
|
|
virtual CConfig *Values() { return &g_Config; }
|
|
|
|
|
|
|
|
virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData);
|
|
|
|
|
|
|
|
virtual void WriteLine(const char *pLine);
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#endif
|