From 8f5e99397de8a09e04c7a09180073fd8f0585a0d Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Fri, 6 May 2005 09:44:41 +0000 Subject: [PATCH] Moved adding of FCVAR_GAMEDLL to Unload; added SourceHook iface/impl info to meta version --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4064 --- sourcemm/concommands.cpp | 17 ++++++++++++++++- sourcemm/concommands.h | 3 +++ sourcemm/sourcemm.cpp | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sourcemm/concommands.cpp b/sourcemm/concommands.cpp index b68794a..2602961 100644 --- a/sourcemm/concommands.cpp +++ b/sourcemm/concommands.cpp @@ -22,13 +22,27 @@ bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand) { // Add the FCVAR_GAMEDLL flag // => No crash on exit! - pCommand->AddFlags(FCVAR_GAMEDLL); + // UPDATE: Do _not_ add the FCVAR_GAMEDLL flag here, as it + // causes the command to be unusable on listenservers until you load a map + // We will set the FCVAR_GAMEDLL flag on all commands we have registered once we are being unloaded + //pCommand->AddFlags(FCVAR_GAMEDLL); + m_RegisteredCommands.push_back(pCommand); + pCommand->SetNext( NULL ); g_Engine.icvar->RegisterConCommandBase(pCommand); return true; } +void SMConVarAccessor::MarkCommandsAsGameDLL() +{ + for (std::list::iterator iter = m_RegisteredCommands.begin(); + iter != m_RegisteredCommands.end(); ++iter) + { + (*iter)->AddFlags(FCVAR_GAMEDLL); + } +} + ConVar metamod_version("metamod_version", SOURCEMM_VERSION, FCVAR_REPLICATED | FCVAR_SPONLY, "Metamod:Source Version"); CON_COMMAND(meta, "Metamod:Source Menu") @@ -54,6 +68,7 @@ CON_COMMAND(meta, "Metamod:Source Menu") Msg("Metamod:Source version %s\n", SOURCEMM_VERSION); Msg("Compiled on: %s\n", SOURCEMM_DATE); Msg("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION); + Msg("SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion()); Msg("http://www.sourcemm.net/\n\n"); return; diff --git a/sourcemm/concommands.h b/sourcemm/concommands.h index e80c021..a6b94be 100644 --- a/sourcemm/concommands.h +++ b/sourcemm/concommands.h @@ -20,11 +20,14 @@ #include #include "sourcemm.h" #include +#include class SMConVarAccessor : public IConCommandBaseAccessor { + std::list m_RegisteredCommands; public: virtual bool RegisterConCommandBase(ConCommandBase *pCommand); + void MarkCommandsAsGameDLL(); }; extern SMConVarAccessor g_SMConVarAccessor; diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index 2e6e0ce..8a947d5 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -289,6 +289,9 @@ void CServerGameDLL::DLLShutdown() // Shutdown sourcehook now g_SourceHook.CompleteShutdown(); + + // Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly + g_SMConVarAccessor.MarkCommandsAsGameDLL(); } int LoadPluginsFromFile(const char *file)