Beispiel #1
0
void ConCmdManager::RemoveConCmds(List<CmdHook *> &cmdlist)
{
	List<CmdHook *>::iterator iter = cmdlist.begin();

	while (iter != cmdlist.end())
	{
		CmdHook *pHook = (*iter);
		IPluginContext *pContext = pHook->pf->GetParentContext();
		IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
		CmdList *pList = NULL;
		
		//gaben
		if (!pPlugin->GetProperty("CommandList", (void **)&pList, false) || !pList)
		{
			continue;
		}

		CmdList::iterator p_iter = pList->begin();
		while (p_iter != pList->end())
		{
			PlCmdInfo &cmd = (*p_iter);
			if (cmd.pHook == pHook)
			{
				p_iter = pList->erase(p_iter);
			}
			else
			{
				p_iter++;
			}
		}

		delete pHook->pAdmin;
		delete pHook;
		
		iter = cmdlist.erase(iter);
	}
}
Beispiel #2
0
void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
{
	/* Whoa, first get its information struct */
	ConCmdInfo *pInfo;

	if (!m_Cmds.retrieve(name, &pInfo))
		return;

	CmdHookList::iterator iter = pInfo->hooks.begin();
	while (iter != pInfo->hooks.end())
	{
		CmdHook *hook = *iter;

		IPluginContext *pContext = hook->pf->GetParentContext();
		IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());

		// The list is guaranteed to exist.
		PluginHookList *list;
		pPlugin->GetProperty("CommandList", (void **)&list, false);
		for (PluginHookList::iterator hiter = list->begin(); hiter != list->end(); hiter++)
		{
			if (*hiter == hook)
			{
				list->erase(hiter);
				break;
			}
		}

		if (hook->admin)
			hook->admin->group->hooks.remove(hook);

		iter = pInfo->hooks.erase(iter);
		delete hook;
	}

	RemoveConCmd(pInfo, name, is_read_safe, false);
}