1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-20 13:54:14 +01:00

Backported GetVSPInfo from new API to legacy API (bug 4079, r=ds).

This commit is contained in:
David Anderson 2009-10-29 00:52:39 -07:00
parent 801e0e5dfc
commit e93bd0fdbb
6 changed files with 29 additions and 1 deletions

View File

@ -638,3 +638,11 @@ const char *CSmmAPI::GetUserMessage(int index, int *size)
return msg->name;
}
IServerPluginCallbacks *CSmmAPI::GetVSPInfo(int *pVersion)
{
if (pVersion != NULL)
*pVersion = g_vsp_version;
return g_pRealVspCallbacks;
}

View File

@ -63,6 +63,7 @@ namespace SourceMM
virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
virtual const char *GetBaseDir();
virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion);
void ClientConPrintf(edict_t *client, const char *fmt, ...);
void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
void EnableVSPListener();

View File

@ -303,6 +303,19 @@ public: // Added in 1.4 (1:5)
* @return Message name, or NULL on failure.
*/
virtual const char *GetUserMessage(int index, int *size=NULL) =0;
/**
* @brief Returns the VSP listener loaded.
*
* This is useful for late-loading plugins which need to decide whether
* to add a listener or not (or need to get the pointer at all).
*
* @param pVersion Optional pointer to store the VSP version.
* @return IServerPluginCallbacks pointer, or NULL if an
* IMetamodListener event has yet to occur for
* EnableVSPListener().
*/
virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion) =0;
};
@ -315,7 +328,7 @@ public: // Added in 1.4 (1:5)
* 1.2.2 Added API for printing to client console (with string formatting).
* 1.3 Added new interface search API.
* 1.4 Added VSP listener and user message API.
* 1.8 Added VP hooks to SH-legacy, new API for cvars.
* 1.8 Backported SH VP hooks and various "new API" calls.
*/
#endif //_INCLUDE_ISMM_API_H

View File

@ -67,6 +67,7 @@ static const char GAMEINFO_PATH[] = "|gameinfo_path|";
IFileSystem *baseFs = NULL;
bool g_bLevelChanged = false;
IServerPluginCallbacks *g_pRealVspCallbacks = &g_VspListener;
unsigned int g_vsp_version = 0;
#define ITER_EVENT(evn, args) \
CPluginManager::CPlugin *pl; \
@ -148,6 +149,8 @@ CreateInterface(const char *iface, int *ret)
return NULL;
}
g_vsp_version = vsp_version;
return g_pRealVspCallbacks;
}

View File

@ -108,6 +108,8 @@ extern int g_GameDllVersion;
extern bool g_bGameInit;
extern bool g_bLevelChanged;
extern unsigned int g_vsp_version;
void UnloadMetamod(bool shutting_down);
void LoadAsGameDLL(const gamedll_bridge_info *info);

View File

@ -84,6 +84,7 @@ class VspBridge : public IVspBridge
g_bIsBridgedAsVsp = true;
g_pRealVspCallbacks = info->vsp_callbacks;
g_vsp_version = info->vsp_version;
g_PluginMngr.SetVSPAsLoaded();