Added the ability to mark plugins as "disabled." This blocks the plugin from loading in other files.
Fixed a bug where the PCALM cache was invalidated on file read, rather than plugin finalization.
This commit is contained in:
parent
e015df58c8
commit
5524d5dca1
|
@ -99,6 +99,8 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
|
|||
|
||||
String line;
|
||||
|
||||
List<String *>::iterator block_iter;
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
pluginName[0] = '\0';
|
||||
|
@ -122,13 +124,32 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
|
|||
sscanf(line.c_str(), "%s %s", pluginName, debug);
|
||||
|
||||
if (!isalnum(*pluginName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
||||
if (isalnum(*debug) && !strcmp(debug, "debug"))
|
||||
{
|
||||
debugFlag = 1;
|
||||
}
|
||||
|
||||
bool skip = false;
|
||||
for (block_iter = m_BlockList.begin();
|
||||
block_iter != m_BlockList.end();
|
||||
block_iter++)
|
||||
{
|
||||
if ((*block_iter)->compare(pluginName) == 0)
|
||||
{
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip || !strcmp(debug, "disabled"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
|
||||
|
||||
if (plugin->getStatusCode() == ps_bad_load)
|
||||
|
@ -142,8 +163,6 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
|
|||
|
||||
fclose(fp);
|
||||
|
||||
InvalidateCache();
|
||||
|
||||
return pCounter;
|
||||
}
|
||||
|
||||
|
@ -161,6 +180,14 @@ void CPluginMngr::clear()
|
|||
delete [] pNatives;
|
||||
pNatives = NULL;
|
||||
}
|
||||
|
||||
List<String *>::iterator iter = m_BlockList.begin();
|
||||
while (iter != m_BlockList.end())
|
||||
{
|
||||
delete (*iter);
|
||||
iter = m_BlockList.erase(iter);
|
||||
}
|
||||
m_BlockList.clear();
|
||||
}
|
||||
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
||||
|
@ -616,7 +643,9 @@ void CPluginMngr::CALMFromFile(const char *file)
|
|||
{
|
||||
fgets(line, sizeof(line)-1, fp);
|
||||
if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/** quick hack */
|
||||
char *ptr = line;
|
||||
|
@ -635,8 +664,28 @@ void CPluginMngr::CALMFromFile(const char *file)
|
|||
pluginName[0] = '\0';
|
||||
sscanf(rline.c_str(), "%s", pluginName);
|
||||
|
||||
/* HACK: see if there's a 'disabled' coming up
|
||||
* new block for scopying flexibility
|
||||
*/
|
||||
if (1)
|
||||
{
|
||||
const char *_ptr = rline.c_str() + strlen(pluginName);
|
||||
while (*_ptr != '\0' && isspace(*_ptr))
|
||||
{
|
||||
_ptr++;
|
||||
}
|
||||
if ((*_ptr != '\0') && !strcmp(_ptr, "disabled"))
|
||||
{
|
||||
String *pString = new String(pluginName);
|
||||
m_BlockList.push_back(pString);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isalnum(*pluginName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ public:
|
|||
void CALMFromFile(const char *file);
|
||||
private:
|
||||
List<plcache_entry *> m_plcache;
|
||||
List<String *> m_BlockList;
|
||||
};
|
||||
|
||||
#endif //PLUGIN_H
|
||||
|
|
|
@ -268,7 +268,9 @@ const char* get_localinfo(const char* name, const char* def)
|
|||
const char* b = LOCALINFO((char*)name);
|
||||
|
||||
if (b == 0 || *b == 0)
|
||||
{
|
||||
SET_LOCALINFO((char*)name, (char*)(b = def));
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
@ -280,7 +282,9 @@ const char* get_localinfo(const char* name, const char* def)
|
|||
int C_Spawn(edict_t *pent)
|
||||
{
|
||||
if (g_initialized)
|
||||
{
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
g_activated = false;
|
||||
g_initialized = true;
|
||||
|
@ -365,7 +369,7 @@ int C_Spawn(edict_t *pent)
|
|||
if (!g_opt_level)
|
||||
g_opt_level = 7;
|
||||
|
||||
// ###### Load AMX scripts
|
||||
// ###### Load AMX Mod X plugins
|
||||
g_plugins.loadPluginsFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
|
||||
BuildPluginFileList(files);
|
||||
while (!files.empty())
|
||||
|
@ -379,6 +383,7 @@ int C_Spawn(edict_t *pent)
|
|||
files.pop();
|
||||
}
|
||||
g_plugins.Finalize();
|
||||
g_plugins.InvalidateCache();
|
||||
|
||||
// Register forwards
|
||||
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
|
||||
|
|
Loading…
Reference in New Issue
Block a user