From a36c266e7d22e86719c5855739e2f25c15098529 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 21 Jul 2013 11:53:56 -0400 Subject: [PATCH] Split TF2, DoD:S, HL2:DM, and ND to separate binaries (bug 5813, r=asherkin). --- AMBuildScript | 45 +++++---- core/HalfLife2.cpp | 2 +- core/MenuStyle_Base.cpp | 2 +- core/PlayerManager.cpp | 22 ++--- core/convar_sm_l4d.h | 2 +- core/logic/ExtensionSys.cpp | 18 ++++ core/logic/GameConfigs.cpp | 101 ++++++++++++++------- core/logic/GameConfigs.h | 6 +- core/logic_bridge.cpp | 20 +++- core/smn_console.cpp | 6 +- core/smn_entities.cpp | 8 +- core/smn_halflife.cpp | 13 ++- extensions/sdkhooks/extension.cpp | 6 +- extensions/sdkhooks/extension.h | 4 +- extensions/sdkhooks/takedamageinfohack.cpp | 2 +- extensions/sdktools/gamerulesnatives.cpp | 5 +- extensions/sdktools/vcaller.cpp | 2 +- extensions/sdktools/vnatives.cpp | 2 +- extensions/sdktools/vsound.cpp | 16 ++-- extensions/sdktools/vsound.h | 4 +- extensions/tf2/AMBuilder | 10 +- loader/loader.cpp | 51 +++++++++-- plugins/basechat.sp | 6 +- plugins/funcommands.sp | 15 +-- plugins/funcommands/ice.sp | 4 +- plugins/include/halflife.inc | 33 +++++++ plugins/playercommands.sp | 4 +- plugins/playercommands/rename.sp | 2 +- plugins/reservedslots.sp | 13 +-- plugins/testsuite/cstrike-test.sp | 8 +- public/sm_platform.h | 4 + tools/buildbot/PackageScript | 4 +- 32 files changed, 298 insertions(+), 142 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index 0d55fde1..92ae138c 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -38,37 +38,46 @@ class SM: self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3', 'name': 'ORANGEBOX', 'platform': ['windows', 'linux'], 'dir': 'hl2sdk-ob'} - self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6', + self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6', 'name': 'CSS', 'platform': ['windows', 'linux', 'darwin'], 'dir': 'hl2sdk-css'} - self.possibleSdks['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '7', - 'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin'], - 'dir': 'hl2sdk-ob-valve'} - self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '8', + self.possibleSdks['hl2dm'] = {'sdk': 'HL2SDKHL2DM', 'ext': '2.hl2dm', 'def': '7', + 'name': 'HL2DM', 'platform': ['windows', 'linux', 'darwin'], + 'dir': 'hl2sdk-hl2dm'} + self.possibleSdks['dods'] = {'sdk': 'HL2SDKDODS', 'ext': '2.dods', 'def': '8', + 'name': 'DODS', 'platform': ['windows', 'linux', 'darwin'], + 'dir': 'hl2sdk-dods'} + self.possibleSdks['tf2'] = {'sdk': 'HL2SDKTF2', 'ext': '2.tf2', 'def': '9', + 'name': 'TF2', 'platform': ['windows', 'linux', 'darwin'], + 'dir': 'hl2sdk-tf2'} + self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '10', 'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin'], 'dir': 'hl2sdk-l4d'} - self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '9', + self.possibleSdks['nd'] = {'sdk': 'HL2SDKND', 'ext': '2.nd', 'def': '11', + 'name': 'NUCLEARDAWN', 'platform': ['windows', 'linux', 'darwin'], + 'dir': 'hl2sdk-nd'} + self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '12', 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin'], 'dir': 'hl2sdk-l4d2'} self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', 'name': 'DARKMESSIAH', 'platform': ['windows'], 'dir': 'hl2sdk-darkm'} - self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '10', + self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '13', 'name': 'ALIENSWARM', 'platform': ['windows'], 'dir': 'hl2sdk-swarm'} - self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4', + self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4', 'name': 'BLOODYGOODTIME', 'platform': ['windows'], 'dir': 'hl2sdk-bgt'} - self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5', - 'name': 'EYE', 'platform': ['windows'], + self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5', + 'name': 'EYE', 'platform': ['windows'], 'dir': 'hl2sdk-eye'} - self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12', + self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '15', 'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin'], 'dir': 'hl2sdk-csgo'} - self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13', + self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '16', 'name': 'DOTA', 'platform': ['windows'], 'dir': 'hl2sdk-dota'} - # self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11', + # self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '14', # 'name': 'PORTAL2', 'platform': ['windows'], # 'dir': 'hl2sdk-portal2'} @@ -312,7 +321,7 @@ class SM: else: staticLibs = os.path.join(sdkPath, 'lib', 'linux') workFolder = os.path.join(AMBuild.outputFolder, job.workFolder) - if sdk in ['ep2v', 'css', 'l4d2']: + if sdk in ['css', 'hl2dm', 'dods', 'tf2', 'l4d2']: libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib_srv.so', 'libtier0_srv.so'] for lib in libs: link = os.path.join(workFolder, lib) @@ -321,7 +330,7 @@ class SM: os.lstat(link) except: job.AddCommand(SymlinkCommand(link, target)) - elif sdk in ['l4d', 'csgo']: + elif sdk in ['l4d', 'nd', 'csgo']: libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.so', 'libtier0.so'] if sdk == 'csgo': libs.append('interfaces_i486.a') @@ -384,7 +393,7 @@ class SM: # We don't build for Portal 2 (yet?, ever?), but using this define in code as # it saves trouble if we ever need to - compiler['CDEFINES'].append('SE_PORTAL2=11') + compiler['CDEFINES'].append('SE_PORTAL2=14') paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'], ['public', 'tier0'], ['public', 'tier1']] @@ -423,10 +432,10 @@ class SM: if not noLink: if AMBuild.target['platform'] == 'linux': compiler['POSTLINKFLAGS'][0:0] = ['-lm'] - if sdk in ['ep2v', 'css', 'l4d2']: + if sdk in ['css', 'hl2dm', 'dods', 'tf2', 'l4d2']: compiler['POSTLINKFLAGS'][0:0] = ['libtier0_srv.so'] compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib_srv.so'] - elif sdk in ['l4d', 'csgo']: + elif sdk in ['l4d', 'nd', 'csgo']: compiler['POSTLINKFLAGS'][0:0] = ['libtier0.so'] compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.so'] else: diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index ab2765a1..eea6c8a9 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -58,7 +58,7 @@ typedef ICommandLine *(*FakeGetCommandLine)(); #define TIER0_NAME "libtier0.dylib" #define VSTDLIB_NAME "libvstdlib.dylib" #elif defined __linux__ -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2 +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_LEFT4DEAD2 #define TIER0_NAME "libtier0_srv.so" #define VSTDLIB_NAME "libvstdlib_srv.so" #elif SOURCE_ENGINE >= SE_LEFT4DEAD diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index 748133a9..381328a9 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -338,7 +338,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) #endif 0, PITCH_NORM, -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 0, #endif &pos); diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 5c4790bd..24e5c498 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -266,7 +266,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl #endif { static ConVar *tv_enable = icvar->FindVar("tv_enable"); -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_TF2 static ConVar *replay_enable = icvar->FindVar("replay_enable"); #endif @@ -276,7 +276,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl ICommandLine *commandLine = g_HL2.GetValveCommandLine(); m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && (!commandLine || commandLine->FindParm("-nohltv") == 0)); m_bIsReplayActive = false; -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_TF2 m_bIsReplayActive = (replay_enable && replay_enable->GetBool()); #endif m_PlayersSinceActive = 0; @@ -634,17 +634,14 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername int newCount = m_PlayersSinceActive + 1; int userId = GetPlayerUserId(pEntity); -#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2) +#if (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2) static ConVar *tv_name = icvar->FindVar("tv_name"); #endif -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_TF2 static ConVar *replay_name = icvar->FindVar("replay_name"); #endif -#if SOURCE_ENGINE == SE_LEFT4DEAD2 - static bool bIsNuclearDawn = (strcmp(g_SourceMod.GetGameFolderName(), "nucleardawn") == 0); -#endif -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_TF2 if (m_bIsReplayActive && newCount == 1 && (m_ReplayUserId == userId || (replay_name && strcmp(playername, replay_name->GetString()) == 0) || (replay_name && replay_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0) @@ -662,15 +659,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername && (m_SourceTVUserId == userId #if SOURCE_ENGINE == SE_CSGO || strcmp(playername, "GOTV") == 0 -#elif (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2) -#if SOURCE_ENGINE == SE_LEFT4DEAD2 - || (bIsNuclearDawn && ( true -#endif // SE_LEFT4DEAD2 +#elif (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_NUCLEARDAWN) || (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0) -#if SOURCE_ENGINE == SE_LEFT4DEAD2 - )) - || (!bIsNuclearDawn && strcmp(playername, "SourceTV") == 0) -#endif // SE_LEFT4DEAD2 #else || strcmp(playername, "SourceTV") == 0 #endif diff --git a/core/convar_sm_l4d.h b/core/convar_sm_l4d.h index b25098f9..7e535e55 100644 --- a/core/convar_sm_l4d.h +++ b/core/convar_sm_l4d.h @@ -386,7 +386,7 @@ public: virtual void SetValue( const char *value ); virtual void SetValue( float value ); virtual void SetValue( int value ); -#if SOURCE_ENGINE >= SE_LEFT4DEAD2 +#if SOURCE_ENGINE >= SE_NUCLEARDAWN virtual void SetValue( Color value ); #endif diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index 9342b82e..61989e5a 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -84,6 +84,24 @@ CLocalExtension::CLocalExtension(const char *filename) goto found; } + /* COMPAT HACK: One-halfth, if ep2v, see if there is an engine specific build in the new place with old naming */ + if (strcmp(smcore.gamesuffix, "2.tf2") == 0 + || strcmp(smcore.gamesuffix, "2.dods") == 0 + || strcmp(smcore.gamesuffix, "2.hl2dm") == 0 + ) + { + g_pSM->BuildPath(Path_SM, + path, + PLATFORM_MAX_PATH, + "extensions/%s.2.ep2v." PLATFORM_LIB_EXT, + filename); + + if (libsys->IsPathFile(path)) + { + goto found; + } + } + /* First see if there is an engine specific build! */ g_pSM->BuildPath(Path_SM, path, diff --git a/core/logic/GameConfigs.cpp b/core/logic/GameConfigs.cpp index 7a9aa74c..2cd305f2 100644 --- a/core/logic/GameConfigs.cpp +++ b/core/logic/GameConfigs.cpp @@ -54,6 +54,7 @@ IGameConfig *g_pGameConf = NULL; static char g_Game[256]; static char g_GameDesc[256] = {'!', '\0'}; static char g_GameName[256] = {'$', '\0'}; +static const char *g_pParseEngine = NULL; #define PSTATE_NONE 0 #define PSTATE_GAMES 1 @@ -112,10 +113,10 @@ static bool DoesGameMatch(const char *value) static bool DoesEngineMatch(const char *value) { - return strcmp(value, smcore.GetSourceEngineName()) == 0; + return strcmp(value, g_pParseEngine) == 0; } -CGameConfig::CGameConfig(const char *file) +CGameConfig::CGameConfig(const char *file, const char *engine) { strncopy(m_File, file, sizeof(m_File)); m_pAddresses = new KTrie(); @@ -124,6 +125,16 @@ CGameConfig::CGameConfig(const char *file) m_CustomLevel = 0; m_CustomHandler = NULL; + + if (!engine) + m_pEngine = smcore.GetSourceEngineName(); + else + m_pEngine = engine; + + if (strcmp(m_pEngine, "css") == 0 || strcmp(m_pEngine, "dods") == 0 || strcmp(m_pEngine, "hl2dm") == 0 || strcmp(m_pEngine, "tf2") == 0) + this->SetBaseEngine("orangebox_valve"); + else + this->SetBaseEngine(NULL); } CGameConfig::~CGameConfig() @@ -772,19 +783,29 @@ bool CGameConfig::Reparse(char *error, size_t maxlength) SMCStates state = {0, 0}; List fileList; master_reader.fileList = &fileList; + const char *pEngine[2] = { m_pBaseEngine, m_pEngine }; - err = textparsers->ParseSMCFile(path, &master_reader, &state, error, maxlength); - if (err != SMCError_Okay) + for (unsigned char iter = 0; iter < SM_ARRAYSIZE(pEngine); ++iter) { - const char *msg = textparsers->GetSMCErrorString(err); + if (pEngine[iter] == NULL) + { + continue; + } - smcore.LogError("[SM] Error parsing master gameconf file \"%s\":", path); - smcore.LogError("[SM] Error %d on line %d, col %d: %s", - err, - state.line, - state.col, - msg ? msg : "Unknown error"); - return false; + this->SetParseEngine(pEngine[iter]); + err = textparsers->ParseSMCFile(path, &master_reader, &state, error, maxlength); + if (err != SMCError_Okay) + { + const char *msg = textparsers->GetSMCErrorString(err); + + smcore.LogError("[SM] Error parsing master gameconf file \"%s\":", path); + smcore.LogError("[SM] Error %d on line %d, col %d: %s", + err, + state.line, + state.col, + msg ? msg : "Unknown error"); + return false; + } } /* Go through each file we found and parse it. */ @@ -850,35 +871,53 @@ bool CGameConfig::EnterFile(const char *file, char *error, size_t maxlength) m_IgnoreLevel = 0; bShouldBeReadingDefault = true; m_ParseState = PSTATE_NONE; + const char *pEngine[2] = { m_pBaseEngine, m_pEngine }; - if ((err=textparsers->ParseSMCFile(m_CurFile, this, &state, error, maxlength)) - != SMCError_Okay) + for (unsigned char iter = 0; iter < SM_ARRAYSIZE(pEngine); ++iter) { - const char *msg; - - msg = textparsers->GetSMCErrorString(err); - - smcore.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile); - smcore.LogError("[SM] Error %d on line %d, col %d: %s", - err, - state.line, - state.col, - msg ? msg : "Unknown error"); - - if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM) + if (pEngine[iter] == NULL) { - //error occurred while parsing a custom section - m_CustomHandler->ReadSMC_ParseEnd(true, true); - m_CustomHandler = NULL; - m_CustomLevel = 0; + continue; } - return false; + this->SetParseEngine(pEngine[iter]); + if ((err=textparsers->ParseSMCFile(m_CurFile, this, &state, error, maxlength)) + != SMCError_Okay) + { + const char *msg = textparsers->GetSMCErrorString(err); + + smcore.LogError("[SM] Error parsing gameconfig file \"%s\":", m_CurFile); + smcore.LogError("[SM] Error %d on line %d, col %d: %s", + err, + state.line, + state.col, + msg ? msg : "Unknown error"); + + if (m_ParseState == PSTATE_GAMEDEFS_CUSTOM) + { + //error occurred while parsing a custom section + m_CustomHandler->ReadSMC_ParseEnd(true, true); + m_CustomHandler = NULL; + m_CustomLevel = 0; + } + + return false; + } } return true; } +void CGameConfig::SetBaseEngine(const char *engine) +{ + m_pBaseEngine = engine; +} + +void CGameConfig::SetParseEngine(const char *engine) +{ + g_pParseEngine = engine; +} + bool CGameConfig::GetOffset(const char *key, int *value) { int *pvalue; diff --git a/core/logic/GameConfigs.h b/core/logic/GameConfigs.h index d24785d7..c1db3655 100644 --- a/core/logic/GameConfigs.h +++ b/core/logic/GameConfigs.h @@ -50,11 +50,13 @@ class CGameConfig : { friend class GameConfigManager; public: - CGameConfig(const char *file); + CGameConfig(const char *file, const char *engine = NULL); ~CGameConfig(); public: bool Reparse(char *error, size_t maxlength); bool EnterFile(const char *file, char *error, size_t maxlength); + void SetBaseEngine(const char *engine); + void SetParseEngine(const char *engine); public: //ITextListener_SMC SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name); SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value); @@ -111,6 +113,8 @@ private: int m_AddressReadCount; int m_AddressRead[8]; KTrie *m_pAddresses; + const char *m_pEngine; + const char *m_pBaseEngine; }; class GameConfigManager : diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index 5062513f..fc633024 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -214,10 +214,16 @@ static const char *get_source_engine_name() return "eye"; #elif SOURCE_ENGINE == SE_CSS return "css"; -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE - return "orangebox_valve"; +#elif SOURCE_ENGINE == SE_HL2DM + return "hl2dm"; +#elif SOURCE_ENGINE == SE_DODS + return "dods"; +#elif SOURCE_ENGINE == SE_TF2 + return "tf2"; #elif SOURCE_ENGINE == SE_LEFT4DEAD return "left4dead"; +#elif SOURCE_ENGINE == SE_NUCLEARDAWN + return "nucleardawn"; #elif SOURCE_ENGINE == SE_LEFT4DEAD2 return "left4dead2"; #elif SOURCE_ENGINE == SE_ALIENSWARM @@ -233,7 +239,7 @@ static const char *get_source_engine_name() static bool symbols_are_hidden() { -#if (SOURCE_ENGINE == SE_CSS) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2) || (SOURCE_ENGINE == SE_CSGO) || (SOURCE_ENGINE == SE_DOTA) +#if (SOURCE_ENGINE == SE_CSS) || (SOURCE_ENGINE == SE_HL2DM) || (SOURCE_ENGINE == SE_DODS) || (SOURCE_ENGINE == SE_TF2) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_NUCLEARDAWN) || (SOURCE_ENGINE == SE_LEFT4DEAD2) || (SOURCE_ENGINE == SE_CSGO) || (SOURCE_ENGINE == SE_DOTA) return true; #else return false; @@ -321,8 +327,12 @@ void do_global_plugin_loads() #define GAMEFIX "2.eye" #elif SOURCE_ENGINE == SE_CSS #define GAMEFIX "2.css" -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE -#define GAMEFIX "2.ep2v" +#elif SOURCE_ENGINE == SE_HL2DM +#define GAMEFIX "2.hl2dm" +#elif SOURCE_ENGINE == SE_DODS +#define GAMEFIX "2.dods" +#elif SOURCE_ENGINE == SE_TF2 +#define GAMEFIX "2.tf2" #elif SOURCE_ENGINE == SE_DARKMESSIAH #define GAMEFIX "2.darkm" #elif SOURCE_ENGINE == SE_PORTAL2 diff --git a/core/smn_console.cpp b/core/smn_console.cpp index e3d291ae..e4a4e039 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -916,7 +916,7 @@ cell_t g_ServerCommandBufferLength; bool g_ShouldCatchSpew = false; -#if SOURCE_ENGINE < SE_LEFT4DEAD2 +#if SOURCE_ENGINE < SE_NUCLEARDAWN SpewOutputFunc_t g_OriginalSpewOutputFunc = NULL; SpewRetval_t SourcemodSpewOutputFunc(SpewType_t spewType, tchar const *pMsg) @@ -955,7 +955,7 @@ CON_COMMAND(sm_conhook_start, "") return; } -#if SOURCE_ENGINE < SE_LEFT4DEAD2 +#if SOURCE_ENGINE < SE_NUCLEARDAWN g_OriginalSpewOutputFunc = GetSpewOutputFunc(); SpewOutputFunc(SourcemodSpewOutputFunc); #else @@ -976,7 +976,7 @@ CON_COMMAND(sm_conhook_stop, "") return; } -#if SOURCE_ENGINE < SE_LEFT4DEAD2 +#if SOURCE_ENGINE < SE_NUCLEARDAWN SpewOutputFunc(g_OriginalSpewOutputFunc); #else LoggingSystem_PopLoggingState(false); diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 8870ac58..d724e423 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -1208,7 +1208,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) is_unsigned = ((pProp->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED); // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -1306,7 +1306,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params) FIND_PROP_SEND(DPT_Int, "integer"); // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -2030,7 +2030,7 @@ static int32_t SDKEntFlagToSMEntFlag(int flag) #if SOURCE_ENGINE == SE_ALIENSWARM case FL_FREEZING: return ENTFLAG_FREEZING; -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 case FL_EP2V_UNKNOWN: return ENTFLAG_EP2V_UNKNOWN1; #endif @@ -2108,7 +2108,7 @@ static int32_t SMEntFlagToSDKEntFlag(int32_t flag) #if SOURCE_ENGINE == SE_ALIENSWARM case ENTFLAG_FREEZING: return FL_FREEZING; -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 case ENTFLAG_EP2V_UNKNOWN1: return FL_EP2V_UNKNOWN; #endif diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index 05394a81..d8c55f09 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -72,7 +72,7 @@ static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params) static cell_t GetEngineTime(IPluginContext *pContext, const cell_t *params) { -#if SOURCE_ENGINE >= SE_LEFT4DEAD2 +#if SOURCE_ENGINE >= SE_NUCLEARDAWN float fTime = Plat_FloatTime(); #else float fTime = engine->Time(); @@ -493,10 +493,13 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params) return 33; case SOURCE_ENGINE_CSS: return 34; - case SOURCE_ENGINE_ORANGEBOXVALVE: + case SOURCE_ENGINE_HL2DM: + case SOURCE_ENGINE_DODS: + case SOURCE_ENGINE_TF2: return 35; case SOURCE_ENGINE_LEFT4DEAD: return 40; + case SOURCE_ENGINE_NUCLEARDAWN: case SOURCE_ENGINE_LEFT4DEAD2: return 50; case SOURCE_ENGINE_ALIENSWARM: @@ -523,6 +526,11 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params) return 0; } +static cell_t GetEngineVersion(IPluginContext *pContext, const cell_t *params) +{ + return g_SMAPI->GetSourceEngineBuild(); +} + static cell_t IndexToReference(IPluginContext *pContext, const cell_t *params) { if (params[1] >= NUM_ENT_ENTRIES || params[1] < 0) @@ -574,6 +582,7 @@ REGISTER_NATIVES(halflifeNatives) {"ShowVGUIPanel", ShowVGUIPanel}, {"IsPlayerAlive", smn_IsPlayerAlive}, {"GuessSDKVersion", GuessSDKVersion}, + {"GetEngineVersion", GetEngineVersion}, {"EntIndexToEntRef", IndexToReference}, {"EntRefToEntIndex", ReferenceToIndex}, {"MakeCompatEntRef", ReferenceToBCompatRef}, diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index 18129579..6865ea5c 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -148,7 +148,7 @@ SH_DECL_MANUALHOOK0_void(Spawn, 0, 0, 0); SH_DECL_MANUALHOOK1_void(StartTouch, 0, 0, 0, CBaseEntity *); SH_DECL_MANUALHOOK0_void(Think, 0, 0, 0); SH_DECL_MANUALHOOK1_void(Touch, 0, 0, 0, CBaseEntity *); -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 SH_DECL_MANUALHOOK4_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *, void *); #else SH_DECL_MANUALHOOK3_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *); @@ -1244,7 +1244,7 @@ void SDKHooks::Hook_TouchPost(CBaseEntity *pOther) RETURN_META(MRES_IGNORED); } -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, void *pUnknownJK) #else void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr) @@ -1309,7 +1309,7 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, RETURN_META(MRES_IGNORED); } -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, void *pUnknownJK) #else void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr) diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index 10b29a71..7af983ab 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -19,7 +19,7 @@ #if SOURCE_ENGINE >= SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD #define GETMAXHEALTH_IS_VIRTUAL #endif -#if SOURCE_ENGINE != SE_ORANGEBOXVALVE && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN #define GAMEDESC_CAN_CHANGE #endif @@ -264,7 +264,7 @@ public: void Hook_ThinkPost(); void Hook_Touch(CBaseEntity *pOther); void Hook_TouchPost(CBaseEntity *pOther); -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 void Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, void *pUnknownJK); void Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, void *pUnknownJK); #else diff --git a/extensions/sdkhooks/takedamageinfohack.cpp b/extensions/sdkhooks/takedamageinfohack.cpp index a3a1ec8f..e7be1dab 100644 --- a/extensions/sdkhooks/takedamageinfohack.cpp +++ b/extensions/sdkhooks/takedamageinfohack.cpp @@ -62,7 +62,7 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity * m_vecReportedPosition = vec3_origin; m_iAmmoType = -1; -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 m_iDamagedOtherPlayers = 0; m_iPlayerPenetrateCount = 0; m_flUnknown = 0.0f; diff --git a/extensions/sdktools/gamerulesnatives.cpp b/extensions/sdktools/gamerulesnatives.cpp index ec3e24d9..8a7ad34e 100644 --- a/extensions/sdktools/gamerulesnatives.cpp +++ b/extensions/sdktools/gamerulesnatives.cpp @@ -174,7 +174,7 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params) is_unsigned = ((pProp->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED); // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -243,8 +243,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params) FIND_PROP_SEND(DPT_Int, "integer"); - // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later -#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_ORANGEBOXVALVE +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; diff --git a/extensions/sdktools/vcaller.cpp b/extensions/sdktools/vcaller.cpp index 8a83ed4a..d6bc1c41 100644 --- a/extensions/sdktools/vcaller.cpp +++ b/extensions/sdktools/vcaller.cpp @@ -129,7 +129,7 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p { return 0; } -#if (SOURCE_ENGINE == SE_CSS) || (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2) || (SOURCE_ENGINE == SE_CSGO) +#if (SOURCE_ENGINE == SE_CSS) || (SOURCE_ENGINE == SE_HL2DM) || (SOURCE_ENGINE == SE_DODS) || (SOURCE_ENGINE == SE_TF2) || (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2) || (SOURCE_ENGINE == SE_NUCLEARDAWN) || (SOURCE_ENGINE == SE_CSGO) s_call_addr = memutils->ResolveSymbol(handle, &sig[1]); #else s_call_addr = dlsym(handle, &sig[1]); diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 0f70d8a0..b130850a 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -532,7 +532,7 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params) CellRecipientFilter rf; rf.SetToReliable(true); rf.Initialize(player_list, total_players); -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 engsound->EmitSound(rf, params[1], CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, 0, &pos); #elif SOURCE_ENGINE < SE_PORTAL2 engsound->EmitSound(rf, params[1], CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, &pos); diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index afdd67c1..4b503791 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -41,7 +41,7 @@ SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, int, const #if SOURCE_ENGINE >= SE_PORTAL2 SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 0, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 1, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 SH_DECL_HOOK15_void(IEngineSound, EmitSound, SH_NOATTRIB, 0, IRecipientFilter &, int, int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); SH_DECL_HOOK15_void(IEngineSound, EmitSound, SH_NOATTRIB, 1, IRecipientFilter &, int, int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int); #else @@ -288,7 +288,7 @@ int SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChanne float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity) -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -349,7 +349,7 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, iSoundlevel, nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity) ); -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 RETURN_META_NEWPARAMS( MRES_IGNORED, static_cast *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity) -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, float flAttenuation, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -442,7 +442,7 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, SNDLVL_TO_ATTN(static_cast(sndlevel)), nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity) ); -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 RETURN_META_NEWPARAMS( MRES_IGNORED, static_cast *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity); #else -#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 void OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int iFlags, int iPitch, int iSpecialDSP, const Vector *pOrigin, @@ -86,7 +86,7 @@ public: float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity); -#endif // SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS +#endif // SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 #endif // SOURCE_ENGINE >= SE_PORTAL2 private: size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); diff --git a/extensions/tf2/AMBuilder b/extensions/tf2/AMBuilder index d6b6963c..24b5c03c 100644 --- a/extensions/tf2/AMBuilder +++ b/extensions/tf2/AMBuilder @@ -1,13 +1,13 @@ # vim: set ts=2 sw=2 tw=99 noet ft=python: import os -if 'ep2v' in SM.sdkInfo: - sdk = SM.sdkInfo['ep2v'] - compiler = SM.DefaultHL2Compiler('extensions/tf2', 'ep2v') +if 'tf2' in SM.sdkInfo: + sdk = SM.sdkInfo['tf2'] + compiler = SM.DefaultHL2Compiler('extensions/tf2', 'tf2') name = 'game.tf2.ext.' + sdk['ext'] extension = AMBuild.AddJob(name) binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) - SM.PreSetupHL2Job(extension, binary, 'ep2v') + SM.PreSetupHL2Job(extension, binary, 'tf2') binary.AddSourceFiles('extensions/tf2', [ 'extension.cpp', 'natives.cpp', @@ -22,7 +22,7 @@ if 'ep2v' in SM.sdkInfo: 'sdk/smsdk_ext.cpp', 'asm/asm.c' ]) - SM.PostSetupHL2Job(extension, binary, 'ep2v') + SM.PostSetupHL2Job(extension, binary, 'tf2') SM.AutoVersion('extensions/tf2', binary) SM.ExtractDebugInfo(extension, binary) binary.SendToJob() diff --git a/loader/loader.cpp b/loader/loader.cpp index 7fa002f8..2050a634 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -68,7 +68,6 @@ #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_EP2VALVE "sourcemod.2.ep2v" PLATFORM_EXT #define FILENAME_1_6_EP1 "sourcemod.2.ep1" PLATFORM_EXT #define FILENAME_1_6_L4D "sourcemod.2.l4d" PLATFORM_EXT #define FILENAME_1_6_DARKM "sourcemod.2.darkm" PLATFORM_EXT @@ -79,6 +78,10 @@ #define FILENAME_1_6_PORTAL2 "sourcemod.2.portal2" PLATFORM_EXT #define FILENAME_1_6_CSGO "sourcemod.2.csgo" PLATFORM_EXT #define FILENAME_1_6_CSS "sourcemod.2.css" PLATFORM_EXT +#define FILENAME_1_6_HL2DM "sourcemod.2.hl2dm" PLATFORM_EXT +#define FILENAME_1_6_DODS "sourcemod.2.dods" PLATFORM_EXT +#define FILENAME_1_6_TF2 "sourcemod.2.tf2" PLATFORM_EXT +#define FILENAME_1_6_ND "sourcemod.2.nd" PLATFORM_EXT #define FILENAME_1_6_DOTA "sourcemod.2.dota" PLATFORM_EXT HINSTANCE g_hCore = NULL; @@ -236,16 +239,16 @@ DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, co filename = FILENAME_1_6_DARKM; break; } - case SOURCE_ENGINE_ORANGEBOXVALVE: - { - filename = FILENAME_1_6_EP2VALVE; - break; - } case SOURCE_ENGINE_LEFT4DEAD2: { filename = FILENAME_1_6_L4D2; break; } + case SOURCE_ENGINE_NUCLEARDAWN: + { + filename = FILENAME_1_6_ND; + break; + } case SOURCE_ENGINE_ALIENSWARM: { filename = FILENAME_1_6_SWARM; @@ -276,6 +279,42 @@ DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, co filename = FILENAME_1_6_CSS; break; } + case SOURCE_ENGINE_HL2DM: + { + filename = FILENAME_1_6_HL2DM; + break; + } + case SOURCE_ENGINE_DODS: + { + filename = FILENAME_1_6_DODS; + break; + } + case SOURCE_ENGINE_TF2: + { + filename = FILENAME_1_6_TF2; + break; + } + case SOURCE_ENGINE_ORANGEBOXVALVE_DEPRECATED: + { + const char *gamedir = mvi->GetGameDir(); + if (strcmp(gamedir, "tf") == 0) + { + filename = FILENAME_1_6_TF2; + } + else if (strcmp(gamedir, "dod") == 0) + { + filename = FILENAME_1_6_DODS; + } + else if (strcmp(gamedir, "hl2mp") == 0) + { + filename = FILENAME_1_6_HL2DM; + } + else + { + return NULL; + } + break; + } case SOURCE_ENGINE_DOTA: { filename = FILENAME_1_6_DOTA; diff --git a/plugins/basechat.sp b/plugins/basechat.sp index 469768e9..a7b96726 100644 --- a/plugins/basechat.sp +++ b/plugins/basechat.sp @@ -51,13 +51,13 @@ new g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{ new Handle:g_Cvar_Chatmode = INVALID_HANDLE; -new g_GameEngine = SOURCE_SDK_UNKNOWN; +new EngineVersion:g_GameEngine = Engine_Unknown; public OnPluginStart() { LoadTranslations("common.phrases"); - g_GameEngine = GuessSDKVersion(); + g_GameEngine = GetEngineVersion(); g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0); @@ -67,7 +67,7 @@ public OnPluginStart() RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay - sends centered message to all players"); /* HintText does not work on Dark Messiah */ - if (g_GameEngine != SOURCE_SDK_DARKMESSIAH) + if (g_GameEngine != Engine_DarkMessiah) { RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay - sends hint message to all players"); } diff --git a/plugins/funcommands.sp b/plugins/funcommands.sp index d8fda4b9..1241dda7 100644 --- a/plugins/funcommands.sp +++ b/plugins/funcommands.sp @@ -78,7 +78,7 @@ new UserMsg:g_FadeUserMsgId; // Serial Generator for Timer Safety new g_Serial_Gen = 0; -new g_GameEngine = SOURCE_SDK_UNKNOWN; +new EngineVersion:g_GameEngine = Engine_Unknown; // Flags used in various timers #define DEFAULT_TIMER_FLAGS TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE @@ -102,7 +102,7 @@ public OnPluginStart() LoadTranslations("common.phrases"); LoadTranslations("funcommands.phrases"); - g_GameEngine = GuessSDKVersion(); + g_GameEngine = GetEngineVersion(); g_FadeUserMsgId = GetUserMessageId("Fade"); RegisterCvars( ); @@ -185,25 +185,26 @@ public OnMapStart() PrecacheSound(SOUND_BOOM, true); PrecacheSound(SOUND_FREEZE, true); - new sdkversion = GuessSDKVersion(); - if (sdkversion >= SOURCE_SDK_LEFT4DEAD) + new EngineVersion:sdkversion = GetEngineVersion(); + if (sdkversion == Engine_Left4Dead || sdkversion == Engine_Left4Dead2 + || sdkversion == Engine_AlienSwarm || sdkversion == Engine_CSGO) { g_BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt"); g_HaloSprite = PrecacheModel("materials/sprites/glow01.vmt"); // l4d, l4d2, and csgo have this. swarm does not. - if (sdkversion != SOURCE_SDK_ALIENSWARM) + if (sdkversion != Engine_AlienSwarm) { g_BeamSprite2 = PrecacheModel("materials/sprites/physbeam.vmt"); } g_GlowSprite = PrecacheModel("materials/sprites/blueflare1.vmt"); - if (sdkversion == SOURCE_SDK_LEFT4DEAD || sdkversion == SOURCE_SDK_LEFT4DEAD2) + if (sdkversion == Engine_Left4Dead || sdkversion == Engine_Left4Dead2) { g_ExplosionSprite = PrecacheModel("sprites/floorfire4_.vmt"); } - else if (sdkversion == SOURCE_SDK_ALIENSWARM) + else if (sdkversion == Engine_AlienSwarm) { g_ExplosionSprite = PrecacheModel("sprites/flamelet1.vmt"); } diff --git a/plugins/funcommands/ice.sp b/plugins/funcommands/ice.sp index ed281b44..cad1afc0 100644 --- a/plugins/funcommands/ice.sp +++ b/plugins/funcommands/ice.sp @@ -157,7 +157,7 @@ public Action:Timer_Freeze(Handle:timer, any:value) UnfreezeClient(client); /* HintText doesn't work on Dark Messiah */ - if (g_GameEngine != SOURCE_SDK_DARKMESSIAH) + if (g_GameEngine != Engine_DarkMessiah) { PrintHintText(client, "%t", "Unfrozen"); } @@ -169,7 +169,7 @@ public Action:Timer_Freeze(Handle:timer, any:value) return Plugin_Stop; } - if (g_GameEngine != SOURCE_SDK_DARKMESSIAH) + if (g_GameEngine != Engine_DarkMessiah) { PrintHintText(client, "%t", "You will be unfrozen", g_FreezeTime[client]); } diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index bbda0d5d..99e4da08 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -64,6 +64,28 @@ enum DialogType DialogType_AskConnect /**< ask the client to connect to a specified IP */ }; +enum EngineVersion +{ + Engine_Unknown, /**< Could not determine the engine version */ + Engine_Original, /**< Original Source Engine (used by The Ship) */ + Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */ + Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */ + Engine_Left4Dead, /**< Left 4 Dead */ + Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */ + Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */ + Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */ + Engine_BloodyGoodTime, /**< Bloody Good Time */ + Engine_EYE, /**< E.Y.E Divine Cybermancy */ + Engine_Portal2, /**< Portal 2 */ + Engine_CSGO, /**< Counter-Strike: Global Offensive */ + Engine_CSS, /**< Counter-Strike: Source */ + Engine_DOTA, /**< Dota 2 */ + Engine_HL2DM, /**< Half-Life 2 Deathmatch */ + Engine_DODS, /**< Day of Defeat: Source */ + Engine_TF2, /**< Team Fortress 2 */ + Engine_NuclearDawn /**< Nuclear Dawn */ +}; + #define INVALID_ENT_REFERENCE 0xFFFFFFFF /** @@ -264,8 +286,19 @@ native CreateDialog(client, Handle:kv, DialogType:type); * * @return SOURCE_SDK version code. */ +#pragma deprecated See GetEngineVersion() native GuessSDKVersion(); +/** + * Gets the engine version that the currently-loaded SM core was compiled against. + * + * The engine version values are not guaranteed to be in any particular order, + * and should only be compared by (in)equality. + * + * @return An EngineVersion value. + */ +native EngineVersion:GetEngineVersion(); + /** * Prints a message to a specific client in the chat area. * diff --git a/plugins/playercommands.sp b/plugins/playercommands.sp index 678cf260..efc544d8 100644 --- a/plugins/playercommands.sp +++ b/plugins/playercommands.sp @@ -51,7 +51,7 @@ new Handle:hTopMenu = INVALID_HANDLE; /* Used to get the SDK / Engine version. */ /* This is used in sm_rename and sm_changeteam */ -new g_ModVersion = 0; +new EngineVersion:g_ModVersion = Engine_Unknown; #include "playercommands/slay.sp" #include "playercommands/slap.sp" @@ -66,7 +66,7 @@ public OnPluginStart() RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>"); RegAdminCmd("sm_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>"); - g_ModVersion = GuessSDKVersion(); + g_ModVersion = GetEngineVersion(); /* Account for late loading */ new Handle:topmenu; diff --git a/plugins/playercommands/rename.sp b/plugins/playercommands/rename.sp index 20fe23f7..a9f4b8cd 100644 --- a/plugins/playercommands/rename.sp +++ b/plugins/playercommands/rename.sp @@ -38,7 +38,7 @@ PerformRename(client, target) LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]); /* Used on OB / L4D engine */ - if (g_ModVersion > SOURCE_SDK_EPISODE1) + if (g_ModVersion != Engine_SourceSDK2006) { SetClientInfo(target, "name", g_NewName[target]); } diff --git a/plugins/reservedslots.sp b/plugins/reservedslots.sp index 2225128d..642828e3 100644 --- a/plugins/reservedslots.sp +++ b/plugins/reservedslots.sp @@ -55,7 +55,7 @@ new Handle:sm_reserve_type; new Handle:sm_reserve_maxadmins; new Handle:sm_reserve_kicktype; -new g_SDKVersion; +new bool:g_BotsSubtractFromMax; new g_SourceTV = -1; new g_Replay = -1; @@ -80,9 +80,10 @@ public OnPluginStart() HookConVarChange(sm_reserved_slots, SlotCountChanged); HookConVarChange(sm_hide_slots, SlotHideChanged); - g_SDKVersion = GuessSDKVersion(); + new EngineVersion:engineVersion = GetEngineVersion(); + g_BotsSubtractFromMax = engineVersion == Engine_TF2 || engineVersion == Engine_CSS || engineVersion == Engine_DODS || engineVersion == Engine_HL2DM; - if (g_SDKVersion == SOURCE_SDK_EPISODE2VALVE) + if (g_BotsSubtractFromMax) { for (new i = 1; i <= MaxClients; i++) { @@ -142,7 +143,7 @@ public Action:OnTimedKick(Handle:timer, any:client) public OnClientPostAdminCheck(client) { - if (g_SDKVersion == SOURCE_SDK_EPISODE2VALVE) + if (g_BotsSubtractFromMax) { if (IsClientSourceTV(client)) { @@ -234,7 +235,7 @@ public OnClientPostAdminCheck(client) public OnClientDisconnect_Post(client) { - if (g_SDKVersion == SOURCE_SDK_EPISODE2VALVE) + if (g_BotsSubtractFromMax) { if (client == g_SourceTV) { @@ -296,7 +297,7 @@ SetVisibleMaxSlots(clients, limit) num = limit; } - if (g_SDKVersion == SOURCE_SDK_EPISODE2VALVE) + if (g_BotsSubtractFromMax) { if (g_SourceTV > -1) { diff --git a/plugins/testsuite/cstrike-test.sp b/plugins/testsuite/cstrike-test.sp index 601f6460..1067573c 100644 --- a/plugins/testsuite/cstrike-test.sp +++ b/plugins/testsuite/cstrike-test.sp @@ -37,7 +37,7 @@ public Action:set_mvps( client, argc ) public Action:get_score( client, argc ) { - if( GuessSDKVersion() != SOURCE_SDK_CSGO ) + if( GetEngineVersion() != Engine_CSGO ) { ReplyToCommand( client, "This command is only intended for CS:GO" ); return Plugin_Handled; @@ -50,7 +50,7 @@ public Action:get_score( client, argc ) public Action:set_score( client, argc ) { - if( GuessSDKVersion() != SOURCE_SDK_CSGO ) + if( GetEngineVersion() != Engine_CSGO ) { ReplyToCommand( client, "This command is only intended for CS:GO" ); return Plugin_Handled; @@ -66,7 +66,7 @@ public Action:set_score( client, argc ) public Action:get_assists( client, argc ) { - if( GuessSDKVersion() != SOURCE_SDK_CSGO ) + if( GetEngineVersion() != Engine_CSGO ) { ReplyToCommand( client, "This command is only intended for CS:GO" ); return Plugin_Handled; @@ -79,7 +79,7 @@ public Action:get_assists( client, argc ) public Action:set_assists( client, argc ) { - if( GuessSDKVersion() != SOURCE_SDK_CSGO ) + if( GetEngineVersion() != Engine_CSGO ) { ReplyToCommand( client, "This command is only intended for CS:GO" ); return Plugin_Handled; diff --git a/public/sm_platform.h b/public/sm_platform.h index b3a950c3..2bf75431 100644 --- a/public/sm_platform.h +++ b/public/sm_platform.h @@ -91,5 +91,9 @@ #define SOURCEMOD_BUILD #endif +#if !defined SM_ARRAYSIZE +#define SM_ARRAYSIZE(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) +#endif + #endif //_INCLUDE_SOURCEMOD_PLATFORM_H_ diff --git a/tools/buildbot/PackageScript b/tools/buildbot/PackageScript index 156567ca..68d59702 100644 --- a/tools/buildbot/PackageScript +++ b/tools/buildbot/PackageScript @@ -240,8 +240,8 @@ if 'css' in SM.sdkInfo: if 'csgo' in SM.sdkInfo: AddNormalLibrary('game.cstrike.ext.2.csgo', 'extensions') -if 'ep2v' in SM.sdkInfo: - AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions') +if 'tf2' in SM.sdkInfo: + AddNormalLibrary('game.tf2.ext.2.tf2', 'extensions') AddNormalLibrary('topmenus.ext', 'extensions') AddNormalLibrary('regex.ext', 'extensions')