mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-17 10:54:14 +01:00
Allow loading of plugins without "_i486" in the filename when ".so" extension is ommitted on Linux (bug 4410, r=dvander).
This commit is contained in:
parent
92132dd895
commit
a8f53b8e14
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||
* Copyright (C) 2004-2010 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -16,6 +16,9 @@
|
||||
#include "util.h"
|
||||
#include "sh_memory.h"
|
||||
#include <setjmp.h>
|
||||
#if defined __linux__
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Implementation of main API interface
|
||||
@ -607,3 +610,44 @@ int CSmmAPI::GetSourceEngineBuild()
|
||||
{
|
||||
return g_Engine.original ? SOURCE_ENGINE_ORIGINAL : SOURCE_ENGINE_EPISODEONE;
|
||||
}
|
||||
|
||||
void CSmmAPI::GetFullPluginPath(const char *plugin, char *buffer, size_t len)
|
||||
{
|
||||
const char *pext, *ext;
|
||||
|
||||
/* First find if it's an absolute path or not... */
|
||||
if (plugin[0] == '/' || strncmp(&(plugin[1]), ":\\", 2) == 0)
|
||||
{
|
||||
UTIL_Format(buffer, len, plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Attempt to find a file extension */
|
||||
pext = UTIL_GetExtension(plugin);
|
||||
/* Add an extension if there's none there */
|
||||
if (!pext)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ".dll";
|
||||
#else
|
||||
ext = "_i486.so";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ext = "";
|
||||
}
|
||||
|
||||
/* Format the new path */
|
||||
PathFormat(buffer, len, "%s/%s%s", g_ModPath.c_str(), plugin, ext);
|
||||
|
||||
#if defined __linux__
|
||||
/* If path was passed without extension and it doesn't exist with "_i486.so" try ".so" */
|
||||
struct stat s;
|
||||
if (!pext && stat(buffer, &s) != 0)
|
||||
{
|
||||
PathFormat(buffer, len, "%s/%s.so", g_ModPath.c_str(), plugin);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||
* Copyright (C) 2004-2010 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -71,6 +71,7 @@ namespace SourceMM
|
||||
return m_VSP;
|
||||
}
|
||||
void CacheUserMessages();
|
||||
void GetFullPluginPath(const char *plugin, char *buffer, size_t len);
|
||||
private:
|
||||
META_RES m_Res;
|
||||
CONPRINTF_FUNC m_ConPrintf;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||
* Copyright (C) 2004-2010 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -424,18 +424,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
file = alias;
|
||||
}
|
||||
|
||||
if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
|
||||
{
|
||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s", file);
|
||||
} else {
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
|
||||
}
|
||||
g_SmmAPI.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
char error[255]={0};
|
||||
bool already;
|
||||
@ -526,19 +515,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
file = alias;
|
||||
}
|
||||
|
||||
/* first check if it's a known filename */
|
||||
if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
|
||||
{
|
||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s", file);
|
||||
} else {
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
|
||||
}
|
||||
g_SmmAPI.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator iter, end;
|
||||
SourceMM::CPluginManager::CPlugin *pl;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||
* Copyright (C) 2004-2010 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -36,7 +36,6 @@
|
||||
#define PATH_SEP_CHAR '\\'
|
||||
#define ALT_SEP_CHAR '/'
|
||||
#define PATH_SIZE MAX_PATH
|
||||
#define SERVER_DLL "server.dll"
|
||||
#elif defined __linux__
|
||||
#define OS_LINUX
|
||||
#include <dlfcn.h>
|
||||
@ -52,7 +51,6 @@
|
||||
#define PATH_SIZE PATH_MAX
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#define SERVER_DLL "server_i486.so"
|
||||
#endif
|
||||
|
||||
#if defined __linux__
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||
* Copyright (C) 2004-2010 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -336,29 +336,7 @@ bool LoadFromVDF(const char *file, bool &skipped)
|
||||
g_PluginMngr.SetAlias(alias, plugin_file);
|
||||
}
|
||||
|
||||
/* Attempt to find a file extension */
|
||||
if (UTIL_GetExtension(plugin_file) == NULL)
|
||||
{
|
||||
g_SmmAPI.PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s%s",
|
||||
g_ModPath.c_str(),
|
||||
plugin_file,
|
||||
#if defined WIN32 || defined _WIN32
|
||||
".dll"
|
||||
#else
|
||||
"_i486.so"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_SmmAPI.PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s",
|
||||
g_ModPath.c_str(),
|
||||
plugin_file);
|
||||
}
|
||||
g_SmmAPI.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
skipped = already;
|
||||
@ -559,61 +537,21 @@ int LoadPluginsFromFile(const char *filepath, int &skipped)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* First find if it's an absolute path or not... */
|
||||
if (file[0] == '/' || strncmp(&(file[1]), ":\\", 2) == 0)
|
||||
g_SmmAPI.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
/* If we're in an absolute path, ignore our normal heuristics */
|
||||
id = g_PluginMngr.Load(file, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (already)
|
||||
{
|
||||
skipped++;
|
||||
}
|
||||
else
|
||||
{
|
||||
total++;
|
||||
}
|
||||
}
|
||||
LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Attempt to find a file extension */
|
||||
ptr = UTIL_GetExtension(file);
|
||||
/* Add an extension if there's none there */
|
||||
if (!ptr)
|
||||
if (already)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ".dll";
|
||||
#else
|
||||
ext = "_i486.so";
|
||||
#endif
|
||||
skipped++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext = "";
|
||||
}
|
||||
/* Format the new path */
|
||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (already)
|
||||
{
|
||||
skipped++;
|
||||
}
|
||||
else
|
||||
{
|
||||
total++;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
129
core/metamod.cpp
129
core/metamod.cpp
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* ======================================================
|
||||
* Metamod:Source
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||
* Copyright (C) 2004-2010 AlliedModders LLC and authors.
|
||||
* All rights reserved.
|
||||
* ======================================================
|
||||
*
|
||||
@ -33,6 +33,9 @@
|
||||
#include "metamod_util.h"
|
||||
#include "metamod_console.h"
|
||||
#include "provider/provider_ep2.h"
|
||||
#if defined __linux__
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace SourceMM;
|
||||
using namespace SourceHook;
|
||||
@ -288,56 +291,20 @@ LoadPluginsFromFile(const char *filepath, int &skipped)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* First find if it's an absolute path or not... */
|
||||
if (file[0] == '/' || strncmp(&(file[1]), ":\\", 2) == 0)
|
||||
|
||||
g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
/* If we're in an absolute path, ignore our normal heuristics */
|
||||
id = g_PluginMngr.Load(file, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
mm_LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (already)
|
||||
skipped++;
|
||||
else
|
||||
total++;
|
||||
}
|
||||
mm_LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Attempt to find a file extension */
|
||||
ptr = UTIL_GetExtension(file);
|
||||
/* Add an extension if there's none there */
|
||||
if (!ptr)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ".dylib";
|
||||
#else
|
||||
ext = "_i486.so";
|
||||
#endif
|
||||
}
|
||||
if (already)
|
||||
skipped++;
|
||||
else
|
||||
{
|
||||
ext = "";
|
||||
}
|
||||
/* Format the new path */
|
||||
g_Metamod.PathFormat(full_path, sizeof(full_path), "%s/%s%s", mod_path.c_str(), file, ext);
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
|
||||
{
|
||||
mm_LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (already)
|
||||
skipped++;
|
||||
else
|
||||
total++;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
@ -1099,6 +1066,50 @@ void MetamodSource::SetVSPListener(const char *path)
|
||||
metamod_path.assign(path);
|
||||
}
|
||||
|
||||
size_t MetamodSource::GetFullPluginPath(const char *plugin, char *buffer, size_t len)
|
||||
{
|
||||
const char *pext, *ext;
|
||||
size_t num;
|
||||
|
||||
/* First find if it's an absolute path or not... */
|
||||
if (plugin[0] == '/' || strncmp(&(plugin[1]), ":\\", 2) == 0)
|
||||
{
|
||||
return UTIL_Format(buffer, len, plugin);
|
||||
}
|
||||
|
||||
/* Attempt to find a file extension */
|
||||
pext = UTIL_GetExtension(plugin);
|
||||
/* Add an extension if there's none there */
|
||||
if (!pext)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ".dylib";
|
||||
#else
|
||||
ext = "_i486.so";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ext = "";
|
||||
}
|
||||
|
||||
/* Format the new path */
|
||||
num = PathFormat(buffer, len, "%s/%s%s", mod_path.c_str(), plugin, ext);
|
||||
|
||||
#if defined __linux__
|
||||
/* If path was passed without extension and it doesn't exist with "_i486.so" try ".so" */
|
||||
struct stat s;
|
||||
if (!pext && stat(buffer, &s) != 0)
|
||||
{
|
||||
num = PathFormat(buffer, len, "%s/%s.so", mod_path.c_str(), plugin);
|
||||
}
|
||||
#endif
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
static bool
|
||||
ProcessVDF(const char *path, bool &skipped)
|
||||
{
|
||||
@ -1115,31 +1126,7 @@ ProcessVDF(const char *path, bool &skipped)
|
||||
if (alias[0] != '\0')
|
||||
g_PluginMngr.SetAlias(alias, file);
|
||||
|
||||
/* Attempt to find a file extension */
|
||||
if (UTIL_GetExtension(file) == NULL)
|
||||
{
|
||||
g_pMetamod->PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s%s",
|
||||
g_pMetamod->GetBaseDir(),
|
||||
file,
|
||||
#if defined WIN32 || defined _WIN32
|
||||
".dll"
|
||||
#elif defined __APPLE__
|
||||
".dylib"
|
||||
#else
|
||||
"_i486.so"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pMetamod->PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s",
|
||||
g_pMetamod->GetBaseDir(),
|
||||
file);
|
||||
}
|
||||
g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error));
|
||||
skipped = already;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* ======================================================
|
||||
* Metamod:Source
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||
* Copyright (C) 2004-2010 AlliedModders LLC and authors.
|
||||
* All rights reserved.
|
||||
* ======================================================
|
||||
*
|
||||
@ -99,6 +99,7 @@ public:
|
||||
void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version);
|
||||
void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded);
|
||||
void SetVSPListener(const char *path);
|
||||
size_t GetFullPluginPath(const char *plugin, char *buffer, size_t len);
|
||||
};
|
||||
|
||||
bool
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* ======================================================
|
||||
* Metamod:Source
|
||||
* Copyright (C) 2004-2009 AlliedModders LLC and authors.
|
||||
* Copyright (C) 2004-2010 AlliedModders LLC and authors.
|
||||
* All rights reserved.
|
||||
* ======================================================
|
||||
*
|
||||
@ -416,27 +416,7 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
|
||||
file = alias;
|
||||
}
|
||||
|
||||
if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
|
||||
{
|
||||
g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ext ? "" : ".dylib";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
g_Metamod.PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s%s",
|
||||
g_Metamod.GetBaseDir(),
|
||||
file,
|
||||
ext);
|
||||
}
|
||||
g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
char error[255]={0};
|
||||
bool already;
|
||||
@ -539,28 +519,7 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
|
||||
file = alias;
|
||||
}
|
||||
|
||||
/* first check if it's a known filename */
|
||||
if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
|
||||
{
|
||||
g_Metamod.PathFormat(full_path, sizeof(full_path), "%s", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext = ext ? "" : ".dll";
|
||||
#elif defined __APPLE__
|
||||
ext = ext ? "" : ".dylib";
|
||||
#else
|
||||
ext = ext ? "" : "_i486.so";
|
||||
#endif
|
||||
g_Metamod.PathFormat(full_path,
|
||||
sizeof(full_path),
|
||||
"%s/%s%s",
|
||||
g_Metamod.GetBaseDir(),
|
||||
file,
|
||||
ext);
|
||||
}
|
||||
g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path));
|
||||
|
||||
List<CPluginManager::CPlugin *>::iterator iter, end;
|
||||
CPluginManager::CPlugin *pl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user