failsafe autoloading of libraries for 1.71- plugins

This commit is contained in:
David Anderson 2006-05-11 10:19:09 +00:00
parent 79f86bfabd
commit 6995b182c1
3 changed files with 24 additions and 2 deletions

View File

@ -522,6 +522,20 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
int num;
char name[sNAMEMAX+1];
num = amx_GetLibraries(&amx);
for (int i=0; i<num; i++)
{
amx_GetLibrary(&amx, i, name, sNAMEMAX);
if (stricmp(name, "Float")==0)
continue;
//awful backwards compat hack
if (stricmp(name, "socket")==0)
strcpy(name, "sockets");
//we don't want to report failed modules here...
LoadModule(name, PT_ANYTIME, true, true);
}
cell tag_id;
amx_NumTags(&amx, &num);

View File

@ -868,7 +868,7 @@ bool ConvertModuleName(const char *pathString, String &path)
return true;
}
bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify)
bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool noFileBail)
{
char pathString[512];
String path;
@ -888,6 +888,14 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify)
path.assign(pathString);
}
if (noFileBail)
{
FILE *fp = fopen(path.c_str(), "rb");
if (!fp)
return false;
fclose(fp);
}
CList<CModule, const char *>::iterator a = g_modules.find(path.c_str());
if (a)

View File

@ -72,7 +72,7 @@ typedef enum
} PlayerProp;
int CheckModules(AMX *amx, char error[128]);
bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify=true);
bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify=true, bool noFileBail=false);
const char *StrCaseStr(const char *as, const char *bs);
class Debugger;