Use newer MM:S api for Ep1/Original engine. (#548)
* Use newer MM:S api for Ep1/Original engine. * Remove doubled FILENAME_1_6_EP1 define.
This commit is contained in:
parent
d9312799c3
commit
ad3588d0aa
@ -17,7 +17,7 @@ WinLinux = ['windows', 'linux']
|
||||
WinLinuxMac = ['windows', 'linux', 'mac']
|
||||
|
||||
PossibleSDKs = {
|
||||
'episode1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
|
||||
'episode1': SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
|
||||
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
|
||||
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
|
||||
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
|
||||
@ -362,14 +362,9 @@ class SMConfig(object):
|
||||
def ConfigureForHL2(self, binary, sdk):
|
||||
compiler = binary.compiler
|
||||
|
||||
if sdk.name == 'episode1':
|
||||
mms_path = os.path.join(self.mms_root, 'core-legacy')
|
||||
else:
|
||||
mms_path = os.path.join(self.mms_root, 'core')
|
||||
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(mms_path),
|
||||
os.path.join(mms_path, 'sourcehook'),
|
||||
os.path.join(self.mms_root, 'core'),
|
||||
os.path.join(self.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
|
||||
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
|
||||
|
@ -62,16 +62,10 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if SH_IMPL_VERSION >= 5
|
||||
# if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||
# else
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
# endif
|
||||
#else
|
||||
extern int __SourceHook_FHVPAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>,bool);
|
||||
extern int __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
|
||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
#endif
|
||||
|
||||
class GenericCommandHooker : public IConCommandLinkListener
|
||||
|
@ -70,12 +70,8 @@ void CheckAndFinalizeConfigs();
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||
void Hook_ExecDispatchPre(const CCommand &cmd)
|
||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
void Hook_ExecDispatchPre()
|
||||
#else
|
||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
void Hook_ExecDispatchPre()
|
||||
#endif
|
||||
{
|
||||
|
@ -50,11 +50,8 @@ SH_DECL_HOOK4_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, co
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
#else
|
||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
#endif
|
||||
|
||||
ConCommand *changeLevelCmd = NULL;
|
||||
|
@ -90,11 +90,8 @@ SH_DECL_HOOK1_void(IServerGameDLL, SetServerHibernation, SH_NOATTRIB, 0, bool);
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
#else
|
||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
#endif
|
||||
|
||||
ConCommand *maxplayersCmd = NULL;
|
||||
|
@ -354,7 +354,6 @@ void UTIL_ConsolePrint(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
#if SOURCE_ENGINE == SE_LEFT4DEAD
|
||||
#define GAMEFIX "2.l4d"
|
||||
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
|
||||
@ -395,10 +394,7 @@ void UTIL_ConsolePrint(const char *fmt, ...)
|
||||
#define GAMEFIX "2.contagion"
|
||||
#else
|
||||
#define GAMEFIX "2.ep1"
|
||||
#endif //(SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||
#else //METAMOD_PLAPI_VERSION
|
||||
#define GAMEFIX "1.ep1"
|
||||
#endif //METAMOD_PLAPI_VERSION
|
||||
#endif
|
||||
|
||||
static ServerGlobals serverGlobals;
|
||||
|
||||
@ -601,18 +597,7 @@ int CoreProviderImpl::LoadMMSPlugin(const char *file, bool *ok, char *error, siz
|
||||
|
||||
Pl_Status status;
|
||||
|
||||
#ifndef METAMOD_PLAPI_VERSION
|
||||
const char *filep;
|
||||
PluginId source;
|
||||
#endif
|
||||
|
||||
if (!id || (
|
||||
#ifndef METAMOD_PLAPI_VERSION
|
||||
g_pMMPlugins->Query(id, filep, status, source)
|
||||
#else
|
||||
g_pMMPlugins->Query(id, NULL, &status, NULL)
|
||||
#endif
|
||||
&& status < Pl_Paused))
|
||||
if (!id || (g_pMMPlugins->Query(id, NULL, &status, NULL) && status < Pl_Paused))
|
||||
{
|
||||
*ok = false;
|
||||
}
|
||||
|
@ -484,9 +484,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
|
||||
return 10;
|
||||
case SOURCE_ENGINE_EPISODEONE:
|
||||
return 20;
|
||||
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
/* Newer games. */
|
||||
case SOURCE_ENGINE_DARKMESSIAH:
|
||||
return 15;
|
||||
case SOURCE_ENGINE_ORANGEBOX:
|
||||
@ -516,7 +513,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
|
||||
return 70;
|
||||
case SOURCE_ENGINE_CSGO:
|
||||
return 80;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -525,7 +521,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t GetEngineVersion(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int engineVer = g_SMAPI->GetSourceEngineBuild();
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
if (engineVer == SOURCE_ENGINE_ORANGEBOXVALVE_DEPRECATED)
|
||||
{
|
||||
const char *gamedir = g_SourceMod.GetGameFolderName();
|
||||
@ -538,7 +533,6 @@ static cell_t GetEngineVersion(IPluginContext *pContext, const cell_t *params)
|
||||
else if (strcmp(gamedir, "hl2mp") == 0)
|
||||
return SOURCE_ENGINE_HL2DM;
|
||||
}
|
||||
#endif
|
||||
|
||||
return engineVer;
|
||||
}
|
||||
|
@ -63,13 +63,6 @@ int vsp_version = 0;
|
||||
|
||||
PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
|
||||
|
||||
#if !defined(METAMOD_PLAPI_VERSION) && PLAPI_VERSION < 11
|
||||
# error "SourceMod requires Metamod:Source 1.8 or higher."
|
||||
#endif
|
||||
#if SH_IMPL_VERSION < 4
|
||||
# error "SourceMod requires a newer version of SourceHook."
|
||||
#endif
|
||||
|
||||
ConVar sourcemod_version("sourcemod_version", SOURCEMOD_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "SourceMod Version");
|
||||
|
||||
bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
|
@ -49,10 +49,6 @@
|
||||
#include <IEngineSound.h>
|
||||
#include <toolframework/itoolentity.h>
|
||||
|
||||
#ifndef METAMOD_PLAPI_VERSION
|
||||
#include <metamod_wrappers.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file Contains wrappers around required Metamod:Source API exports
|
||||
*/
|
||||
|
@ -18,12 +18,6 @@
|
||||
|
||||
#include "takedamageinfohack.h"
|
||||
|
||||
#ifndef METAMOD_PLAPI_VERSION
|
||||
#define GetCGlobals pGlobals
|
||||
#define GetEngineFactory engineFactory
|
||||
#define GetServerFactory serverFactory
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE >= SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD
|
||||
#define GETMAXHEALTH_IS_VIRTUAL
|
||||
#endif
|
||||
|
@ -357,11 +357,7 @@ void SDKTools::NotifyInterfaceDrop(SMInterface *pInterface)
|
||||
|
||||
bool SDKTools::RegisterConCommandBase(ConCommandBase *pVar)
|
||||
{
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
return g_SMAPI->RegisterConCommandBase(g_PLAPI, pVar);
|
||||
#else
|
||||
return g_SMAPI->RegisterConCmdBase(g_PLAPI, pVar);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
|
||||
|
@ -41,10 +41,6 @@
|
||||
#define PLATFORM_EXT ".dll"
|
||||
#define vsnprintf _vsnprintf
|
||||
#define PATH_SEP_CHAR "\\"
|
||||
inline bool IsPathSepChar(char c)
|
||||
{
|
||||
return (c == '/' || c == '\\');
|
||||
}
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#define DLL_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
@ -58,15 +54,10 @@
|
||||
#endif
|
||||
typedef void * HINSTANCE;
|
||||
#define PATH_SEP_CHAR "/"
|
||||
inline bool IsPathSepChar(char c)
|
||||
{
|
||||
return (c == '/');
|
||||
}
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define METAMOD_API_MAJOR 2
|
||||
#define FILENAME_1_4_EP1 "sourcemod.1.ep1" PLATFORM_EXT
|
||||
#define FILENAME_1_6_EP2 "sourcemod.2.ep2" PLATFORM_EXT
|
||||
#define FILENAME_1_6_EP1 "sourcemod.2.ep1" PLATFORM_EXT
|
||||
#define FILENAME_1_6_L4D "sourcemod.2.l4d" PLATFORM_EXT
|
||||
@ -187,28 +178,6 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
|
||||
{
|
||||
#if defined _MSC_VER
|
||||
MEMORY_BASIC_INFORMATION mem;
|
||||
if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
|
||||
return false;
|
||||
if (mem.AllocationBase == NULL)
|
||||
return false;
|
||||
HMODULE dll = (HMODULE)mem.AllocationBase;
|
||||
GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
|
||||
#else
|
||||
Dl_info info;
|
||||
if (!dladdr(pAddr, &info))
|
||||
return false;
|
||||
if (!info.dli_fbase || !info.dli_fname)
|
||||
return false;
|
||||
const char *dllpath = info.dli_fname;
|
||||
snprintf(buffer, maxlength, "%s", dllpath);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, const MetamodLoaderInfo *mli)
|
||||
{
|
||||
const char *filename;
|
||||
@ -373,44 +342,6 @@ DLL_EXPORT void UnloadInterface_MMS()
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT void *CreateInterface(const char *iface, int *ret)
|
||||
{
|
||||
/**
|
||||
* If a load has already been attempted, bail out immediately.
|
||||
*/
|
||||
if (load_attempted)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
|
||||
{
|
||||
char thisfile[256];
|
||||
char targetfile[256];
|
||||
|
||||
if (!GetFileOfAddress((void *)CreateInterface_MMS, thisfile, sizeof(thisfile)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t len = strlen(thisfile);
|
||||
for (size_t iter=len-1; iter<len; iter--)
|
||||
{
|
||||
if (IsPathSepChar(thisfile[iter]))
|
||||
{
|
||||
thisfile[iter] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UTIL_Format(targetfile, sizeof(targetfile), "%s" PATH_SEP_CHAR FILENAME_1_4_EP1, thisfile);
|
||||
|
||||
return _GetPluginPtr(targetfile, METAMOD_FAIL_API_V1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined _MSC_VER
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user