From 0abdcb58cf0ccca6d6d057fb52dccf34e63e7cd2 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 26 Aug 2009 11:26:12 +1200 Subject: [PATCH] Removed auto folders (bug 3949, r=pred) --- core/ExtensionSys.cpp | 110 ++++++++++++------ core/ExtensionSys.h | 4 + core/Makefile | 2 +- core/msvc9/sourcemod_mm.vcproj | 6 +- extensions/bintools/Makefile | 8 +- extensions/bintools/msvc9/bintools.vcproj | 36 ++++-- extensions/bintools/version.rc | 2 +- .../clientprefs/msvc9/clientprefs.vcproj | 2 + extensions/clientprefs/version.rc | 2 +- extensions/cstrike/Makefile | 8 +- 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 | 8 +- extensions/sdktools/msvc9/sdktools.vcproj | 36 ++++-- extensions/sdktools/version.rc | 2 +- extensions/sqlite/msvc9/sm_sqlite.vcproj | 2 + extensions/sqlite/version.rc | 2 +- extensions/structs/msvc9/structs.vcproj | 6 + 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 +- tools/builder/PkgCore.cs | 54 ++++----- 35 files changed, 244 insertions(+), 124 deletions(-) diff --git a/core/ExtensionSys.cpp b/core/ExtensionSys.cpp index 26cd56fc..6a9b7282 100644 --- a/core/ExtensionSys.cpp +++ b/core/ExtensionSys.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -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(file)) { 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) { @@ -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 234f2b88..d9583b0b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -79,7 +79,7 @@ ifeq "$(ENGINE)" "orangeboxvalve" METAMOD = $(MMSOURCE17)/core INCLUDE += -I$(HL2SDK)/public/game/server 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 69f55556..cd469886 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) 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) diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 82e41b50..8d47079b 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -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 @@ />