added autoloading of extensions
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40403
This commit is contained in:
parent
b3b1978d10
commit
aea1073d13
@ -216,6 +216,9 @@ void SourceModBase::DoGlobalPluginLoads()
|
|||||||
sizeof(plugins_path),
|
sizeof(plugins_path),
|
||||||
"plugins");
|
"plugins");
|
||||||
|
|
||||||
|
/* Load any auto extensions */
|
||||||
|
g_Extensions.TryAutoload();
|
||||||
|
|
||||||
/* Run the first pass */
|
/* Run the first pass */
|
||||||
g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
|
g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "ExtensionSys.h"
|
#include "ExtensionSys.h"
|
||||||
#include "LibrarySys.h"
|
#include "LibrarySys.h"
|
||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
@ -18,7 +19,7 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
#include "sm_srvcmds.h"
|
#include "sm_srvcmds.h"
|
||||||
#include <stdlib.h>
|
#include "sm_stringutil.h"
|
||||||
|
|
||||||
CExtensionManager g_Extensions;
|
CExtensionManager g_Extensions;
|
||||||
IdentityType_t g_ExtType;
|
IdentityType_t g_ExtType;
|
||||||
@ -267,6 +268,52 @@ void CExtensionManager::OnSourceModShutdown()
|
|||||||
g_ShareSys.DestroyIdentType(g_ExtType);
|
g_ShareSys.DestroyIdentType(g_ExtType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CExtensionManager::TryAutoload()
|
||||||
|
{
|
||||||
|
char path[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
|
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "extensions");
|
||||||
|
|
||||||
|
IDirectory *pDir = g_LibSys.OpenDirectory(path);
|
||||||
|
if (!pDir)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *lfile;
|
||||||
|
size_t len;
|
||||||
|
while (pDir->MoreFiles())
|
||||||
|
{
|
||||||
|
if (pDir->IsEntryDirectory())
|
||||||
|
{
|
||||||
|
pDir->NextEntry();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lfile = pDir->GetEntryName();
|
||||||
|
len = strlen(lfile);
|
||||||
|
if (len <= 9) /* size of ".autoload" */
|
||||||
|
{
|
||||||
|
pDir->NextEntry();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(&lfile[len - 9], ".autoload") != 0)
|
||||||
|
{
|
||||||
|
pDir->NextEntry();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char file[PLATFORM_MAX_PATH];
|
||||||
|
len = UTIL_Format(file, sizeof(file), "%s", lfile);
|
||||||
|
strcpy(&file[len - 9], ".ext." PLATFORM_LIB_EXT);
|
||||||
|
|
||||||
|
LoadAutoExtension(file);
|
||||||
|
|
||||||
|
pDir->NextEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
|
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
|
||||||
{
|
{
|
||||||
if (!strstr(path, "." PLATFORM_LIB_EXT))
|
if (!strstr(path, "." PLATFORM_LIB_EXT))
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
void BindAllNativesToPlugin(IPlugin *pPlugin);
|
void BindAllNativesToPlugin(IPlugin *pPlugin);
|
||||||
void MarkAllLoaded();
|
void MarkAllLoaded();
|
||||||
void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
|
void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
|
||||||
|
void TryAutoload();
|
||||||
private:
|
private:
|
||||||
CExtension *FindByOrder(unsigned int num);
|
CExtension *FindByOrder(unsigned int num);
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user