1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-01 13:24:25 +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:
Scott Ehlert 2009-11-22 23:54:55 -06:00
parent a2bd947492
commit 15e694bce8
27 changed files with 211 additions and 683 deletions

View File

@ -1,5 +1,5 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2008 Metamod:Source Development Team
* Copyright (C) 2004-2009 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
@ -12,7 +12,6 @@
#include "CSmmAPI.h"
#include "sourcemm.h"
#include "concommands.h"
#include "vsp_listener.h"
#include "util.h"
/**
@ -427,8 +426,7 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
//if (pl->m_API->GetApiVersion() >= 4)
pl->m_API->AllPluginsLoaded();
}
if (g_bIsBridgedAsVsp ||
(g_VspListener.IsLoaded() && g_SmmAPI.VSPEnabled()))
if (g_bIsBridgedAsVsp)
{
SourceHook::List<CPluginEventHandler>::iterator event;
for (event = pl->m_Events.begin();

View File

@ -1,5 +1,5 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2008 Metamod:Source Development Team
* Copyright (C) 2004-2009 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
@ -13,7 +13,6 @@
#include "sourcemm.h"
#include "concommands.h"
#include "CPlugin.h"
#include "vsp_listener.h"
#include "util.h"
/**
@ -466,15 +465,13 @@ void CSmmAPI::LoadAsVSP()
}
}
char our_path[PATH_SIZE];
GetFileOfAddress((void*)LoadAsGameDLL, our_path, sizeof(our_path));
const char *usepath = our_path;
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, our_path))
const char *usepath = g_MetamodPath.c_str();
if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, g_MetamodPath.c_str()))
{
usepath = rel_path;
}
char command[PATH_SIZE * 2];
g_VspListener.SetLoadable(true);
UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", usepath);
g_Engine.engine->ServerCommand(command);
}
@ -482,7 +479,7 @@ void CSmmAPI::LoadAsVSP()
void CSmmAPI::EnableVSPListener()
{
/* 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();
}

View File

@ -21,7 +21,6 @@ OBJECTS = oslink.cpp \
CSmmAPI.cpp \
sourcemm.cpp \
CPlugin.cpp \
vsp_listener.cpp \
vsp_bridge.cpp \
gamedll_bridge.cpp \
sourcehook/sourcehook.cpp

View File

@ -1,5 +1,5 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2008 Metamod:Source Development Team
* Copyright (C) 2004-2009 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
@ -15,7 +15,6 @@
#include "CPlugin.h"
#include "sh_string.h"
#include "sh_list.h"
#include "vsp_listener.h"
#include "util.h"
/**
@ -121,7 +120,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
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");
return;
@ -143,13 +142,13 @@ CON_COMMAND(meta, "Metamod:Source Menu")
} else if (strcmp(command, "version") == 0) {
CONMSG("Metamod:Source version %s\n", MMS_FULL_VERSION);
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
{
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
CONMSG("Loaded As: Valve Server Plugin\n");
}
CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);

View File

@ -226,10 +226,6 @@
RelativePath="..\vsp_bridge.cpp"
>
</File>
<File
RelativePath="..\vsp_listener.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
@ -264,10 +260,6 @@
RelativePath="..\util.h"
>
</File>
<File
RelativePath="..\vsp_listener.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View File

@ -1,5 +1,5 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2008 Metamod:Source Development Team
* Copyright (C) 2004-2009 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
@ -18,7 +18,6 @@
#include "CSmmAPI.h"
#include "CPlugin.h"
#include "util.h"
#include "vsp_listener.h"
#include "iplayerinfo.h"
#include <filesystem.h>
@ -57,6 +56,7 @@ EngineInfo g_Engine;
SourceHook::CSourceHookImpl g_SourceHook;
SourceHook::ISourceHook *g_SHPtr = &g_SourceHook;
SourceHook::String g_ModPath;
SourceHook::String g_MetamodPath;
PluginId g_PLID = Pl_Console; /* Technically, SourceMM is the "Console" plugin... :p */
static bool bInFirstLevel = true;
bool g_bGameInit = false;
@ -66,7 +66,7 @@ static const char VSPIFACE_002[] = "ISERVERPLUGINCALLBACKS002";
static const char GAMEINFO_PATH[] = "|gameinfo_path|";
IFileSystem *baseFs = NULL;
bool g_bLevelChanged = false;
IServerPluginCallbacks *g_pRealVspCallbacks = &g_VspListener;
IServerPluginCallbacks *g_pRealVspCallbacks = NULL;
unsigned int g_vsp_version = 0;
#define ITER_EVENT(evn, args) \
@ -125,41 +125,6 @@ void DoInitialPluginLoads()
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)
{
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.pGameDLL = (IServerGameDLL*)info->isgd;
g_GameDllVersion = info->dllVersion;
g_MetamodPath.assign(info->vsp_listener_path);
InitMainStates();

View File

@ -1,5 +1,5 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2008 Metamod:Source Development Team
* Copyright (C) 2004-2009 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
@ -96,6 +96,9 @@ extern SourceHook::CSourceHookImpl g_SourceHook;
/** @brief Mod path (important!)*/
extern SourceHook::String g_ModPath;
/** @brief Path to Metamod binary */
extern SourceHook::String g_MetamodPath;
/** @brief Global variable for SourceHook macros */
extern SourceHook::ISourceHook *g_SHPtr;

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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 <assert.h>
@ -36,6 +34,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
ConCommand *g_plugin_unload = NULL;
bool g_bIsTryingToUnload;
bool g_bIsBridgedAsVsp;
const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
void InterceptPluginUnloads()
{
@ -51,14 +50,27 @@ class VspBridge : public IVspBridge
{
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 gsFactory = (CreateInterfaceFn)info->gsFactory;
if (!AlternatelyLoadMetamod(engineFactory, gsFactory))
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();
while (pBase != NULL)
{
@ -76,12 +88,6 @@ class VspBridge : public IVspBridge
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_pRealVspCallbacks = info->vsp_callbacks;
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);
g_plugin_unload = NULL;
}
if (!g_GameDll.loaded)
{
g_SMConVarAccessor.UnloadMetamodCommands();
UnloadMetamod(false);
}
}
virtual const char *GetDescription()
{
return "Metamod:Source " MMS_FULL_VERSION;
return vsp_desc;
}
};

