From 83393f299a844f855bf6ac71404f3eb7d2102a8e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 30 Aug 2009 00:03:58 -0700 Subject: [PATCH] Removed auto folders (bug 3949). --- core/ExtensionSys.cpp | 118 ++++++++++++------ core/ExtensionSys.h | 4 + core/Makefile | 2 +- core/msvc9/sourcemod_mm.vcproj | 6 +- extensions/bintools/Makefile | 10 +- extensions/bintools/msvc9/bintools.vcproj | 36 ++++-- extensions/bintools/version.rc | 2 +- .../clientprefs/msvc9/clientprefs.vcproj | 2 + extensions/clientprefs/version.rc | 2 +- extensions/cstrike/Makefile | 10 +- extensions/cstrike/msvc9/cstrike.vcproj | 18 ++- extensions/cstrike/version.rc | 2 +- extensions/curl/msvc9/curl.vcproj | 10 ++ extensions/curl/version.rc | 2 +- extensions/geoip/msvc9/geoip.vcproj | 2 + extensions/geoip/version.rc | 2 +- extensions/mysql/msvc9/sm_mysql.vcproj | 2 + extensions/mysql/version.rc | 2 +- extensions/regex/msvc9/regex.vcproj | 2 + extensions/regex/version.rc | 2 +- extensions/sdktools/Makefile | 10 +- extensions/sdktools/msvc9/sdktools.vcproj | 61 +++++---- extensions/sdktools/version.rc | 2 +- extensions/sqlite/msvc9/sm_sqlite.vcproj | 2 + extensions/sqlite/version.rc | 2 +- extensions/tf2/Makefile | 8 +- extensions/tf2/msvc9/tf2.vcproj | 6 +- extensions/tf2/version.rc | 2 +- extensions/topmenus/msvc9/topmenus.vcproj | 2 + extensions/topmenus/version.rc | 2 +- extensions/updater/msvc9/updater.vcproj | 10 ++ extensions/updater/version.rc | 2 +- loader/loader.cpp | 2 +- public/mms_sample_ext/Makefile | 15 ++- public/sample_ext/Makefile | 15 ++- 35 files changed, 256 insertions(+), 121 deletions(-) diff --git a/core/ExtensionSys.cpp b/core/ExtensionSys.cpp index 9bb5a9a5..3868b463 100644 --- a/core/ExtensionSys.cpp +++ b/core/ExtensionSys.cpp @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -49,6 +49,9 @@ void CExtension::Initialize(const char *filename, const char *path) m_bFullyLoaded = false; m_File.assign(filename); m_Path.assign(path); + char real_name[PLATFORM_MAX_PATH]; + g_LibSys.GetFileFromPath(real_name, sizeof(real_name), m_Path.c_str()); + m_RealFile.assign(real_name); } CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filename, const char *path) @@ -57,6 +60,22 @@ CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filena m_pAPI = pAPI; } +#if defined METAMOD_PLAPI_VERSION +#if SOURCE_ENGINE == SE_LEFT4DEAD +#define GAMEFIX "2.l4d" +#elif SOURCE_ENGINE == SE_ORANGEBOX +#define GAMEFIX "2.ep2" +#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE +#define GAMEFIX "2.ep2v" +#elif SOURCE_ENGINE == SE_DARKMESSIAH +#define GAMEFIX "2.darkm" +#else +#define GAMEFIX "2.ep1" +#endif //SOURCE_ENGINE == SE_LEFT4DEAD +#else //METAMOD_PLAPI_VERSION +#define GAMEFIX "1.ep1" +#endif //METAMOD_PLAPI_VERSION + CLocalExtension::CLocalExtension(const char *filename) { m_PlId = 0; @@ -64,33 +83,36 @@ CLocalExtension::CLocalExtension(const char *filename) char path[PLATFORM_MAX_PATH]; + /* Zeroth, see if there is an engine specific build in the new place. */ + g_SourceMod.BuildPath(Path_SM, + path, + PLATFORM_MAX_PATH, + "extensions/%s." GAMEFIX "." PLATFORM_LIB_EXT, + filename); + + if (g_LibSys.IsPathFile(path)) + { + goto found; + } + /* First see if there is an engine specific build! */ g_SourceMod.BuildPath(Path_SM, path, - PLATFORM_MAX_PATH, -#if defined METAMOD_PLAPI_VERSION -#if SOURCE_ENGINE == SE_LEFT4DEAD - "extensions/auto.2.l4d/%s", -#elif SOURCE_ENGINE == SE_ORANGEBOX - "extensions/auto.2.ep2/%s", -#elif SOURCE_ENGINE == SE_ORANGEBOXVALVE - "extensions/auto.2.ep2valve/%s", -#elif SOURCE_ENGINE == SE_DARKMESSIAH - "extensions/auto.2.darkm/%s", -#else - "extensions/auto.2.ep1/%s", -#endif //SOURCE_ENGINE == SE_LEFT4DEAD -#else //METAMOD_PLAPI_VERSION - "extensions/auto.1.ep1/%s", -#endif //METAMOD_PLAPI_VERSION + PLATFORM_MAX_PATH, + "extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT, filename); /* Try the "normal" version */ if (!g_LibSys.IsPathFile(path)) { - g_SourceMod.BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "extensions/%s", filename); + g_SourceMod.BuildPath(Path_SM, + path, + PLATFORM_MAX_PATH, + "extensions/%s." PLATFORM_LIB_EXT, + filename); } +found: Initialize(filename, path); } @@ -310,7 +332,7 @@ IExtensionInterface *CExtension::GetAPI() const char *CExtension::GetFilename() { - return m_File.c_str(); + return m_RealFile.c_str(); } IdentityToken_t *CExtension::GetIdentity() @@ -513,7 +535,7 @@ void CExtensionManager::TryAutoload() char file[PLATFORM_MAX_PATH]; len = UTIL_Format(file, sizeof(file), "%s", lfile); - strcpy(&file[len - 9], ".ext." PLATFORM_LIB_EXT); + strcpy(&file[len - 9], ".ext"); LoadAutoExtension(file); @@ -523,11 +545,14 @@ void CExtensionManager::TryAutoload() IExtension *CExtensionManager::LoadAutoExtension(const char *path) { - if (!strstr(path, "." PLATFORM_LIB_EXT)) + /* Remove platform extension if it's there. Compat hack. */ + const char *ext = g_LibSys.GetFileExtension(path); + if (strcmp(ext, PLATFORM_LIB_EXT) == 0) { - char newpath[PLATFORM_MAX_PATH]; - g_LibSys.PathFormat(newpath, sizeof(newpath), "%s.%s", path, PLATFORM_LIB_EXT); - return LoadAutoExtension(newpath); + char path2[PLATFORM_MAX_PATH]; + UTIL_Format(path2, sizeof(path2), "%s", path); + path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; + return LoadAutoExtension(path2); } IExtension *pAlready; @@ -565,24 +590,12 @@ IExtension *CExtensionManager::FindExtensionByFile(const char *file) for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { pExt = (*iter); - char short_file[PLATFORM_MAX_PATH]; - g_LibSys.GetFileFromPath(short_file, sizeof(short_file), pExt->GetFilename()); - if (strcmp(lookup, short_file) == 0) + if (pExt->IsSameFile(lookup)) { return pExt; } } - /* If we got no results, test if there was a platform extension. - * If not, add one. - */ - if (!strstr(file, "." PLATFORM_LIB_EXT)) - { - char path[PLATFORM_MAX_PATH]; - UTIL_Format(path, sizeof(path), "%s.%s", file, PLATFORM_LIB_EXT); - return FindExtensionByFile(path); - } - return NULL; } @@ -620,6 +633,16 @@ IExtension *CExtensionManager::FindExtensionByName(const char *ext) IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength) { + /* Remove platform extension if it's there. Compat hack. */ + const char *ext = g_LibSys.GetFileExtension(file); + if (strcmp(ext, PLATFORM_LIB_EXT) == 0) + { + char path2[PLATFORM_MAX_PATH]; + UTIL_Format(path2, sizeof(path2), "%s", file); + path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; + return LoadExtension(path2, error, maxlength); + } + IExtension *pAlready; if ((pAlready=FindExtensionByFile(file)) != NULL) { @@ -963,7 +986,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand { if (argcount < 4) { - g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>"); + g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>"); return; } @@ -971,7 +994,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand unsigned int id = atoi(sId); if (id <= 0) { - g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>"); + g_RootMenu.ConsolePrint("[SM] Usage: sm info <#>"); return; } @@ -1196,7 +1219,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand } return; - } + } else { g_RootMenu.ConsolePrint("[SM] Extension %s is not loaded.", pExt->GetFilename()); @@ -1306,3 +1329,16 @@ void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, } } } + +bool CLocalExtension::IsSameFile(const char *file) +{ + /* Only care about the shortened name. */ + return strcmp(file, m_File.c_str()) == 0; +} + +bool CRemoteExtension::IsSameFile(const char *file) +{ + /* :TODO: this could be better, but no one uses this API anyway. */ + return strcmp(file, m_Path.c_str()) == 0; +} + diff --git a/core/ExtensionSys.h b/core/ExtensionSys.h index 4a4fa188..a670273c 100644 --- a/core/ExtensionSys.h +++ b/core/ExtensionSys.h @@ -84,6 +84,7 @@ public: virtual bool IsLoaded() =0; virtual void Unload() =0; virtual bool Reload(char *error, size_t maxlength) =0; + virtual bool IsSameFile(const char* file) =0; protected: void Initialize(const char *filename, const char *path); bool PerformAPICheck(char *error, size_t maxlength); @@ -93,6 +94,7 @@ protected: IdentityToken_t *m_pIdentToken; IExtensionInterface *m_pAPI; String m_File; + String m_RealFile; String m_Path; String m_Error; List m_Deps; /** Dependencies */ @@ -113,6 +115,7 @@ public: void Unload(); bool Reload(char *error, size_t maxlength); bool IsExternal(); + bool IsSameFile(const char *file); private: PluginId m_PlId; ILibrary *m_pLib; @@ -128,6 +131,7 @@ public: void Unload(); bool Reload(char *error, size_t maxlength); bool IsExternal(); + bool IsSameFile(const char *file); }; class CExtensionManager : diff --git a/core/Makefile b/core/Makefile index 4799c5e9..d2838883 100644 --- a/core/Makefile +++ b/core/Makefile @@ -78,7 +78,7 @@ ifeq "$(ENGINE)" "orangeboxvalve" METAMOD = $(MMSOURCE17)/core INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common SRCDS = $(SRCDS_BASE)/orangebox - BINARY = sourcemod.2.ep2valve.so + BINARY = sourcemod.2.ep2v.so override ENGSET = true endif ifeq "$(ENGINE)" "left4dead" diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj index 71bbd4c3..e3c5d2dd 100644 --- a/core/msvc9/sourcemod_mm.vcproj +++ b/core/msvc9/sourcemod_mm.vcproj @@ -1302,7 +1302,7 @@ &1 | cut -b1) diff --git a/extensions/bintools/msvc9/bintools.vcproj b/extensions/bintools/msvc9/bintools.vcproj index 477155bb..1839c103 100644 --- a/extensions/bintools/msvc9/bintools.vcproj +++ b/extensions/bintools/msvc9/bintools.vcproj @@ -59,6 +59,7 @@ /> &1 | cut -b1) @@ -123,8 +127,6 @@ ifeq "$(GCC_VERSION)" "4" CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp diff --git a/extensions/cstrike/msvc9/cstrike.vcproj b/extensions/cstrike/msvc9/cstrike.vcproj index 1a6c04e8..c4971c86 100644 --- a/extensions/cstrike/msvc9/cstrike.vcproj +++ b/extensions/cstrike/msvc9/cstrike.vcproj @@ -58,6 +58,7 @@ /> &1 | cut -b1) @@ -126,8 +130,6 @@ ifeq "$(GCC_VERSION)" "4" CPPFLAGS += $(CPP_GCC4_FLAGS) endif -BINARY = $(PROJECT).ext.so - OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BIN_DIR)/%.o: %.cpp diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 71dba3cb..e2f4c2a0 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_ORANGEBOXVALVE=4 /D SE_LEFT4DEAD=5" 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";"$(HL2SDK)\game_shared";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -59,6 +59,7 @@ /> &1 | cut -b1) diff --git a/extensions/tf2/msvc9/tf2.vcproj b/extensions/tf2/msvc9/tf2.vcproj index d3b57b9f..2471153c 100644 --- a/extensions/tf2/msvc9/tf2.vcproj +++ b/extensions/tf2/msvc9/tf2.vcproj @@ -58,6 +58,7 @@ />