diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 65e6fd2e5..4af835b5e 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -4251,6 +4251,13 @@ static bool UnknownArgumentCallback(const char *pCommand, void *pUser) return false; } +static bool SaveUnknownCommandCallback(const char *pCommand, void *pUser) +{ + CClient *pClient = static_cast(pUser); + pClient->ConfigManager()->StoreUnknownCommand(pCommand); + return true; +} + /* Server Time Client Mirror Time @@ -4478,6 +4485,7 @@ int main(int argc, const char **argv) // execute config file if(pStorage->FileExists(CONFIG_FILE, IStorage::TYPE_ALL)) { + pConsole->SetUnknownCommandCallback(SaveUnknownCommandCallback, pClient); if(!pConsole->ExecuteFile(CONFIG_FILE)) { const char *pError = "Failed to load config from '" CONFIG_FILE "'."; @@ -4486,6 +4494,7 @@ int main(int argc, const char **argv) PerformAllCleanup(); return -1; } + pConsole->SetUnknownCommandCallback(IConsole::EmptyUnknownCommandCallback, nullptr); } // execute autoexec file diff --git a/src/engine/config.h b/src/engine/config.h index cf37c3cb1..8155212b0 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -20,6 +20,8 @@ public: virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) = 0; virtual void WriteLine(const char *pLine) = 0; + + virtual void StoreUnknownCommand(const char *pCommand) = 0; }; extern IConfigManager *CreateConfigManager(); diff --git a/src/engine/shared/config.cpp b/src/engine/shared/config.cpp index 5f0df84bf..ce930d27f 100644 --- a/src/engine/shared/config.cpp +++ b/src/engine/shared/config.cpp @@ -110,6 +110,11 @@ bool CConfigManager::Save() for(int i = 0; i < m_NumCallbacks; i++) m_aCallbacks[i].m_pfnFunc(this, m_aCallbacks[i].m_pUserData); + for(const auto &Command : m_vUnknownCommands) + { + WriteLine(Command.c_str()); + } + if(io_sync(m_ConfigFile) != 0) { m_Failed = true; @@ -153,4 +158,9 @@ void CConfigManager::WriteLine(const char *pLine) } } +void CConfigManager::StoreUnknownCommand(const char *pCommand) +{ + m_vUnknownCommands.emplace_back(pCommand); +} + IConfigManager *CreateConfigManager() { return new CConfigManager; } diff --git a/src/engine/shared/config.h b/src/engine/shared/config.h index 5a7bbe574..63c640fb6 100644 --- a/src/engine/shared/config.h +++ b/src/engine/shared/config.h @@ -6,6 +6,9 @@ #include #include +#include +#include + // include protocol for MAX_CLIENT used in config_variables #include @@ -72,6 +75,8 @@ class CConfigManager : public IConfigManager CCallback m_aCallbacks[MAX_CALLBACKS]; int m_NumCallbacks; + std::vector m_vUnknownCommands; + public: CConfigManager(); @@ -84,6 +89,8 @@ public: void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) override; void WriteLine(const char *pLine) override; + + void StoreUnknownCommand(const char *pCommand) override; }; #endif