added a little more flexibility to modules.ini

fixed bug where unloading was never called
This commit is contained in:
David Anderson 2006-05-07 10:05:04 +00:00
parent dad00a2eb6
commit 00e32aca97
3 changed files with 34 additions and 10 deletions

View File

@ -41,6 +41,7 @@
#include "natives.h" #include "natives.h"
#include "binlog.h" #include "binlog.h"
#include "optimizer.h" #include "optimizer.h"
#include "libraries.h"
plugin_info_t Plugin_info = plugin_info_t Plugin_info =
{ {
@ -488,6 +489,8 @@ void C_ServerDeactivate_Post()
{ {
if (!g_initialized) if (!g_initialized)
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
modules_callPluginsUnloading();
detachReloadModules(); detachReloadModules();
g_auth.clear(); g_auth.clear();
@ -1278,6 +1281,8 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
return (FALSE); return (FALSE);
} }
modules_callPluginsUnloading();
g_auth.clear(); g_auth.clear();
g_forwards.clear(); g_forwards.clear();
g_commands.clear(); g_commands.clear();

View File

@ -839,7 +839,7 @@ bool ConvertModuleName(const char *pathString, String &path)
return true; return true;
} }
bool LoadModule(const char *shortname, PLUG_LOADTIME now) bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify)
{ {
char pathString[512]; char pathString[512];
String path; String path;
@ -851,8 +851,17 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now)
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
shortname); shortname);
if (!ConvertModuleName(pathString, path)) if (simplify)
return false; {
if (!ConvertModuleName(pathString, path))
return false;
} else {
path.assign(pathString);
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()); CList<CModule, const char *>::iterator a = g_modules.find(path.c_str());
@ -937,27 +946,37 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
return 0; return 0;
} }
char moduleName[256];
String line; String line;
char moduleName[256];
char buffer[255];
int loaded = 0; int loaded = 0;
String path; String path;
while (!feof(fp)) while (!feof(fp))
{ {
if (!line._fread(fp) || line.size() < 1) fgets(buffer, sizeof(buffer)-1, fp);
if (buffer[0] == ';' || buffer[0] == '\n')
continue; continue;
bool simplify = true;
if (buffer[0] == '>')
{
simplify = false;
line.assign(&buffer[1]);
} else {
line.assign(buffer);
}
line.trim(); line.trim();
*moduleName = 0; *moduleName = 0;
if (sscanf(line.c_str(), "%s", moduleName) == EOF) if (sscanf(line.c_str(), "%s", moduleName) == EOF)
continue; continue;
if (moduleName[0] == ';') if (LoadModule(moduleName, now, simplify))
continue;
if (LoadModule(moduleName, now))
loaded++; loaded++;
} }

View File

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