mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-12-02 14:24:16 +01:00
Fixed VSP listener on Linux when loaded via gameinfo.txt on Left 4 Dead 2 (bug 4113, r=dvander).
This moves the actual VSP listener to the loader and so "plugin_load" is given the path to the loader rather than one of the engine specific binaries.
This commit is contained in:
parent
a2bd947492
commit
15e694bce8
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceMM ========
|
/* ======== SourceMM ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -12,7 +12,6 @@
|
|||||||
#include "CSmmAPI.h"
|
#include "CSmmAPI.h"
|
||||||
#include "sourcemm.h"
|
#include "sourcemm.h"
|
||||||
#include "concommands.h"
|
#include "concommands.h"
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -427,8 +426,7 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
|
|||||||
//if (pl->m_API->GetApiVersion() >= 4)
|
//if (pl->m_API->GetApiVersion() >= 4)
|
||||||
pl->m_API->AllPluginsLoaded();
|
pl->m_API->AllPluginsLoaded();
|
||||||
}
|
}
|
||||||
if (g_bIsBridgedAsVsp ||
|
if (g_bIsBridgedAsVsp)
|
||||||
(g_VspListener.IsLoaded() && g_SmmAPI.VSPEnabled()))
|
|
||||||
{
|
{
|
||||||
SourceHook::List<CPluginEventHandler>::iterator event;
|
SourceHook::List<CPluginEventHandler>::iterator event;
|
||||||
for (event = pl->m_Events.begin();
|
for (event = pl->m_Events.begin();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceMM ========
|
/* ======== SourceMM ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -13,7 +13,6 @@
|
|||||||
#include "sourcemm.h"
|
#include "sourcemm.h"
|
||||||
#include "concommands.h"
|
#include "concommands.h"
|
||||||
#include "CPlugin.h"
|
#include "CPlugin.h"
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,15 +465,13 @@ void CSmmAPI::LoadAsVSP()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char our_path[PATH_SIZE];
|
const char *usepath = g_MetamodPath.c_str();
|
||||||
GetFileOfAddress((void*)LoadAsGameDLL, our_path, sizeof(our_path));
|
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, g_MetamodPath.c_str()))
|
||||||
|
{
|
||||||
const char *usepath = our_path;
|
|
||||||
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, our_path))
|
|
||||||
usepath = rel_path;
|
usepath = rel_path;
|
||||||
|
}
|
||||||
|
|
||||||
char command[PATH_SIZE * 2];
|
char command[PATH_SIZE * 2];
|
||||||
g_VspListener.SetLoadable(true);
|
|
||||||
UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", usepath);
|
UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", usepath);
|
||||||
g_Engine.engine->ServerCommand(command);
|
g_Engine.engine->ServerCommand(command);
|
||||||
}
|
}
|
||||||
@ -482,7 +479,7 @@ void CSmmAPI::LoadAsVSP()
|
|||||||
void CSmmAPI::EnableVSPListener()
|
void CSmmAPI::EnableVSPListener()
|
||||||
{
|
{
|
||||||
/* If GameInit already passed and we're not already enabled or loaded, go ahead and LoadAsVSP load */
|
/* If GameInit already passed and we're not already enabled or loaded, go ahead and LoadAsVSP load */
|
||||||
if (g_bGameInit && !m_VSP && !g_VspListener.IsLoaded() && !g_bIsBridgedAsVsp)
|
if (g_bGameInit && !m_VSP && !g_bIsBridgedAsVsp)
|
||||||
{
|
{
|
||||||
LoadAsVSP();
|
LoadAsVSP();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ OBJECTS = oslink.cpp \
|
|||||||
CSmmAPI.cpp \
|
CSmmAPI.cpp \
|
||||||
sourcemm.cpp \
|
sourcemm.cpp \
|
||||||
CPlugin.cpp \
|
CPlugin.cpp \
|
||||||
vsp_listener.cpp \
|
|
||||||
vsp_bridge.cpp \
|
vsp_bridge.cpp \
|
||||||
gamedll_bridge.cpp \
|
gamedll_bridge.cpp \
|
||||||
sourcehook/sourcehook.cpp
|
sourcehook/sourcehook.cpp
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceMM ========
|
/* ======== SourceMM ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -15,7 +15,6 @@
|
|||||||
#include "CPlugin.h"
|
#include "CPlugin.h"
|
||||||
#include "sh_string.h"
|
#include "sh_string.h"
|
||||||
#include "sh_list.h"
|
#include "sh_list.h"
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +120,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
|
|
||||||
int args = e->Cmd_Argc();
|
int args = e->Cmd_Argc();
|
||||||
|
|
||||||
if (g_bIsBridgedAsVsp && !g_bLevelChanged)
|
if (!g_GameDll.loaded && !g_bLevelChanged)
|
||||||
{
|
{
|
||||||
CONMSG("WARNING: You must change the map to activate Metamod:Source.\n");
|
CONMSG("WARNING: You must change the map to activate Metamod:Source.\n");
|
||||||
return;
|
return;
|
||||||
@ -143,13 +142,13 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
} else if (strcmp(command, "version") == 0) {
|
} else if (strcmp(command, "version") == 0) {
|
||||||
CONMSG("Metamod:Source version %s\n", MMS_FULL_VERSION);
|
CONMSG("Metamod:Source version %s\n", MMS_FULL_VERSION);
|
||||||
CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID);
|
CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID);
|
||||||
if (g_bIsBridgedAsVsp)
|
if (g_GameDll.loaded)
|
||||||
{
|
{
|
||||||
CONMSG("Loaded As: Valve Server Plugin\n");
|
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
|
CONMSG("Loaded As: Valve Server Plugin\n");
|
||||||
}
|
}
|
||||||
CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
|
CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
|
||||||
CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
|
CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
|
||||||
|
@ -226,10 +226,6 @@
|
|||||||
RelativePath="..\vsp_bridge.cpp"
|
RelativePath="..\vsp_bridge.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\vsp_listener.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
@ -264,10 +260,6 @@
|
|||||||
RelativePath="..\util.h"
|
RelativePath="..\util.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\vsp_listener.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceMM ========
|
/* ======== SourceMM ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -18,7 +18,6 @@
|
|||||||
#include "CSmmAPI.h"
|
#include "CSmmAPI.h"
|
||||||
#include "CPlugin.h"
|
#include "CPlugin.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "iplayerinfo.h"
|
#include "iplayerinfo.h"
|
||||||
#include <filesystem.h>
|
#include <filesystem.h>
|
||||||
|
|
||||||
@ -57,6 +56,7 @@ EngineInfo g_Engine;
|
|||||||
SourceHook::CSourceHookImpl g_SourceHook;
|
SourceHook::CSourceHookImpl g_SourceHook;
|
||||||
SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
|
SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
|
||||||
SourceHook::String g_ModPath;
|
SourceHook::String g_ModPath;
|
||||||
|
SourceHook::String g_MetamodPath;
|
||||||
PluginId g_PLID = Pl_Console; /* Technically, SourceMM is the "Console" plugin... :p */
|
PluginId g_PLID = Pl_Console; /* Technically, SourceMM is the "Console" plugin... :p */
|
||||||
static bool bInFirstLevel = true;
|
static bool bInFirstLevel = true;
|
||||||
bool g_bGameInit = false;
|
bool g_bGameInit = false;
|
||||||
@ -66,7 +66,7 @@ static const char VSPIFACE_002[] = "ISERVERPLUGINCALLBACKS002";
|
|||||||
static const char GAMEINFO_PATH[] = "|gameinfo_path|";
|
static const char GAMEINFO_PATH[] = "|gameinfo_path|";
|
||||||
IFileSystem *baseFs = NULL;
|
IFileSystem *baseFs = NULL;
|
||||||
bool g_bLevelChanged = false;
|
bool g_bLevelChanged = false;
|
||||||
IServerPluginCallbacks *g_pRealVspCallbacks = &g_VspListener;
|
IServerPluginCallbacks *g_pRealVspCallbacks = NULL;
|
||||||
unsigned int g_vsp_version = 0;
|
unsigned int g_vsp_version = 0;
|
||||||
|
|
||||||
#define ITER_EVENT(evn, args) \
|
#define ITER_EVENT(evn, args) \
|
||||||
@ -125,41 +125,6 @@ void DoInitialPluginLoads()
|
|||||||
LoadPlugins(filepath, vdfpath);
|
LoadPlugins(filepath, vdfpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMM_API void *
|
|
||||||
CreateInterface(const char *iface, int *ret)
|
|
||||||
{
|
|
||||||
void *ptr = NULL;
|
|
||||||
|
|
||||||
if (!g_bIsBridgedAsVsp && strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
|
||||||
{
|
|
||||||
if (g_VspListener.IsLoaded())
|
|
||||||
{
|
|
||||||
if (ret != NULL)
|
|
||||||
*ret = IFACE_FAILED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(&g_VspListener == g_pRealVspCallbacks);
|
|
||||||
|
|
||||||
int vsp_version = atoi(&iface[22]);
|
|
||||||
if (vsp_version < 1 || vsp_version > 2)
|
|
||||||
{
|
|
||||||
if (ret != NULL)
|
|
||||||
*ret = IFACE_FAILED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_vsp_version = vsp_version;
|
|
||||||
|
|
||||||
return g_pRealVspCallbacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
*ret = (ptr != NULL) ? IFACE_OK : IFACE_FAILED;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartupMetamod(CreateInterfaceFn engineFactory, bool bWaitForGameInit)
|
bool StartupMetamod(CreateInterfaceFn engineFactory, bool bWaitForGameInit)
|
||||||
{
|
{
|
||||||
g_Engine.engine = (IVEngineServer *)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
|
g_Engine.engine = (IVEngineServer *)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
|
||||||
@ -241,6 +206,7 @@ void LoadAsGameDLL(const gamedll_bridge_info *info)
|
|||||||
g_GameDll.factory = (CreateInterfaceFn)info->gsFactory;
|
g_GameDll.factory = (CreateInterfaceFn)info->gsFactory;
|
||||||
g_GameDll.pGameDLL = (IServerGameDLL*)info->isgd;
|
g_GameDll.pGameDLL = (IServerGameDLL*)info->isgd;
|
||||||
g_GameDllVersion = info->dllVersion;
|
g_GameDllVersion = info->dllVersion;
|
||||||
|
g_MetamodPath.assign(info->vsp_listener_path);
|
||||||
|
|
||||||
InitMainStates();
|
InitMainStates();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceMM ========
|
/* ======== SourceMM ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -96,6 +96,9 @@ extern SourceHook::CSourceHookImpl g_SourceHook;
|
|||||||
/** @brief Mod path (important!)*/
|
/** @brief Mod path (important!)*/
|
||||||
extern SourceHook::String g_ModPath;
|
extern SourceHook::String g_ModPath;
|
||||||
|
|
||||||
|
/** @brief Path to Metamod binary */
|
||||||
|
extern SourceHook::String g_MetamodPath;
|
||||||
|
|
||||||
/** @brief Global variable for SourceHook macros */
|
/** @brief Global variable for SourceHook macros */
|
||||||
extern SourceHook::ISourceHook *g_SHPtr;
|
extern SourceHook::ISourceHook *g_SHPtr;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -36,6 +34,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|||||||
ConCommand *g_plugin_unload = NULL;
|
ConCommand *g_plugin_unload = NULL;
|
||||||
bool g_bIsTryingToUnload;
|
bool g_bIsTryingToUnload;
|
||||||
bool g_bIsBridgedAsVsp;
|
bool g_bIsBridgedAsVsp;
|
||||||
|
const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
|
||||||
|
|
||||||
void InterceptPluginUnloads()
|
void InterceptPluginUnloads()
|
||||||
{
|
{
|
||||||
@ -51,14 +50,27 @@ class VspBridge : public IVspBridge
|
|||||||
{
|
{
|
||||||
virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
|
virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
assert(!g_GameDll.loaded && !g_bIsBridgedAsVsp);
|
assert(!g_bIsBridgedAsVsp);
|
||||||
|
|
||||||
|
if (!g_GameDll.loaded)
|
||||||
|
{
|
||||||
CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
|
CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
|
||||||
CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
|
CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
|
||||||
|
|
||||||
if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
|
if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
extern ConVar metamod_version;
|
||||||
|
char buffer[255];
|
||||||
|
|
||||||
|
UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
|
||||||
|
metamod_version.SetValue(buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
ConCommandBase *pBase = g_Engine.icvar->GetCommands();
|
ConCommandBase *pBase = g_Engine.icvar->GetCommands();
|
||||||
while (pBase != NULL)
|
while (pBase != NULL)
|
||||||
{
|
{
|
||||||
@ -76,12 +88,6 @@ class VspBridge : public IVspBridge
|
|||||||
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern ConVar metamod_version;
|
|
||||||
char buffer[255];
|
|
||||||
|
|
||||||
UTIL_Format(buffer, sizeof(buffer), "%sV", metamod_version.GetString());
|
|
||||||
metamod_version.SetValue(buffer);
|
|
||||||
|
|
||||||
g_bIsBridgedAsVsp = true;
|
g_bIsBridgedAsVsp = true;
|
||||||
g_pRealVspCallbacks = info->vsp_callbacks;
|
g_pRealVspCallbacks = info->vsp_callbacks;
|
||||||
g_vsp_version = info->vsp_version;
|
g_vsp_version = info->vsp_version;
|
||||||
@ -104,13 +110,16 @@ class VspBridge : public IVspBridge
|
|||||||
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
||||||
g_plugin_unload = NULL;
|
g_plugin_unload = NULL;
|
||||||
}
|
}
|
||||||
|
if (!g_GameDll.loaded)
|
||||||
|
{
|
||||||
g_SMConVarAccessor.UnloadMetamodCommands();
|
g_SMConVarAccessor.UnloadMetamodCommands();
|
||||||
UnloadMetamod(false);
|
UnloadMetamod(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual const char *GetDescription()
|
virtual const char *GetDescription()
|
||||||
{
|
{
|
||||||
return "Metamod:Source " MMS_FULL_VERSION;
|
return vsp_desc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
/* ======== SourceMM ========
|
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
|
||||||
* No warranties of any kind
|
|
||||||
*
|
|
||||||
* License: zlib/libpng
|
|
||||||
*
|
|
||||||
* Author(s): David "BAILOPAN" Anderson
|
|
||||||
* ============================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "CPlugin.h"
|
|
||||||
#include "concommands.h"
|
|
||||||
|
|
||||||
using namespace SourceMM;
|
|
||||||
|
|
||||||
VSPListener g_VspListener;
|
|
||||||
|
|
||||||
VSPListener::VSPListener()
|
|
||||||
{
|
|
||||||
m_Loaded = false;
|
|
||||||
m_Loadable = 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 " MMS_FULL_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VSPListener::IsLoaded()
|
|
||||||
{
|
|
||||||
return m_Loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
m_Loadable = true;
|
|
||||||
m_Loaded = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VSPListener::SetLoadable(bool set)
|
|
||||||
{
|
|
||||||
m_Loadable = set;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
|
|
||||||
{
|
|
||||||
if (m_Loaded || !m_Loadable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_Loaded = true;
|
|
||||||
SetLoadable(false);
|
|
||||||
|
|
||||||
g_PluginMngr.SetVSPAsLoaded();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/* ======== SourceMM ========
|
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
|
||||||
* No warranties of any kind
|
|
||||||
*
|
|
||||||
* License: zlib/libpng
|
|
||||||
*
|
|
||||||
* Author(s): David "BAILOPAN" Anderson
|
|
||||||
* ============================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMM_VSPLISTENER_H_
|
|
||||||
#define _INCLUDE_SOURCEMM_VSPLISTENER_H_
|
|
||||||
|
|
||||||
#include "sourcemm.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_Loaded;
|
|
||||||
bool m_Loadable;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern VSPListener g_VspListener;
|
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMM_VSPLISTENER_H_
|
|
||||||
|
|
@ -20,7 +20,6 @@ OBJECTS = metamod.cpp \
|
|||||||
sourcehook/sourcehook_hookmangen.cpp \
|
sourcehook/sourcehook_hookmangen.cpp \
|
||||||
provider/console.cpp \
|
provider/console.cpp \
|
||||||
provider/provider_ep2.cpp \
|
provider/provider_ep2.cpp \
|
||||||
provider/vsp_listener.cpp \
|
|
||||||
vsp_bridge.cpp \
|
vsp_bridge.cpp \
|
||||||
gamedll_bridge.cpp
|
gamedll_bridge.cpp
|
||||||
|
|
||||||
@ -43,6 +42,7 @@ ifeq "$(ENGINE)" "orangebox"
|
|||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
SRCDS = $(SRCDS_BASE)/orangebox
|
SRCDS = $(SRCDS_BASE)/orangebox
|
||||||
BINARY = metamod.2.ep2.so
|
BINARY = metamod.2.ep2.so
|
||||||
|
LIB_SUFFIX = i486
|
||||||
override ENGSET = true
|
override ENGSET = true
|
||||||
endif
|
endif
|
||||||
ifeq "$(ENGINE)" "orangeboxvalve"
|
ifeq "$(ENGINE)" "orangeboxvalve"
|
||||||
@ -53,6 +53,7 @@ ifeq "$(ENGINE)" "orangeboxvalve"
|
|||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
SRCDS = $(SRCDS_BASE)/orangebox
|
SRCDS = $(SRCDS_BASE)/orangebox
|
||||||
BINARY = metamod.2.ep2v.so
|
BINARY = metamod.2.ep2v.so
|
||||||
|
LIB_SUFFIX = i486
|
||||||
override ENGSET = true
|
override ENGSET = true
|
||||||
endif
|
endif
|
||||||
ifeq "$(ENGINE)" "left4dead"
|
ifeq "$(ENGINE)" "left4dead"
|
||||||
@ -63,6 +64,7 @@ ifeq "$(ENGINE)" "left4dead"
|
|||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
SRCDS = $(SRCDS_BASE)/l4d
|
SRCDS = $(SRCDS_BASE)/l4d
|
||||||
BINARY = metamod.2.l4d.so
|
BINARY = metamod.2.l4d.so
|
||||||
|
LIB_SUFFIX = i486
|
||||||
override ENGSET = true
|
override ENGSET = true
|
||||||
endif
|
endif
|
||||||
ifeq "$(ENGINE)" "left4dead2"
|
ifeq "$(ENGINE)" "left4dead2"
|
||||||
@ -73,16 +75,13 @@ ifeq "$(ENGINE)" "left4dead2"
|
|||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||||
SRCDS = $(SRCDS_BASE)/left4dead2_demo
|
SRCDS = $(SRCDS_BASE)/left4dead2_demo
|
||||||
BINARY = metamod.2.l4d2.so
|
BINARY = metamod.2.l4d2.so
|
||||||
|
LIB_SUFFIX = linux
|
||||||
override ENGSET = true
|
override ENGSET = true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6
|
CFLAGS += -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_ORANGEBOXVALVE=4 -DSE_LEFT4DEAD=5 -DSE_LEFT4DEAD2=6
|
||||||
|
|
||||||
ifeq "$(ENGINE)" "left4dead2"
|
LINK += $(HL2LIB)/tier1_i486.a vstdlib_$(LIB_SUFFIX).so tier0_$(LIB_SUFFIX).so -static-libgcc
|
||||||
LINK += $(HL2LIB)/tier1_i486.a vstdlib_linux.so tier0_linux.so -static-libgcc
|
|
||||||
else
|
|
||||||
LINK += $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -static-libgcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
|
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
|
||||||
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -Isourcehook -I../loader
|
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -Isourcehook -I../loader
|
||||||
@ -123,13 +122,8 @@ all: check
|
|||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
mkdir -p $(BIN_DIR)/provider
|
mkdir -p $(BIN_DIR)/provider
|
||||||
mkdir -p $(BIN_DIR)/sourcehook
|
mkdir -p $(BIN_DIR)/sourcehook
|
||||||
if [ "$(ENGINE)" = "left4dead2" ]; then \
|
ln -sf $(HL2LIB)/vstdlib_$(LIB_SUFFIX).so
|
||||||
ln -sf $(HL2LIB)/vstdlib_linux.so vstdlib_linux.so; \
|
ln -sf $(HL2LIB)/tier0_$(LIB_SUFFIX).so
|
||||||
ln -sf $(HL2LIB)/tier0_linux.so tier0_linux.so; \
|
|
||||||
else \
|
|
||||||
ln -sf $(HL2LIB)/vstdlib_i486.so vstdlib_i486.so; \
|
|
||||||
ln -sf $(HL2LIB)/tier0_i486.so tier0_i486.so; \
|
|
||||||
fi
|
|
||||||
$(MAKE) -f Makefile metamod
|
$(MAKE) -f Makefile metamod
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -49,6 +47,7 @@ public:
|
|||||||
g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
|
g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
|
||||||
info->dllVersion,
|
info->dllVersion,
|
||||||
true);
|
true);
|
||||||
|
g_Metamod.SetVSPListener(info->vsp_listener_path);
|
||||||
mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
|
mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
|
||||||
(CreateInterfaceFn)info->physicsFactory,
|
(CreateInterfaceFn)info->physicsFactory,
|
||||||
(CreateInterfaceFn)info->fsFactory,
|
(CreateInterfaceFn)info->fsFactory,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -182,17 +180,8 @@ mm_InitializeForLoad()
|
|||||||
bool
|
bool
|
||||||
mm_DetectGameInformation()
|
mm_DetectGameInformation()
|
||||||
{
|
{
|
||||||
char mm_path[PATH_SIZE];
|
|
||||||
char game_path[PATH_SIZE];
|
char game_path[PATH_SIZE];
|
||||||
|
|
||||||
/* Get path to SourceMM DLL */
|
|
||||||
if (!GetFileOfAddress((void *)mm_InitializeForLoad, mm_path, sizeof(mm_path)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
metamod_path.assign(mm_path);
|
|
||||||
|
|
||||||
/* 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 */
|
||||||
const char *game_dir = provider->GetCommandLineValue("-game");
|
const char *game_dir = provider->GetCommandLineValue("-game");
|
||||||
|
|
||||||
@ -220,33 +209,6 @@ ServerFactory(const char *iface, int *ret)
|
|||||||
IFACE_MACRO(gamedll_info.factory, GameDLL);
|
IFACE_MACRO(gamedll_info.factory, GameDLL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMM_API void *
|
|
||||||
CreateInterface(const char *iface, int *ret)
|
|
||||||
{
|
|
||||||
void *ptr = NULL;
|
|
||||||
|
|
||||||
if (!mm_IsVspBridged() && strncmp(iface, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
|
||||||
{
|
|
||||||
if (vsp_callbacks != NULL)
|
|
||||||
{
|
|
||||||
if (ret != NULL)
|
|
||||||
*ret = IFACE_FAILED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
vsp_version = atoi(&iface[22]);
|
|
||||||
ptr = provider->GetVSPCallbacks(vsp_version);
|
|
||||||
|
|
||||||
if (ptr == NULL)
|
|
||||||
vsp_version = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
*ret = (ptr != NULL) ? IFACE_OK : IFACE_FAILED;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
LoadPluginsFromFile(const char *filepath, int &skipped)
|
LoadPluginsFromFile(const char *filepath, int &skipped)
|
||||||
{
|
{
|
||||||
@ -868,7 +830,9 @@ void MetamodSource::ClientConPrintf(edict_t *client, const char *fmt, ...)
|
|||||||
void MetamodSource::EnableVSPListener()
|
void MetamodSource::EnableVSPListener()
|
||||||
{
|
{
|
||||||
if (is_game_init && !vsp_load_requested && !vsp_loaded)
|
if (is_game_init && !vsp_load_requested && !vsp_loaded)
|
||||||
|
{
|
||||||
InitializeVSP();
|
InitializeVSP();
|
||||||
|
}
|
||||||
|
|
||||||
vsp_load_requested = true;
|
vsp_load_requested = true;
|
||||||
}
|
}
|
||||||
@ -1077,6 +1041,16 @@ void MetamodSource::NotifyVSPListening(IServerPluginCallbacks *callbacks, int ve
|
|||||||
|
|
||||||
vsp_callbacks = callbacks;
|
vsp_callbacks = callbacks;
|
||||||
ITER_EVENT(OnVSPListening, (callbacks));
|
ITER_EVENT(OnVSPListening, (callbacks));
|
||||||
|
|
||||||
|
if (is_gamedll_loaded)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* MM:S is loaded as a game DLL so we need to set these for mm_IsVspBridged() and
|
||||||
|
* mm_IsVspLoadComplete()
|
||||||
|
*/
|
||||||
|
g_bIsVspBridged = true;
|
||||||
|
were_plugins_loaded = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IServerPluginCallbacks *MetamodSource::GetVSPInfo(int *pVersion)
|
IServerPluginCallbacks *MetamodSource::GetVSPInfo(int *pVersion)
|
||||||
@ -1118,6 +1092,11 @@ void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, int version,
|
|||||||
is_gamedll_loaded = loaded;
|
is_gamedll_loaded = loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetamodSource::SetVSPListener(const char *path)
|
||||||
|
{
|
||||||
|
metamod_path.assign(path);
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ProcessVDF(const char *path, bool &skipped)
|
ProcessVDF(const char *path, bool &skipped)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_SOURCEMM_H
|
#ifndef _INCLUDE_SOURCEMM_H
|
||||||
@ -100,6 +98,7 @@ public:
|
|||||||
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
|
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
|
||||||
void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version);
|
void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version);
|
||||||
void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded);
|
void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded);
|
||||||
|
void SetVSPListener(const char *path);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_METAMOD_SOURCE_SUPPORT_H_
|
#ifndef _INCLUDE_METAMOD_SOURCE_SUPPORT_H_
|
||||||
@ -142,15 +140,6 @@ namespace SourceMM
|
|||||||
*/
|
*/
|
||||||
virtual void ClientConsolePrint(edict_t *client, const char *msg) =0;
|
virtual void ClientConsolePrint(edict_t *client, const char *msg) =0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns a server plugin helper for the given interface
|
|
||||||
* string.
|
|
||||||
*
|
|
||||||
* @param iface Interface version
|
|
||||||
* @return IServerPluginCallbacks pointer.
|
|
||||||
*/
|
|
||||||
virtual IServerPluginCallbacks *GetVSPCallbacks(int version) =0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Halts the server with a fatal error message.
|
* @brief Halts the server with a fatal error message.
|
||||||
*
|
*
|
||||||
|
@ -983,10 +983,6 @@
|
|||||||
RelativePath="..\provider\provider_ep2.h"
|
RelativePath="..\provider\provider_ep2.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\provider\vsp_listener.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
@ -999,10 +995,6 @@
|
|||||||
RelativePath="..\provider\provider_ep2.cpp"
|
RelativePath="..\provider\provider_ep2.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\provider\vsp_listener.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "provider_ep2.h"
|
#include "provider_ep2.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "metamod_console.h"
|
#include "metamod_console.h"
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include <filesystem.h>
|
#include <filesystem.h>
|
||||||
#include "metamod.h"
|
#include "metamod.h"
|
||||||
|
|
||||||
@ -74,7 +73,6 @@ void _ServerCommand();
|
|||||||
/* Variables */
|
/* Variables */
|
||||||
static bool usermsgs_extracted = false;
|
static bool usermsgs_extracted = false;
|
||||||
static CVector<UsrMsgInfo> usermsgs_list;
|
static CVector<UsrMsgInfo> usermsgs_list;
|
||||||
static VSPListener g_VspListener;
|
|
||||||
static BaseProvider g_Ep1Provider;
|
static BaseProvider g_Ep1Provider;
|
||||||
static List<ConCommandBase *> conbases_unreg;
|
static List<ConCommandBase *> conbases_unreg;
|
||||||
|
|
||||||
@ -420,17 +418,6 @@ ConVar *BaseProvider::CreateConVar(const char *name,
|
|||||||
return pVar;
|
return pVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
IServerPluginCallbacks *BaseProvider::GetVSPCallbacks(int version)
|
|
||||||
{
|
|
||||||
if (version > 2)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_VspListener.SetLoadable(true);
|
|
||||||
return &g_VspListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BaseProvider::ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len)
|
bool BaseProvider::ProcessVDF(const char *file, char path[], size_t path_len, char alias[], size_t alias_len)
|
||||||
{
|
{
|
||||||
if (baseFs == NULL)
|
if (baseFs == NULL)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_METAMOD_SOURCE_BASE_PROVIDER_H_
|
#ifndef _INCLUDE_METAMOD_SOURCE_BASE_PROVIDER_H_
|
||||||
@ -56,7 +54,6 @@ public:
|
|||||||
virtual void ConsolePrint(const char *msg);
|
virtual void ConsolePrint(const char *msg);
|
||||||
virtual bool IsRemotePrintingAvailable();
|
virtual bool IsRemotePrintingAvailable();
|
||||||
virtual void ClientConsolePrint(edict_t *client, const char *msg);
|
virtual void ClientConsolePrint(edict_t *client, const char *msg);
|
||||||
virtual IServerPluginCallbacks *GetVSPCallbacks(int version);
|
|
||||||
virtual void DisplayError(const char *fmt, ...);
|
virtual void DisplayError(const char *fmt, ...);
|
||||||
virtual void DisplayWarning(const char *fmt, ...);
|
virtual void DisplayWarning(const char *fmt, ...);
|
||||||
virtual int TryServerGameDLL(const char *iface);
|
virtual int TryServerGameDLL(const char *iface);
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* ======================================================
|
|
||||||
* Metamod:Source
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
|
||||||
* All rights reserved.
|
|
||||||
* ======================================================
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
* In no event will the authors be held liable for any damages arising from
|
|
||||||
* the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software in a
|
|
||||||
* product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "../metamod_oslink.h"
|
|
||||||
#include "metamod.h"
|
|
||||||
#include <sourcehook.h>
|
|
||||||
#include <convar.h>
|
|
||||||
#include <eiface.h>
|
|
||||||
#include "iplayerinfo.h"
|
|
||||||
#include "vsp_listener.h"
|
|
||||||
#include "version.h"
|
|
||||||
#include "provider_ep2.h"
|
|
||||||
|
|
||||||
using namespace SourceMM;
|
|
||||||
|
|
||||||
VSPListener::VSPListener()
|
|
||||||
{
|
|
||||||
m_bLoaded = false;
|
|
||||||
m_bLoadable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VSPListener::ClientActive(edict_t *pEntity)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
PLUGIN_RESULT VSPListener::ClientCommand(edict_t *pEntity, const CCommand &cmd)
|
|
||||||
#else
|
|
||||||
PLUGIN_RESULT VSPListener::ClientCommand(edict_t *pEntity)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
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 " MMS_FULL_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
m_bLoaded = false;
|
|
||||||
m_bLoadable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VSPListener::SetLoadable(bool set)
|
|
||||||
{
|
|
||||||
m_bLoadable = set;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
|
|
||||||
{
|
|
||||||
m_bLoaded = true;
|
|
||||||
SetLoadable(false);
|
|
||||||
|
|
||||||
g_Metamod.NotifyVSPListening(this, -1);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
void VSPListener::OnQueryCvarValueFinished(QueryCvarCookie_t iCookie,
|
|
||||||
edict_t *pPlayerEntity,
|
|
||||||
EQueryCvarValueStatus eStatus,
|
|
||||||
const char *pCvarName,
|
|
||||||
const char *pCvarValue)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* ======================================================
|
|
||||||
* Metamod:Source
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
|
||||||
* All rights reserved.
|
|
||||||
* ======================================================
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
* In no event will the authors be held liable for any damages arising from
|
|
||||||
* the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software in a
|
|
||||||
* product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
|
||||||
#define _INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
|
||||||
|
|
||||||
#if defined _DEBUG
|
|
||||||
#define DEBUG2
|
|
||||||
#undef _DEBUG
|
|
||||||
#endif
|
|
||||||
#include "iserverplugin.h"
|
|
||||||
#if defined DEBUG2
|
|
||||||
#undef DEBUG2
|
|
||||||
#define _DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
virtual PLUGIN_RESULT ClientCommand(edict_t *pEntity, const CCommand &cmd);
|
|
||||||
#else
|
|
||||||
virtual PLUGIN_RESULT ClientCommand(edict_t *pEntity);
|
|
||||||
#endif
|
|
||||||
virtual PLUGIN_RESULT NetworkIDValidated(const char *pszUserName, const char *pszNetworkID);
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue );
|
|
||||||
#endif
|
|
||||||
public:
|
|
||||||
bool IsLoaded();
|
|
||||||
void SetLoadable(bool loadable);
|
|
||||||
private:
|
|
||||||
bool m_bLoaded;
|
|
||||||
bool m_bLoadable;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_INCLUDE_METAMOD_SOURCE_VSP_LISTENER_H_
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "metamod.h"
|
#include "metamod.h"
|
||||||
@ -42,6 +40,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|||||||
|
|
||||||
ConCommand *g_plugin_unload = NULL;
|
ConCommand *g_plugin_unload = NULL;
|
||||||
bool g_bIsTryingToUnload;
|
bool g_bIsTryingToUnload;
|
||||||
|
const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void InterceptPluginUnloads(const CCommand &args)
|
void InterceptPluginUnloads(const CCommand &args)
|
||||||
@ -66,8 +65,8 @@ class VspBridge : public IVspBridge
|
|||||||
public:
|
public:
|
||||||
virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
|
virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
assert(!g_Metamod.IsLoadedAsGameDLL());
|
if (!g_Metamod.IsLoadedAsGameDLL())
|
||||||
|
{
|
||||||
CGlobalVars *pGlobals;
|
CGlobalVars *pGlobals;
|
||||||
IPlayerInfoManager *playerInfoManager;
|
IPlayerInfoManager *playerInfoManager;
|
||||||
|
|
||||||
@ -118,6 +117,12 @@ public:
|
|||||||
pGlobals);
|
pGlobals);
|
||||||
g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
|
g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
|
||||||
mm_StartupMetamod(true);
|
mm_StartupMetamod(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION;
|
||||||
|
g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
|
||||||
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
g_plugin_unload = icvar->FindCommand("plugin_unload");
|
g_plugin_unload = icvar->FindCommand("plugin_unload");
|
||||||
@ -156,12 +161,15 @@ public:
|
|||||||
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
|
||||||
g_plugin_unload = NULL;
|
g_plugin_unload = NULL;
|
||||||
}
|
}
|
||||||
|
if (!g_Metamod.IsLoadedAsGameDLL())
|
||||||
|
{
|
||||||
mm_UnloadMetamod();
|
mm_UnloadMetamod();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual const char *GetDescription()
|
virtual const char *GetDescription()
|
||||||
{
|
{
|
||||||
return "Metamod:Source " MMS_FULL_VERSION;
|
return vsp_desc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ CPP = gcc-4.1
|
|||||||
|
|
||||||
ifeq "$(ENGINE)" "left4dead2"
|
ifeq "$(ENGINE)" "left4dead2"
|
||||||
BINARY = server_linux.so
|
BINARY = server_linux.so
|
||||||
CFLAGS += -DBINARY_SUFFIX=\"_linux.so\"
|
CFLAGS += -DLIB_SUFFIX=\"_linux.so\"
|
||||||
else
|
else
|
||||||
BINARY = server_i486.so
|
BINARY = server_i486.so
|
||||||
CFLAGS += -DBINARY_SUFFIX=\"_i486.so\"
|
CFLAGS += -DLIB_SUFFIX=\"_i486.so\"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LINK += -static-libgcc
|
LINK += -static-libgcc
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -52,17 +50,17 @@ static IServerGameDLL *gamedll_iface = NULL;
|
|||||||
static QueryValveInterface gamedll_qvi = NULL;
|
static QueryValveInterface gamedll_qvi = NULL;
|
||||||
static int gamedll_version = 0;
|
static int gamedll_version = 0;
|
||||||
static int isgd_shutdown_index = -1;
|
static int isgd_shutdown_index = -1;
|
||||||
|
static char mm_path[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
#define SERVER_NAME "server.dll"
|
#define SERVER_NAME "server.dll"
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define SERVER_NAME "server" BINARY_SUFFIX
|
#define SERVER_NAME "server" LIB_SUFFIX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
mm_DetectGameInformation()
|
mm_DetectGameInformation()
|
||||||
{
|
{
|
||||||
char mm_path[PLATFORM_MAX_PATH];
|
|
||||||
char game_path[PLATFORM_MAX_PATH];
|
char game_path[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
if (game_info_detected)
|
if (game_info_detected)
|
||||||
@ -77,7 +75,7 @@ mm_DetectGameInformation()
|
|||||||
|
|
||||||
if (!mm_GetFileOfAddress((void*)mm_DetectGameInformation, mm_path, sizeof(mm_path)))
|
if (!mm_GetFileOfAddress((void*)mm_DetectGameInformation, mm_path, sizeof(mm_path)))
|
||||||
{
|
{
|
||||||
mm_LogFatal("Could not locate metamod loader library path");
|
mm_LogFatal("Could not locate Metamod loader library path");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,18 +214,18 @@ public:
|
|||||||
QueryValveInterface fileSystemFactory,
|
QueryValveInterface fileSystemFactory,
|
||||||
void *pGlobals)
|
void *pGlobals)
|
||||||
{
|
{
|
||||||
MetamodBackend backend = mm_DetermineBackend(engineFactory, game_name);
|
mm_backend = mm_DetermineBackend(engineFactory, game_name);
|
||||||
|
|
||||||
char error[255];
|
char error[255];
|
||||||
if (backend == MMBackend_UNKNOWN)
|
if (mm_backend == MMBackend_UNKNOWN)
|
||||||
{
|
{
|
||||||
mm_LogFatal("Could not detect engine version");
|
mm_LogFatal("Could not detect engine version");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mm_LoadMetamodLibrary(backend, error, sizeof(error)))
|
if (!mm_LoadMetamodLibrary(mm_backend, error, sizeof(error)))
|
||||||
{
|
{
|
||||||
mm_LogFatal("Detected engine %d but could not load: %s", backend, error);
|
mm_LogFatal("Detected engine %d but could not load: %s", mm_backend, error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -236,7 +234,7 @@ public:
|
|||||||
if (get_bridge == NULL)
|
if (get_bridge == NULL)
|
||||||
{
|
{
|
||||||
mm_UnloadMetamodLibrary();
|
mm_UnloadMetamodLibrary();
|
||||||
mm_LogFatal("Detected engine %d but could not find GetGameDllBridge callback", backend);
|
mm_LogFatal("Detected engine %d but could not find GetGameDllBridge callback", mm_backend);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -256,13 +254,14 @@ public:
|
|||||||
info.dllVersion = gamedll_version;
|
info.dllVersion = gamedll_version;
|
||||||
info.isgd = gamedll_iface;
|
info.isgd = gamedll_iface;
|
||||||
info.gsFactory = gamedll_qvi;
|
info.gsFactory = gamedll_qvi;
|
||||||
|
info.vsp_listener_path = mm_path;
|
||||||
|
|
||||||
strcpy(error, "Unknown error");
|
strcpy(error, "Unknown error");
|
||||||
if (!gamedll_bridge->DLLInit_Pre(&info, error, sizeof(error)))
|
if (!gamedll_bridge->DLLInit_Pre(&info, error, sizeof(error)))
|
||||||
{
|
{
|
||||||
gamedll_bridge = NULL;
|
gamedll_bridge = NULL;
|
||||||
mm_UnloadMetamodLibrary();
|
mm_UnloadMetamodLibrary();
|
||||||
mm_LogFatal("Unknown error loading Metamod for engine %d: %s", backend, error);
|
mm_LogFatal("Unknown error loading Metamod for engine %d: %s", mm_backend, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ typedef ICommandLine *(*GetCommandLine)();
|
|||||||
|
|
||||||
static HMODULE mm_library = NULL;
|
static HMODULE mm_library = NULL;
|
||||||
static char mm_fatal_logfile[PLATFORM_MAX_PATH] = "metamod-fatal.log";
|
static char mm_fatal_logfile[PLATFORM_MAX_PATH] = "metamod-fatal.log";
|
||||||
|
MetamodBackend mm_backend = MMBackend_UNKNOWN;
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
mm_LogFatal(const char *message, ...)
|
mm_LogFatal(const char *message, ...)
|
||||||
@ -81,7 +82,7 @@ static const char *backend_names[] =
|
|||||||
#define LIBRARY_EXT ".dll"
|
#define LIBRARY_EXT ".dll"
|
||||||
#define LIBRARY_MINEXT ".dll"
|
#define LIBRARY_MINEXT ".dll"
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define LIBRARY_EXT BINARY_SUFFIX
|
#define LIBRARY_EXT LIB_SUFFIX
|
||||||
#define LIBRARY_MINEXT ".so"
|
#define LIBRARY_MINEXT ".so"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -146,16 +147,22 @@ CreateInterface(const char *name, int *ret)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we've got a gamedll bridge, forward the request. */
|
|
||||||
if (gamedll_bridge != NULL)
|
|
||||||
return gamedll_bridge->QueryInterface(name, ret);
|
|
||||||
|
|
||||||
/* Otherwise, we're probably trying to load Metamod. */
|
|
||||||
void *ptr;
|
void *ptr;
|
||||||
if (strncmp(name, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
if (strncmp(name, "ISERVERPLUGINCALLBACKS", 22) == 0)
|
||||||
|
{
|
||||||
|
/* Either load as VSP or start VSP listener */
|
||||||
ptr = mm_GetVspCallbacks(atoi(&name[22]));
|
ptr = mm_GetVspCallbacks(atoi(&name[22]));
|
||||||
else
|
}
|
||||||
|
else if (gamedll_bridge == NULL)
|
||||||
|
{
|
||||||
|
/* Load as gamedll */
|
||||||
ptr = mm_GameDllRequest(name, ret);
|
ptr = mm_GameDllRequest(name, ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If we've got a gamedll bridge, forward the request. */
|
||||||
|
return gamedll_bridge->QueryInterface(name, ret);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != NULL)
|
if (ret != NULL)
|
||||||
*ret = (ptr != NULL) ? 0 : 1;
|
*ret = (ptr != NULL) ? 0 : 1;
|
||||||
@ -173,8 +180,8 @@ mm_GetProcAddress(const char *name)
|
|||||||
#define TIER0_NAME "bin\\tier0.dll"
|
#define TIER0_NAME "bin\\tier0.dll"
|
||||||
#define VSTDLIB_NAME "bin\\vstdlib.dll"
|
#define VSTDLIB_NAME "bin\\vstdlib.dll"
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define TIER0_NAME "bin/tier0" BINARY_SUFFIX
|
#define TIER0_NAME "bin/tier0" LIB_SUFFIX
|
||||||
#define VSTDLIB_NAME "bin/vstdlib" BINARY_SUFFIX
|
#define VSTDLIB_NAME "bin/vstdlib" LIB_SUFFIX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -86,5 +86,7 @@ mm_GetGameName();
|
|||||||
extern MetamodBackend
|
extern MetamodBackend
|
||||||
mm_DetermineBackend(QueryValveInterface qvi, const char *game_name);
|
mm_DetermineBackend(QueryValveInterface qvi, const char *game_name);
|
||||||
|
|
||||||
|
extern MetamodBackend mm_backend;
|
||||||
|
|
||||||
#endif /* _INCLUDE_METAMOD_SOURCE_LOADER_H_ */
|
#endif /* _INCLUDE_METAMOD_SOURCE_LOADER_H_ */
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* ======================================================
|
* ======================================================
|
||||||
* Metamod:Source
|
* Metamod:Source
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
|
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -21,8 +21,6 @@
|
|||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_METAMOD_SOURCE_LOADER_BRIDGE_H_
|
#ifndef _INCLUDE_METAMOD_SOURCE_LOADER_BRIDGE_H_
|
||||||
@ -56,6 +54,7 @@ struct gamedll_bridge_info
|
|||||||
void * pGlobals;
|
void * pGlobals;
|
||||||
unsigned int dllVersion;
|
unsigned int dllVersion;
|
||||||
void * isgd;
|
void * isgd;
|
||||||
|
const char * vsp_listener_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IGameDllBridge
|
class IGameDllBridge
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <sh_memfuncinfo.h>
|
#include <sh_memfuncinfo.h>
|
||||||
#include <sh_memory.h>
|
#include <sh_memory.h>
|
||||||
#include "serverplugin.h"
|
#include "serverplugin.h"
|
||||||
|
#include "gamedll.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -52,12 +53,6 @@ class CCommand;
|
|||||||
class IServerPluginCallbacks;
|
class IServerPluginCallbacks;
|
||||||
struct edict_t;
|
struct edict_t;
|
||||||
|
|
||||||
#if defined WIN32
|
|
||||||
#define LIBRARY_EXT ".dll"
|
|
||||||
#else
|
|
||||||
#define LIBRARY_EXT "_i486.so"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class IRandomThings
|
class IRandomThings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -90,19 +85,23 @@ public:
|
|||||||
|
|
||||||
load_allowed = false;
|
load_allowed = false;
|
||||||
|
|
||||||
|
/* Backend should already filled in if loaded as gamedll */
|
||||||
|
if (gamedll_bridge == NULL)
|
||||||
|
{
|
||||||
if ((game_name = mm_GetGameName()) == NULL)
|
if ((game_name = mm_GetGameName()) == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetamodBackend backend = mm_DetermineBackend(engineFactory, game_name);
|
mm_backend = mm_DetermineBackend(engineFactory, game_name);
|
||||||
|
}
|
||||||
|
|
||||||
if (backend == MMBackend_UNKNOWN)
|
if (mm_backend == MMBackend_UNKNOWN)
|
||||||
{
|
{
|
||||||
mm_LogFatal("Could not detect engine version");
|
mm_LogFatal("Could not detect engine version");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (backend >= MMBackend_Episode2)
|
else if (mm_backend >= MMBackend_Episode2)
|
||||||
{
|
{
|
||||||
/* We need to insert the right type of call into this vtable */
|
/* We need to insert the right type of call into this vtable */
|
||||||
void **vtable_src;
|
void **vtable_src;
|
||||||
@ -132,18 +131,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
char error[255];
|
char error[255];
|
||||||
if (!mm_LoadMetamodLibrary(backend, error, sizeof(error)))
|
if (gamedll_bridge == NULL)
|
||||||
{
|
{
|
||||||
mm_LogFatal("Detected engine %d but could not load: %s", backend, error);
|
if (!mm_LoadMetamodLibrary(mm_backend, error, sizeof(error)))
|
||||||
|
{
|
||||||
|
mm_LogFatal("Detected engine %d but could not load: %s", mm_backend, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef IVspBridge *(*GetVspBridge)();
|
typedef IVspBridge *(*GetVspBridge)();
|
||||||
GetVspBridge get_bridge = (GetVspBridge)mm_GetProcAddress("GetVspBridge");
|
GetVspBridge get_bridge = (GetVspBridge)mm_GetProcAddress("GetVspBridge");
|
||||||
if (get_bridge == NULL)
|
if (get_bridge == NULL)
|
||||||
|
{
|
||||||
|
if (gamedll_bridge == NULL)
|
||||||
{
|
{
|
||||||
mm_UnloadMetamodLibrary();
|
mm_UnloadMetamodLibrary();
|
||||||
mm_LogFatal("Detected engine %d but could not find GetVspBridge callback", backend);
|
}
|
||||||
|
mm_LogFatal("Detected engine %d but could not find GetVspBridge callback", mm_backend);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +165,11 @@ public:
|
|||||||
if (!vsp_bridge->Load(&info, error, sizeof(error)))
|
if (!vsp_bridge->Load(&info, error, sizeof(error)))
|
||||||
{
|
{
|
||||||
vsp_bridge = NULL;
|
vsp_bridge = NULL;
|
||||||
|
if (gamedll_bridge == NULL)
|
||||||
|
{
|
||||||
mm_UnloadMetamodLibrary();
|
mm_UnloadMetamodLibrary();
|
||||||
mm_LogFatal("Unknown error loading Metamod for engine %d: %s", backend, error);
|
}
|
||||||
|
mm_LogFatal("Unknown error loading Metamod for engine %d: %s", mm_backend, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +180,12 @@ public:
|
|||||||
if (vsp_bridge == NULL)
|
if (vsp_bridge == NULL)
|
||||||
return;
|
return;
|
||||||
vsp_bridge->Unload();
|
vsp_bridge->Unload();
|
||||||
|
|
||||||
|
if (gamedll_bridge == NULL)
|
||||||
|
{
|
||||||
mm_UnloadMetamodLibrary();
|
mm_UnloadMetamodLibrary();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
virtual void Pause()
|
virtual void Pause()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user