View File

@ -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;
}

View File

@ -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_

View File

@ -20,7 +20,6 @@ OBJECTS = metamod.cpp \
sourcehook/sourcehook_hookmangen.cpp \
provider/console.cpp \
provider/provider_ep2.cpp \
provider/vsp_listener.cpp \
vsp_bridge.cpp \
gamedll_bridge.cpp
@ -43,6 +42,7 @@ ifeq "$(ENGINE)" "orangebox"
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/orangebox
BINARY = metamod.2.ep2.so
LIB_SUFFIX = i486
override ENGSET = true
endif
ifeq "$(ENGINE)" "orangeboxvalve"
@ -53,6 +53,7 @@ ifeq "$(ENGINE)" "orangeboxvalve"
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/orangebox
BINARY = metamod.2.ep2v.so
LIB_SUFFIX = i486
override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead"
@ -63,6 +64,7 @@ ifeq "$(ENGINE)" "left4dead"
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/l4d
BINARY = metamod.2.l4d.so
LIB_SUFFIX = i486
override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead2"
@ -73,16 +75,13 @@ ifeq "$(ENGINE)" "left4dead2"
INCLUDE += -I$(HL2SDK)/public/game/server
SRCDS = $(SRCDS_BASE)/left4dead2_demo
BINARY = metamod.2.l4d2.so
LIB_SUFFIX = linux
override ENGSET = true
endif
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_linux.so tier0_linux.so -static-libgcc
else
LINK += $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so -static-libgcc
endif
LINK += $(HL2LIB)/tier1_i486.a vstdlib_$(LIB_SUFFIX).so tier0_$(LIB_SUFFIX).so -static-libgcc
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I. -Isourcehook -I../loader
@ -123,13 +122,8 @@ all: check
mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/provider
mkdir -p $(BIN_DIR)/sourcehook
if [ "$(ENGINE)" = "left4dead2" ]; then \
ln -sf $(HL2LIB)/vstdlib_linux.so vstdlib_linux.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
ln -sf $(HL2LIB)/vstdlib_$(LIB_SUFFIX).so
ln -sf $(HL2LIB)/tier0_$(LIB_SUFFIX).so
$(MAKE) -f Makefile metamod
check:

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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 <assert.h>
@ -49,6 +47,7 @@ public:
g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
info->dllVersion,
true);
g_Metamod.SetVSPListener(info->vsp_listener_path);
mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
(CreateInterfaceFn)info->physicsFactory,
(CreateInterfaceFn)info->fsFactory,

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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>
@ -182,17 +180,8 @@ mm_InitializeForLoad()
bool
mm_DetectGameInformation()
{
char mm_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 */
const char *game_dir = provider->GetCommandLineValue("-game");
@ -220,33 +209,6 @@ ServerFactory(const char *iface, int *ret)
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
LoadPluginsFromFile(const char *filepath, int &skipped)
{
@ -868,7 +830,9 @@ void MetamodSource::ClientConPrintf(edict_t *client, const char *fmt, ...)
void MetamodSource::EnableVSPListener()
{
if (is_game_init && !vsp_load_requested && !vsp_loaded)
{
InitializeVSP();
}
vsp_load_requested = true;
}
@ -1077,6 +1041,16 @@ void MetamodSource::NotifyVSPListening(IServerPluginCallbacks *callbacks, int ve
vsp_callbacks = 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)
@ -1118,6 +1092,11 @@ void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, int version,
is_gamedll_loaded = loaded;
}
void MetamodSource::SetVSPListener(const char *path)
{
metamod_path.assign(path);
}
static bool
ProcessVDF(const char *path, bool &skipped)
{

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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_SOURCEMM_H
@ -100,6 +98,7 @@ public:
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version);
void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded);
void SetVSPListener(const char *path);
};
bool

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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_SUPPORT_H_
@ -142,15 +140,6 @@ namespace SourceMM
*/
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.
*

