summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/cmd.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/cmd.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/cmd.cpp b/3rdparty/bgfx/examples/common/entry/cmd.cpp
index 4c68be9b51c..51742b8eb89 100644
--- a/3rdparty/bgfx/examples/common/entry/cmd.cpp
+++ b/3rdparty/bgfx/examples/common/entry/cmd.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ * Copyright 2010-2022 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include <bx/allocator.h>
@@ -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) );
- BX_CHECK(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _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];