From 0a956115ebdf628c9061c4db6502ca420f05247a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 12 Nov 2008 22:47:24 -0800 Subject: [PATCH 01/15] Bumped version on trunk. --- modules.versions | 2 +- product.version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules.versions b/modules.versions index d24e68ad..7fa4c6ba 100644 --- a/modules.versions +++ b/modules.versions @@ -1,6 +1,6 @@ [PRODUCT] major = 1 -minor = 1 +minor = 2 revision = 0 [core] diff --git a/product.version b/product.version index 9084fa2f..26aaba0e 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -1.1.0 +1.2.0 From 7e3f9ada31fa419fe5e8b7668b9a6cc83a38d6e8 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 14 Nov 2008 03:38:59 -0600 Subject: [PATCH 02/15] Moved IDA scripts from editor/ida to tools/ida_scripts --HG-- rename : editor/ida/gcc_fpic.idc => tools/ida_scripts/gcc_fpic.idc rename : editor/ida/linux_vtable_dump.idc => tools/ida_scripts/linux_vtable_dump.idc --- {editor/ida => tools/ida_scripts}/gcc_fpic.idc | 0 {editor/ida => tools/ida_scripts}/linux_vtable_dump.idc | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {editor/ida => tools/ida_scripts}/gcc_fpic.idc (100%) rename {editor/ida => tools/ida_scripts}/linux_vtable_dump.idc (100%) diff --git a/editor/ida/gcc_fpic.idc b/tools/ida_scripts/gcc_fpic.idc similarity index 100% rename from editor/ida/gcc_fpic.idc rename to tools/ida_scripts/gcc_fpic.idc diff --git a/editor/ida/linux_vtable_dump.idc b/tools/ida_scripts/linux_vtable_dump.idc similarity index 100% rename from editor/ida/linux_vtable_dump.idc rename to tools/ida_scripts/linux_vtable_dump.idc From ff7a2c6b73ad3500d9b9a3b830c8521ee0bf6279 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 14 Nov 2008 09:18:30 -0600 Subject: [PATCH 03/15] Added preliminary support for Left 4 Dead; some things may not yet work. --- core/ChatTriggers.cpp | 39 +- core/ChatTriggers.h | 2 +- core/ConCmdManager.cpp | 24 +- core/ConCmdManager.h | 2 +- core/ConVarManager.cpp | 57 +- core/ConVarManager.h | 2 +- core/CoreConfig.cpp | 20 +- core/GameDataFetcher.cpp | 6 +- core/HalfLife2.cpp | 4 +- core/HalfLife2.h | 2 +- core/Makefile | 34 +- core/MenuStyle_Base.cpp | 2 +- core/MenuStyle_Valve.cpp | 4 +- core/MenuVoting.cpp | 4 +- core/NextMap.cpp | 27 +- core/NextMap.h | 4 +- core/PlayerManager.cpp | 51 +- core/PlayerManager.h | 4 +- core/UserMessages.cpp | 24 + core/UserMessages.h | 5 + core/concmd_cleaner.cpp | 23 +- core/concmd_cleaner.h | 1 - core/convar_sm_l4d.h | 712 ++++++++++++++++++++++ core/msvc9/sourcemod_mm.sln | 9 + core/msvc9/sourcemod_mm.vcproj | 275 ++++++++- core/sm_srvcmds.cpp | 6 +- core/smn_console.cpp | 60 +- core/smn_entities.cpp | 8 +- core/smn_halflife.cpp | 2 +- core/smn_vector.cpp | 2 +- core/sourcemm_api.cpp | 1 - core/sourcemm_api.h | 8 +- core/systems/ExtensionSys.cpp | 6 +- core/systems/PluginSys.h | 4 +- extensions/bintools/Makefile | 33 +- extensions/clientprefs/Makefile | 33 +- extensions/cstrike/Makefile | 34 +- extensions/geoip/Makefile | 33 +- extensions/mysql/Makefile | 33 +- extensions/regex/Makefile | 33 +- extensions/sdktools/Makefile | 34 +- extensions/sdktools/extension.cpp | 9 +- extensions/sdktools/extension.h | 4 +- extensions/sdktools/inputnatives.cpp | 2 +- extensions/sdktools/msvc9/sdktools.sln | 8 +- extensions/sdktools/msvc9/sdktools.vcproj | 173 +++++- extensions/sdktools/output.cpp | 8 +- extensions/sdktools/outputnatives.cpp | 8 +- extensions/sdktools/teamnatives.cpp | 2 +- extensions/sdktools/tempents.cpp | 2 +- extensions/sdktools/trnatives.cpp | 12 +- extensions/sdktools/vcaller.cpp | 4 +- extensions/sdktools/vdecoder.cpp | 14 +- extensions/sdktools/vhelpers.cpp | 12 +- extensions/sdktools/vnatives.cpp | 55 +- extensions/sdktools/vstringtable.cpp | 2 +- extensions/sqlite/Makefile | 33 +- extensions/structs/Makefile | 37 +- extensions/tf2/Makefile | 34 +- extensions/topmenus/Makefile | 33 +- gamedata/core.games.txt | 13 + gamedata/sdktools.games.l4d.txt | 361 +++++++++++ loader/Makefile | 4 +- loader/loader.cpp | 6 + plugins/include/console.inc | 25 +- plugins/include/halflife.inc | 5 +- public/compat_wrappers.h | 72 ++- public/mms_sample_ext/Makefile | 34 +- public/sample_ext/Makefile | 33 +- sourcepawn/jit/Makefile | 2 +- tools/builder/LinuxBuilder.cs | 8 + tools/builder/Package.cs | 3 +- tools/builder/PkgCore.cs | 17 + tools/builder/Win32Builder.cs | 4 + 74 files changed, 2285 insertions(+), 421 deletions(-) create mode 100644 core/convar_sm_l4d.h create mode 100644 gamedata/sdktools.games.l4d.txt diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 0cfc9042..9c9ad4f8 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -41,7 +41,7 @@ * While the OB build only runs on MM:S 1.6.0+ (SH 5+), the older one * can technically be compiled against any MM:S version after 1.4.2. */ -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate1); extern int __SourceHook_FHAddConCommandDispatch(void *, ISourceHook::AddHookMode, bool, class fastdelegate::FastDelegate1); #else @@ -53,7 +53,7 @@ extern int __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate #elif SH_IMPL_VERSION == 3 extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0); #endif //SH_IMPL_VERSION -#endif //ORANGEBOX_BUILD +#endif //SE_ORANGEBOX ChatTriggers g_ChatTriggers; bool g_bSupressSilentFails = false; @@ -118,31 +118,8 @@ void ChatTriggers::OnSourceModAllInitialized_Post() void ChatTriggers::OnSourceModGameInitialized() { - unsigned int total = 2; - ConCommandBase *pCmd = icvar->GetCommands(); - const char *name; - while (pCmd) - { - if (pCmd->IsCommand()) - { - name = pCmd->GetName(); - if (!m_pSayCmd && strcmp(name, "say") == 0) - { - m_pSayCmd = (ConCommand *)pCmd; - if (--total == 0) - { - break; - } - } else if (!m_pSayTeamCmd && strcmp(name, "say_team") == 0) { - m_pSayTeamCmd = (ConCommand *)pCmd; - if (--total == 0) - { - break; - } - } - } - pCmd = const_cast(pCmd->GetNext()); - } + m_pSayCmd = FindCommand("say"); + m_pSayTeamCmd = FindCommand("say_team"); if (m_pSayCmd) { @@ -173,7 +150,7 @@ void ChatTriggers::OnSourceModShutdown() g_Forwards.ReleaseForward(m_pDidFloodBlock); } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void ChatTriggers::OnSayCommand_Pre(const CCommand &command) { #else @@ -267,7 +244,7 @@ void ChatTriggers::OnSayCommand_Pre() /** * Test if this is actually a command! */ - if (!PreProcessTrigger(engine->PEntityOfEntIndex(client), args, is_quoted)) + if (!PreProcessTrigger(PEntityOfEntIndex(client), args, is_quoted)) { CPlayer *pPlayer; if (is_silent @@ -299,7 +276,7 @@ void ChatTriggers::OnSayCommand_Pre() RETURN_META(MRES_IGNORED); } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void ChatTriggers::OnSayCommand_Post(const CCommand &command) #else void ChatTriggers::OnSayCommand_Post() @@ -315,7 +292,7 @@ void ChatTriggers::OnSayCommand_Post() /* Execute the cached command */ int client = g_ConCmds.GetCommandClient(); unsigned int old = SetReplyTo(SM_REPLY_CHAT); - serverpluginhelpers->ClientCommand(engine->PEntityOfEntIndex(client), m_ToExecute); + serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute); SetReplyTo(old); } } diff --git a/core/ChatTriggers.h b/core/ChatTriggers.h index c003f997..38295c5c 100644 --- a/core/ChatTriggers.h +++ b/core/ChatTriggers.h @@ -54,7 +54,7 @@ public: //SMGlobalClass char *error, size_t maxlength); private: //ConCommand -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void OnSayCommand_Pre(const CCommand &command); void OnSayCommand_Post(const CCommand &command); #else diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index 44d4e4f7..aaf33a1d 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -40,7 +40,7 @@ ConCmdManager g_ConCmds; -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #else SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false); @@ -205,7 +205,7 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin) delete pList; } } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void CommandCallback(const CCommand &command) { #else @@ -515,7 +515,7 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi return true; } - edict_t *pEdict = engine->PEntityOfEntIndex(client); + edict_t *pEdict = PEntityOfEntIndex(client); /* If we got here, the command failed... */ char buffer[128]; @@ -897,23 +897,7 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri { pInfo = new ConCmdInfo(); /* Find the commandopan */ - ConCommandBase *pBase = icvar->GetCommands(); - ConCommand *pCmd = NULL; - while (pBase) - { - if (strcmp(pBase->GetName(), name) == 0) - { - /* Don't want to return convar with same name */ - if (!pBase->IsCommand()) - { - return NULL; - } - - pCmd = (ConCommand *)pBase; - break; - } - pBase = const_cast(pBase->GetNext()); - } + ConCommand *pCmd = FindCommand(name); if (!pCmd) { diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index 8c25bb73..456f7064 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -98,7 +98,7 @@ class ConCmdManager : public IPluginsListener, public IConCommandTracker { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX friend void CommandCallback(const CCommand &command); #else friend void CommandCallback(); diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index f8e27cee..04109672 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -41,16 +41,18 @@ ConVarManager g_ConVarManager; -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE #define CallGlobalChangeCallbacks CallGlobalChangeCallback #endif -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK3_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar *, const char *, float); #else SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar *, const char *); #endif +SH_DECL_HOOK1_void(ICvar, InstallGlobalChangeCallback, SH_NOATTRIB, false, FnChangeCallback_t); + SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); @@ -79,12 +81,41 @@ void ConVarManager::OnSourceModStartup(bool late) m_ConVarType = g_HandleSys.CreateType("ConVar", this, 0, NULL, &sec, g_pCoreIdent, NULL); } +bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength) +{ +#if defined WIN32 || defined _WIN32 + 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); +#elif defined __linux__ + 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; +} + +void InstallCallback(FnChangeCallback_t callback) +{ + char path[MAX_PATH]; + GetFileOfAddress((void *)callback, path, sizeof(path)); + printf("Yo: %s\n", path); +} + void ConVarManager::OnSourceModAllInitialized() { /** * Episode 2 has this function by default, but the older versions do not. */ -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE if (g_SMAPI->GetGameDLLVersion() >= 6) { SH_ADD_HOOK_MEMFUNC(IServerGameDLL, OnQueryCvarValueFinished, gamedll, this, &ConVarManager::OnQueryCvarValueFinished, false); @@ -93,6 +124,7 @@ void ConVarManager::OnSourceModAllInitialized() #endif SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); + SH_ADD_HOOK_STATICFUNC(ICvar, InstallGlobalChangeCallback, icvar, InstallCallback, false); /* Add the 'convars' option to the 'sm' console command */ g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); @@ -359,17 +391,10 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, } } - /* To prevent creating a convar that has the same name as a console command... ugh */ - ConCommandBase *pBase = icvar->GetCommands(); - - while (pBase) + /* Prevent creating a convar that has the same name as a console command */ + if (FindCommand(name)) { - if (pBase->IsCommand() && strcmp(pBase->GetName(), name) == 0) - { - return BAD_HANDLE; - } - - pBase = const_cast(pBase->GetNext()); + return BAD_HANDLE; } /* Create and initialize ConVarInfo structure */ @@ -595,7 +620,7 @@ void ConVarManager::AddConVarToPluginList(IPluginContext *pContext, const ConVar } } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue) #else void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue) @@ -623,7 +648,7 @@ void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue) i != pInfo->changeListeners.end(); i++) { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX (*i)->OnConVarChanged(pConVar, oldValue, flOldValue); #else (*i)->OnConVarChanged(pConVar, oldValue, atof(oldValue)); @@ -668,7 +693,7 @@ void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t * cell_t ret; pCallback->PushCell(cookie); - pCallback->PushCell(engine->IndexOfEdict(pPlayer)); + pCallback->PushCell(IndexOfEdict(pPlayer)); pCallback->PushCell(result); pCallback->PushString(cvarName); diff --git a/core/ConVarManager.h b/core/ConVarManager.h index 148f7c40..a55636ed 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -140,7 +140,7 @@ private: /** * Static callback that Valve's ConVar object executes when the convar's value changes. */ -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX static void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue); #else static void OnConVarChanged(ConVar *pConVar, const char *oldValue); diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 68aeccf8..c1a5db6b 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -61,7 +61,7 @@ ConVar *g_ServerCfgFile = NULL; void CheckAndFinalizeConfigs(); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); void Hook_ExecDispatchPre(const CCommand &cmd) #else @@ -70,7 +70,7 @@ extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelega void Hook_ExecDispatchPre() #endif { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand cmd; #endif @@ -84,7 +84,7 @@ void Hook_ExecDispatchPre() } } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void Hook_ExecDispatchPost(const CCommand &cmd) #else void Hook_ExecDispatchPost() @@ -103,7 +103,7 @@ void CheckAndFinalizeConfigs() if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart) { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX g_PendingInternalPush = true; #else SM_InternalCmdTrigger(); @@ -151,17 +151,7 @@ void CoreConfig::OnSourceModLevelChange(const char *mapName) if (g_ServerCfgFile != NULL) { - ConCommandBase *pBase = icvar->GetCommands(); - while (pBase != NULL) - { - if (pBase->IsCommand() && strcmp(pBase->GetName(), "exec") == 0) - { - break; - } - pBase = const_cast(pBase->GetNext()); - } - - g_pExecPtr = (ConCommand *)pBase; + g_pExecPtr = FindCommand("exec"); if (g_pExecPtr != NULL) { SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, g_pExecPtr, Hook_ExecDispatchPre, false); diff --git a/core/GameDataFetcher.cpp b/core/GameDataFetcher.cpp index ca54bdb7..c21178b2 100644 --- a/core/GameDataFetcher.cpp +++ b/core/GameDataFetcher.cpp @@ -50,7 +50,9 @@ #include "sh_string.h" #include "sm_version.h" -#ifdef ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_LEFT4DEAD +#include "convar_sm_l4d.h" +#elif SOURCE_ENGINE == SE_ORANGEBOX #include "convar_sm_ob.h" #else #include "convar_sm.h" @@ -724,7 +726,7 @@ public: CON_COMMAND(sm_gamedata_md5, "Checks the MD5 sum for a given gamedata file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 93f84133..3595b7bd 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -481,7 +481,7 @@ void CHalfLife2::PushCommandStack(const CCommand *cmd) CachedCommandInfo info; info.args = cmd; -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE strncopy(info.cmd, cmd->Arg(0), sizeof(info.cmd)); #endif @@ -505,7 +505,7 @@ void CHalfLife2::PopCommandStack() const char *CHalfLife2::CurrentCommandName() { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX return m_CommandStack.front().args->Arg(0); #else return m_CommandStack.front().cmd; diff --git a/core/HalfLife2.h b/core/HalfLife2.h index 48d0c2fb..8808b0a6 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -74,7 +74,7 @@ struct DelayedFakeCliCmd struct CachedCommandInfo { const CCommand *args; -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE char cmd[300]; #endif }; diff --git a/core/Makefile b/core/Makefile index 304dbb8f..b88a12a3 100644 --- a/core/Makefile +++ b/core/Makefile @@ -5,8 +5,9 @@ SMSDK = .. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../hl2sdk HL2SDK_OB = ../../hl2sdk-ob -SOURCEMM14 = ../../sourcemm-1.4 -SOURCEMM16 = ../../sourcemm-1.6 +HL2SDK_L4D = ../../hl2sdk-l4d +SOURCEMM14 = ../../mmsource-legacy +SOURCEMM16 = ../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -45,8 +46,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -55,15 +57,28 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox BINARY = sourcemod.2.ep2.so override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + BINARY = sourcemod.2.l4d.so + override ENGSET = true +endif + +CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so \ tier0_i486.so -lpthread -static-libgcc @@ -73,8 +88,7 @@ INCLUDE_SMSDK = -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn INCLUDE_SM16 = -I. -I.. -I$(SOURCEMM16)/sourcehook $(INCLUDE_SMSDK) INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \ - -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \ - -I$(METAMOD)/sourcemm -Isystems $(INCLUDE_SMSDK) + -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -Isystems $(INCLUDE_SMSDK) CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \ @@ -117,7 +131,7 @@ all: check check: if [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index f53afa7f..786cc86a 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -314,7 +314,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) if (sound != NULL) { - edict_t *pEdict = engine->PEntityOfEntIndex(client); + edict_t *pEdict = PEntityOfEntIndex(client); if (pEdict) { ICollideable *pCollideable = pEdict->GetCollideable(); diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index 39e987a1..12edf620 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -88,7 +88,7 @@ void ValveMenuStyle::HookCreateMessage(edict_t *pEdict, return; } - int client = engine->IndexOfEdict(pEdict); + int client = IndexOfEdict(pEdict); if (client < 1 || client > 256) { return; @@ -325,7 +325,7 @@ void CValveMenuDisplay::SendRawDisplay(int client, int priority, unsigned int ti m_pKv->SetInt("time", time ? time : 200); SH_CALL(g_pSPHCC, &IServerPluginHelpers::CreateMessage)( - engine->PEntityOfEntIndex(client), + PEntityOfEntIndex(client), DIALOG_MENU, m_pKv, vsp_interface); diff --git a/core/MenuVoting.cpp b/core/MenuVoting.cpp index 44c3e9d2..bc46bef4 100644 --- a/core/MenuVoting.cpp +++ b/core/MenuVoting.cpp @@ -37,7 +37,7 @@ float g_next_vote = 0.0f; -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void OnVoteDelayChange(IConVar *cvar, const char *value, float flOldValue); #else void OnVoteDelayChange(ConVar *cvar, const char *value); @@ -52,7 +52,7 @@ ConVar sm_vote_delay("sm_vote_delay", 0.0, OnVoteDelayChange); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void OnVoteDelayChange(IConVar *cvar, const char *value, float flOldValue) #else void OnVoteDelayChange(ConVar *cvar, const char *value) diff --git a/core/NextMap.cpp b/core/NextMap.cpp index 0ce236c8..a7c2699c 100644 --- a/core/NextMap.cpp +++ b/core/NextMap.cpp @@ -40,7 +40,7 @@ NextMapManager g_NextMap; SH_DECL_HOOK2_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #else extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0); @@ -55,30 +55,13 @@ bool g_forcedChange = false; void NextMapManager::OnSourceModAllInitialized_Post() { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); #else SH_ADD_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false); #endif - ConCommandBase *pBase = icvar->GetCommands(); - ConCommand *pCmd = NULL; - while (pBase) - { - if (strcmp(pBase->GetName(), "changelevel") == 0) - { - /* Don't want to return convar with same name */ - if (!pBase->IsCommand()) - { - break; - } - - pCmd = (ConCommand *)pBase; - break; - } - pBase = const_cast(pBase->GetNext()); - } - + ConCommand *pCmd = FindCommand("changelevel"); if (pCmd != NULL) { SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdChangeLevelCallback, false); @@ -88,7 +71,7 @@ void NextMapManager::OnSourceModAllInitialized_Post() void NextMapManager::OnSourceModShutdown() { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); #else SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, ChangeLevel, engine, this, &NextMapManager::HookChangeLevel, false); @@ -203,7 +186,7 @@ NextMapManager::NextMapManager() m_mapHistory = SourceHook::List(); } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void CmdChangeLevelCallback(const CCommand &command) { #else diff --git a/core/NextMap.h b/core/NextMap.h index c1dd9c5a..aa1b8c84 100644 --- a/core/NextMap.h +++ b/core/NextMap.h @@ -58,7 +58,7 @@ struct MapChangeData time_t startTime; }; -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void CmdChangeLevelCallback(const CCommand &command); #else void CmdChangeLevelCallback(); @@ -69,7 +69,7 @@ class NextMapManager : public SMGlobalClass public: NextMapManager(); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX friend void CmdChangeLevelCallback(const CCommand &command); #else friend void CmdChangeLevelCallback(); diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index b17a6f9c..880a84b1 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -61,7 +61,7 @@ List target_processors; SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int); SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *); SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &); #else SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *); @@ -69,7 +69,7 @@ SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *) SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *); SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); #else extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0); @@ -151,24 +151,7 @@ void PlayerManager::OnSourceModAllInitialized() g_ConVarManager.AddConVarChangeListener("tv_enable", this); - ConCommandBase *pBase = icvar->GetCommands(); - ConCommand *pCmd = NULL; - while (pBase) - { - if (strcmp(pBase->GetName(), "maxplayers") == 0) - { - /* Don't want to return convar with same name */ - if (!pBase->IsCommand()) - { - break; - } - - pCmd = (ConCommand *)pBase; - break; - } - pBase = const_cast(pBase->GetNext()); - } - + ConCommand *pCmd = FindCommand("maxplayers"); if (pCmd != NULL) { SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdMaxplayersCallback, true); @@ -408,7 +391,7 @@ void PlayerManager::RunAuthChecks() bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) { - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); CPlayer *pPlayer = &m_Players[client]; List::iterator iter; @@ -452,7 +435,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen) { - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); bool orig_value = META_RESULT_ORIG_RET(bool); CPlayer *pPlayer = &m_Players[client]; @@ -492,7 +475,7 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername) { cell_t res; - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); CPlayer *pPlayer = &m_Players[client]; /* If they're not connected, they're a bot */ @@ -590,7 +573,7 @@ void PlayerManager::OnSourceModLevelEnd() void PlayerManager::OnClientDisconnect(edict_t *pEntity) { cell_t res; - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); CPlayer *pPlayer = &m_Players[client]; if (pPlayer->IsConnected()) @@ -628,7 +611,7 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity) void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) { cell_t res; - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); m_cldisconnect_post->PushCell(client); m_cldisconnect_post->Execute(&res, NULL); @@ -642,7 +625,7 @@ void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) } } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args) { #else @@ -650,7 +633,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity) { CCommand args; #endif - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); cell_t res = Pl_Continue; CPlayer *pPlayer = &m_Players[client]; @@ -705,7 +688,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity) void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) { cell_t res; - int client = engine->IndexOfEdict(pEntity); + int client = IndexOfEdict(pEntity); CPlayer *pPlayer = &m_Players[client]; if (!pPlayer->IsConnected()) @@ -713,7 +696,7 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) return; } - m_clinfochanged->PushCell(engine->IndexOfEdict(pEntity)); + m_clinfochanged->PushCell(client); m_clinfochanged->Execute(&res, NULL); IPlayerInfo *info = pPlayer->GetPlayerInfo(); @@ -833,7 +816,7 @@ void PlayerManager::RemoveClientListener(IClientListener *listener) IGamePlayer *PlayerManager::GetGamePlayer(edict_t *pEdict) { - int index = engine->IndexOfEdict(pEdict); + int index = IndexOfEdict(pEdict); return GetGamePlayer(index); } @@ -1304,7 +1287,7 @@ void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ ) } } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void CmdMaxplayersCallback(const CCommand &command) { #else @@ -1342,7 +1325,7 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity) m_Name.assign(name); m_Ip.assign(ip); m_pEdict = pEntity; - m_iIndex = engine->IndexOfEdict(pEntity); + m_iIndex = IndexOfEdict(pEntity); m_LangId = g_Translator.GetServerLanguage(); char ip2[24], *ptr; @@ -1364,7 +1347,7 @@ void CPlayer::Connect() m_IsInGame = true; const char *var = g_Players.GetPassInfoVar(); - int client = engine->IndexOfEdict(m_pEdict); + int client = IndexOfEdict(m_pEdict); if (var[0] != '\0') { const char *pass = engine->GetClientConVarValue(client, var); @@ -1611,7 +1594,7 @@ void CPlayer::DoBasicAdminChecks() /* First check the name */ AdminId id; - int client = engine->IndexOfEdict(m_pEdict); + int client = IndexOfEdict(m_pEdict); if ((id = g_Admins.FindAdminByIdentity("name", GetName())) != INVALID_ADMIN_ID) { diff --git a/core/PlayerManager.h b/core/PlayerManager.h index 8fcb5606..2c33ec0d 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -135,7 +135,7 @@ public: void OnClientPutInServer(edict_t *pEntity, char const *playername); void OnClientDisconnect(edict_t *pEntity); void OnClientDisconnect_Post(edict_t *pEntity); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void OnClientCommand(edict_t *pEntity, const CCommand &args); #else void OnClientCommand(edict_t *pEntity); @@ -204,7 +204,7 @@ private: int m_ListenClient; }; -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void CmdMaxplayersCallback(const CCommand &command); #else void CmdMaxplayersCallback(); diff --git a/core/UserMessages.cpp b/core/UserMessages.cpp index 62ea58f1..2618e80c 100644 --- a/core/UserMessages.cpp +++ b/core/UserMessages.cpp @@ -34,7 +34,11 @@ UserMessages g_UserMsgs; +#if SOURCE_ENGINE == SE_LEFT4DEAD +SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int, const char *); +#else SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int); +#endif SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0); UserMessages::UserMessages() : m_InterceptBuffer(m_pBase, 2500) @@ -164,9 +168,17 @@ bf_write *UserMessages::StartMessage(int msg_id, const cell_t players[], unsigne if (m_CurFlags & USERMSG_BLOCKHOOKS) { +#if SOURCE_ENGINE == SE_LEFT4DEAD + buffer = ENGINE_CALL(UserMessageBegin)(static_cast(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id)); +#else buffer = ENGINE_CALL(UserMessageBegin)(static_cast(&m_CellRecFilter), msg_id); +#endif } else { +#if SOURCE_ENGINE == SE_LEFT4DEAD + buffer = engine->UserMessageBegin(static_cast(&m_CellRecFilter), msg_id, g_SMAPI->GetUserMessage(msg_id)); +#else buffer = engine->UserMessageBegin(static_cast(&m_CellRecFilter), msg_id); +#endif } return buffer; @@ -279,7 +291,11 @@ void UserMessages::_DecRefCounter() } } +#if SOURCE_ENGINE == SE_LEFT4DEAD +bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name) +#else bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type) +#endif { bool is_intercept_empty = m_msgIntercepts[msg_type].empty(); bool is_hook_empty = m_msgHooks[msg_type].empty(); @@ -305,7 +321,11 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ RETURN_META_VALUE(MRES_IGNORED, NULL); } +#if SOURCE_ENGINE == SE_LEFT4DEAD +bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name) +#else bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type) +#endif { if (!m_InHook) { @@ -444,7 +464,11 @@ void UserMessages::OnMessageEnd_Pre() { bf_write *engine_bfw; +#if SOURCE_ENGINE == SE_LEFT4DEAD + engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId, g_SMAPI->GetUserMessage(m_CurId)); +#else engine_bfw = ENGINE_CALL(UserMessageBegin)(m_CurRecFilter, m_CurId); +#endif m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten()); engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten()); ENGINE_CALL(MessageEnd)(); diff --git a/core/UserMessages.h b/core/UserMessages.h index 4fbf5c43..772cafe8 100644 --- a/core/UserMessages.h +++ b/core/UserMessages.h @@ -72,8 +72,13 @@ public: //IUserMessages bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags); bool EndMessage(); public: +#if SOURCE_ENGINE == SE_LEFT4DEAD + bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name); + bf_write *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name); +#else bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type); bf_write *OnStartMessage_Post(IRecipientFilter *filter, int msg_type); +#endif void OnMessageEnd_Pre(); void OnMessageEnd_Post(); private: diff --git a/core/concmd_cleaner.cpp b/core/concmd_cleaner.cpp index 658c4c37..f9ec8215 100644 --- a/core/concmd_cleaner.cpp +++ b/core/concmd_cleaner.cpp @@ -35,8 +35,9 @@ #include "concmd_cleaner.h" #include "sm_stringutil.h" #include "sourcemm_api.h" +#include "compat_wrappers.h" -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *); #endif @@ -56,7 +57,7 @@ ConCommandBase *FindConCommandBase(const char *name); class ConCommandCleaner : public SMGlobalClass { public: -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX void OnSourceModAllInitialized() { SH_ADD_HOOK_MEMFUNC(ICvar, UnregisterConCommand, icvar, this, &ConCommandCleaner::UnlinkConCommandBase, false); @@ -95,7 +96,7 @@ public: while (iter != tracked_bases.end()) { /* This is just god-awful! */ - if (FindConCommandBase((*iter)->name) != (*iter)->pBase) + if (FindCommandBase((*iter)->name) != (*iter)->pBase) { pInfo = (*iter); iter = tracked_bases.erase(iter); @@ -143,22 +144,6 @@ public: } } s_ConCmdTracker; -ConCommandBase *FindConCommandBase(const char *name) -{ - const ConCommandBase *pBase = icvar->GetCommands(); - - while (pBase != NULL) - { - if (strcmp(pBase->GetName(), name) == 0) - { - return const_cast(pBase); - } - pBase = pBase->GetNext(); - } - - return NULL; -} - void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me) { s_ConCmdTracker.AddTarget(pBase, me); diff --git a/core/concmd_cleaner.h b/core/concmd_cleaner.h index 99122ccd..0573ca12 100644 --- a/core/concmd_cleaner.h +++ b/core/concmd_cleaner.h @@ -38,7 +38,6 @@ public: virtual void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe) = 0; }; -ConCommandBase *FindConCommandBase(const char *name); void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me); void UntrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me); void Global_OnUnlinkConCommandBase(ConCommandBase *pBase); diff --git a/core/convar_sm_l4d.h b/core/convar_sm_l4d.h new file mode 100644 index 00000000..87da7c02 --- /dev/null +++ b/core/convar_sm_l4d.h @@ -0,0 +1,712 @@ +//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $NoKeywords: $ +//===========================================================================// + +#ifndef CONVAR_H +#define CONVAR_H + +#if _WIN32 +#pragma once +#endif + +#include "tier0/dbg.h" +#include "tier1/iconvar.h" +#include "tier1/utlvector.h" +#include "tier1/utlstring.h" +#include "icvar.h" + +#ifdef _WIN32 +#define FORCEINLINE_CVAR FORCEINLINE +#elif _LINUX +#define FORCEINLINE_CVAR inline +#else +#error "implement me" +#endif + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class ConVar; +class CCommand; +class ConCommand; +class ConCommandBase; +struct characterset_t; + + + +//----------------------------------------------------------------------------- +// Any executable that wants to use ConVars need to implement one of +// these to hook up access to console variables. +//----------------------------------------------------------------------------- +class IConCommandBaseAccessor +{ +public: + // Flags is a combination of FCVAR flags in cvar.h. + // hOut is filled in with a handle to the variable. + virtual bool RegisterConCommandBase( ConCommandBase *pVar ) = 0; +}; + + +//----------------------------------------------------------------------------- +// Helper method for console development +//----------------------------------------------------------------------------- +#if defined( _X360 ) && !defined( _RETAIL ) +void ConVar_PublishToVXConsole(); +#endif + + +//----------------------------------------------------------------------------- +// Called when a ConCommand needs to execute +//----------------------------------------------------------------------------- +typedef void ( *FnCommandCallbackV1_t )( void ); +typedef void ( *FnCommandCallback_t )( const CCommand &command ); + +#define COMMAND_COMPLETION_MAXITEMS 64 +#define COMMAND_COMPLETION_ITEM_LENGTH 64 + +//----------------------------------------------------------------------------- +// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings +//----------------------------------------------------------------------------- +typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ); + + +//----------------------------------------------------------------------------- +// Interface version +//----------------------------------------------------------------------------- +class ICommandCallback +{ +public: + virtual void CommandCallback( const CCommand &command ) = 0; +}; + +class ICommandCompletionCallback +{ +public: + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: The base console invoked command/cvar interface +//----------------------------------------------------------------------------- +class ConCommandBase +{ + friend class CCvar; + friend class ConVar; + friend class ConCommand; + friend void ConVar_Register( int nCVarFlag, IConCommandBaseAccessor *pAccessor ); + friend void ConVar_PublishToVXConsole(); + + // FIXME: Remove when ConVar changes are done + friend class CDefaultCvar; + +public: + ConCommandBase( void ); + ConCommandBase( const char *pName, const char *pHelpString = 0, + int flags = 0 ); + + virtual ~ConCommandBase( void ); + + virtual bool IsCommand( void ) const; + + // Check flag + virtual bool IsFlagSet( int flag ) const; + // Set flag + virtual void AddFlags( int flags ); + // Remove flag + virtual void RemoveFlags( int flags ); + // Get flags + virtual int GetFlags( void ) const; + + // Return name of cvar + virtual const char *GetName( void ) const; + + // Return help text for cvar + virtual const char *GetHelpText( void ) const; + + // Deal with next pointer + const ConCommandBase *GetNext( void ) const; + ConCommandBase *GetNext( void ); + + inline void SetNext(ConCommandBase *pBase) + { + m_pNext = pBase; + } + + virtual bool IsRegistered( void ) const; + + // Returns the DLL identifier + virtual CVarDLLIdentifier_t GetDLLIdentifier() const; + +protected: + virtual void Create( const char *pName, const char *pHelpString = 0, + int flags = 0 ); + + // Used internally by OneTimeInit to initialize/shutdown + virtual void Init(); + void Shutdown(); + + // Internal copy routine ( uses new operator from correct module ) + char *CopyString( const char *from ); + +private: + // Next ConVar in chain + // Prior to register, it points to the next convar in the DLL. + // Once registered, though, m_pNext is reset to point to the next + // convar in the global list + ConCommandBase *m_pNext; + + // Has the cvar been added to the global list? + bool m_bRegistered; + + // Static data + const char *m_pszName; + const char *m_pszHelpString; + + // ConVar flags + int m_nFlags; + +protected: + // ConVars add themselves to this list for the executable. + // Then ConVar_Register runs through all the console variables + // and registers them into a global list stored in vstdlib.dll + static ConCommandBase *s_pConCommandBases; + + // ConVars in this executable use this 'global' to access values. + static IConCommandBaseAccessor *s_pAccessor; +public: + inline void SetFlags(int flags) + { + m_nFlags = flags; + } +}; + + +//----------------------------------------------------------------------------- +// Command tokenizer +//----------------------------------------------------------------------------- +class CCommand +{ +public: + CCommand(); + CCommand( int nArgC, const char **ppArgV ); + bool Tokenize( const char *pCommand, characterset_t *pBreakSet = NULL ); + void Reset(); + + int ArgC() const; + const char **ArgV() const; + const char *ArgS() const; // All args that occur after the 0th arg, in string form + const char *GetCommandString() const; // The entire command in string form, including the 0th arg + const char *operator[]( int nIndex ) const; // Gets at arguments + const char *Arg( int nIndex ) const; // Gets at arguments + + // Helper functions to parse arguments to commands. + const char* FindArg( const char *pName ) const; + int FindArgInt( const char *pName, int nDefaultVal ) const; + + static int MaxCommandLength(); + static characterset_t* DefaultBreakSet(); + +private: + enum + { + COMMAND_MAX_ARGC = 64, + COMMAND_MAX_LENGTH = 512, + }; + + int m_nArgc; + int m_nArgv0Size; + char m_pArgSBuffer[ COMMAND_MAX_LENGTH ]; + char m_pArgvBuffer[ COMMAND_MAX_LENGTH ]; + const char* m_ppArgv[ COMMAND_MAX_ARGC ]; +}; + +inline int CCommand::MaxCommandLength() +{ + return COMMAND_MAX_LENGTH - 1; +} + +inline int CCommand::ArgC() const +{ + return m_nArgc; +} + +inline const char **CCommand::ArgV() const +{ + return m_nArgc ? (const char**)m_ppArgv : NULL; +} + +inline const char *CCommand::ArgS() const +{ + return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : ""; +} + +inline const char *CCommand::GetCommandString() const +{ + return m_nArgc ? m_pArgSBuffer : ""; +} + +inline const char *CCommand::Arg( int nIndex ) const +{ + // FIXME: Many command handlers appear to not be particularly careful + // about checking for valid argc range. For now, we're going to + // do the extra check and return an empty string if it's out of range + if ( nIndex < 0 || nIndex >= m_nArgc ) + return ""; + return m_ppArgv[nIndex]; +} + +inline const char *CCommand::operator[]( int nIndex ) const +{ + return Arg( nIndex ); +} + + +//----------------------------------------------------------------------------- +// Purpose: The console invoked command +//----------------------------------------------------------------------------- +class ConCommand : public ConCommandBase +{ +friend class CCvar; + +public: + typedef ConCommandBase BaseClass; + + ConCommand( const char *pName, FnCommandCallbackV1_t callback, + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ); + ConCommand( const char *pName, FnCommandCallback_t callback, + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ); + ConCommand( const char *pName, ICommandCallback *pCallback, + const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 ); + + virtual ~ConCommand( void ); + + virtual bool IsCommand( void ) const; + + virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands ); + + virtual bool CanAutoComplete( void ); + + // Invoke the function + virtual void Dispatch( const CCommand &command ); + +private: + // NOTE: To maintain backward compat, we have to be very careful: + // All public virtual methods must appear in the same order always + // since engine code will be calling into this code, which *does not match* + // in the mod code; it's using slightly different, but compatible versions + // of this class. Also: Be very careful about adding new fields to this class. + // Those fields will not exist in the version of this class that is instanced + // in mod code. + + // Call this function when executing the command + union + { + FnCommandCallbackV1_t m_fnCommandCallbackV1; + FnCommandCallback_t m_fnCommandCallback; + ICommandCallback *m_pCommandCallback; + }; + + union + { + FnCommandCompletionCallback m_fnCompletionCallback; + ICommandCompletionCallback *m_pCommandCompletionCallback; + }; + + bool m_bHasCompletionCallback : 1; + bool m_bUsingNewCommandCallback : 1; + bool m_bUsingCommandCallbackInterface : 1; +public: + inline FnCommandCallback_t GetCallback() const + { + return m_fnCommandCallback; + } +}; + + +//----------------------------------------------------------------------------- +// Purpose: A console variable +//----------------------------------------------------------------------------- +class ConVar : public ConCommandBase, public IConVar +{ +friend class CCvar; +friend class ConVarRef; + +public: + typedef ConCommandBase BaseClass; + + ConVar( const char *pName, const char *pDefaultValue, int flags = 0); + + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, FnChangeCallback_t callback ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax, + FnChangeCallback_t callback ); + + virtual ~ConVar( void ); + + virtual bool IsCommand( void ) const; + virtual bool IsFlagSet( int flag ) const; + virtual void AddFlags( int flags ); + virtual int GetFlags( void ) const; + virtual const char *GetName( void ) const; + virtual const char* GetHelpText( void ) const; + virtual bool IsRegistered( void ) const; + + // Install a change callback (there shouldn't already be one....) + void InstallChangeCallback( FnChangeCallback_t callback ); + + // Retrieve value + FORCEINLINE_CVAR float GetFloat( void ) const; + FORCEINLINE_CVAR int GetInt( void ) const; + FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); } + FORCEINLINE_CVAR char const *GetString( void ) const; + + // Used internally by OneTimeInit to initialize. + virtual void Init(); + + virtual const char *GetBaseName( void ) const; + virtual int GetSplitScreenPlayerSlot ( void ) const; + + // Any function that allocates/frees memory needs to be virtual or else you'll have crashes + // from alloc/free across dll/exe boundaries. + + // These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue). + virtual void SetValue( const char *value ); + virtual void SetValue( float value ); + virtual void SetValue( int value ); + + // Reset to default value + void Revert( void ); + + // True if it has a min/max setting + bool GetMin( float& minVal ) const; + bool GetMax( float& maxVal ) const; + const char *GetDefault( void ) const; + +private: + // Called by CCvar when the value of a var is changing. + virtual void InternalSetValue(const char *value); + // For CVARs marked FCVAR_NEVER_AS_STRING + virtual void InternalSetFloatValue( float fNewValue ); + virtual void InternalSetIntValue( int nValue ); + + virtual bool ClampValue( float& value ); + virtual void ChangeStringValue( const char *tempVal, float flOldValue ); + + virtual void Create( const char *pName, const char *pDefaultValue, int flags = 0, + const char *pHelpString = 0, bool bMin = false, float fMin = 0.0, + bool bMax = false, float fMax = false, FnChangeCallback_t callback = 0 ); + +private: + + // This either points to "this" or it points to the original declaration of a ConVar. + // This allows ConVars to exist in separate modules, and they all use the first one to be declared. + // m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar). + ConVar *m_pParent; + + // Static data + const char *m_pszDefaultValue; + + // Value + // Dynamically allocated + char *m_pszString; + int m_StringLength; + + // Values + float m_fValue; + int m_nValue; + + // Min/Max values + bool m_bHasMin; + float m_fMinVal; + bool m_bHasMax; + float m_fMaxVal; + + // Call this function when ConVar changes + FnChangeCallback_t m_fnChangeCallback; +public: + inline FnChangeCallback_t GetCallback() const + { + return m_fnChangeCallback; + } + inline void SetMin(bool set, float min=0.0) + { + m_bHasMin = set; + m_fMinVal = min; + } + inline void SetMax(bool set, float max=0.0) + { + m_bHasMax = set; + m_fMaxVal = max; + } +}; + + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a float +// Output : float +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR float ConVar::GetFloat( void ) const +{ + return m_pParent->m_fValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +// Output : int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR int ConVar::GetInt( void ) const +{ + return m_pParent->m_nValue; +} + + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc. +// Output : const char * +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR const char *ConVar::GetString( void ) const +{ + if ( m_nFlags & FCVAR_NEVER_AS_STRING ) + return "FCVAR_NEVER_AS_STRING"; + + return ( m_pParent->m_pszString ) ? m_pParent->m_pszString : ""; +} + + +//----------------------------------------------------------------------------- +// Used to read/write convars that already exist (replaces the FindVar method) +//----------------------------------------------------------------------------- +class ConVarRef +{ +public: + ConVarRef( const char *pName ); + ConVarRef( const char *pName, bool bIgnoreMissing ); + ConVarRef( IConVar *pConVar ); + + void Init( const char *pName, bool bIgnoreMissing ); + bool IsValid() const; + bool IsFlagSet( int nFlags ) const; + IConVar *GetLinkedConVar(); + + // Get/Set value + float GetFloat( void ) const; + int GetInt( void ) const; + bool GetBool() const { return !!GetInt(); } + const char *GetString( void ) const; + + void SetValue( const char *pValue ); + void SetValue( float flValue ); + void SetValue( int nValue ); + void SetValue( bool bValue ); + + const char *GetName() const; + + const char *GetDefault() const; + +private: + // High-speed method to read convar data + IConVar *m_pConVar; + ConVar *m_pConVarState; +}; + + +//----------------------------------------------------------------------------- +// Did we find an existing convar of that name? +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR bool ConVarRef::IsFlagSet( int nFlags ) const +{ + return ( m_pConVar->IsFlagSet( nFlags ) != 0 ); +} + +FORCEINLINE_CVAR IConVar *ConVarRef::GetLinkedConVar() +{ + return m_pConVar; +} + +FORCEINLINE_CVAR const char *ConVarRef::GetName() const +{ + return m_pConVar->GetName(); +} + + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a float +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR float ConVarRef::GetFloat( void ) const +{ + return m_pConVarState->m_fValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR int ConVarRef::GetInt( void ) const +{ + return m_pConVarState->m_nValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc. +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR const char *ConVarRef::GetString( void ) const +{ + Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) ); + return m_pConVarState->m_pszString; +} + + +FORCEINLINE_CVAR void ConVarRef::SetValue( const char *pValue ) +{ + m_pConVar->SetValue( pValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( float flValue ) +{ + m_pConVar->SetValue( flValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( int nValue ) +{ + m_pConVar->SetValue( nValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( bool bValue ) +{ + m_pConVar->SetValue( bValue ? 1 : 0 ); +} + +FORCEINLINE_CVAR const char *ConVarRef::GetDefault() const +{ + return m_pConVarState->m_pszDefaultValue; +} + + +//----------------------------------------------------------------------------- +// Called by the framework to register ConCommands with the ICVar +//----------------------------------------------------------------------------- +void ConVar_Register( int nCVarFlag = 0, IConCommandBaseAccessor *pAccessor = NULL ); +void ConVar_Unregister( ); + + +//----------------------------------------------------------------------------- +// Utility methods +//----------------------------------------------------------------------------- +void ConVar_PrintFlags( const ConCommandBase *var ); +void ConVar_PrintDescription( const ConCommandBase *pVar ); + + +//----------------------------------------------------------------------------- +// Purpose: Utility class to quickly allow ConCommands to call member methods +//----------------------------------------------------------------------------- +#ifdef _MSC_VER +#pragma warning (disable : 4355 ) +#endif + +template< class T > +class CConCommandMemberAccessor : public ConCommand, public ICommandCallback, public ICommandCompletionCallback +{ + typedef ConCommand BaseClass; + typedef void ( T::*FnMemberCommandCallback_t )( const CCommand &command ); + typedef int ( T::*FnMemberCommandCompletionCallback_t )( const char *pPartial, CUtlVector< CUtlString > &commands ); + +public: + CConCommandMemberAccessor( T* pOwner, const char *pName, FnMemberCommandCallback_t callback, const char *pHelpString = 0, + int flags = 0, FnMemberCommandCompletionCallback_t completionFunc = 0 ) : + BaseClass( pName, this, pHelpString, flags, ( completionFunc != 0 ) ? this : NULL ) + { + m_pOwner = pOwner; + m_Func = callback; + m_CompletionFunc = completionFunc; + } + + ~CConCommandMemberAccessor() + { + Shutdown(); + } + + void SetOwner( T* pOwner ) + { + m_pOwner = pOwner; + } + + virtual void CommandCallback( const CCommand &command ) + { + Assert( m_pOwner && m_Func ); + (m_pOwner->*m_Func)( command ); + } + + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) + { + Assert( m_pOwner && m_CompletionFunc ); + return (m_pOwner->*m_CompletionFunc)( pPartial, commands ); + } + +private: + T* m_pOwner; + FnMemberCommandCallback_t m_Func; + FnMemberCommandCompletionCallback_t m_CompletionFunc; +}; + +#ifdef _MSC_VER +#pragma warning ( default : 4355 ) +#endif + +//----------------------------------------------------------------------------- +// Purpose: Utility macros to quicky generate a simple console command +//----------------------------------------------------------------------------- +#define CON_COMMAND( name, description ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description ); \ + static void name( const CCommand &args ) + +#define CON_COMMAND_F( name, description, flags ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags ); \ + static void name( const CCommand &args ) + +#define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags, completion ); \ + static void name( const CCommand &args ) + +#define CON_COMMAND_EXTERN( name, _funcname, description ) \ + void _funcname( const CCommand &args ); \ + static ConCommand name##_command( #name, _funcname, description ); \ + void _funcname( const CCommand &args ) + +#define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \ + void _funcname( const CCommand &args ); \ + static ConCommand name##_command( #name, _funcname, description, flags ); \ + void _funcname( const CCommand &args ) + +#define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \ + void _funcname( const CCommand &args ); \ + friend class CCommandMemberInitializer_##_funcname; \ + class CCommandMemberInitializer_##_funcname \ + { \ + public: \ + CCommandMemberInitializer_##_funcname() : m_ConCommandAccessor( NULL, name, &_thisclass::_funcname, description, flags ) \ + { \ + m_ConCommandAccessor.SetOwner( GET_OUTER( _thisclass, m_##_funcname##_register ) ); \ + } \ + private: \ + CConCommandMemberAccessor< _thisclass > m_ConCommandAccessor; \ + }; \ + \ + CCommandMemberInitializer_##_funcname m_##_funcname##_register; \ + + +#endif // CONVAR_H diff --git a/core/msvc9/sourcemod_mm.sln b/core/msvc9/sourcemod_mm.sln index 0c848ec7..ca801e17 100644 --- a/core/msvc9/sourcemod_mm.sln +++ b/core/msvc9/sourcemod_mm.sln @@ -6,30 +6,39 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32 + CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32 CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32 CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32 Debug - Episode 1|Win32 = Debug - Episode 1|Win32 + Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 Debug - Orange Box|Win32 = Debug - Orange Box|Win32 Release - Episode 1|Win32 = Release - Episode 1|Win32 + Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 Release - Old Metamod|Win32 = Release - Old Metamod|Win32 Release - Orange Box|Win32 = Release - Orange Box|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 + {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 {E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj index d3f79183..1923c809 100644 --- a/core/msvc9/sourcemod_mm.vcproj +++ b/core/msvc9/sourcemod_mm.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -122,7 +122,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -203,7 +203,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" @@ -283,7 +283,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=3" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -363,7 +363,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=3" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -444,7 +444,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;ORANGEBOX_BUILD" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=3" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" @@ -524,7 +524,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -604,7 +604,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -685,7 +685,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..\;..\systems;..\..\public;..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\public\vstdlib";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD;SM_DEFAULT_THREADER;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" RuntimeTypeInfo="false" @@ -739,6 +739,247 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -831,6 +1072,22 @@ Name="VCCLCompilerTool" /> + + + + + + = SE_ORANGEBOX g_pCVar = icvar; #endif CONVAR_REGISTER(this); @@ -291,7 +291,7 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand & CON_COMMAND(sm, "SourceMod Menu") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif g_RootMenu.GotRootCmd(args); @@ -327,7 +327,7 @@ void write_handles_to_game(const char *fmt, ...) CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle leaks") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif if (args.ArgC() < 2) diff --git a/core/smn_console.cpp b/core/smn_console.cpp index cab0daec..5ee3a344 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -44,7 +44,11 @@ #include #include +#if SOURCE_ENGINE == SE_LEFT4DEAD +#define NET_SETCONVAR 6 +#else #define NET_SETCONVAR 5 +#endif enum ConVarBounds { @@ -63,7 +67,11 @@ struct GlobCmdIter struct ConCmdIter { +#if SOURCE_ENGINE == SE_LEFT4DEAD + ICvarIteratorInternal *pLast; +#else const ConCommandBase *pLast; +#endif }; class ConsoleHelpers : @@ -129,7 +137,7 @@ public: *flags = (*ppCmd)->GetFlags(); return true; } - else if ((pCmd=FindConCommandBase(name))) + else if ((pCmd=FindCommandBase(name))) { m_CmdFlags.insert(name, pCmd); TrackConCommandBase(pCmd, this); @@ -151,7 +159,7 @@ public: TrackConCommandBase((*ppCmd), this); return true; } - else if ((pCmd=FindConCommandBase(name))) + else if ((pCmd=FindCommandBase(name))) { m_CmdFlags.insert(name, pCmd); pCmd->SetFlags(flags); @@ -167,7 +175,7 @@ private: KTrie m_CmdFlags; } s_CommandFlagsHelper; -#ifndef ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX static void ReplicateConVar(ConVar *pConVar) { int maxClients = g_Players.GetMaxClients(); @@ -341,7 +349,7 @@ static cell_t sm_SetConVarNum(IPluginContext *pContext, const cell_t *params) pConVar->SetValue(params[2]); -#ifndef ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX /* Should we replicate it? */ if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) { @@ -390,7 +398,7 @@ static cell_t sm_SetConVarFloat(IPluginContext *pContext, const cell_t *params) float value = sp_ctof(params[2]); pConVar->SetValue(value); -#ifndef ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX /* Should we replicate it? */ if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) { @@ -441,7 +449,7 @@ static cell_t sm_SetConVarString(IPluginContext *pContext, const cell_t *params) pConVar->SetValue(value); -#ifndef ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX /* Should we replicate it? */ if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) { @@ -472,7 +480,7 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params) pConVar->Revert(); -#ifndef ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX /* Should we replicate it? */ if (params[3] && IsFlagSet(pConVar, FCVAR_REPLICATED)) { @@ -1151,12 +1159,21 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params pContext->LocalToPhysAddr(params[3], &pIsCmd); pContext->LocalToPhysAddr(params[4], &pFlags); +#if SOURCE_ENGINE == SE_LEFT4DEAD + ICvarIteratorInternal *cvarIter = icvar->FactoryInternalIterator(); + cvarIter->SetFirst(); + if (!cvarIter->IsValid()) + { + return BAD_HANDLE; + } + pConCmd = cvarIter->Get(); +#else pConCmd = icvar->GetCommands(); - if (pConCmd == NULL) { return BAD_HANDLE; } +#endif pContext->StringToLocalUTF8(params[1], params[2], pConCmd->GetName(), NULL); *pIsCmd = pConCmd->IsCommand() ? 1 : 0; @@ -1169,7 +1186,11 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params } pIter = new ConCmdIter; +#if SOURCE_ENGINE == SE_LEFT4DEAD + pIter->pLast = cvarIter; +#else pIter->pLast = pConCmd; +#endif if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL)) == BAD_HANDLE) @@ -1187,6 +1208,7 @@ static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params) ConCmdIter *pIter; cell_t *pIsCmd, *pFlags; const char *desc; + const ConCommandBase *pConCmd; HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); if ((err = g_HandleSys.ReadHandle(params[1], htConCmdIter, &sec, (void **)&pIter)) != HandleError_None) @@ -1199,21 +1221,33 @@ static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params) return 0; } - if ((pIter->pLast = pIter->pLast->GetNext()) == NULL) +#if SOURCE_ENGINE == SE_LEFT4DEAD + ICvarIteratorInternal *cvarIter = pIter->pLast; + cvarIter->Next(); + if (!cvarIter->IsValid()) { return 0; } + pConCmd = cvarIter->Get(); +#else + pConCmd = pIter->pLast->GetNext(); + if (pConCmd == NULL) + { + return 0; + } + pIter->pLast = pConCmd; +#endif pContext->LocalToPhysAddr(params[4], &pIsCmd); pContext->LocalToPhysAddr(params[5], &pFlags); - pContext->StringToLocalUTF8(params[2], params[3], pIter->pLast->GetName(), NULL); - *pIsCmd = pIter->pLast->IsCommand() ? 1 : 0; - *pFlags = pIter->pLast->GetFlags(); + pContext->StringToLocalUTF8(params[2], params[3], pConCmd->GetName(), NULL); + *pIsCmd = pConCmd->IsCommand() ? 1 : 0; + *pFlags = pConCmd->GetFlags(); if (params[7]) { - desc = pIter->pLast->GetHelpText(); + desc = pConCmd->GetHelpText(); pContext->StringToLocalUTF8(params[6], params[7], (desc && desc[0]) ? desc : "", NULL); } diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index bb29d7fd..c6abe5b2 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -56,7 +56,7 @@ enum PropFieldType inline edict_t *GetEdict(cell_t num) { - edict_t *pEdict = engine->PEntityOfEntIndex(num); + edict_t *pEdict = PEntityOfEntIndex(num); if (!pEdict || pEdict->IsFree()) { return NULL; @@ -74,7 +74,7 @@ inline edict_t *GetEdict(cell_t num) inline edict_t *GetEntity(cell_t num, CBaseEntity **pData) { - edict_t *pEdict = engine->PEntityOfEntIndex(num); + edict_t *pEdict = PEntityOfEntIndex(num); if (!pEdict || pEdict->IsFree()) { return NULL; @@ -156,12 +156,12 @@ static cell_t CreateEdict(IPluginContext *pContext, const cell_t *params) return 0; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } static cell_t RemoveEdict(IPluginContext *pContext, const cell_t *params) { - edict_t *pEdict = engine->PEntityOfEntIndex(params[1]); + edict_t *pEdict = PEntityOfEntIndex(params[1]); if (!pEdict) { diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index 40590d94..301a16c5 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -97,7 +97,7 @@ static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params) return 0; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } static cell_t SetFakeClientConVar(IPluginContext *pContext, const cell_t *params) diff --git a/core/smn_vector.cpp b/core/smn_vector.cpp index 46158d7a..6165a02a 100644 --- a/core/smn_vector.cpp +++ b/core/smn_vector.cpp @@ -31,7 +31,7 @@ #include "sm_globals.h" #include -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX #include #else #include diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 263c5ff8..94f92b7b 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -237,4 +237,3 @@ void *SourceMod_Core::OnMetamodQuery(const char *iface, int *ret) return ptr; } - diff --git a/core/sourcemm_api.h b/core/sourcemm_api.h index 2b31c851..2f0f04dd 100644 --- a/core/sourcemm_api.h +++ b/core/sourcemm_api.h @@ -32,10 +32,12 @@ #ifndef _INCLUDE_SOURCEMOD_MM_API_H_ #define _INCLUDE_SOURCEMOD_MM_API_H_ -#if defined ORANGEBOX_BUILD - #include "convar_sm_ob.h" +#if SOURCE_ENGINE == SE_LEFT4DEAD +#include "convar_sm_l4d.h" +#elif SOURCE_ENGINE == SE_ORANGEBOX +#include "convar_sm_ob.h" #else - #include "convar_sm.h" +#include "convar_sm.h" #endif #include #include diff --git a/core/systems/ExtensionSys.cpp b/core/systems/ExtensionSys.cpp index 04b78bd2..08ec1a15 100644 --- a/core/systems/ExtensionSys.cpp +++ b/core/systems/ExtensionSys.cpp @@ -69,11 +69,13 @@ CLocalExtension::CLocalExtension(const char *filename) path, PLATFORM_MAX_PATH, #if defined METAMOD_PLAPI_VERSION -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_LEFT4DEAD + "extensions/auto.2.l4d/%s", +#elif SOURCE_ENGINE == SE_ORANGEBOX "extensions/auto.2.ep2/%s", #else "extensions/auto.2.ep1/%s", -#endif //ORANGEBOX_BUILD +#endif //SOURCE_ENGINE == SE_LEFT4DEAD #else //METAMOD_PLAPI_VERSION "extensions/auto.1.ep1/%s", #endif //METAMOD_PLAPI_VERSION diff --git a/core/systems/PluginSys.h b/core/systems/PluginSys.h index aa29ffaa..68d27e1e 100644 --- a/core/systems/PluginSys.h +++ b/core/systems/PluginSys.h @@ -47,7 +47,9 @@ #include "sm_trie.h" #include "sourcemod.h" #include -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_LEFT4DEAD +#include "convar_sm_l4d.h" +#elif SOURCE_ENGINE == SE_ORANGEBOX #include "convar_sm_ob.h" #else #include "convar_sm.h" diff --git a/extensions/bintools/Makefile b/extensions/bintools/Makefile index 60a5df27..2d1ccf68 100644 --- a/extensions/bintools/Makefile +++ b/extensions/bintools/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/extensions -I$(SMSDK)/public/jit \ -I$(SMSDK)/public/jit/x86 -I$(SMSDK)/public/sourcepawn @@ -109,7 +122,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/clientprefs/Makefile b/extensions/clientprefs/Makefile index b951a39f..3838ebed 100644 --- a/extensions/clientprefs/Makefile +++ b/extensions/clientprefs/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ -I$(SOURCEMM16)/sourcehook @@ -109,7 +122,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/cstrike/Makefile b/extensions/cstrike/Makefile index f4a93d92..082ee567 100644 --- a/extensions/cstrike/Makefile +++ b/extensions/cstrike/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a tier0_i486.so @@ -56,8 +68,10 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/extensions -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ + -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -107,7 +121,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/geoip/Makefile b/extensions/geoip/Makefile index 12dbceb5..653a80cf 100644 --- a/extensions/geoip/Makefile +++ b/extensions/geoip/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -108,7 +121,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/mysql/Makefile b/extensions/mysql/Makefile index 645c0f36..a6b30874 100644 --- a/extensions/mysql/Makefile +++ b/extensions/mysql/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource MYSQL = ../../../mysql-5.0 ##################################### @@ -36,8 +37,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -45,14 +47,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -60,11 +72,12 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SOURCEMM16)/sourcehook \ -I$(MYSQL)/include + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 endif LINK += $(MYSQL)/lib/libmysqlclient_r.a -lz -static-libgcc -lpthread @@ -114,7 +127,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/regex/Makefile b/extensions/regex/Makefile index 8289b2f3..36cb464a 100644 --- a/extensions/regex/Makefile +++ b/extensions/regex/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SOURCEMM16)/sourcehook endif @@ -108,7 +121,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/sdktools/Makefile b/extensions/sdktools/Makefile index 20469114..f9102218 100644 --- a/extensions/sdktools/Makefile +++ b/extensions/sdktools/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -35,8 +36,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -44,14 +46,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so tier0_i486.so @@ -59,8 +71,10 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/tier0 \ - -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/extensions -I$(SMSDK)/public/sourcepawn + -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ + -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -111,7 +125,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index e8782e61..5810df49 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -30,6 +30,7 @@ */ #include "extension.h" +#include #include "vcallbuilder.h" #include "vnatives.h" #include "vhelpers.h" @@ -38,7 +39,9 @@ #include "vsound.h" #include "output.h" -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_LEFT4DEAD + #define SDKTOOLS_GAME_FILE "sdktools.games.l4d" +#elif SOURCE_ENGINE == SE_ORANGEBOX #define SDKTOOLS_GAME_FILE "sdktools.games.ep2" #else #define SDKTOOLS_GAME_FILE "sdktools.games" @@ -65,6 +68,7 @@ IVoiceServer *voiceserver = NULL; IPlayerInfoManager *playerinfomngr = NULL; ICvar *icvar = NULL; IServer *iserver = NULL; +CGlobalVars *gpGlobals; SourceHook::CallClass *enginePatch = NULL; SourceHook::CallClass *enginesoundPatch = NULL; HandleType_t g_CallHandle = 0; @@ -125,7 +129,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) return false; } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX g_pCVar = icvar; #endif CONVAR_REGISTER(this); @@ -231,6 +235,7 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool GET_V_IFACE_ANY(GetServerFactory, playerinfomngr, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER); GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION); + gpGlobals = ismm->GetCGlobals(); enginePatch = SH_GET_CALLCLASS(engine); enginesoundPatch = SH_GET_CALLCLASS(engsound); diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 54eec222..7e64aae4 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -50,7 +50,6 @@ #include #include #include -#include /** * @brief Implementation of the SDK Tools extension. @@ -106,6 +105,7 @@ extern IVoiceServer *voiceserver; extern IPlayerInfoManager *playerinfomngr; extern ICvar *icvar; extern IServer *iserver; +extern CGlobalVars *gpGlobals; /* Interfaces from SourceMod */ extern IBinTools *g_pBinTools; extern IGameConfig *g_pGameConf; @@ -119,6 +119,8 @@ extern ICallWrapper *g_pAcceptInput; extern SourceHook::CallClass *enginePatch; extern SourceHook::CallClass *enginesoundPatch; +#include + #define ENGINE_CALL(func) SH_CALL(enginePatch, &IVEngineServer::func) #endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/sdktools/inputnatives.cpp b/extensions/sdktools/inputnatives.cpp index b8b56620..b0bcbf44 100644 --- a/extensions/sdktools/inputnatives.cpp +++ b/extensions/sdktools/inputnatives.cpp @@ -38,7 +38,7 @@ ICallWrapper *g_pAcceptInput = NULL; unsigned char g_Variant_t[SIZEOF_VARIANT_T] = {0}; #define ENTINDEX_TO_CBASEENTITY(index, buffer) \ - pEdict = engine->PEntityOfEntIndex(index); \ + pEdict = PEntityOfEntIndex(index); \ if (!pEdict || pEdict->IsFree()) \ { \ return pContext->ThrowNativeError("Entity %d is not valid or is freed", index); \ diff --git a/extensions/sdktools/msvc9/sdktools.sln b/extensions/sdktools/msvc9/sdktools.sln index b314d769..78e814c4 100644 --- a/extensions/sdktools/msvc9/sdktools.sln +++ b/extensions/sdktools/msvc9/sdktools.sln @@ -1,26 +1,32 @@  Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug - Episode 1|Win32 = Debug - Episode 1|Win32 + Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32 Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32 Debug - Orange Box|Win32 = Debug - Orange Box|Win32 Release - Episode 1|Win32 = Release - Episode 1|Win32 + Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32 Release - Old Metamod|Win32 = Release - Old Metamod|Win32 Release - Orange Box|Win32 = Release - Orange Box|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32 + {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32 + {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32 + {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32 + {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32 {7A740927-C751-4312-BF9D-6367F8C508F8}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32 diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 33674010..43ac0283 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -123,7 +123,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="1" RuntimeTypeInfo="false" @@ -203,7 +203,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=3" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -284,7 +284,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=3" RuntimeLibrary="0" EnableEnhancedInstructionSet="1" RuntimeTypeInfo="false" @@ -364,7 +364,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -445,7 +445,7 @@ Name="VCCLCompilerTool" FavorSizeOrSpeed="1" AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SE_EPISODEONE=2;SE_ORANGEBOX=3;SE_LEFT4DEAD=4;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="1" RuntimeTypeInfo="false" @@ -499,6 +499,167 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/sdktools/output.cpp b/extensions/sdktools/output.cpp index bc925f4c..a77163ae 100644 --- a/extensions/sdktools/output.cpp +++ b/extensions/sdktools/output.cpp @@ -251,7 +251,7 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator int serial = pEdict->m_NetworkSerialNumber; - if (serial != hook->entity_filter && hook->entity_index == engine->IndexOfEdict(pEdict)) + if (serial != hook->entity_filter && hook->entity_index == IndexOfEdict(pEdict)) { // same entity index but different serial number. Entity has changed, kill the hook. _iter = pOutputName->hooks.erase(_iter); @@ -264,7 +264,7 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator { //fire the forward to hook->pf hook->pf->PushString(pOutputName->Name); - hook->pf->PushCell(engine->IndexOfEdict(pEdict)); + hook->pf->PushCell(IndexOfEdict(pEdict)); edict_t *pEdictActivator = gameents->BaseEntityToEdict(pActivator); if (!pEdictActivator) @@ -273,7 +273,7 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator } else { - hook->pf->PushCell(engine->IndexOfEdict(pEdictActivator)); + hook->pf->PushCell(IndexOfEdict(pEdictActivator)); } //hook->pf->PushCell(handle); hook->pf->PushFloat(fDelay); @@ -466,7 +466,7 @@ edict_t *EntityOutputManager::BaseHandleToEdict(CBaseHandle &hndl) edict_t *pStoredEdict; - pStoredEdict = engine->PEntityOfEntIndex(index); + pStoredEdict = PEntityOfEntIndex(index); if (pStoredEdict == NULL) { diff --git a/extensions/sdktools/outputnatives.cpp b/extensions/sdktools/outputnatives.cpp index dc3350e2..dc33cd50 100644 --- a/extensions/sdktools/outputnatives.cpp +++ b/extensions/sdktools/outputnatives.cpp @@ -40,7 +40,7 @@ cell_t HookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Entity Outputs are disabled - See error logs for details"); } - edict_t *pEdict = engine->PEntityOfEntIndex(params[1]); + edict_t *pEdict = PEntityOfEntIndex(params[1]); if (!pEdict) { return pContext->ThrowNativeError("Invalid Entity index %i", params[1]); @@ -72,7 +72,7 @@ cell_t HookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) hook = g_OutputManager.NewHook(); hook->entity_filter = pEdict->m_NetworkSerialNumber; - hook->entity_index = engine->IndexOfEdict(pEdict); + hook->entity_index = IndexOfEdict(pEdict); hook->only_once= !!params[4]; hook->pf = pFunction; hook->m_parent = pOutputName; @@ -220,7 +220,7 @@ cell_t UnHookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) } // Find the classname of the entity and lookup the classname and output structures - edict_t *pEdict = engine->PEntityOfEntIndex(params[1]); + edict_t *pEdict = PEntityOfEntIndex(params[1]); if (!pEdict) { return pContext->ThrowNativeError("Invalid Entity index %i", params[1]); @@ -249,7 +249,7 @@ cell_t UnHookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) { hook = (omg_hooks *)*_iter; - if (hook->pf == pFunction && hook->entity_index == engine->IndexOfEdict(pEdict)) + if (hook->pf == pFunction && hook->entity_index == IndexOfEdict(pEdict)) { // remove this hook. if (hook->in_use) diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index d558e8c2..fad64c2c 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -72,7 +72,7 @@ void SDKTools::OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax for (int i=0; iPEntityOfEntIndex(i); + edict_t *pEdict = PEntityOfEntIndex(i); if (!pEdict || pEdict->IsFree()) { continue; diff --git a/extensions/sdktools/tempents.cpp b/extensions/sdktools/tempents.cpp index 407f709a..f6bbd744 100644 --- a/extensions/sdktools/tempents.cpp +++ b/extensions/sdktools/tempents.cpp @@ -47,7 +47,7 @@ CON_COMMAND(sm_print_telist, "Prints the temp entity list") CON_COMMAND(sm_dump_teprops, "Dumps tempentity props to a file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif if (!g_TEManager.IsAvailable()) diff --git a/extensions/sdktools/trnatives.cpp b/extensions/sdktools/trnatives.cpp index 58ab0c1a..3bf555de 100644 --- a/extensions/sdktools/trnatives.cpp +++ b/extensions/sdktools/trnatives.cpp @@ -39,7 +39,7 @@ public: { cell_t res = 1; edict_t *pEdict = gameents->BaseEntityToEdict(reinterpret_cast(pEntity)); - m_pFunc->PushCell(engine->IndexOfEdict(pEdict)); + m_pFunc->PushCell(IndexOfEdict(pEdict)); m_pFunc->PushCell(contentsMask); m_pFunc->PushCell(m_Data); m_pFunc->Execute(&res); @@ -506,7 +506,7 @@ static cell_t smn_TRGetEntityIndex(IPluginContext *pContext, const cell_t *param } edict_t *pEdict = gameents->BaseEntityToEdict(tr->m_pEnt); - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *params) @@ -527,9 +527,13 @@ static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *par { mask = enginetrace->GetPointContents(pos); } else { +#if SOURCE_ENGINE == SE_LEFT4DEAD + mask = enginetrace->GetPointContents(pos, 0, &hentity); +#else mask = enginetrace->GetPointContents(pos, &hentity); +#endif edict_t *pEdict = gameents->BaseEntityToEdict(reinterpret_cast(hentity)); - *ent = engine->IndexOfEdict(pEdict); + *ent = IndexOfEdict(pEdict); } return mask; @@ -537,7 +541,7 @@ static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *par static cell_t smn_TRGetPointContentsEnt(IPluginContext *pContext, const cell_t *params) { - edict_t *pEdict = engine->PEntityOfEntIndex(params[1]); + edict_t *pEdict = PEntityOfEntIndex(params[1]); if (!pEdict || pEdict->IsFree()) { return pContext->ThrowNativeError("Entity %d is invalid", params[1]); diff --git a/extensions/sdktools/vcaller.cpp b/extensions/sdktools/vcaller.cpp index 6ea1f131..1da76029 100644 --- a/extensions/sdktools/vcaller.cpp +++ b/extensions/sdktools/vcaller.cpp @@ -413,14 +413,14 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params) { return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } else if (vc->retinfo->vtype == Valve_Edict) { edict_t *pEdict = *(edict_t **)(vc->retbuf); if (!pEdict || pEdict->IsFree()) { return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } else if (vc->retinfo->vtype == Valve_Bool) { bool *addr = (bool *)vc->retbuf; if (vc->retinfo->flags & PASSFLAG_ASPOINTER) diff --git a/extensions/sdktools/vdecoder.cpp b/extensions/sdktools/vdecoder.cpp index 03f0dcff..1e6e2131 100644 --- a/extensions/sdktools/vdecoder.cpp +++ b/extensions/sdktools/vdecoder.cpp @@ -223,7 +223,7 @@ DataStatus EncodeValveParam(IPluginContext *pContext, if (pEntity) { edict_t *pEdict = gameents->BaseEntityToEdict(pEntity); - *addr = engine->IndexOfEdict(pEdict); + *addr = IndexOfEdict(pEdict); } else { *addr = -1; } @@ -238,7 +238,7 @@ DataStatus EncodeValveParam(IPluginContext *pContext, edict_t *pEdict = *(edict_t **)buffer; if (pEdict) { - *addr = engine->IndexOfEdict(pEdict); + *addr = IndexOfEdict(pEdict); } else { *addr = -1; } @@ -415,7 +415,7 @@ DataStatus DecodeValveParam(IPluginContext *pContext, } else if (param == 0) { if (data->decflags & VDECODE_FLAG_ALLOWWORLD) { - pEdict = engine->PEntityOfEntIndex(0); + pEdict = PEntityOfEntIndex(0); } else { pContext->ThrowNativeError("World not allowed"); return Data_Fail; @@ -479,13 +479,13 @@ DataStatus DecodeValveParam(IPluginContext *pContext, } else if (param == 0) { if (data->decflags & VDECODE_FLAG_ALLOWWORLD) { - pEdict = engine->PEntityOfEntIndex(0); + pEdict = PEntityOfEntIndex(0); } else { pContext->ThrowNativeError("World not allowed"); return Data_Fail; } } else { - pEdict = engine->PEntityOfEntIndex(param); + pEdict = PEntityOfEntIndex(param); if (!pEdict || pEdict->IsFree()) { pContext->ThrowNativeError("Entity %d is not valid or is freed", param); @@ -547,13 +547,13 @@ DataStatus DecodeValveParam(IPluginContext *pContext, } else if (param == 0) { if (data->decflags & VDECODE_FLAG_ALLOWWORLD) { - pEdict = engine->PEntityOfEntIndex(0); + pEdict = PEntityOfEntIndex(0); } else { pContext->ThrowNativeError("World not allowed"); return Data_Fail; } } else { - pEdict = engine->PEntityOfEntIndex(param); + pEdict = PEntityOfEntIndex(param); if (!pEdict || pEdict->IsFree()) { pContext->ThrowNativeError("Entity %d is not valid or is freed", param); diff --git a/extensions/sdktools/vhelpers.cpp b/extensions/sdktools/vhelpers.cpp index b0d1507c..b119bbf4 100644 --- a/extensions/sdktools/vhelpers.cpp +++ b/extensions/sdktools/vhelpers.cpp @@ -247,7 +247,7 @@ int GetClientAimTarget(edict_t *pEdict, bool only_players) return -1; } - int ent_index = engine->IndexOfEdict(pTarget); + int ent_index = IndexOfEdict(pTarget); IGamePlayer *pTargetPlayer = playerhelpers->GetGamePlayer(ent_index); if (pTargetPlayer != NULL && !pTargetPlayer->IsInGame()) @@ -269,7 +269,7 @@ bool IsEyeAnglesSupported() bool GetPlayerInfo(int client, player_info_t *info) { -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX return engine->GetPlayerInfo(client, info); #else return (iserver) ? iserver->GetPlayerInfo(client-1, info) : false; @@ -420,7 +420,7 @@ void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level) CON_COMMAND(sm_dump_netprops_xml, "Dumps the networkable property table as an XML file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif @@ -462,7 +462,7 @@ CON_COMMAND(sm_dump_netprops_xml, "Dumps the networkable property table as an XM CON_COMMAND(sm_dump_netprops, "Dumps the networkable property table as a text file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif @@ -517,7 +517,7 @@ void _ignore_invalid_parameter( CON_COMMAND(sm_dump_classes, "Dumps the class list as a text file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif @@ -710,7 +710,7 @@ void UTIL_DrawDataTable(FILE *fp, datamap_t *pMap, int level) CON_COMMAND(sm_dump_datamaps, "Dumps the data map list as a text file") { -#if !defined ORANGEBOX_BUILD +#if SOURCE_ENGINE == SE_EPISODEONE CCommand args; #endif diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 5dff4cd0..af334457 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -175,7 +175,7 @@ static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params) return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } static cell_t GetPlayerWeaponSlot(IPluginContext *pContext, const cell_t *params) @@ -211,7 +211,7 @@ static cell_t GetPlayerWeaponSlot(IPluginContext *pContext, const cell_t *params return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params) @@ -290,7 +290,7 @@ static cell_t TeleportEntity(IPluginContext *pContext, const cell_t *params) return 1; } -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX /* :TODO: This is Team Fortress 2 specific */ static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params) { @@ -352,7 +352,7 @@ static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params return pContext->ThrowNativeError("Client %d is not in game", params[1]); } - edict_t *pEdict = engine->PEntityOfEntIndex(params[2]); + edict_t *pEdict = PEntityOfEntIndex(params[2]); if (!pEdict || pEdict->IsFree()) { return pContext->ThrowNativeError("Entity %d is not valid", params[2]); @@ -639,9 +639,49 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } +#if SOURCE_ENGINE == SE_LEFT4DEAD +static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[4]; + InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[3], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("CreateEntityByName", ValveCall_Static, &pass[3], pass, 3, &pCall)) + { + return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized"); + } + } + + CBaseEntity *pEntity = NULL; + START_CALL(); + DECODE_VALVE_PARAM(1, vparams, 0); + DECODE_VALVE_PARAM(2, vparams, 1); + *(bool *)(vptr + 8) = true; + FINISH_CALL_SIMPLE(&pEntity); + + if (pEntity == NULL) + { + return -1; + } + + edict_t *pEdict = gameents->BaseEntityToEdict(pEntity); + if (!pEdict) + { + return -1; + } + + return IndexOfEdict(pEdict); +} +#else static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) { static ValveCall *pCall = NULL; @@ -676,8 +716,9 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) return -1; } - return engine->IndexOfEdict(pEdict); + return IndexOfEdict(pEdict); } +#endif static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params) { @@ -764,7 +805,7 @@ static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *par { ValvePassInfo pass[3]; InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX InitPass(pass[1], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL); #else InitPass(pass[1], Valve_Vector, PassType_Object, PASSFLAG_BYVAL|PASSFLAG_OCTOR|PASSFLAG_OASSIGNOP); diff --git a/extensions/sdktools/vstringtable.cpp b/extensions/sdktools/vstringtable.cpp index 522e4e47..9bb29b24 100644 --- a/extensions/sdktools/vstringtable.cpp +++ b/extensions/sdktools/vstringtable.cpp @@ -239,7 +239,7 @@ static cell_t AddToStringTable(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[2], &str); pContext->LocalToString(params[3], &userdata); -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX pTable->AddString(true, str, params[4], userdata); #else pTable->AddString(str, params[4], userdata); diff --git a/extensions/sqlite/Makefile b/extensions/sqlite/Makefile index 08fd03ba..b59f96fb 100644 --- a/extensions/sqlite/Makefile +++ b/extensions/sqlite/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -52,8 +53,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -61,14 +63,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -76,8 +88,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SOURCEMM16)/sourcehook endif @@ -135,7 +148,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/structs/Makefile b/extensions/structs/Makefile index 22bfb7e0..833b27c5 100644 --- a/extensions/structs/Makefile +++ b/extensions/structs/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,23 +33,34 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) - INCLUDE += -I$(HL2SDK)/public/dlls + INCLUDE += -I$(HL2SDK)/public/dlls -I$(HL2SDK)/game_shared SRCDS = $(SRCDS_BASE) override ENGSET = true endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/public/mathlib + INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/game/shared SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/game/shared + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn -I$(HL2SDK_OB)/game/shared + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -108,7 +121,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile index d8b772a8..341bc165 100644 --- a/extensions/tf2/Makefile +++ b/extensions/tf2/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -33,8 +34,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -42,14 +44,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a tier0_i486.so @@ -57,8 +69,10 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/extensions -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \ + -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -110,7 +124,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/extensions/topmenus/Makefile b/extensions/topmenus/Makefile index 6d2a7afb..2f76c05b 100644 --- a/extensions/topmenus/Makefile +++ b/extensions/topmenus/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -33,8 +34,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -42,14 +44,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -57,8 +69,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \ -I$(SOURCEMM16)/sourcehook @@ -110,7 +123,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/gamedata/core.games.txt b/gamedata/core.games.txt index 50c41a65..8490f2fe 100644 --- a/gamedata/core.games.txt +++ b/gamedata/core.games.txt @@ -58,6 +58,18 @@ } } + "left4dead" + { + "Offsets" + { + "GetDataDescMap" + { + "windows" "11" + "linux" "12" + } + } + } + /** * Which games support ShowMenu? */ @@ -75,6 +87,7 @@ "game" "diprip" "game" "synergy" "game" "FortressForever" + "game" "left4dead" } "Keys" diff --git a/gamedata/sdktools.games.l4d.txt b/gamedata/sdktools.games.l4d.txt new file mode 100644 index 00000000..8ba8ec6b --- /dev/null +++ b/gamedata/sdktools.games.l4d.txt @@ -0,0 +1,361 @@ +"Games" +{ + /* Sounds */ + "#default" + { + "Keys" + { + "SlapSoundCount" "3" + "SlapSound1" "player/pl_fallpain1.wav" + "SlapSound2" "player/pl_fallpain3.wav" + "SlapSound3" "player/pl_pain5.wav" + "m_iFrags" "m_iFrags" + } + "Offsets" + { + "m_iHealth" + { + "class" "CBasePlayer" + "prop" "m_iHealth" + } + "m_lifeState" + { + "class" "CBasePlayer" + "prop" "m_lifeState" + } + } + } + + /* General Temp Entities */ + "#default" + { + "#supported" + { + "game" "left4dead" + } + + "Offsets" + { + /* Offset into CBaseTempEntity constructor */ + "s_pTempEntities" + { + "windows" "17" + } + "GetTEName" + { + "windows" "4" + "linux" "4" + } + "GetTENext" + { + "windows" "8" + "linux" "8" + } + "TE_GetServerClass" + { + "windows" "0" + "linux" "0" + } + } + + "Signatures" + { + "CBaseTempEntity" + { + "library" "server" + "windows" "\x8B\xC1\x8B\x4C\x24\x04\xC7\x00\x2A\x2A\x2A\x2A\x89\x48\x04\x8B\x15\x2A\x2A\x2A\x2A\x89\x50\x08\xA3\x2A\x2A\x2A\x2A\xC2\x04\x00" + } + "s_pTempEntities" + { + "library" "server" + "linux" "@_ZN15CBaseTempEntity15s_pTempEntitiesE" + } + } + } + + /* Create Entity Signatures */ + "#default" + { + "#supported" + { + "game" "left4dead" + } + + "Signatures" + { + "DispatchSpawn" + { + "library" "server" + "linux" "@_Z13DispatchSpawnP11CBaseEntity" + "windows" "\x53\x55\x56\x8B\x74\x24\x10\x85\xF6\x57\x0F\x84\x2A\x2A\x2A\x2A\x8B\x1D\x2A\x2A\x2A\x2A\x8B\x03\x8B\x50\x64\x8B\xCB" + } + "CreateEntityByName" + { + "library" "server" + "linux" "@_Z18CreateEntityByNamePKcib" + "windows" "\x56\x8B\x74\x24\x0C\x83\xFE\xFF\x57\x8B\x7C\x24\x0C\x74\x27\x8B\x0D\x2A\x2A\x2A\x2A\x8B\x01\x8B\x50\x54\x56\xFF\xD2" + } + } + } + + /* CGlobalEntityList */ + "#default" + { + "#supported" + { + "game" "left4dead" + } + + "Offsets" + { + /* Offset into LevelShutdown */ + "gEntList" + { + "windows" "11" + } + } + + "Signatures" + { + "LevelShutdown" + { + "library" "server" + "windows" "\xE8\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\xE8" + } + "gEntList" + { + "library" "server" + "linux" "@gEntList" + } + + /* Functions in CGlobalEntityList */ + "FindEntityByClassname" + { + "library" "server" + "windows" "\x53\x55\x56\x8B\xF1\x8B\x4C\x24\x10\x85\xC9\x57\x74\x19\x8B\x01\x8B\x50\x08\xFF\xD2\x8B\x00\x25\xFF\x0F\x00\x00\x83\xC0\x01\xC1\xE0\x04\x8B\x3C\x30\xEB\x06\x8B\xBE\x2A\x2A\x2A\x2A\x85\xFF\x74\x39\x8B\x5C\x24\x18\x8B\x2D\x2A\x2A\x2A\x2A\xEB\x03" + "linux" "@_ZN17CGlobalEntityList21FindEntityByClassnameEP11CBaseEntityPKc" + } + } + } + + /* General GameRules */ + "#default" + { + "#supported" + { + "game" "left4dead" + } + + "Offsets" + { + /* Offset into CreateGameRulesObject */ + "g_pGameRules" + { + "windows" "2" + } + } + + "Signatures" + { + /* This signature sometimes has multiple matches, but this + * does not matter as g_pGameRules is involved in all of them. + * The same g_pGameRules offset applies to each match. + * + * Sometimes this block of bytes is at the beginning of the static + * CreateGameRulesObject function and sometimes it is in the middle + * of an entirely different function. This depends on the game. + */ + "CreateGameRulesObject" + { + "library" "server" + "windows" "\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x2A\x8B\x01\x8B\x50\x2A\x6A\x01\xFF\xD2" + } + "g_pGameRules" + { + "library" "server" + "linux" "@g_pGameRules" + } + } + } + + /* IServer interface pointer */ + "#default" + { + "Offsets" + { + /* Offset into IVEngineServer::CreateFakeClient */ + "sv" + { + "windows" "6" + } + } + + "Signatures" + { + /* CBaseServer object for IServer interface */ + "sv" + { + "library" "engine" + "linux" "@sv" + } + } + } + + /* EntityFactoryDictionary function */ + "#default" + { + "Signatures" + { + "EntityFactory" + { + "library" "server" + "windows" "\xB8\x01\x00\x00\x00\x84\x2A\x2A\x2A\x2A\x2A\x75\x1D\x09\x2A\x2A\x2A\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x04\xB8\x2A\x2A\x2A\x2A\xC3" + "linux" "@_Z23EntityFactoryDictionaryv" + } + } + } + + /* CBaseEntityOutput::FireOutput */ + "#default" + { + "#supported" + { + "game" "left4dead" + } + "Signatures" + { + "FireOutput" + { + "library" "server" + "windows" "\x81\xEC\x1C\x01\x00\x00\x53\x55\x56\x8B\x71\x14\x85\xF6" + "linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" + } + } + "Offsets" + { + "FireOutputBackup" + { + "windows" "6" + "linux" "10" + } + } + } + + /* SetUserInfo data */ + "#default" + { + "Offsets" + { + /** + * CBaseClient::SetUserCVar(char const*,char const*); + * Linux offset straight from VTable dump. + * Windows offset is crazy. Found the windows 'SetName' function using string "(%d)%-0.*s" + * Cross referenced back to the vtable and counted manually (SetUserCvar is 1 higher, offsets start from 1) + */ + "SetUserCvar" + { + "windows" "17" + "linux" "62" + } + /** + * Offset into CBaseClient - Used by CBaseServer::UpdateUserSettings to determine when changes have been made. + * Find CBaseClient::UpdateUserSettings (strings "net_maxroutable", "cl_updaterate" etc) and the offset is set to 0 near the end. + * Linux: mov byte ptr [esi+0B0h], 0 + * Win: mov byte ptr [esi+0B0h], 0 + */ + "InfoChanged" + { + "windows" "176" + "linux" "176" + } + } + } + + /* Left 4 Dead */ + "left4dead" + { + "Offsets" + { + "GiveNamedItem" + { + "windows" "480" + "linux" "481" + } + "RemovePlayerItem" + { + "windows" "269" + "linux" "270" + } + "Weapon_GetSlot" + { + "windows" "267" + "linux" "268" + } + "Ignite" + { + "windows" "206" + "linux" "207" + } + "Extinguish" + { + "windows" "210" + "linux" "211" + } + "Teleport" + { + "windows" "105" + "linux" "106" + } + "CommitSuicide" + { + "windows" "449" + "linux" "449" + } + "GetVelocity" + { + "windows" "136" + "linux" "137" + } + "EyeAngles" + { + "windows" "127" + "linux" "128" + } + "AcceptInput" + { + "windows" "37" + "linux" "38" + } + "DispatchKeyValue" + { + "windows" "29" + "linux" "28" + } + "DispatchKeyValueFloat" + { + "windows" "28" + "linux" "29" + } + "DispatchKeyValueVector" + { + "windows" "27" + "linux" "30" + } + "SetEntityModel" + { + "windows" "23" + "linux" "24" + } + "WeaponEquip" + { + "windows" "260" + "linux" "261" + } + "Activate" + { + "windows" "31" + "linux" "32" + } + } + } +} diff --git a/loader/Makefile b/loader/Makefile index 9e0a82e9..525bab6c 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -1,7 +1,7 @@ # (C)2004-2008 SourceMod Development Team # Makefile written by David "BAILOPAN" Anderson -SOURCEMM16 = ../../sourcemm-1.6 +SOURCEMM16 = ../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -23,7 +23,7 @@ CPP = gcc-4.1 LINK = -static-libgcc -INCLUDE = -I$(SOURCEMM16) -I$(SOURCEMM16)/sourcehook -I$(SOURCEMM16)/sourcemm +INCLUDE = -I$(SOURCEMM16) -I$(SOURCEMM16)/sourcehook CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Wno-uninitialized \ diff --git a/loader/loader.cpp b/loader/loader.cpp index bb5f5ee9..46db5f72 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -67,6 +67,7 @@ #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_7_L4D "sourcemod.2.l4d" PLATFORM_EXT HINSTANCE g_hCore = NULL; bool load_attempted = false; @@ -213,6 +214,11 @@ DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, co filename = FILENAME_1_6_EP1; break; } + case SOURCE_ENGINE_LEFT4DEAD: + { + filename = FILENAME_1_7_L4D; + break; + } default: { return NULL; diff --git a/plugins/include/console.inc b/plugins/include/console.inc index 1a4e3529..ffe5dcda 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -473,8 +473,9 @@ native bool:GetConVarBool(Handle:convar); /** * Sets the boolean value of a console variable. * - * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine. - * This engine automatically replicates and notifies as soon as the convar is changed. + * Note: The replicate and notify params are ignored on the engines for Episode 2/Orange Box + * and Left 4 Dead. These engines automatically replicates and notifies as soon as the convar + * is changed. * * @param convar Handle to the convar. * @param value New boolean value. @@ -500,8 +501,9 @@ native GetConVarInt(Handle:convar); /** * Sets the integer value of a console variable. * - * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine. - * This engine automatically replicates and notifies as soon as the convar is changed. + * Note: The replicate and notify params are ignored on the engines for Episode 2/Orange Box + * and Left 4 Dead. These engines automatically replicates and notifies as soon as the convar + * is changed. * * @param convar Handle to the convar. * @param value New integer value. @@ -527,8 +529,9 @@ native Float:GetConVarFloat(Handle:convar); /** * Sets the floating point value of a console variable. * - * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine. - * This engine automatically replicates and notifies as soon as the convar is changed. + * Note: The replicate and notify params are ignored on the engines for Episode 2/Orange Box + * and Left 4 Dead. These engines automatically replicates and notifies as soon as the convar + * is changed. * * @param convar Handle to the convar. * @param value New floating point value. @@ -556,8 +559,9 @@ native GetConVarString(Handle:convar, String:value[], maxlength); /** * Sets the string value of a console variable. * - * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine. - * This engine automatically replicates and notifies as soon as the convar is changed. + * Note: The replicate and notify params are ignored on the engines for Episode 2/Orange Box + * and Left 4 Dead. These engines automatically replicates and notifies as soon as the convar + * is changed. * * @param convar Handle to the convar. * @param value New string value. @@ -574,8 +578,9 @@ native SetConVarString(Handle:convar, const String:value[], bool:replicate=false /** * Resets the console variable to its default value. * - * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine. - * This engine automatically replicates and notifies as soon as the convar is changed. + * Note: The replicate and notify params are ignored on the engines for Episode 2/Orange Box + * and Left 4 Dead. These engines automatically replicates and notifies as soon as the convar + * is changed. * * @param convar Handle to the convar. * @param replicate If set to true, the new convar value will be set on all clients. diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index a58adabc..24e9b89c 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -38,7 +38,8 @@ #define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */ #define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */ #define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */ -#define SOURCE_SDK_EPISODE2 30 /**< Engine released after Episode 2 (no SDK yet) */ +#define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */ +#define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */ #define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */ #define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */ @@ -51,7 +52,7 @@ enum DialogType DialogType_Menu, /**< an options menu */ DialogType_Text, /**< a richtext dialog */ DialogType_Entry, /**< an entry box */ - DialogType_AskConnect /**< ask the client to connect to a specified IP */ + DialogType_AskConnect /**< ask the client to connect to a specified IP */ }; /** diff --git a/public/compat_wrappers.h b/public/compat_wrappers.h index c5fd14d4..242c12c6 100644 --- a/public/compat_wrappers.h +++ b/public/compat_wrappers.h @@ -32,7 +32,7 @@ #ifndef _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ #define _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ -#if defined ORANGEBOX_BUILD +#if SOURCE_ENGINE >= SE_ORANGEBOX #define CONVAR_REGISTER(object) ConVar_Register(0, object) inline bool IsFlagSet(ConCommandBase *cmd, int flag) @@ -43,6 +43,14 @@ { engine->InsertServerCommand(buf); } + inline ConCommandBase *FindCommandBase(const char *name) + { + return icvar->FindCommandBase(name); + } + inline ConCommand *FindCommand(const char *name) + { + return icvar->FindCommand(name); + } #else class CCommand { @@ -69,11 +77,71 @@ { engine->InsertServerCommand(buf); } + inline ConCommandBase *FindCommandBase(const char *name) + { + ConCommandBase *pBase = icvar->GetCommands(); + while (pBase) + { + if (strcmp(pBase->GetName(), name) == 0) + { + if (pBase->IsCommand()) + { + return NULL; + } + + return pBase; + } + pBase = const_cast(pBase->GetNext()); + } + return NULL; + } + inline ConCommand *FindCommand(const char *name) + { + ConCommandBase *pBase = icvar->GetCommands(); + while (pBase) + { + if (strcmp(pBase->GetName(), name) == 0) + { + if (!pBase->IsCommand()) + { + return NULL; + } + + return static_cast(pBase); + } + pBase = const_cast(pBase->GetNext()); + } + return NULL; + } #define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION #define CONVAR_REGISTER(object) ConCommandBaseMgr::OneTimeInit(object) typedef FnChangeCallback FnChangeCallback_t; -#endif //ORANGEBOX_BUILD +#endif //SOURCE_ENGINE >= SE_ORANGEBOX + +#if SOURCE_ENGINE >= SE_LEFT4DEAD + inline int IndexOfEdict(const edict_t *pEdict) + { + return ((int)pEdict - (int)gpGlobals->baseEdict) >> 4; + } + inline edict_t *PEntityOfEntIndex(int iEntIndex) + { + if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities) + { + return (edict_t *)((int)gpGlobals->baseEdict + (iEntIndex << 4)); + } + return NULL; + } +#else + inline int IndexOfEdict(const edict_t *pEdict) + { + return engine->IndexOfEdict(pEdict); + } + inline edict_t *PEntityOfEntIndex(int iEntIndex) + { + return engine->PEntityOfEntIndex(iEntIndex); + } +#endif //SOURCE_ENGINE >= SE_LEFT4DEAD #endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ diff --git a/public/mms_sample_ext/Makefile b/public/mms_sample_ext/Makefile index 87801801..7fc77a6a 100644 --- a/public/mms_sample_ext/Makefile +++ b/public/mms_sample_ext/Makefile @@ -5,8 +5,9 @@ SMSDK = .. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -29,8 +30,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -38,20 +40,32 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif + +CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 LINK = vstdlib_i486.so tier0_i486.so -static-libgcc INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK) -I$(SMSDK)/jit \ - -I$(SMSDK)/jit/x86 -I$(SMSDK)/extensions -I$(SMSDK)/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK) -I$(SMSDK)/jit -I$(SMSDK)/jit/x86 \ + -I$(SMSDK)/extensions -I$(SMSDK)/sourcepawn CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \ @@ -91,7 +105,7 @@ all: check check: if [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/public/sample_ext/Makefile b/public/sample_ext/Makefile index b68f5bd1..3c1afc2b 100644 --- a/public/sample_ext/Makefile +++ b/public/sample_ext/Makefile @@ -5,8 +5,9 @@ SMSDK = ../.. SRCDS_BASE = ~/srcds HL2SDK_ORIG = ../../../hl2sdk HL2SDK_OB = ../../../hl2sdk-ob -SOURCEMM14 = ../../../sourcemm-1.4 -SOURCEMM16 = ../../../sourcemm-1.6 +HL2SDK_L4D = ../../../hl2sdk-l4d +SOURCEMM14 = ../../../mmsource-legacy +SOURCEMM16 = ../../../mmsource ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -32,8 +33,9 @@ CPP = gcc-4.1 override ENGSET = false ifeq "$(ENGINE)" "original" HL2SDK = $(HL2SDK_ORIG) - HL2PUB = $(HL2SDK_ORIG)/public - HL2LIB = $(HL2SDK_ORIG)/linux_sdk + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/linux_sdk + CFLAGS += -DSOURCE_ENGINE=2 METAMOD = $(SOURCEMM14) INCLUDE += -I$(HL2SDK)/public/dlls SRCDS = $(SRCDS_BASE) @@ -41,14 +43,24 @@ ifeq "$(ENGINE)" "original" endif ifeq "$(ENGINE)" "orangebox" HL2SDK = $(HL2SDK_OB) - HL2PUB = $(HL2SDK_OB)/public - HL2LIB = $(HL2SDK_OB)/lib/linux - CFLAGS += -DORANGEBOX_BUILD + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif +ifeq "$(ENGINE)" "left4dead" + HL2SDK = $(HL2SDK_L4D) + HL2PUB = $(HL2SDK)/public + HL2LIB = $(HL2SDK)/lib/linux + CFLAGS += -DSOURCE_ENGINE=4 + METAMOD = $(SOURCEMM16) + INCLUDE += -I$(HL2SDK)/public/game/server + SRCDS = $(SRCDS_BASE)/l4d_demo + override ENGSET = true +endif ifeq "$(USEMETA)" "true" LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so @@ -56,8 +68,9 @@ ifeq "$(USEMETA)" "true" LINK += $(LINK_HL2) INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \ - -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \ - -I$(SMSDK)/public/sourcepawn + -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn + + CFLAGS += -DSE_EPISODEONE=2 -DSE_ORANGEBOX=3 -DSE_LEFT4DEAD=4 else INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn endif @@ -108,7 +121,7 @@ all: check check: if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \ - echo "You must supply ENGINE=orangebox or ENGINE=original"; \ + echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \ exit 1; \ fi diff --git a/sourcepawn/jit/Makefile b/sourcepawn/jit/Makefile index 51df620e..697257ed 100644 --- a/sourcepawn/jit/Makefile +++ b/sourcepawn/jit/Makefile @@ -2,7 +2,7 @@ # Makefile written by David "BAILOPAN" Anderson SMSDK = ../.. -SOURCEHOOK = ../../../sourcemm-1.6/sourcehook +SOURCEHOOK = ../../../mmsource/sourcehook ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### diff --git a/tools/builder/LinuxBuilder.cs b/tools/builder/LinuxBuilder.cs index 1fac9619..9f3332e5 100644 --- a/tools/builder/LinuxBuilder.cs +++ b/tools/builder/LinuxBuilder.cs @@ -49,6 +49,10 @@ namespace builder { output_folder += ".original"; } + else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) + { + output_folder += ".left4dead"; + } string binpath = Config.PathFormat("{0}/{1}/{2}", path, @@ -74,6 +78,10 @@ namespace builder { makefile_args = "ENGINE=\"original\""; } + else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) + { + makefile_args = "ENGINE=\"left4dead\""; + } /* Clean the project first */ info.WorkingDirectory = path; diff --git a/tools/builder/Package.cs b/tools/builder/Package.cs index bbbbdcf4..98436f79 100644 --- a/tools/builder/Package.cs +++ b/tools/builder/Package.cs @@ -13,7 +13,8 @@ namespace builder BuildMode_Simple, BuildMode_OldMetamod, BuildMode_Episode1, - BuildMode_Episode2 + BuildMode_Episode2, + BuildMode_Left4Dead }; public class Library diff --git a/tools/builder/PkgCore.cs b/tools/builder/PkgCore.cs index 58531e8e..29c23931 100644 --- a/tools/builder/PkgCore.cs +++ b/tools/builder/PkgCore.cs @@ -67,6 +67,7 @@ namespace builder folders.Add("addons/sourcemod/extensions/auto.1.ep1"); //folders.Add("addons/sourcemod/extensions/auto.2.ep1"); folders.Add("addons/sourcemod/extensions/auto.2.ep2"); + folders.Add("addons/sourcemod/extensions/auto.2.l4d"); folders.Add("addons/sourcemod/scripting/playercommands"); folders.Add("addons/metamod"); @@ -171,6 +172,14 @@ namespace builder lib.build_mode = BuildMode.BuildMode_Episode2; libraries.Add(lib); + lib = new Library(); + lib.package_path = "addons/sourcemod/bin"; + lib.source_path = "core"; + lib.binary_name = "sourcemod.2.l4d"; + lib.vcproj_name = "sourcemod_mm"; + lib.build_mode = BuildMode.BuildMode_Left4Dead; + libraries.Add(lib); + lib = new Library(); lib.package_path = "addons/sourcemod/bin"; lib.source_path = "sourcepawn/jit"; @@ -230,6 +239,14 @@ namespace builder lib.build_mode = BuildMode.BuildMode_Episode2; libraries.Add(lib); + lib = new Library(); + lib.package_path = "addons/sourcemod/extensions/auto.2.l4d"; + lib.source_path = "extensions/sdktools"; + lib.binary_name = "sdktools.ext"; + lib.vcproj_name = "sdktools"; + lib.build_mode = BuildMode.BuildMode_Left4Dead; + libraries.Add(lib); + lib = new Library(); lib.package_path = "addons/sourcemod/extensions"; lib.source_path = "extensions/sqlite"; diff --git a/tools/builder/Win32Builder.cs b/tools/builder/Win32Builder.cs index 4d8f9f15..04792798 100644 --- a/tools/builder/Win32Builder.cs +++ b/tools/builder/Win32Builder.cs @@ -50,6 +50,10 @@ namespace builder { config_name = config_name + " - Old Metamod"; } + else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) + { + config_name = config_name + " - Left 4 Dead"; + } string binpath = Config.PathFormat("{0}/{1}/{2}", path, From 31e30faace8b0abc06b92edc604e7a57e05c322e Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 14 Nov 2008 09:58:40 -0600 Subject: [PATCH 04/15] Triggering build --- pushbuild.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushbuild.txt b/pushbuild.txt index 48082f72..b1bd38b6 100644 --- a/pushbuild.txt +++ b/pushbuild.txt @@ -1 +1 @@ -12 +13 From 41b61ed36f0ffc98daf7be2d41ab67c32cc29519 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 14 Nov 2008 16:55:09 -0600 Subject: [PATCH 05/15] Fixed tab inconsistency in some build tool source files. --- tools/builder/Package.cs | 2 +- tools/builder/PkgCore.cs | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/builder/Package.cs b/tools/builder/Package.cs index 98436f79..cb69bcb1 100644 --- a/tools/builder/Package.cs +++ b/tools/builder/Package.cs @@ -14,7 +14,7 @@ namespace builder BuildMode_OldMetamod, BuildMode_Episode1, BuildMode_Episode2, - BuildMode_Left4Dead + BuildMode_Left4Dead }; public class Library diff --git a/tools/builder/PkgCore.cs b/tools/builder/PkgCore.cs index 29c23931..aab75844 100644 --- a/tools/builder/PkgCore.cs +++ b/tools/builder/PkgCore.cs @@ -67,7 +67,7 @@ namespace builder folders.Add("addons/sourcemod/extensions/auto.1.ep1"); //folders.Add("addons/sourcemod/extensions/auto.2.ep1"); folders.Add("addons/sourcemod/extensions/auto.2.ep2"); - folders.Add("addons/sourcemod/extensions/auto.2.l4d"); + folders.Add("addons/sourcemod/extensions/auto.2.l4d"); folders.Add("addons/sourcemod/scripting/playercommands"); folders.Add("addons/metamod"); @@ -172,13 +172,13 @@ namespace builder lib.build_mode = BuildMode.BuildMode_Episode2; libraries.Add(lib); - lib = new Library(); - lib.package_path = "addons/sourcemod/bin"; - lib.source_path = "core"; - lib.binary_name = "sourcemod.2.l4d"; - lib.vcproj_name = "sourcemod_mm"; - lib.build_mode = BuildMode.BuildMode_Left4Dead; - libraries.Add(lib); + lib = new Library(); + lib.package_path = "addons/sourcemod/bin"; + lib.source_path = "core"; + lib.binary_name = "sourcemod.2.l4d"; + lib.vcproj_name = "sourcemod_mm"; + lib.build_mode = BuildMode.BuildMode_Left4Dead; + libraries.Add(lib); lib = new Library(); lib.package_path = "addons/sourcemod/bin"; @@ -239,13 +239,13 @@ namespace builder lib.build_mode = BuildMode.BuildMode_Episode2; libraries.Add(lib); - lib = new Library(); - lib.package_path = "addons/sourcemod/extensions/auto.2.l4d"; - lib.source_path = "extensions/sdktools"; - lib.binary_name = "sdktools.ext"; - lib.vcproj_name = "sdktools"; - lib.build_mode = BuildMode.BuildMode_Left4Dead; - libraries.Add(lib); + lib = new Library(); + lib.package_path = "addons/sourcemod/extensions/auto.2.l4d"; + lib.source_path = "extensions/sdktools"; + lib.binary_name = "sdktools.ext"; + lib.vcproj_name = "sdktools"; + lib.build_mode = BuildMode.BuildMode_Left4Dead; + libraries.Add(lib); lib = new Library(); lib.package_path = "addons/sourcemod/extensions"; From 43f5d71724121eda528aaf96e2cdd5e88f4bb2ad Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 14 Nov 2008 23:08:24 -0600 Subject: [PATCH 06/15] Fixed IndexOfEdict and PEntityOfEntIndex inlines to be in line with updated edict_t structure in SDK --- public/compat_wrappers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/compat_wrappers.h b/public/compat_wrappers.h index 242c12c6..40b6534d 100644 --- a/public/compat_wrappers.h +++ b/public/compat_wrappers.h @@ -123,13 +123,13 @@ #if SOURCE_ENGINE >= SE_LEFT4DEAD inline int IndexOfEdict(const edict_t *pEdict) { - return ((int)pEdict - (int)gpGlobals->baseEdict) >> 4; + return (int)(pEdict - gpGlobals->baseEdict); } inline edict_t *PEntityOfEntIndex(int iEntIndex) { if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities) { - return (edict_t *)((int)gpGlobals->baseEdict + (iEntIndex << 4)); + return (edict_t *)(gpGlobals->baseEdict + iEntIndex); } return NULL; } From 373fbb6ca3f99203536f189ac0d57fed8875756d Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 17 Nov 2008 22:11:06 -0600 Subject: [PATCH 07/15] Removed debugging code from ConVarManager --- core/ConVarManager.cpp | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 04109672..d1c0dff0 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -51,8 +51,6 @@ SH_DECL_HOOK3_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar *, const char *); #endif -SH_DECL_HOOK1_void(ICvar, InstallGlobalChangeCallback, SH_NOATTRIB, false, FnChangeCallback_t); - SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *); @@ -81,35 +79,6 @@ void ConVarManager::OnSourceModStartup(bool late) m_ConVarType = g_HandleSys.CreateType("ConVar", this, 0, NULL, &sec, g_pCoreIdent, NULL); } -bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength) -{ -#if defined WIN32 || defined _WIN32 - 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); -#elif defined __linux__ - 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; -} - -void InstallCallback(FnChangeCallback_t callback) -{ - char path[MAX_PATH]; - GetFileOfAddress((void *)callback, path, sizeof(path)); - printf("Yo: %s\n", path); -} - void ConVarManager::OnSourceModAllInitialized() { /** @@ -123,7 +92,6 @@ void ConVarManager::OnSourceModAllInitialized() } #endif - SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); SH_ADD_HOOK_STATICFUNC(ICvar, InstallGlobalChangeCallback, icvar, InstallCallback, false); /* Add the 'convars' option to the 'sm' console command */ From 5bbeddc134f4dea4eacdebb62929d3617391de2b Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 17 Nov 2008 22:13:32 -0600 Subject: [PATCH 08/15] Oops, removed something I shouldn't have --- core/ConVarManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index d1c0dff0..1ea3eab5 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -92,7 +92,7 @@ void ConVarManager::OnSourceModAllInitialized() } #endif - SH_ADD_HOOK_STATICFUNC(ICvar, InstallGlobalChangeCallback, icvar, InstallCallback, false); + SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); /* Add the 'convars' option to the 'sm' console command */ g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); From 9ae456b9d175c32120ea02584cfda6f389638320 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Tue, 18 Nov 2008 06:00:31 -0600 Subject: [PATCH 09/15] Updated makefiles to link against binaries at l4d directory instead of l4d_demo --- core/Makefile | 2 +- extensions/bintools/Makefile | 2 +- extensions/clientprefs/Makefile | 2 +- extensions/cstrike/Makefile | 2 +- extensions/geoip/Makefile | 2 +- extensions/mysql/Makefile | 2 +- extensions/regex/Makefile | 2 +- extensions/sdktools/Makefile | 2 +- extensions/sqlite/Makefile | 2 +- extensions/structs/Makefile | 2 +- extensions/tf2/Makefile | 2 +- extensions/topmenus/Makefile | 2 +- public/mms_sample_ext/Makefile | 2 +- public/sample_ext/Makefile | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/Makefile b/core/Makefile index b88a12a3..8e17b678 100644 --- a/core/Makefile +++ b/core/Makefile @@ -73,7 +73,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d BINARY = sourcemod.2.l4d.so override ENGSET = true endif diff --git a/extensions/bintools/Makefile b/extensions/bintools/Makefile index 2d1ccf68..a476a513 100644 --- a/extensions/bintools/Makefile +++ b/extensions/bintools/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/clientprefs/Makefile b/extensions/clientprefs/Makefile index 3838ebed..6c9bec88 100644 --- a/extensions/clientprefs/Makefile +++ b/extensions/clientprefs/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/cstrike/Makefile b/extensions/cstrike/Makefile index 082ee567..6b807f57 100644 --- a/extensions/cstrike/Makefile +++ b/extensions/cstrike/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/geoip/Makefile b/extensions/geoip/Makefile index 653a80cf..47198287 100644 --- a/extensions/geoip/Makefile +++ b/extensions/geoip/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/mysql/Makefile b/extensions/mysql/Makefile index a6b30874..8ba038d3 100644 --- a/extensions/mysql/Makefile +++ b/extensions/mysql/Makefile @@ -62,7 +62,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/regex/Makefile b/extensions/regex/Makefile index 36cb464a..feb1dda6 100644 --- a/extensions/regex/Makefile +++ b/extensions/regex/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/sdktools/Makefile b/extensions/sdktools/Makefile index f9102218..884ddab6 100644 --- a/extensions/sdktools/Makefile +++ b/extensions/sdktools/Makefile @@ -61,7 +61,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/sqlite/Makefile b/extensions/sqlite/Makefile index b59f96fb..5ad75831 100644 --- a/extensions/sqlite/Makefile +++ b/extensions/sqlite/Makefile @@ -78,7 +78,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/structs/Makefile b/extensions/structs/Makefile index 833b27c5..bab4781b 100644 --- a/extensions/structs/Makefile +++ b/extensions/structs/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/game/shared - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile index 341bc165..f8bb36e7 100644 --- a/extensions/tf2/Makefile +++ b/extensions/tf2/Makefile @@ -59,7 +59,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/topmenus/Makefile b/extensions/topmenus/Makefile index 2f76c05b..a2801060 100644 --- a/extensions/topmenus/Makefile +++ b/extensions/topmenus/Makefile @@ -59,7 +59,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/public/mms_sample_ext/Makefile b/public/mms_sample_ext/Makefile index 7fc77a6a..5efbca8b 100644 --- a/public/mms_sample_ext/Makefile +++ b/public/mms_sample_ext/Makefile @@ -55,7 +55,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/public/sample_ext/Makefile b/public/sample_ext/Makefile index 3c1afc2b..2fdc6260 100644 --- a/public/sample_ext/Makefile +++ b/public/sample_ext/Makefile @@ -58,7 +58,7 @@ ifeq "$(ENGINE)" "left4dead" CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(SOURCEMM16) INCLUDE += -I$(HL2SDK)/public/game/server - SRCDS = $(SRCDS_BASE)/l4d_demo + SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif From 2acf1b08d520f03af324975cdae8fa7d2df36766 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 19 Nov 2008 02:14:43 -0600 Subject: [PATCH 10/15] 'Relatized' the path passed to FileToKeyValues() native. This eliminates the annoying warning in L4D: ***VPK: FindFile Attempting to use full path with VPK file! --- core/smn_keyvalues.cpp | 153 ++++++++++++++++++++++++++++++++++++++++- public/sm_platform.h | 4 +- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index ee7252b4..cf7d16ad 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -91,6 +91,151 @@ public: } }; +/* From MM:S - metamod_util.cpp */ +inline bool pathchar_isalpha(char a) +{ + return (((a & 1<<7) == 0) && isalpha(a)); +} + +inline bool pathchar_sep(char a) +{ +#if defined WIN32 + return (a == '/' || a == '\\'); +#elif defined __linux__ + return (a == '/'); +#endif +} + +inline bool pathstr_isabsolute(const char *str) +{ +#if defined WIN32 + return (pathchar_isalpha(str[0]) + && str[1] == ':' + && pathchar_sep(str[2])); +#elif defined __linux__ + return (str[0] == '/'); +#endif +} + +inline bool pathchar_cmp(char a, char b) +{ +#if defined PLATFORM_WINDOWS + if (pathchar_isalpha(a) && pathchar_isalpha(b)) + { + return (tolower(a) == tolower(b)); + } + /* Either path separator is acceptable */ + if (pathchar_sep(a)) + { + return pathchar_sep(b); + } +#endif + return (a == b); +} + +bool UTIL_Relatize(char buffer[], + size_t maxlength, + const char *relTo, + const char *relFrom) +{ + /* We don't allow relative paths in here, force + * the user to resolve these himself! + */ + if (!pathstr_isabsolute(relTo) + || !pathstr_isabsolute(relFrom)) + { + return false; + } + +#if defined PLATFORM_WINDOWS + /* Relative paths across drives are not possible */ + if (!pathchar_cmp(relTo[0], relFrom[0])) + { + return false; + } + /* Get rid of the drive and semicolon part */ + relTo = &relTo[2]; + relFrom = &relFrom[2]; +#endif + + /* Eliminate the common root between the paths */ + const char *rootTo = NULL; + const char *rootFrom = NULL; + while (*relTo != '\0' && *relFrom != '\0') + { + /* If we get to a new path sequence, start over */ + if (pathchar_sep(*relTo) + && pathchar_sep(*relFrom)) + { + rootTo = relTo; + rootFrom = relFrom; + /* If the paths don't compare, stop looking for a common root */ + } else if (!pathchar_cmp(*relTo, *relFrom)) { + break; + } + relTo++; + relFrom++; + } + + /* NULLs shouldn't happen! */ + if (rootTo == NULL + || rootFrom == NULL) + { + return false; + } + + size_t numLevels = 0; + + /* The root case is special! + * Don't count anything from it. + */ + if (*(rootTo + 1) != '\0') + { + /* Search for how many levels we need to go up. + * Since the root pointer points to a '/', we increment + * the initial pointer by one. + */ + while (*rootTo != '\0') + { + if (pathchar_sep(*rootTo)) + { + /* Check for an improper trailing slash, + * just to be nice even though the user + * should NOT have done this! + */ + if (*(rootTo + 1) == '\0') + { + break; + } + numLevels++; + } + rootTo++; + } + } + + /* Now build the new relative path. */ + size_t len, total = 0; + while (numLevels--) + { + len = _snprintf(&buffer[total], maxlength - total, ".." PLATFORM_SEP_STR); + if (len >= maxlength - total) + { + /* Not enough space in the buffer */ + return false; + } + total += len; + } + + /* Add the absolute path. */ + len = _snprintf(&buffer[total], maxlength - total, "%s", &rootFrom[1]); + if (len >= maxlength - total) + { + return false; + } + + return true; +} + KeyValues *SourceModBase::ReadKeyValuesHandle(Handle_t hndl, HandleError *err, bool root) { HandleError herr; @@ -771,9 +916,11 @@ static cell_t smn_KeyValuesToFile(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[2], &path); char realpath[PLATFORM_MAX_PATH]; + char relpath[PLATFORM_MAX_PATH * 2]; g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path); + UTIL_Relatize(relpath, sizeof(relpath), g_SourceMod.GetGamePath(), realpath); - return pStk->pCurRoot.front()->SaveToFile(basefilesystem, realpath); + return pStk->pCurRoot.front()->SaveToFile(basefilesystem, relpath); } static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params) @@ -797,10 +944,12 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[2], &path); char realpath[PLATFORM_MAX_PATH]; + char relpath[PLATFORM_MAX_PATH * 2]; g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path); + UTIL_Relatize(relpath, sizeof(relpath), g_SourceMod.GetGamePath(), realpath); kv = pStk->pCurRoot.front(); - return g_HL2.KVLoadFromFile(kv, basefilesystem, realpath); + return g_HL2.KVLoadFromFile(kv, basefilesystem, relpath); } static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *params) diff --git a/public/sm_platform.h b/public/sm_platform.h index 50928e61..fb658130 100644 --- a/public/sm_platform.h +++ b/public/sm_platform.h @@ -54,6 +54,7 @@ #include #define PLATFORM_LIB_EXT "dll" #define PLATFORM_MAX_PATH MAX_PATH +#define PLATFORM_SEP_STR "\\" #define PLATFORM_SEP_CHAR '\\' #define PLATFORM_SEP_ALTCHAR '/' #define PLATFORM_EXTERN_C extern "C" __declspec(dllexport) @@ -68,8 +69,9 @@ #include #include #include -#define PLATFORM_MAX_PATH PATH_MAX #define PLATFORM_LIB_EXT "so" +#define PLATFORM_MAX_PATH PATH_MAX +#define PLATFORM_SEP_STR "/" #define PLATFORM_SEP_CHAR '/' #define PLATFORM_SEP_ALTCHAR '\\' #define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default"))) From c2756c731fdf4572634ee4a1c911d69843654ed1 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 19 Nov 2008 02:38:28 -0600 Subject: [PATCH 11/15] Try 2 of eliminating VPK warning. Previous commit was more complicated then it really needed to be. --- core/smn_keyvalues.cpp | 159 +---------------------------------------- public/sm_platform.h | 2 - 2 files changed, 2 insertions(+), 159 deletions(-) diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index cf7d16ad..35cca4a9 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -91,151 +91,6 @@ public: } }; -/* From MM:S - metamod_util.cpp */ -inline bool pathchar_isalpha(char a) -{ - return (((a & 1<<7) == 0) && isalpha(a)); -} - -inline bool pathchar_sep(char a) -{ -#if defined WIN32 - return (a == '/' || a == '\\'); -#elif defined __linux__ - return (a == '/'); -#endif -} - -inline bool pathstr_isabsolute(const char *str) -{ -#if defined WIN32 - return (pathchar_isalpha(str[0]) - && str[1] == ':' - && pathchar_sep(str[2])); -#elif defined __linux__ - return (str[0] == '/'); -#endif -} - -inline bool pathchar_cmp(char a, char b) -{ -#if defined PLATFORM_WINDOWS - if (pathchar_isalpha(a) && pathchar_isalpha(b)) - { - return (tolower(a) == tolower(b)); - } - /* Either path separator is acceptable */ - if (pathchar_sep(a)) - { - return pathchar_sep(b); - } -#endif - return (a == b); -} - -bool UTIL_Relatize(char buffer[], - size_t maxlength, - const char *relTo, - const char *relFrom) -{ - /* We don't allow relative paths in here, force - * the user to resolve these himself! - */ - if (!pathstr_isabsolute(relTo) - || !pathstr_isabsolute(relFrom)) - { - return false; - } - -#if defined PLATFORM_WINDOWS - /* Relative paths across drives are not possible */ - if (!pathchar_cmp(relTo[0], relFrom[0])) - { - return false; - } - /* Get rid of the drive and semicolon part */ - relTo = &relTo[2]; - relFrom = &relFrom[2]; -#endif - - /* Eliminate the common root between the paths */ - const char *rootTo = NULL; - const char *rootFrom = NULL; - while (*relTo != '\0' && *relFrom != '\0') - { - /* If we get to a new path sequence, start over */ - if (pathchar_sep(*relTo) - && pathchar_sep(*relFrom)) - { - rootTo = relTo; - rootFrom = relFrom; - /* If the paths don't compare, stop looking for a common root */ - } else if (!pathchar_cmp(*relTo, *relFrom)) { - break; - } - relTo++; - relFrom++; - } - - /* NULLs shouldn't happen! */ - if (rootTo == NULL - || rootFrom == NULL) - { - return false; - } - - size_t numLevels = 0; - - /* The root case is special! - * Don't count anything from it. - */ - if (*(rootTo + 1) != '\0') - { - /* Search for how many levels we need to go up. - * Since the root pointer points to a '/', we increment - * the initial pointer by one. - */ - while (*rootTo != '\0') - { - if (pathchar_sep(*rootTo)) - { - /* Check for an improper trailing slash, - * just to be nice even though the user - * should NOT have done this! - */ - if (*(rootTo + 1) == '\0') - { - break; - } - numLevels++; - } - rootTo++; - } - } - - /* Now build the new relative path. */ - size_t len, total = 0; - while (numLevels--) - { - len = _snprintf(&buffer[total], maxlength - total, ".." PLATFORM_SEP_STR); - if (len >= maxlength - total) - { - /* Not enough space in the buffer */ - return false; - } - total += len; - } - - /* Add the absolute path. */ - len = _snprintf(&buffer[total], maxlength - total, "%s", &rootFrom[1]); - if (len >= maxlength - total) - { - return false; - } - - return true; -} - KeyValues *SourceModBase::ReadKeyValuesHandle(Handle_t hndl, HandleError *err, bool root) { HandleError herr; @@ -915,12 +770,7 @@ static cell_t smn_KeyValuesToFile(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[2], &path); - char realpath[PLATFORM_MAX_PATH]; - char relpath[PLATFORM_MAX_PATH * 2]; - g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path); - UTIL_Relatize(relpath, sizeof(relpath), g_SourceMod.GetGamePath(), realpath); - - return pStk->pCurRoot.front()->SaveToFile(basefilesystem, relpath); + return pStk->pCurRoot.front()->SaveToFile(basefilesystem, path); } static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params) @@ -943,13 +793,8 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[2], &path); - char realpath[PLATFORM_MAX_PATH]; - char relpath[PLATFORM_MAX_PATH * 2]; - g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", path); - UTIL_Relatize(relpath, sizeof(relpath), g_SourceMod.GetGamePath(), realpath); - kv = pStk->pCurRoot.front(); - return g_HL2.KVLoadFromFile(kv, basefilesystem, relpath); + return g_HL2.KVLoadFromFile(kv, basefilesystem, path); } static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *params) diff --git a/public/sm_platform.h b/public/sm_platform.h index fb658130..bd994289 100644 --- a/public/sm_platform.h +++ b/public/sm_platform.h @@ -54,7 +54,6 @@ #include #define PLATFORM_LIB_EXT "dll" #define PLATFORM_MAX_PATH MAX_PATH -#define PLATFORM_SEP_STR "\\" #define PLATFORM_SEP_CHAR '\\' #define PLATFORM_SEP_ALTCHAR '/' #define PLATFORM_EXTERN_C extern "C" __declspec(dllexport) @@ -71,7 +70,6 @@ #include #define PLATFORM_LIB_EXT "so" #define PLATFORM_MAX_PATH PATH_MAX -#define PLATFORM_SEP_STR "/" #define PLATFORM_SEP_CHAR '/' #define PLATFORM_SEP_ALTCHAR '\\' #define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default"))) From 9c1e45d97c03edfd01a0775351acc0c62decc661 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 21 Nov 2008 14:09:50 -0600 Subject: [PATCH 12/15] Fixed crash when L4D server went into hibernation mode after having had an active bot and a reserved name was used by this bot - When going into hibernation, ClientSettingsChanged is called for remaining bots - Hook checks bot's name against reserved names in admins config and tries to kick using IClient::Disconnect - Method of getting IClient relies on client having an INetChannel pointer - Bots do not have an INetChannel pointer so this results in a crash --- core/PlayerManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index f5076495..720cadb7 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -699,6 +699,11 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) m_clinfochanged->PushCell(client); m_clinfochanged->Execute(&res, NULL); + if (pPlayer->IsFakeClient()) + { + return; + } + IPlayerInfo *info = pPlayer->GetPlayerInfo(); const char *new_name = info ? info->GetName() : engine->GetClientConVarValue(client, "name"); const char *old_name = pPlayer->m_Name.c_str(); From 7a38e5584ce0aa06808cd83c789911af525b092e Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 24 Nov 2008 08:37:06 -0600 Subject: [PATCH 13/15] OriginalFilename field in core/version.rc now has correct filename based on engine. --- core/msvc9/sourcemod_mm.vcproj | 12 ++++++++++++ core/version.rc | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj index ca859094..a386ab81 100644 --- a/core/msvc9/sourcemod_mm.vcproj +++ b/core/msvc9/sourcemod_mm.vcproj @@ -58,6 +58,7 @@ /> Date: Mon, 24 Nov 2008 09:33:11 -0600 Subject: [PATCH 14/15] Moved SE_* constants from PrePreprocessorDefinitions to AdditionalOptions in MSVC project files. -Doing this should make it a bit easier to maintain in the future. Also added back /MP to core and sdktools. --- core/msvc9/sourcemod_mm.vcproj | 36 +++++++++++++++-------- extensions/sdktools/msvc9/sdktools.vcproj | 24 ++++++++++----- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj index a386ab81..818ec2fc 100644 --- a/core/msvc9/sourcemod_mm.vcproj +++ b/core/msvc9/sourcemod_mm.vcproj @@ -40,9 +40,10 @@ /> Date: Tue, 25 Nov 2008 19:13:08 +1300 Subject: [PATCH 15/15] SourceMod now handles steamid's internally without the STEAM_*: part (bug 3428) --- core/AdminCache.cpp | 12 ++++++++++++ core/PlayerManager.cpp | 2 +- plugins/admin-flatfile/admin-simple.sp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/AdminCache.cpp b/core/AdminCache.cpp index a03c1899..2dfd5fc3 100644 --- a/core/AdminCache.cpp +++ b/core/AdminCache.cpp @@ -1182,6 +1182,12 @@ bool AdminCache::BindAdminIdentity(AdminId id, const char *auth, const char *ide return false; } + /* If the id was a steam id strip off the STEAM_*: part */ + if (strcmp(auth, "steam") == 0 && strncmp(ident, "STEAM_", 6) == 0) + { + ident += 8; + } + if (sm_trie_retrieve(pTable, ident, NULL)) { return false; @@ -1204,6 +1210,12 @@ AdminId AdminCache::FindAdminByIdentity(const char *auth, const char *identity) return INVALID_ADMIN_ID; } + /* If the id was a steam id strip off the STEAM_*: part */ + if (strcmp(auth, "steam") == 0 && strncmp(identity, "STEAM_", 6) == 0) + { + identity += 8; + } + void *object; if (!sm_trie_retrieve(pTable, identity, &object)) { diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index f5076495..284bfab0 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -1615,7 +1615,7 @@ void CPlayer::DoBasicAdminChecks() } } - /* Check IP address */ + /* Check steam id */ if ((id = g_Admins.FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID) { if (g_Players.CheckSetAdmin(client, this, id)) diff --git a/plugins/admin-flatfile/admin-simple.sp b/plugins/admin-flatfile/admin-simple.sp index c615ac8e..fbf89803 100644 --- a/plugins/admin-flatfile/admin-simple.sp +++ b/plugins/admin-flatfile/admin-simple.sp @@ -96,7 +96,7 @@ public ReadSimpleUsers() DecodeAuthMethod(const String:auth[], String:method[32], &offset) { - if (StrContains(auth, "STEAM_") == 0) + if ((StrContains(auth, "STEAM_") == 0) || (strncmp("0:", auth, 2) == 0) || (strncmp("1:", auth, 2) == 0)) { strcopy(method, sizeof(method), AUTHMETHOD_STEAM); offset = 0;