mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-11-30 12:24:20 +01:00
Only load plugins that have executable extensions.
Bug: issue #102 Test: meta load crab.yam with hl2sdk-mock
This commit is contained in:
parent
0e35864432
commit
86b5917309
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "third_party/amtl"]
|
||||
path = third_party/amtl
|
||||
url = https://github.com/alliedmodders/amtl
|
@ -334,6 +334,7 @@ class MMSConfig(object):
|
||||
cxx.defines += [ 'MMS_USE_VERSIONLIB' ]
|
||||
cxx.includes += [
|
||||
os.path.join(builder.sourcePath, 'public'),
|
||||
os.path.join(builder.sourcePath, 'third_party', 'amtl'),
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
cxx.defines += ['MMS_GENERATED_BUILD']
|
||||
|
@ -40,13 +40,6 @@
|
||||
#endif
|
||||
|
||||
#define X64_SUFFIX ".x64"
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define BINARY_EXT ".dll"
|
||||
#elif defined(__linux__)
|
||||
#define BINARY_EXT ".so"
|
||||
#elif defined(__APPLE__)
|
||||
#define BINARY_EXT ".dylib"
|
||||
#endif
|
||||
|
||||
using namespace SourceMM;
|
||||
using namespace SourceHook;
|
||||
|
@ -24,6 +24,10 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <amtl/am-string.h>
|
||||
#include "metamod_oslink.h"
|
||||
#include "metamod.h"
|
||||
#include "metamod_plugins.h"
|
||||
@ -414,7 +418,7 @@ struct Unloader : public SourceHook::Impl::UnloadListener
|
||||
|
||||
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
|
||||
{
|
||||
FILE *fp;
|
||||
std::unique_ptr<FILE, decltype(&::fclose)> fp(nullptr, ::fclose);
|
||||
CPlugin *pl;
|
||||
|
||||
pl = new CPlugin();
|
||||
@ -426,21 +430,29 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
|
||||
m_Plugins.push_back(pl);
|
||||
m_LastId++;
|
||||
|
||||
//Check if the file even exists
|
||||
fp = fopen(file, "r");
|
||||
if (!fp)
|
||||
if (ke::EndsWith(file, BINARY_EXT))
|
||||
{
|
||||
//Check if the file even exists
|
||||
fp.reset(fopen(file, "r"));
|
||||
if (!fp)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
UTIL_Format(error, maxlen, "File not found: %s", file);
|
||||
}
|
||||
pl->m_Status = Pl_NotFound;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
UTIL_Format(error, maxlen, "File not found: %s", file);
|
||||
}
|
||||
UTIL_Format(error, maxlen, "File type not supported");
|
||||
pl->m_Status = Pl_NotFound;
|
||||
}
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
fp.reset();
|
||||
|
||||
//Load the file
|
||||
pl->m_Lib = dlmount(file);
|
||||
|
@ -30,6 +30,14 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define BINARY_EXT ".dll"
|
||||
#elif defined(__linux__)
|
||||
#define BINARY_EXT ".so"
|
||||
#elif defined(__APPLE__)
|
||||
#define BINARY_EXT ".dylib"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Utility functions
|
||||
* @file util.h
|
||||
|
1
third_party/amtl
vendored
Submodule
1
third_party/amtl
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ad9d5c33534dcfd902e2aeb0744df1a227b1c6d3
|
Loading…
Reference in New Issue
Block a user