From 0f2d7aa234463a3100cfcd80540f9d65fd407e3d Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 4 Mar 2013 10:38:17 -0500 Subject: [PATCH] Added support for Dota 2 (bug 5640). --- AMBuildScript | 9 ++++++--- core/ISmmPluginExt.h | 1 + core/metamod_console.cpp | 2 ++ core/provider/provider_ep2.cpp | 6 ++++-- loader/loader.cpp | 8 ++++++-- loader/loader.h | 1 + 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index b7bb62f..1b4181b 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -31,6 +31,8 @@ class MMS: 'name': 'EYE', 'platform': ['windows']} self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12', 'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin']} + self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13', + 'name': 'DOTA', 'platform': ['windows']} # self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11', # 'name': 'PORTAL2', 'platform': ['windows']} @@ -58,6 +60,7 @@ class MMS: envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm' envvars['HL2SDK-BGT'] = 'hl2sdk-bgt' envvars['HL2SDK-EYE'] = 'hl2sdk-eye' + envvars['HL2SDK-DOTA'] = 'hl2sdk-dota' # Finds if a dict with `key` set to `value` is present on the dict of dicts `dictionary` def findDictByKey(dictionary, key, value): @@ -309,7 +312,7 @@ class MMS: job.AddCommand(SymlinkCommand(link, target)) elif AMBuild.target['platform'] == 'windows': libs = ['tier0', 'tier1', 'vstdlib'] - if sdk in ['swarm', 'csgo']: + if sdk in ['swarm', 'csgo', 'dota']: libs.append('interfaces') for lib in libs: libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib' @@ -319,7 +322,7 @@ class MMS: def PostSetupHL2Job(self, job, builder, sdk): if AMBuild.target['platform'] in ['linux', 'darwin']: builder.AddObjectFiles(['tier1_i486.a']) - if( sdk == 'csgo' ): + if( sdk in ['csgo', 'dota'] ): builder.AddObjectFiles(['interfaces_i486.a']) def DefaultHL2Compiler(self, path, sdk, noLink = False): @@ -351,7 +354,7 @@ class MMS: compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def']) - if sdk in ['swarm', 'csgo']: + if sdk in ['swarm', 'csgo', 'dota']: if AMBuild.target['platform'] == 'windows': compiler['CDEFINES'].extend(['COMPILER_MSVC', 'COMPILER_MSVC32']) else: diff --git a/core/ISmmPluginExt.h b/core/ISmmPluginExt.h index 50fab8f..b9c3339 100644 --- a/core/ISmmPluginExt.h +++ b/core/ISmmPluginExt.h @@ -56,6 +56,7 @@ enum #define SOURCE_ENGINE_PORTAL2 11 /**< Portal 2 */ #define SOURCE_ENGINE_CSGO 12 /**< Counter-Strike: Global Offensive */ #define SOURCE_ENGINE_CSS 13 /**< Counter-Strike: Source (sometimes older version of Orange Box Valve) */ +#define SOURCE_ENGINE_DOTA 14 /**< Dota 2 */ #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 ff4c552..3f17162 100644 --- a/core/metamod_console.cpp +++ b/core/metamod_console.cpp @@ -133,6 +133,8 @@ bool Command_Meta(IMetamodSourceCommandInfo *info) CONMSG(" Engine: Portal 2 (2011)\n"); #elif SOURCE_ENGINE == SE_CSGO CONMSG(" Engine: Counter-Strike: Global Offensive (2012)\n"); +#elif SOURCE_ENGINE == SE_DOTA + CONMSG(" Engine: Dota 2 (2013)\n"); #else #error "SOURCE_ENGINE not defined to a known value" #endif diff --git a/core/provider/provider_ep2.cpp b/core/provider/provider_ep2.cpp index 960f057..40578b5 100644 --- a/core/provider/provider_ep2.cpp +++ b/core/provider/provider_ep2.cpp @@ -315,7 +315,7 @@ void BaseProvider::UnregisterConCommandBase(ConCommandBase *pCommand) int BaseProvider::GetUserMessageCount() { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA return -1; #else return (int)usermsgs_list.size(); @@ -383,6 +383,8 @@ int BaseProvider::DetermineSourceEngine(const char *game) return SOURCE_ENGINE_PORTAL2; #elif SOURCE_ENGINE == SE_CSGO return SOURCE_ENGINE_CSGO; +#elif SOURCE_ENGINE == SE_DOTA + return SOURCE_ENGINE_DOTA; #else #error "SOURCE_ENGINE not defined to a known value" #endif @@ -526,7 +528,7 @@ void ClientCommand(edict_t *pEdict) RETURN_META(MRES_IGNORED); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA void CacheUserMessages() { diff --git a/loader/loader.cpp b/loader/loader.cpp index 2ee8eef..7f3cc71 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -81,7 +81,8 @@ static const char *backend_names[] = "2.l4d2", "2.swarm", "2.portal2", - "2.csgo" + "2.csgo", + "2.dota", }; #if defined _WIN32 @@ -281,7 +282,10 @@ mm_DetermineBackend(QueryValveInterface engineFactory, const char *game_name) /* Check for L4D */ if (engineFactory("VEngineServer023", NULL) != NULL) { - return MMBackend_CSGO; + if (engineFactory("ISERVERPLUGINHELPERS001", NULL) != NULL) + return MMBackend_CSGO; + else + return MMBackend_DOTA; } else if (engineFactory("VEngineServer022", NULL) != NULL && engineFactory("VEngineCvar007", NULL) != NULL) diff --git a/loader/loader.h b/loader/loader.h index 9544c57..3cdadaa 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -92,6 +92,7 @@ enum MetamodBackend MMBackend_AlienSwarm, MMBackend_Portal2, MMBackend_CSGO, + MMBackend_DOTA, MMBackend_UNKNOWN };