mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-12-02 14:24:16 +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.defines += [ 'MMS_USE_VERSIONLIB' ]
|
||||||
cxx.includes += [
|
cxx.includes += [
|
||||||
os.path.join(builder.sourcePath, 'public'),
|
os.path.join(builder.sourcePath, 'public'),
|
||||||
|
os.path.join(builder.sourcePath, 'third_party', 'amtl'),
|
||||||
]
|
]
|
||||||
if self.use_auto_versioning():
|
if self.use_auto_versioning():
|
||||||
cxx.defines += ['MMS_GENERATED_BUILD']
|
cxx.defines += ['MMS_GENERATED_BUILD']
|
||||||
|
@ -40,13 +40,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define X64_SUFFIX ".x64"
|
#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 SourceMM;
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <amtl/am-string.h>
|
||||||
#include "metamod_oslink.h"
|
#include "metamod_oslink.h"
|
||||||
#include "metamod.h"
|
#include "metamod.h"
|
||||||
#include "metamod_plugins.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)
|
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;
|
CPlugin *pl;
|
||||||
|
|
||||||
pl = new CPlugin();
|
pl = new CPlugin();
|
||||||
@ -426,21 +430,29 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
|
|||||||
m_Plugins.push_back(pl);
|
m_Plugins.push_back(pl);
|
||||||
m_LastId++;
|
m_LastId++;
|
||||||
|
|
||||||
//Check if the file even exists
|
if (ke::EndsWith(file, BINARY_EXT))
|
||||||
fp = fopen(file, "r");
|
{
|
||||||
if (!fp)
|
//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)
|
if (error)
|
||||||
{
|
UTIL_Format(error, maxlen, "File type not supported");
|
||||||
UTIL_Format(error, maxlen, "File not found: %s", file);
|
|
||||||
}
|
|
||||||
pl->m_Status = Pl_NotFound;
|
pl->m_Status = Pl_NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fp.reset();
|
||||||
fp = NULL;
|
|
||||||
|
|
||||||
//Load the file
|
//Load the file
|
||||||
pl->m_Lib = dlmount(file);
|
pl->m_Lib = dlmount(file);
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#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
|
* @brief Utility functions
|
||||||
* @file util.h
|
* @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