diff --git a/sourcemm/Makefile.ep1 b/sourcemm/Makefile.ep1 index 24880e1..e051cb5 100644 --- a/sourcemm/Makefile.ep1 +++ b/sourcemm/Makefile.ep1 @@ -53,7 +53,7 @@ all: ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so ln -sf $(SMM_ROOT)/sourcehook/sourcehook.cpp sourcehook.cpp - $(MAKE) sourcemm + $(MAKE) -f Makefile.ep1 sourcemm rm -rf $(BINARY) ln -sf $(BIN_DIR)/$(BINARY) $(BINARY) @@ -61,7 +61,7 @@ sourcemm: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) debug: - $(MAKE) all DEBUG=true + $(MAKE) -f Makefile.ep1 all DEBUG=true default: all diff --git a/sourcemm/episode1/console.cpp b/sourcemm/episode1/console.cpp index e6d7c83..5903672 100644 --- a/sourcemm/episode1/console.cpp +++ b/sourcemm/episode1/console.cpp @@ -80,6 +80,37 @@ void SMConVarAccessor::MarkCommandsAsGameDLL() } } +void SMConVarAccessor::UnregisterGameDLLCommands() +{ + ConCommandBase *begin = icvar->GetCommands(); + ConCommandBase *iter = begin; + ConCommandBase *prev = NULL; + while (iter) + { + /* Watch out for the ETERNAL COMMAND! */ + if (iter != &s_EternalCommand && iter->IsBitSet(FCVAR_GAMEDLL)) + { + /* Remove it! */ + if (iter == begin) + { + s_EternalCommand.BringToFront(); + iter = const_cast(iter->GetNext()); + s_EternalCommand.SetNext(iter); + prev = &s_EternalCommand; + continue; + } + else + { + iter = const_cast(iter->GetNext()); + prev->SetNext(iter); + continue; + } + } + prev = iter; + iter = const_cast(iter->GetNext()); + } +} + void SMConVarAccessor::Unregister(ConCommandBase *pCommand) { ConCommandBase *ptr = icvar->GetCommands(); diff --git a/sourcemm/episode1/provider_ep1.cpp b/sourcemm/episode1/provider_ep1.cpp index c535a54..27c2d52 100644 --- a/sourcemm/episode1/provider_ep1.cpp +++ b/sourcemm/episode1/provider_ep1.cpp @@ -85,6 +85,12 @@ void BaseProvider::Notify_DLLInit_Pre(void *gamedll, ConCommandBaseMgr::OneTimeInit(&g_SMConVarAccessor); } +void BaseProvider::Notify_DLLShutdown_Pre() +{ + g_SMConVarAccessor.MarkCommandsAsGameDLL(); + g_SMConVarAccessor.UnregisterGameDLLCommands(); +} + bool BaseProvider::IsRemotePrintingAvailable() { return (echo_msg_func != NULL); diff --git a/sourcemm/episode1/provider_ep1.h b/sourcemm/episode1/provider_ep1.h index acd0a39..c09ae06 100644 --- a/sourcemm/episode1/provider_ep1.h +++ b/sourcemm/episode1/provider_ep1.h @@ -28,6 +28,7 @@ public: virtual void Notify_DLLInit_Pre(void *gamedll, CreateInterfaceFn engineFactory, CreateInterfaceFn serverFactory); + void Notify_DLLShutdown_Pre(); virtual void ServerCommand(const char *cmd); virtual ConVar *CreateConVar(const char *name, const char *defval, diff --git a/sourcemm/metamod.cpp b/sourcemm/metamod.cpp index a943738..6818e22 100644 --- a/sourcemm/metamod.cpp +++ b/sourcemm/metamod.cpp @@ -54,7 +54,6 @@ struct game_dll_t CreateInterfaceFn factory; }; -SourceHook::CallClass *g_GameDllPatch; String mod_path; String metamod_path; String full_bin_path; @@ -662,8 +661,6 @@ bool Handler_DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsF physics_factory = physicsFactory; gpGlobals = pGlobals; - g_GameDllPatch = SH_GET_CALLCLASS(server); - provider->Notify_DLLInit_Pre(server, engineFactory, gamedll_info.factory); metamod_version = provider->CreateConVar("metamod_version", @@ -724,10 +721,9 @@ void Handler_DLLShutdown() /* Unload plugins */ g_PluginMngr.UnloadAll(); - SH_CALL(g_GameDllPatch, &IServerGameDLL::DLLShutdown)(); + provider->Notify_DLLShutdown_Pre(); - SH_RELEASE_CALLCLASS(g_GameDllPatch); - g_GameDllPatch = NULL; + SH_CALL(server, &IServerGameDLL::DLLShutdown)(); g_SourceHook.CompleteShutdown(); diff --git a/sourcemm/metamod_provider.h b/sourcemm/metamod_provider.h index b2c5347..ff01159 100644 --- a/sourcemm/metamod_provider.h +++ b/sourcemm/metamod_provider.h @@ -163,6 +163,8 @@ namespace SourceMM CreateInterfaceFn engineFactory, CreateInterfaceFn serverFactory) =0; + virtual void Notify_DLLShutdown_Pre() =0; + /** * @brief Wrapper around IVEngineServer::ServerCommand() *