View File

@ -983,10 +983,6 @@
RelativePath="..\provider\provider_ep2.h"
>
</File>
<File
RelativePath="..\provider\vsp_listener.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
@ -999,10 +995,6 @@
RelativePath="..\provider\provider_ep2.cpp"
>
</File>
<File
RelativePath="..\provider\vsp_listener.cpp"
>
</File>
</Filter>
</Filter>
<Filter

View File

@ -36,7 +36,6 @@
#include "provider_ep2.h"
#include "console.h"
#include "metamod_console.h"
#include "vsp_listener.h"
#include <filesystem.h>
#include "metamod.h"
@ -74,7 +73,6 @@ void _ServerCommand();
/* Variables */
static bool usermsgs_extracted = false;
static CVector<UsrMsgInfo> usermsgs_list;
static VSPListener g_VspListener;
static BaseProvider g_Ep1Provider;
static List<ConCommandBase *> conbases_unreg;
@ -420,17 +418,6 @@ ConVar *BaseProvider::CreateConVar(const char *name,
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)
{
if (baseFs == NULL)

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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_BASE_PROVIDER_H_
@ -56,7 +54,6 @@ public:
virtual void ConsolePrint(const char *msg);
virtual bool IsRemotePrintingAvailable();
virtual void ClientConsolePrint(edict_t *client, const char *msg);
virtual IServerPluginCallbacks *GetVSPCallbacks(int version);
virtual void DisplayError(const char *fmt, ...);
virtual void DisplayWarning(const char *fmt, ...);
virtual int TryServerGameDLL(const char *iface);

View File

@ -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

View File

@ -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_

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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 "metamod.h"
@ -42,6 +40,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
ConCommand *g_plugin_unload = NULL;
bool g_bIsTryingToUnload;
const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
#if SOURCE_ENGINE >= SE_ORANGEBOX
void InterceptPluginUnloads(const CCommand &args)
@ -66,8 +65,8 @@ class VspBridge : public IVspBridge
public:
virtual bool Load(const vsp_bridge_info *info, char *error, size_t maxlength)
{
assert(!g_Metamod.IsLoadedAsGameDLL());
if (!g_Metamod.IsLoadedAsGameDLL())
{
CGlobalVars *pGlobals;
IPlayerInfoManager *playerInfoManager;
@ -118,6 +117,12 @@ public:
pGlobals);
g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
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
g_plugin_unload = icvar->FindCommand("plugin_unload");
@ -156,12 +161,15 @@ public:
SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, g_plugin_unload, InterceptPluginUnloads_Post, true);
g_plugin_unload = NULL;
}
if (!g_Metamod.IsLoadedAsGameDLL())
{
mm_UnloadMetamod();
}
}
virtual const char *GetDescription()
{
return "Metamod:Source " MMS_FULL_VERSION;
return vsp_desc;
}
};

