diff --git a/sourcemm/ISmmAPI.h b/sourcemm/ISmmAPI.h index 8da205b..9566e2b 100644 --- a/sourcemm/ISmmAPI.h +++ b/sourcemm/ISmmAPI.h @@ -231,8 +231,11 @@ namespace SourceMM * @param len Maximum length of buffer, including null * terminator. * @param fmt Formatted string. + * @param ... Arguments in the string. + * @return Number of bytes written, not including the null + * terminator. */ - virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0; + virtual size_t PathFormat(char *buffer, size_t len, const char *fmt, ...) =0; /** * @brief Prints text in the specified client's console. Same as diff --git a/sourcemm/episode2/msvc8/sourcemm.vcproj b/sourcemm/episode2/msvc8/sourcemm.vcproj index c4ceb5a..a447f7c 100644 --- a/sourcemm/episode2/msvc8/sourcemm.vcproj +++ b/sourcemm/episode2/msvc8/sourcemm.vcproj @@ -41,7 +41,7 @@ @@ -71,6 +72,7 @@ #define stricmp strcasecmp #define strnicmp strncasecmp #define SERVER_DLL "server_i486.so" + inline bool _IsPathSepChar(char c) { return (c == '/'); } #endif #if defined __linux__ diff --git a/sourcemm/metamod_plugins.cpp b/sourcemm/metamod_plugins.cpp index 53a3227..1814956 100644 --- a/sourcemm/metamod_plugins.cpp +++ b/sourcemm/metamod_plugins.cpp @@ -439,7 +439,24 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source GlobVersionInfo.source_engine = g_Metamod.GetSourceEngineBuild(); } - pl->m_API = fnLoad(&GlobVersionInfo, NULL); + /* Build path information */ + char file_path[256]; + size_t len = g_Metamod.PathFormat(file_path, sizeof(file_path), "%s", file); + + for (size_t i = len - 1; i >= 0 && i < len; i--) + { + if (_IsPathSepChar(file_path[i])) + { + file_path[i] = '\0'; + break; + } + } + + MetamodLoaderInfo info; + info.pl_file = file; + info.pl_path = file_path; + + pl->m_API = fnLoad(&GlobVersionInfo, &info); pl->m_UnloadFn = (METAMOD_FN_UNLOAD)dlsym(pl->m_Lib, "UnloadInterface_MMS"); }