mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-30 19:52:17 +01:00
re-added vsp listener support
--HG-- branch : sourcemm-1.6.0 extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.6.0%40441
This commit is contained in:
parent
337e319616
commit
8028dc4d42
@ -343,6 +343,19 @@ public: // Added in 1.6.0 (1:7)
|
|||||||
* @return A SOURCE_ENGINE_* constant value.
|
* @return A SOURCE_ENGINE_* constant value.
|
||||||
*/
|
*/
|
||||||
virtual int GetSourceEngineBuild() =0;
|
virtual int GetSourceEngineBuild() =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 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ HL2PUB = $(HL2SDK)/public
|
|||||||
HL2LIB = $(HL2SDK)/linux_sdk
|
HL2LIB = $(HL2SDK)/linux_sdk
|
||||||
|
|
||||||
OBJECTS = metamod.cpp metamod_util.cpp metamod_console.cpp metamod_oslink.cpp metamod_plugins.cpp \
|
OBJECTS = metamod.cpp metamod_util.cpp metamod_console.cpp metamod_oslink.cpp metamod_plugins.cpp \
|
||||||
sourcehook.cpp episode1/console.cpp episode1/provider_ep1.cpp
|
sourcehook.cpp episode1/console.cpp episode1/provider_ep1.cpp episode1/vsp_listener.cpp
|
||||||
|
|
||||||
LINK = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -static-libgcc
|
LINK = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -static-libgcc
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "provider_ep1.h"
|
#include "provider_ep1.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "metamod_console.h"
|
#include "metamod_console.h"
|
||||||
|
#include "vsp_listener.h"
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
typedef void (*CONPRINTF_FUNC)(const char *, ...);
|
typedef void (*CONPRINTF_FUNC)(const char *, ...);
|
||||||
@ -33,6 +34,7 @@ ICvar *icvar = NULL;
|
|||||||
ISmmAPI *metamod_api = NULL;
|
ISmmAPI *metamod_api = NULL;
|
||||||
IVEngineServer *engine = NULL;
|
IVEngineServer *engine = NULL;
|
||||||
IServerGameClients *gameclients = NULL;
|
IServerGameClients *gameclients = NULL;
|
||||||
|
VSPListener g_VspListener;
|
||||||
BaseProvider g_Ep1Provider;
|
BaseProvider g_Ep1Provider;
|
||||||
IMetamodSourceProvider *provider = &g_Ep1Provider;
|
IMetamodSourceProvider *provider = &g_Ep1Provider;
|
||||||
|
|
||||||
@ -303,7 +305,8 @@ ConVar *BaseProvider::CreateConVar(const char *name,
|
|||||||
|
|
||||||
IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(const char *iface)
|
IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(const char *iface)
|
||||||
{
|
{
|
||||||
return NULL;
|
g_VspListener.SetLoadable(true);
|
||||||
|
return &g_VspListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobCommand : public IMetamodSourceCommandInfo
|
class GlobCommand : public IMetamodSourceCommandInfo
|
||||||
|
111
sourcemm/episode1/vsp_listener.cpp
Normal file
111
sourcemm/episode1/vsp_listener.cpp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#include "vsp_listener.h"
|
||||||
|
#include "svn_version.h"
|
||||||
|
#include "metamod.h"
|
||||||
|
|
||||||
|
using namespace SourceMM;
|
||||||
|
|
||||||
|
VSPListener::VSPListener()
|
||||||
|
{
|
||||||
|
m_bLoaded = false;
|
||||||
|
m_bLoadable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::ClientActive(edict_t *pEntity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PLUGIN_RESULT VSPListener::ClientCommand(edict_t *pEntity)
|
||||||
|
{
|
||||||
|
return PLUGIN_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLUGIN_RESULT VSPListener::ClientConnect(bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
|
||||||
|
{
|
||||||
|
return PLUGIN_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::ClientDisconnect(edict_t *pEntity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::ClientPutInServer(edict_t *pEntity, char const *playername)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::ClientSettingsChanged(edict_t *pEdict)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::SetCommandClient(int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::GameFrame(bool simulating)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *VSPListener::GetPluginDescription()
|
||||||
|
{
|
||||||
|
return "Metamod:Source Interface v" SVN_FILE_VERSION_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VSPListener::IsLoaded()
|
||||||
|
{
|
||||||
|
return m_bLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::LevelInit(char const *pMapName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::LevelShutdown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PLUGIN_RESULT VSPListener::NetworkIDValidated(const char *pszUserName, const char *pszNetworkID)
|
||||||
|
{
|
||||||
|
return PLUGIN_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::Pause()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::UnPause()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::Unload()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VSPListener::SetLoadable(bool set)
|
||||||
|
{
|
||||||
|
m_bLoadable = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
|
||||||
|
{
|
||||||
|
if (!m_bLoadable)
|
||||||
|
{
|
||||||
|
Warning("Do not manually load Metamod:Source as a Valve Server Plugin\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bLoaded)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bLoaded = true;
|
||||||
|
SetLoadable(false);
|
||||||
|
|
||||||
|
g_Metamod.NotifyVSPListening(this);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
37
sourcemm/episode1/vsp_listener.h
Normal file
37
sourcemm/episode1/vsp_listener.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef _INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
||||||
|
#define _INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
||||||
|
|
||||||
|
#include "iserverplugin.h"
|
||||||
|
|
||||||
|
class VSPListener : public IServerPluginCallbacks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VSPListener();
|
||||||
|
public:
|
||||||
|
virtual bool Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory);
|
||||||
|
virtual void Unload();
|
||||||
|
virtual void Pause();
|
||||||
|
virtual void UnPause();
|
||||||
|
virtual const char *GetPluginDescription();
|
||||||
|
virtual void LevelInit(char const *pMapName);
|
||||||
|
virtual void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
|
virtual void GameFrame(bool simulating);
|
||||||
|
virtual void LevelShutdown(void);
|
||||||
|
virtual void ClientActive(edict_t *pEntity);
|
||||||
|
virtual void ClientDisconnect(edict_t *pEntity);
|
||||||
|
virtual void ClientPutInServer(edict_t *pEntity, char const *playername);
|
||||||
|
virtual void SetCommandClient(int index);
|
||||||
|
virtual void ClientSettingsChanged(edict_t *pEdict);
|
||||||
|
virtual PLUGIN_RESULT ClientConnect(bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
||||||
|
virtual PLUGIN_RESULT ClientCommand(edict_t *pEntity);
|
||||||
|
virtual PLUGIN_RESULT NetworkIDValidated(const char *pszUserName, const char *pszNetworkID);
|
||||||
|
public:
|
||||||
|
bool IsLoaded();
|
||||||
|
void SetLoadable(bool loadable);
|
||||||
|
private:
|
||||||
|
bool m_bLoaded;
|
||||||
|
bool m_bLoadable;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
||||||
|
|
@ -80,6 +80,7 @@ SourceHook::CSourceHookImpl g_SourceHook;
|
|||||||
SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
|
SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
|
||||||
PluginId g_PLID = Pl_Console;
|
PluginId g_PLID = Pl_Console;
|
||||||
META_RES last_meta_res;
|
META_RES last_meta_res;
|
||||||
|
IServerPluginCallbacks *vsp_callbacks = NULL;
|
||||||
|
|
||||||
MetamodSource g_Metamod;
|
MetamodSource g_Metamod;
|
||||||
|
|
||||||
@ -187,19 +188,19 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
|||||||
|
|
||||||
if (strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
if (strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
||||||
{
|
{
|
||||||
IServerPluginCallbacks *pCallbacks = provider->GetVSPCallbacks(iface);
|
vsp_callbacks = provider->GetVSPCallbacks(iface);
|
||||||
|
|
||||||
if (pCallbacks && vsp_version == 0)
|
if (vsp_callbacks != NULL && vsp_version == 0)
|
||||||
{
|
{
|
||||||
vsp_version = atoi(&iface[22]);
|
vsp_version = atoi(&iface[22]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCallbacks && ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
*ret = pCallbacks ? IFACE_OK : IFACE_FAILED;
|
*ret = (vsp_callbacks != NULL) ? IFACE_OK : IFACE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pCallbacks;
|
return vsp_callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parsed_game_info)
|
if (!parsed_game_info)
|
||||||
@ -221,6 +222,15 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
|||||||
/* Get value of -game from command line, defaulting to hl2 as engine seems to do */
|
/* Get value of -game from command line, defaulting to hl2 as engine seems to do */
|
||||||
game_dir = provider->GetCommandLineValue("-game", "hl2");
|
game_dir = provider->GetCommandLineValue("-game", "hl2");
|
||||||
|
|
||||||
|
if (strcasecmp(game_dir, "ship") == 0)
|
||||||
|
{
|
||||||
|
engine_build = SOURCE_ENGINE_ORIGINAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
engine_build = SOURCE_ENGINE_EPISODEONE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get absolute path */
|
/* Get absolute path */
|
||||||
abspath(game_path, game_dir);
|
abspath(game_path, game_dir);
|
||||||
mod_path.assign(game_path);
|
mod_path.assign(game_path);
|
||||||
@ -1203,3 +1213,19 @@ int MetamodSource::GetSourceEngineBuild()
|
|||||||
{
|
{
|
||||||
return engine_build;
|
return engine_build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetamodSource::NotifyVSPListening(IServerPluginCallbacks *callbacks)
|
||||||
|
{
|
||||||
|
ITER_EVENT(OnVSPListening, (callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
IServerPluginCallbacks *MetamodSource::GetVSPInfo(int *pVersion)
|
||||||
|
{
|
||||||
|
if (pVersion)
|
||||||
|
{
|
||||||
|
*pVersion = vsp_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vsp_callbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -71,10 +71,12 @@ public:
|
|||||||
const char *GetUserMessage(int index, int *size=NULL);
|
const char *GetUserMessage(int index, int *size=NULL);
|
||||||
int GetVSPVersion();
|
int GetVSPVersion();
|
||||||
int GetSourceEngineBuild();
|
int GetSourceEngineBuild();
|
||||||
|
IServerPluginCallbacks *GetVSPInfo(int *pVersion);
|
||||||
public:
|
public:
|
||||||
const char *GetGameBinaryPath();
|
const char *GetGameBinaryPath();
|
||||||
const char *GetPluginsFile();
|
const char *GetPluginsFile();
|
||||||
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
|
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
|
||||||
|
void NotifyVSPListening(IServerPluginCallbacks *callbacks);
|
||||||
};
|
};
|
||||||
|
|
||||||
void LogMessage(const char *msg, ...);
|
void LogMessage(const char *msg, ...);
|
||||||
|
@ -147,3 +147,4 @@ typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIt
|
|||||||
extern SourceMM::CPluginManager g_PluginMngr;
|
extern SourceMM::CPluginManager g_PluginMngr;
|
||||||
|
|
||||||
#endif //_INCLUDE_CPLUGIN_H
|
#endif //_INCLUDE_CPLUGIN_H
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user