View File

@ -22,10 +22,10 @@ CPP = gcc-4.1
ifeq "$(ENGINE)" "left4dead2"
BINARY = server_linux.so
CFLAGS += -DBINARY_SUFFIX=\"_linux.so\"
CFLAGS += -DLIB_SUFFIX=\"_linux.so\"
else
BINARY = server_i486.so
CFLAGS += -DBINARY_SUFFIX=\"_i486.so\"
CFLAGS += -DLIB_SUFFIX=\"_i486.so\"
endif
LINK += -static-libgcc

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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>
@ -52,17 +50,17 @@ static IServerGameDLL *gamedll_iface = NULL;
static QueryValveInterface gamedll_qvi = NULL;
static int gamedll_version = 0;
static int isgd_shutdown_index = -1;
static char mm_path[PLATFORM_MAX_PATH];
#if defined _WIN32
#define SERVER_NAME "server.dll"
#elif defined __linux__
#define SERVER_NAME "server" BINARY_SUFFIX
#define SERVER_NAME "server" LIB_SUFFIX
#endif
static bool
mm_DetectGameInformation()
{
char mm_path[PLATFORM_MAX_PATH];
char game_path[PLATFORM_MAX_PATH];
if (game_info_detected)
@ -77,7 +75,7 @@ mm_DetectGameInformation()
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;
}
@ -216,18 +214,18 @@ public:
QueryValveInterface fileSystemFactory,
void *pGlobals)
{
MetamodBackend backend = mm_DetermineBackend(engineFactory, game_name);
mm_backend = mm_DetermineBackend(engineFactory, game_name);
char error[255];
if (backend == MMBackend_UNKNOWN)
if (mm_backend == MMBackend_UNKNOWN)
{
mm_LogFatal("Could not detect engine version");
}
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
{
@ -236,7 +234,7 @@ public:
if (get_bridge == NULL)
{
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
{
@ -256,13 +254,14 @@ public:
info.dllVersion = gamedll_version;
info.isgd = gamedll_iface;
info.gsFactory = gamedll_qvi;
info.vsp_listener_path = mm_path;
strcpy(error, "Unknown error");
if (!gamedll_bridge->DLLInit_Pre(&info, error, sizeof(error)))
{
gamedll_bridge = NULL;
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);
}
}

View File

@ -41,6 +41,7 @@ typedef ICommandLine *(*GetCommandLine)();
static HMODULE mm_library = NULL;
static char mm_fatal_logfile[PLATFORM_MAX_PATH] = "metamod-fatal.log";
MetamodBackend mm_backend = MMBackend_UNKNOWN;
extern void
mm_LogFatal(const char *message, ...)
@ -81,7 +82,7 @@ static const char *backend_names[] =
#define LIBRARY_EXT ".dll"
#define LIBRARY_MINEXT ".dll"
#elif defined __linux__
#define LIBRARY_EXT BINARY_SUFFIX
#define LIBRARY_EXT LIB_SUFFIX
#define LIBRARY_MINEXT ".so"
#endif
@ -146,16 +147,22 @@ CreateInterface(const char *name, int *ret)
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;
if (strncmp(name, "ISERVERPLUGINCALLBACKS", 22) == 0)
{
/* Either load as VSP or start VSP listener */
ptr = mm_GetVspCallbacks(atoi(&name[22]));
else
}
else if (gamedll_bridge == NULL)
{
/* Load as gamedll */
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)
*ret = (ptr != NULL) ? 0 : 1;
@ -173,8 +180,8 @@ mm_GetProcAddress(const char *name)
#define TIER0_NAME "bin\\tier0.dll"
#define VSTDLIB_NAME "bin\\vstdlib.dll"
#elif defined __linux__
#define TIER0_NAME "bin/tier0" BINARY_SUFFIX
#define VSTDLIB_NAME "bin/vstdlib" BINARY_SUFFIX
#define TIER0_NAME "bin/tier0" LIB_SUFFIX
#define VSTDLIB_NAME "bin/vstdlib" LIB_SUFFIX
#endif
const char *

View File

@ -86,5 +86,7 @@ mm_GetGameName();
extern MetamodBackend
mm_DetermineBackend(QueryValveInterface qvi, const char *game_name);
extern MetamodBackend mm_backend;
#endif /* _INCLUDE_METAMOD_SOURCE_LOADER_H_ */

View File

@ -1,8 +1,8 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC and authors.
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
* All rights reserved.
* ======================================================
*
@ -21,8 +21,6 @@
* 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_LOADER_BRIDGE_H_
@ -56,6 +54,7 @@ struct gamedll_bridge_info
void * pGlobals;
unsigned int dllVersion;
void * isgd;
const char * vsp_listener_path;
};
class IGameDllBridge

View File

@ -31,6 +31,7 @@
#include <sh_memfuncinfo.h>
#include <sh_memory.h>
#include "serverplugin.h"
#include "gamedll.h"
typedef enum
{
@ -52,12 +53,6 @@ class CCommand;
class IServerPluginCallbacks;
struct edict_t;
#if defined WIN32
#define LIBRARY_EXT ".dll"
#else
#define LIBRARY_EXT "_i486.so"
#endif
class IRandomThings
{
public:
@ -90,19 +85,23 @@ public:
load_allowed = false;
/* Backend should already filled in if loaded as gamedll */
if (gamedll_bridge == NULL)
{
if ((game_name = mm_GetGameName()) == NULL)
{
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");
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 */
void **vtable_src;
@ -132,18 +131,24 @@ public:
}
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;
}
}
typedef IVspBridge *(*GetVspBridge)();
GetVspBridge get_bridge = (GetVspBridge)mm_GetProcAddress("GetVspBridge");
if (get_bridge == NULL)
{
if (gamedll_bridge == NULL)
{
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;
}
@ -160,8 +165,11 @@ public:
if (!vsp_bridge->Load(&info, error, sizeof(error)))
{
vsp_bridge = NULL;
if (gamedll_bridge == NULL)
{
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;
}
@ -172,8 +180,12 @@ public:
if (vsp_bridge == NULL)
return;
vsp_bridge->Unload();
if (gamedll_bridge == NULL)
{
mm_UnloadMetamodLibrary();
}
}
virtual void Pause()
{
}