From 417c4f1e562f179fb89f8ba775ef79523469976c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 4 Jul 2008 02:34:45 +0000 Subject: [PATCH] fixed compatibility with future engine versions --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40694 --- sourcemm/episode2/provider_ep2.cpp | 7 ++++++- sourcemm/episode2/provider_ep2.h | 2 +- sourcemm/metamod.cpp | 18 ++++++++++++++---- sourcemm/metamod_provider.h | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sourcemm/episode2/provider_ep2.cpp b/sourcemm/episode2/provider_ep2.cpp index 6c85716..39a1376 100644 --- a/sourcemm/episode2/provider_ep2.cpp +++ b/sourcemm/episode2/provider_ep2.cpp @@ -383,8 +383,13 @@ ConVar *BaseProvider::CreateConVar(const char *name, return pVar; } -IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(const char *iface) +IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(int version) { + if (version > 2) + { + return NULL; + } + g_VspListener.SetLoadable(true); return &g_VspListener; } diff --git a/sourcemm/episode2/provider_ep2.h b/sourcemm/episode2/provider_ep2.h index 6287240..fa730d8 100644 --- a/sourcemm/episode2/provider_ep2.h +++ b/sourcemm/episode2/provider_ep2.h @@ -56,7 +56,7 @@ public: virtual void ConsolePrint(const char *msg); virtual bool IsRemotePrintingAvailable(); virtual void ClientConsolePrint(edict_t *client, const char *msg); - virtual IServerPluginCallbacks *GetVSPCallbacks(const char *iface); + virtual IServerPluginCallbacks *GetVSPCallbacks(int version); virtual void DisplayError(const char *fmt, ...); virtual void DisplayWarning(const char *fmt, ...); virtual int TryServerGameDLL(const char *iface); diff --git a/sourcemm/metamod.cpp b/sourcemm/metamod.cpp index 97d7282..084273a 100644 --- a/sourcemm/metamod.cpp +++ b/sourcemm/metamod.cpp @@ -227,18 +227,28 @@ SMM_API void *CreateInterface(const char *iface, int *ret) if (strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0) { - vsp_callbacks = provider->GetVSPCallbacks(iface); - - if (vsp_callbacks != NULL && vsp_version == 0) + if (vsp_callbacks != NULL && atoi(&iface[22]) != vsp_version) { - vsp_version = atoi(&iface[22]); + if (ret != NULL) + { + *ret = IFACE_FAILED; + } + return NULL; } + vsp_version = atoi(&iface[22]); + vsp_callbacks = provider->GetVSPCallbacks(vsp_version); + if (ret) { *ret = (vsp_callbacks != NULL) ? IFACE_OK : IFACE_FAILED; } + if (vsp_callbacks == NULL) + { + vsp_version = 0; + } + return vsp_callbacks; } diff --git a/sourcemm/metamod_provider.h b/sourcemm/metamod_provider.h index 8c9a19c..6af8ea7 100644 --- a/sourcemm/metamod_provider.h +++ b/sourcemm/metamod_provider.h @@ -151,7 +151,7 @@ namespace SourceMM * @param iface Interface version * @return IServerPluginCallbacks pointer. */ - virtual IServerPluginCallbacks *GetVSPCallbacks(const char *iface) =0; + virtual IServerPluginCallbacks *GetVSPCallbacks(int version) =0; /** * @brief Halts the server with a fatal error message.