From 4c3d5673e60bb28fc500ef9e0b05d87bac8eb0fc Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Sun, 8 Apr 2007 18:19:06 +0000 Subject: [PATCH] Added VSP listening and a function to SMGlobalClass --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40681 --- core/sm_globals.h | 10 ++++++++++ core/sourcemm_api.cpp | 22 ++++++++++++++++++++++ core/sourcemm_api.h | 6 +++++- core/sourcemod.h | 4 ++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core/sm_globals.h b/core/sm_globals.h index 6636fbe1..8f86e75d 100644 --- a/core/sm_globals.h +++ b/core/sm_globals.h @@ -27,6 +27,8 @@ using namespace SourcePawn; using namespace SourceMod; +class IServerPluginCallbacks; + /** * @brief Lists result codes possible from attempting to set a core configuration option. */ @@ -51,6 +53,7 @@ enum ConfigSource */ class SMGlobalClass { + friend class SourceMod_Core; friend class SourceModBase; friend class CoreConfig; public: @@ -111,6 +114,13 @@ public: virtual void OnSourceModPluginsLoaded() { } + + /** + * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM + */ + virtual void OnSourceModVSPReceived(IServerPluginCallbacks *iface) + { + } private: SMGlobalClass *m_pGlobalClassNext; static SMGlobalClass *head; diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 387c7a1f..e7af5615 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -16,6 +16,7 @@ #include "sourcemm_api.h" #include "sm_version.h" #include "sourcemod.h" +#include "Logger.h" SourceMod_Core g_SourceMod_Core; IVEngineServer *engine = NULL; @@ -62,6 +63,9 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen } gpGlobals = ismm->pGlobals(); + + ismm->AddListener(this, this); + ismm->EnableVSPListener(); return g_SourceMod.InitializeSourceMod(error, maxlen, late); } @@ -125,3 +129,21 @@ const char *SourceMod_Core::GetLogTag() { return "SM"; } + +void SourceMod_Core::OnVSPListening(IServerPluginCallbacks *iface) +{ + /* This shouldn't happen */ + if (!iface) + { + g_Logger.LogFatal("Metamod:Source version is out of date. SourceMod requires 1.4 or greater."); + return; + } + + /* Notify! */ + SMGlobalClass *pBase = SMGlobalClass::head; + while (pBase) + { + pBase->OnSourceModVSPReceived(iface); + pBase = pBase->m_pGlobalClassNext; + } +} diff --git a/core/sourcemm_api.h b/core/sourcemm_api.h index 8e3b7612..2428ff62 100644 --- a/core/sourcemm_api.h +++ b/core/sourcemm_api.h @@ -28,7 +28,9 @@ * @file Contains wrappers around required Metamod:Source API exports */ -class SourceMod_Core : public ISmmPlugin +class SourceMod_Core : + public ISmmPlugin, + public IMetamodListener { public: bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late); @@ -45,6 +47,8 @@ public: const char *GetVersion(); const char *GetDate(); const char *GetLogTag(); +public: + void OnVSPListening(IServerPluginCallbacks *iface); }; extern SourceMod_Core g_SourceMod_Core; diff --git a/core/sourcemod.h b/core/sourcemod.h index 57ef3ef7..a2ca1f84 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -74,8 +74,8 @@ public: unsigned int GetGlobalTarget() const; /** - * @brief Sets whether if SoureMod needs to check player auths. - */ + * @brief Sets whether if SoureMod needs to check player auths. + */ void SetAuthChecking(bool set); public: // SMGlobalClass ConfigResult OnSourceModConfigChanged(const char *key,