From 769ce745b0af697c78d80291589c9639e6a77b93 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Thu, 22 Jul 2010 03:22:27 -0500 Subject: [PATCH] Added support for Alien Swarm (bug 4529, r=dvander). --- AMBuildScript | 12 +++++++++++- core/ISmmPluginExt.h | 1 + core/metamod_console.cpp | 4 +++- core/provider/console.cpp | 4 ++++ core/provider/console.h | 8 -------- core/provider/provider_ep2.cpp | 4 +++- loader/loader.cpp | 16 ++++++++++++++-- loader/loader.h | 1 + 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index fbf61e2..2e5a74b 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -21,6 +21,8 @@ class MMS: 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux']} self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', 'name': 'DARKMESSIAH', 'platform': ['windows']} + self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '7', + 'name': 'ALIENSWARM', 'platform': ['windows']} if AMBuild.mode == 'config': #Detect compilers @@ -39,6 +41,7 @@ class MMS: #Dark Messiah is Windows-only if AMBuild.target['platform'] == 'windows': envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm' + envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm' #Must have a path for each envvar (file a bug if you don't like this) for i in envvars: @@ -90,6 +93,7 @@ class MMS: self.vendor = 'msvc' if AMBuild.options.debug == '1': self.compiler.AddToListVar('CFLAGS', '/MTd') + self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt') else: self.compiler.AddToListVar('CFLAGS', '/MT') self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE') @@ -241,7 +245,10 @@ class MMS: except: job.AddCommand(SymlinkCommand(link, target)) elif AMBuild.target['platform'] == 'windows': - for lib in ['tier0', 'tier1', 'vstdlib']: + libs = ['tier0', 'tier1', 'vstdlib'] + if sdk == 'swarm': + libs.append('interfaces') + for lib in libs: libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib' builder.RebuildIfNewer(libPath) builder['POSTLINKFLAGS'].append(libPath) @@ -275,6 +282,9 @@ class MMS: compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def']) + if sdk == 'swarm' and AMBuild.target['platform'] == 'windows': + compiler['CDEFINES'].extend(['COMPILER_MSVC', 'COMPILER_MSVC32']) + if sdk == 'ep1': if AMBuild.target['platform'] == 'linux': staticLibs = os.path.join(sdkPath, 'linux_sdk') diff --git a/core/ISmmPluginExt.h b/core/ISmmPluginExt.h index 3eb64ae..13dbcb5 100644 --- a/core/ISmmPluginExt.h +++ b/core/ISmmPluginExt.h @@ -43,6 +43,7 @@ #define SOURCE_ENGINE_DARKMESSIAH 5 /**< Dark Messiah Multiplayer (based on original engine) */ #define SOURCE_ENGINE_ORANGEBOXVALVE 6 /**< Orange Box Source Engine for Valve games (TF2/DOD:S) */ #define SOURCE_ENGINE_LEFT4DEAD2 7 /**< Left 4 Dead 2 */ +#define SOURCE_ENGINE_ALIENSWARM 8 /**< Alien Swarm */ #define METAMOD_PLAPI_VERSION 15 /**< Version of this header file */ #define METAMOD_PLAPI_NAME "ISmmPlugin" /**< Name of the plugin interface */ diff --git a/core/metamod_console.cpp b/core/metamod_console.cpp index 7e78c46..56bc21e 100644 --- a/core/metamod_console.cpp +++ b/core/metamod_console.cpp @@ -111,7 +111,9 @@ bool Command_Meta(IMetamodSourceCommandInfo *info) } #endif -#if SOURCE_ENGINE == SE_LEFT4DEAD2 +#if SOURCE_ENGINE == SE_ALIENSWARM + CONMSG(" Engine: Alien Swarm (2010)\n"); +#elif SOURCE_ENGINE == SE_LEFT4DEAD2 CONMSG(" Engine: Left 4 Dead 2 (2009)\n"); #elif SOURCE_ENGINE == SE_LEFT4DEAD CONMSG(" Engine: Left 4 Dead (2008)\n"); diff --git a/core/provider/console.cpp b/core/provider/console.cpp index 2a70924..7e921da 100644 --- a/core/provider/console.cpp +++ b/core/provider/console.cpp @@ -41,7 +41,9 @@ SMConVarAccessor g_SMConVarAccessor; bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand) { m_RegisteredCommands.push_back(pCommand); +#if SOURCE_ENGINE != SE_ALIENSWARM pCommand->SetNext(NULL); +#endif icvar->RegisterConCommand(pCommand); return true; @@ -49,7 +51,9 @@ bool SMConVarAccessor::RegisterConCommandBase(ConCommandBase *pCommand) bool SMConVarAccessor::Register(ConCommandBase *pCommand) { +#if SOURCE_ENGINE != SE_ALIENSWARM pCommand->SetNext(NULL); +#endif icvar->RegisterConCommand(pCommand); return true; diff --git a/core/provider/console.h b/core/provider/console.h index ad56755..9baff51 100644 --- a/core/provider/console.h +++ b/core/provider/console.h @@ -28,18 +28,10 @@ #ifndef _INCLUDE_CONSOLE_MMS_H_ #define _INCLUDE_CONSOLE_MMS_H_ -#if defined _DEBUG -#define DEBUG2 -#undef _DEBUG -#endif #include #include "convar.h" #include #include -#if defined DEBUG2 -#undef DEBUG2 -#define _DEBUG -#endif class SMConVarAccessor : public IConCommandBaseAccessor { diff --git a/core/provider/provider_ep2.cpp b/core/provider/provider_ep2.cpp index 5a1e282..af2a95e 100644 --- a/core/provider/provider_ep2.cpp +++ b/core/provider/provider_ep2.cpp @@ -358,7 +358,9 @@ const char *BaseProvider::GetGameDescription() int BaseProvider::DetermineSourceEngine(const char *game) { -#if SOURCE_ENGINE == SE_LEFT4DEAD2 +#if SOURCE_ENGINE == SE_ALIENSWARM + return SOURCE_ENGINE_ALIENSWARM; +#elif SOURCE_ENGINE == SE_LEFT4DEAD2 return SOURCE_ENGINE_LEFT4DEAD2; #elif SOURCE_ENGINE == SE_LEFT4DEAD return SOURCE_ENGINE_LEFT4DEAD; diff --git a/loader/loader.cpp b/loader/loader.cpp index f7111cd..23d9697 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -75,7 +75,8 @@ static const char *backend_names[] = "2.ep2", "2.ep2v", "2.l4d", - "2.l4d2" + "2.l4d2", + "2.swarm" }; #if defined _WIN32 @@ -212,6 +213,13 @@ mm_GetGameName() } valve_cmdline = (GetCommandLine)mm_GetLibAddress(lib, "CommandLine_Tier0"); + + /* '_Tier0' dropped on Alien Swarm version */ + if (valve_cmdline == NULL) + { + valve_cmdline = (GetCommandLine)mm_GetLibAddress(lib, "CommandLine"); + } + if (valve_cmdline == NULL) { /* We probably have a Ship engine. */ @@ -257,7 +265,11 @@ mm_DetermineBackend(QueryValveInterface engineFactory, const char *game_name) if (engineFactory("VEngineServer022", NULL) != NULL && engineFactory("VEngineCvar007", NULL) != NULL) { - if (engineFactory("VPrecacheSystem001", NULL) != NULL) + if (engineFactory("EngineTraceServer004", NULL) != NULL) + { + return MMBackend_AlienSwarm; + } + else if (engineFactory("VPrecacheSystem001", NULL) != NULL) { return MMBackend_Left4Dead2; } diff --git a/loader/loader.h b/loader/loader.h index ca95a70..a6543fa 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -86,6 +86,7 @@ enum MetamodBackend MMBackend_Episode2Valve, MMBackend_Left4Dead, MMBackend_Left4Dead2, + MMBackend_AlienSwarm, MMBackend_UNKNOWN };