mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Port CConsole::Init() from the upstream code
Partial port of upstream commit c0bf37fb48
This commit is contained in:
parent
77b2b22dd2
commit
09c05ab99f
|
@ -4317,6 +4317,7 @@ int main(int argc, const char **argv) // ignore_convention
|
||||||
|
|
||||||
pEngine->Init();
|
pEngine->Init();
|
||||||
pConfig->Init();
|
pConfig->Init();
|
||||||
|
pConsole->Init();
|
||||||
pEngineMasterServer->Init();
|
pEngineMasterServer->Init();
|
||||||
pEngineMasterServer->Load();
|
pEngineMasterServer->Load();
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
|
typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
|
||||||
typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
|
typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||||
|
|
||||||
|
virtual void Init() = 0;
|
||||||
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int Flagmask) const = 0;
|
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int Flagmask) const = 0;
|
||||||
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp) = 0;
|
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp) = 0;
|
||||||
virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser) = 0;
|
virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser) = 0;
|
||||||
|
|
|
@ -3525,6 +3525,7 @@ int main(int argc, const char **argv) // ignore_convention
|
||||||
|
|
||||||
pEngine->Init();
|
pEngine->Init();
|
||||||
pConfig->Init();
|
pConfig->Init();
|
||||||
|
pConsole->Init();
|
||||||
pEngineMasterServer->Init();
|
pEngineMasterServer->Init();
|
||||||
pEngineMasterServer->Load();
|
pEngineMasterServer->Load();
|
||||||
|
|
||||||
|
|
|
@ -571,8 +571,6 @@ void CConsole::ExecuteFile(const char *pFilename, int ClientID, bool LogFailure,
|
||||||
if(str_comp(pFilename, pCur->m_pFilename) == 0)
|
if(str_comp(pFilename, pCur->m_pFilename) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!m_pStorage)
|
|
||||||
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
|
||||||
if(!m_pStorage)
|
if(!m_pStorage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -951,6 +949,30 @@ CConsole::CConsole(int FlagMask)
|
||||||
Register("access_status", "i[accesslevel]", CFGFLAG_SERVER, ConCommandStatus, this, "List all commands which are accessible for admin = 0, moderator = 1, helper = 2, all = 3");
|
Register("access_status", "i[accesslevel]", CFGFLAG_SERVER, ConCommandStatus, this, "List all commands which are accessible for admin = 0, moderator = 1, helper = 2, all = 3");
|
||||||
Register("cmdlist", "", CFGFLAG_SERVER | CFGFLAG_CHAT, ConUserCommandStatus, this, "List all commands which are accessible for users");
|
Register("cmdlist", "", CFGFLAG_SERVER | CFGFLAG_CHAT, ConUserCommandStatus, this, "List all commands which are accessible for users");
|
||||||
|
|
||||||
|
// DDRace
|
||||||
|
|
||||||
|
m_Cheated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CConsole::~CConsole()
|
||||||
|
{
|
||||||
|
CCommand *pCommand = m_pFirstCommand;
|
||||||
|
while(pCommand)
|
||||||
|
{
|
||||||
|
CCommand *pNext = pCommand->m_pNext;
|
||||||
|
if(pCommand->m_pfnCallback == Con_Chain)
|
||||||
|
delete static_cast<CChain *>(pCommand->m_pUserData);
|
||||||
|
// Temp commands are on m_TempCommands heap, so don't delete them
|
||||||
|
if(!pCommand->m_Temp)
|
||||||
|
delete pCommand;
|
||||||
|
pCommand = pNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CConsole::Init()
|
||||||
|
{
|
||||||
|
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
||||||
|
|
||||||
// TODO: this should disappear
|
// TODO: this should disappear
|
||||||
#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \
|
#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -977,25 +999,6 @@ CConsole::CConsole(int FlagMask)
|
||||||
#undef MACRO_CONFIG_INT
|
#undef MACRO_CONFIG_INT
|
||||||
#undef MACRO_CONFIG_COL
|
#undef MACRO_CONFIG_COL
|
||||||
#undef MACRO_CONFIG_STR
|
#undef MACRO_CONFIG_STR
|
||||||
|
|
||||||
// DDRace
|
|
||||||
|
|
||||||
m_Cheated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CConsole::~CConsole()
|
|
||||||
{
|
|
||||||
CCommand *pCommand = m_pFirstCommand;
|
|
||||||
while(pCommand)
|
|
||||||
{
|
|
||||||
CCommand *pNext = pCommand->m_pNext;
|
|
||||||
if(pCommand->m_pfnCallback == Con_Chain)
|
|
||||||
delete static_cast<CChain *>(pCommand->m_pUserData);
|
|
||||||
// Temp commands are on m_TempCommands heap, so don't delete them
|
|
||||||
if(!pCommand->m_Temp)
|
|
||||||
delete pCommand;
|
|
||||||
pCommand = pNext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConsole::ParseArguments(int NumArgs, const char **ppArguments)
|
void CConsole::ParseArguments(int NumArgs, const char **ppArguments)
|
||||||
|
|
|
@ -196,6 +196,7 @@ public:
|
||||||
CConsole(int FlagMask);
|
CConsole(int FlagMask);
|
||||||
~CConsole();
|
~CConsole();
|
||||||
|
|
||||||
|
virtual void Init();
|
||||||
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int FlagMask) const;
|
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int FlagMask) const;
|
||||||
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp);
|
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp);
|
||||||
virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser);
|
virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser);
|
||||||
|
|
|
@ -343,6 +343,7 @@ int main(int argc, const char **argv) // ignore_convention
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pConfig->Init();
|
pConfig->Init();
|
||||||
|
m_pConsole->Init();
|
||||||
m_NetBan.Init(m_pConsole, pStorage);
|
m_NetBan.Init(m_pConsole, pStorage);
|
||||||
if(argc > 1) // ignore_convention
|
if(argc > 1) // ignore_convention
|
||||||
m_pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention
|
m_pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention
|
||||||
|
|
Loading…
Reference in a new issue