mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-19 21:42:59 +01:00
Added cmdRemove.
This commit is contained in:
@@ -29,12 +29,24 @@ struct CmdContext
|
||||
|
||||
void add(const char* _name, ConsoleFn _fn, void* _userData)
|
||||
{
|
||||
uint32_t cmd = bx::hash<bx::HashMurmur2A>(_name, (uint32_t)bx::strLen(_name) );
|
||||
const uint32_t cmd = bx::hash<bx::HashMurmur2A>(_name, (uint32_t)bx::strLen(_name) );
|
||||
BX_ASSERT(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name);
|
||||
|
||||
Func fn = { _fn, _userData };
|
||||
m_lookup.insert(stl::make_pair(cmd, fn) );
|
||||
}
|
||||
|
||||
void remove(const char* _name)
|
||||
{
|
||||
const uint32_t cmd = bx::hash<bx::HashMurmur2A>(_name, (uint32_t)bx::strLen(_name) );
|
||||
|
||||
CmdLookup::iterator it = m_lookup.find(cmd);
|
||||
if (it != m_lookup.end() )
|
||||
{
|
||||
m_lookup.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void exec(const char* _cmd)
|
||||
{
|
||||
for (bx::StringView next(_cmd); !next.isEmpty(); _cmd = next.getPtr() )
|
||||
@@ -105,6 +117,11 @@ void cmdAdd(const char* _name, ConsoleFn _fn, void* _userData)
|
||||
s_cmdContext->add(_name, _fn, _userData);
|
||||
}
|
||||
|
||||
void cmdRemove(const char* _name)
|
||||
{
|
||||
s_cmdContext->remove(_name);
|
||||
}
|
||||
|
||||
void cmdExec(const char* _format, ...)
|
||||
{
|
||||
char tmp[2048];
|
||||
|
||||
Reference in New Issue
Block a user