Switch sm_srvcmds off KTrie (bug 5884 part 12, r=ds).
This commit is contained in:
parent
3985dd639a
commit
80eba57e6b
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 sw=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
@ -42,14 +42,11 @@ ConVar sourcemod_version("sourcemod_version", SM_VERSION_STRING, FCVAR_SPONLY|FC
|
|||||||
|
|
||||||
RootConsoleMenu::RootConsoleMenu()
|
RootConsoleMenu::RootConsoleMenu()
|
||||||
{
|
{
|
||||||
m_pCommands = sm_trie_create();
|
|
||||||
m_CfgExecDone = false;
|
m_CfgExecDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootConsoleMenu::~RootConsoleMenu()
|
RootConsoleMenu::~RootConsoleMenu()
|
||||||
{
|
{
|
||||||
sm_trie_destroy(m_pCommands);
|
|
||||||
|
|
||||||
List<ConsoleEntry *>::iterator iter;
|
List<ConsoleEntry *>::iterator iter;
|
||||||
for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++)
|
for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++)
|
||||||
{
|
{
|
||||||
@ -129,10 +126,8 @@ bool RootConsoleMenu::_AddRootConsoleCommand(const char *cmd,
|
|||||||
IRootConsoleCommand *pHandler,
|
IRootConsoleCommand *pHandler,
|
||||||
bool version2)
|
bool version2)
|
||||||
{
|
{
|
||||||
if (sm_trie_retrieve(m_pCommands, cmd, NULL))
|
if (m_Commands.contains(cmd))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* Sort this into the menu */
|
/* Sort this into the menu */
|
||||||
List<ConsoleEntry *>::iterator iter = m_Menu.begin();
|
List<ConsoleEntry *>::iterator iter = m_Menu.begin();
|
||||||
@ -148,7 +143,7 @@ bool RootConsoleMenu::_AddRootConsoleCommand(const char *cmd,
|
|||||||
pNew->description.assign(text);
|
pNew->description.assign(text);
|
||||||
pNew->version2 = version2;
|
pNew->version2 = version2;
|
||||||
pNew->cmd = pHandler;
|
pNew->cmd = pHandler;
|
||||||
sm_trie_insert(m_pCommands, cmd, pNew);
|
m_Commands.insert(cmd, pNew);
|
||||||
m_Menu.insert(iter, pNew);
|
m_Menu.insert(iter, pNew);
|
||||||
inserted = true;
|
inserted = true;
|
||||||
break;
|
break;
|
||||||
@ -163,7 +158,7 @@ bool RootConsoleMenu::_AddRootConsoleCommand(const char *cmd,
|
|||||||
pNew->description.assign(text);
|
pNew->description.assign(text);
|
||||||
pNew->version2 = version2;
|
pNew->version2 = version2;
|
||||||
pNew->cmd = pHandler;
|
pNew->cmd = pHandler;
|
||||||
sm_trie_insert(m_pCommands, cmd, pNew);
|
m_Commands.insert(cmd, pNew);
|
||||||
m_Menu.push_back(pNew);
|
m_Menu.push_back(pNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +167,7 @@ bool RootConsoleMenu::_AddRootConsoleCommand(const char *cmd,
|
|||||||
|
|
||||||
bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler)
|
bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler)
|
||||||
{
|
{
|
||||||
sm_trie_delete(m_pCommands, cmd);
|
m_Commands.remove(cmd);
|
||||||
|
|
||||||
List<ConsoleEntry *>::iterator iter;
|
List<ConsoleEntry *>::iterator iter;
|
||||||
ConsoleEntry *pEntry;
|
ConsoleEntry *pEntry;
|
||||||
@ -291,7 +286,7 @@ void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
|
|||||||
CCommandArgs ocmd(cmd);
|
CCommandArgs ocmd(cmd);
|
||||||
|
|
||||||
ConsoleEntry *entry;
|
ConsoleEntry *entry;
|
||||||
if (sm_trie_retrieve(m_pCommands, cmdname, (void **)&entry))
|
if (m_Commands.retrieve(cmdname, &entry))
|
||||||
{
|
{
|
||||||
if (entry->version2)
|
if (entry->version2)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 sw=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
#include <sh_string.h>
|
#include <sh_string.h>
|
||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
#include "sm_trie.h"
|
#include <sm_namehashset.h>
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
@ -49,6 +49,11 @@ struct ConsoleEntry
|
|||||||
String description;
|
String description;
|
||||||
bool version2;
|
bool version2;
|
||||||
IRootConsoleCommand *cmd;
|
IRootConsoleCommand *cmd;
|
||||||
|
|
||||||
|
static inline bool matches(const char *name, const ConsoleEntry *entry)
|
||||||
|
{
|
||||||
|
return strcmp(name, entry->command.c_str()) == 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RootConsoleMenu :
|
class RootConsoleMenu :
|
||||||
@ -87,7 +92,7 @@ public:
|
|||||||
void GotRootCmd(const CCommand &cmd);
|
void GotRootCmd(const CCommand &cmd);
|
||||||
private:
|
private:
|
||||||
bool m_CfgExecDone;
|
bool m_CfgExecDone;
|
||||||
Trie *m_pCommands;
|
NameHashSet<ConsoleEntry *> m_Commands;
|
||||||
List<ConsoleEntry *> m_Menu;
|
List<ConsoleEntry *> m_Menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user