Switch ConCmdManager off KTrie (bug 5884 part 14, r=ds).
This commit is contained in:
parent
d5177fdc74
commit
bc51c3e5b1
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
@ -62,15 +62,11 @@ void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info);
|
|||||||
|
|
||||||
ConCmdManager::ConCmdManager() : m_Strings(1024)
|
ConCmdManager::ConCmdManager() : m_Strings(1024)
|
||||||
{
|
{
|
||||||
m_pCmds = sm_trie_create();
|
|
||||||
m_pCmdGrps = sm_trie_create();
|
|
||||||
m_CmdClient = 0;
|
m_CmdClient = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdManager::~ConCmdManager()
|
ConCmdManager::~ConCmdManager()
|
||||||
{
|
{
|
||||||
sm_trie_destroy(m_pCmds);
|
|
||||||
sm_trie_destroy(m_pCmdGrps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnSourceModAllInitialized()
|
void ConCmdManager::OnSourceModAllInitialized()
|
||||||
@ -93,10 +89,8 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
/* Whoa, first get its information struct */
|
/* Whoa, first get its information struct */
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
|
|
||||||
if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
|
if (!m_Cmds.retrieve(name, &pInfo))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
RemoveConCmds(pInfo->srvhooks);
|
RemoveConCmds(pInfo->srvhooks);
|
||||||
RemoveConCmds(pInfo->conhooks);
|
RemoveConCmds(pInfo->conhooks);
|
||||||
@ -235,7 +229,7 @@ void ConCmdManager::SetCommandClient(int client)
|
|||||||
ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
|
ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
|
if (!m_Cmds.retrieve(name, &pInfo))
|
||||||
return NULL;
|
return NULL;
|
||||||
return pInfo;
|
return pInfo;
|
||||||
}
|
}
|
||||||
@ -595,16 +589,11 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
|||||||
}
|
}
|
||||||
pHook->pAdmin = pAdmin;
|
pHook->pAdmin = pAdmin;
|
||||||
|
|
||||||
void *object;
|
|
||||||
int grpid;
|
int grpid;
|
||||||
if (!sm_trie_retrieve(m_pCmdGrps, group, (void **)&object))
|
if (!m_CmdGrps.retrieve(group, &grpid))
|
||||||
{
|
{
|
||||||
grpid = m_Strings.AddString(group);
|
grpid = m_Strings.AddString(group);
|
||||||
sm_trie_insert(m_pCmdGrps, group, (void *)grpid);
|
m_CmdGrps.insert(group, grpid);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grpid = (int)object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pAdmin->cmdGrpId = grpid;
|
pAdmin->cmdGrpId = grpid;
|
||||||
@ -754,10 +743,8 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
|
|
||||||
if (type == Override_Command)
|
if (type == Override_Command)
|
||||||
{
|
{
|
||||||
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
|
if (!m_Cmds.retrieve(cmd, &pInfo))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
List<CmdHook *>::iterator iter;
|
List<CmdHook *>::iterator iter;
|
||||||
CmdHook *pHook;
|
CmdHook *pHook;
|
||||||
@ -779,12 +766,9 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
}
|
}
|
||||||
else if (type == Override_CommandGroup)
|
else if (type == Override_CommandGroup)
|
||||||
{
|
{
|
||||||
void *object;
|
int grpid;
|
||||||
if (!sm_trie_retrieve(m_pCmdGrps, cmd, &object))
|
if (!m_CmdGrps.retrieve(cmd, &grpid))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
int grpid = (int)object;
|
|
||||||
|
|
||||||
/* This is bad :( loop through all commands */
|
/* This is bad :( loop through all commands */
|
||||||
List<ConCmdInfo *>::iterator iter;
|
List<ConCmdInfo *>::iterator iter;
|
||||||
@ -815,7 +799,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_read_safe, bool untrack)
|
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_read_safe, bool untrack)
|
||||||
{
|
{
|
||||||
/* Remove from the trie */
|
/* Remove from the trie */
|
||||||
sm_trie_delete(m_pCmds, name);
|
m_Cmds.remove(name);
|
||||||
|
|
||||||
/* Remove console-specific information
|
/* Remove console-specific information
|
||||||
* This should always be true as of right now
|
* This should always be true as of right now
|
||||||
@ -856,11 +840,8 @@ void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_rea
|
|||||||
bool ConCmdManager::LookForSourceModCommand(const char *cmd)
|
bool ConCmdManager::LookForSourceModCommand(const char *cmd)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
|
if (!m_Cmds.retrieve(cmd, &pInfo))
|
||||||
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return pInfo->sourceMod && (pInfo->conhooks.size() > 0);
|
return pInfo->sourceMod && (pInfo->conhooks.size() > 0);
|
||||||
}
|
}
|
||||||
@ -868,21 +849,17 @@ bool ConCmdManager::LookForSourceModCommand(const char *cmd)
|
|||||||
bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
|
bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
|
if (!m_Cmds.retrieve(cmd, &pInfo))
|
||||||
if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
*pFlags = pInfo->admin.eflags;
|
*pFlags = pInfo->admin.eflags;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
|
ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
|
if (!m_Cmds.retrieve(name, &pInfo))
|
||||||
{
|
{
|
||||||
ConCmdList::iterator item = FindInList(name);
|
ConCmdList::iterator item = FindInList(name);
|
||||||
if (item != m_CmdList.end())
|
if (item != m_CmdList.end())
|
||||||
@ -914,7 +891,7 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
|
|||||||
|
|
||||||
pInfo->pCmd = pCmd;
|
pInfo->pCmd = pCmd;
|
||||||
|
|
||||||
sm_trie_insert(m_pCmds, name, pInfo);
|
m_Cmds.insert(name, pInfo);
|
||||||
AddToCmdList(pInfo);
|
AddToCmdList(pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
@ -35,13 +35,14 @@
|
|||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "ForwardSys.h"
|
#include "ForwardSys.h"
|
||||||
#include "sm_trie.h"
|
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
#include <sh_string.h>
|
#include <sh_string.h>
|
||||||
#include <IRootConsoleMenu.h>
|
#include <IRootConsoleMenu.h>
|
||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
#include "concmd_cleaner.h"
|
#include "concmd_cleaner.h"
|
||||||
|
#include <sm_stringhashmap.h>
|
||||||
|
#include <am-utility.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
|
||||||
@ -157,8 +158,8 @@ public:
|
|||||||
return m_CmdList;
|
return m_CmdList;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Trie *m_pCmds; /* command lookup */
|
StringHashMap<ConCmdInfo *> m_Cmds; /* command lookup */
|
||||||
Trie *m_pCmdGrps; /* command group lookup */
|
StringHashMap<int> m_CmdGrps; /* command group lookup */
|
||||||
ConCmdList m_CmdList; /* command list */
|
ConCmdList m_CmdList; /* command list */
|
||||||
int m_CmdClient; /* current client */
|
int m_CmdClient; /* current client */
|
||||||
BaseStringTable m_Strings; /* string table */
|
BaseStringTable m_Strings; /* string table */
|
||||||
|
Loading…
Reference in New Issue
Block a user