mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6344
6344: Add `reset` command to server r=def- a=Robyt3 Move `reset` command from client to console, so it's also available on the server. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
08a1214397
|
@ -3540,12 +3540,6 @@ void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->Graphics()->TakeScreenshot(0);
|
||||
}
|
||||
|
||||
void CClient::Con_Reset(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CClient *pSelf = (CClient *)pUserData;
|
||||
pSelf->m_pConfigManager->Reset(pResult->GetString(0));
|
||||
}
|
||||
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
|
||||
void CClient::Con_StartVideo(IConsole::IResult *pResult, void *pUserData)
|
||||
|
@ -4378,7 +4372,6 @@ void CClient::RegisterCommands()
|
|||
m_pConsole->Register("disconnect", "", CFGFLAG_CLIENT, Con_Disconnect, this, "Disconnect from the server");
|
||||
m_pConsole->Register("ping", "", CFGFLAG_CLIENT, Con_Ping, this, "Ping the current server");
|
||||
m_pConsole->Register("screenshot", "", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Screenshot, this, "Take a screenshot");
|
||||
m_pConsole->Register("reset", "s[config-name]", CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Reset, this, "Reset a config its default value");
|
||||
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
m_pConsole->Register("start_video", "", CFGFLAG_CLIENT, Con_StartVideo, this, "Start recording a video");
|
||||
|
|
|
@ -439,7 +439,6 @@ public:
|
|||
static void Con_Minimize(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_Ping(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_Screenshot(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_Reset(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
static void StartVideo(IConsole::IResult *pResult, void *pUserData, const char *pVideoName);
|
||||
|
|
|
@ -660,6 +660,11 @@ void CConsole::Con_Exec(IResult *pResult, void *pUserData)
|
|||
((CConsole *)pUserData)->ExecuteFile(pResult->GetString(0), -1, true, IStorage::TYPE_ALL);
|
||||
}
|
||||
|
||||
void CConsole::Con_Reset(IResult *pResult, void *pUserData)
|
||||
{
|
||||
((CConsole *)pUserData)->ConfigManager()->Reset(pResult->GetString(0));
|
||||
}
|
||||
|
||||
void CConsole::ConCommandAccess(IResult *pResult, void *pUser)
|
||||
{
|
||||
CConsole *pConsole = static_cast<CConsole *>(pUser);
|
||||
|
@ -977,6 +982,7 @@ CConsole::CConsole(int FlagMask)
|
|||
// register some basic commands
|
||||
Register("echo", "r[text]", CFGFLAG_SERVER, Con_Echo, this, "Echo the text");
|
||||
Register("exec", "r[file]", CFGFLAG_SERVER | CFGFLAG_CLIENT, Con_Exec, this, "Execute the specified file");
|
||||
Register("reset", "s[config-name]", CFGFLAG_SERVER | CFGFLAG_CLIENT | CFGFLAG_STORE, Con_Reset, this, "Reset a config to its default value");
|
||||
|
||||
Register("toggle", "s[config-option] i[value 1] i[value 2]", CFGFLAG_SERVER | CFGFLAG_CLIENT, ConToggle, this, "Toggle config value");
|
||||
Register("+toggle", "s[config-option] i[value 1] i[value 2]", CFGFLAG_CLIENT, ConToggleStroke, this, "Toggle config value via keypress");
|
||||
|
@ -1017,7 +1023,8 @@ CConsole::~CConsole()
|
|||
|
||||
void CConsole::Init()
|
||||
{
|
||||
m_pConfig = Kernel()->RequestInterface<IConfigManager>()->Values();
|
||||
m_pConfigManager = Kernel()->RequestInterface<IConfigManager>();
|
||||
m_pConfig = m_pConfigManager->Values();
|
||||
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
||||
|
||||
// TODO: this should disappear
|
||||
|
|
|
@ -46,8 +46,9 @@ class CConsole : public IConsole
|
|||
};
|
||||
|
||||
CExecFile *m_pFirstExec;
|
||||
class CConfig *m_pConfig;
|
||||
class IStorage *m_pStorage;
|
||||
IConfigManager *m_pConfigManager;
|
||||
CConfig *m_pConfig;
|
||||
IStorage *m_pStorage;
|
||||
int m_AccessLevel;
|
||||
|
||||
CCommand *m_pRecycleList;
|
||||
|
@ -58,6 +59,7 @@ class CConsole : public IConsole
|
|||
static void Con_Chain(IResult *pResult, void *pUserData);
|
||||
static void Con_Echo(IResult *pResult, void *pUserData);
|
||||
static void Con_Exec(IResult *pResult, void *pUserData);
|
||||
static void Con_Reset(IResult *pResult, void *pUserData);
|
||||
static void ConToggle(IResult *pResult, void *pUser);
|
||||
static void ConToggleStroke(IResult *pResult, void *pUser);
|
||||
static void ConCommandAccess(IResult *pResult, void *pUser);
|
||||
|
@ -190,6 +192,7 @@ class CConsole : public IConsole
|
|||
CCommand *FindCommand(const char *pName, int FlagMask);
|
||||
|
||||
public:
|
||||
IConfigManager *ConfigManager() { return m_pConfigManager; }
|
||||
CConfig *Config() { return m_pConfig; }
|
||||
|
||||
CConsole(int FlagMask);
|
||||
|
|
Loading…
Reference in a new issue