summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/cmd.cpp
diff options
context:
space:
mode:
author Miodrag Milanović <mmicko@gmail.com>2023-01-05 05:12:10 +0100
committer GitHub <noreply@github.com>2023-01-04 23:12:10 -0500
commit5581eaa50a42256242f32569f59ce10d70ddd8c2 (patch)
tree0d79e41b381ebf6d50ab5b7e20c0993b7328b5b6 /3rdparty/bgfx/examples/common/entry/cmd.cpp
parent34c37d4f5415f886ec3ae462b008cebbf5fa22f9 (diff)
Update BGFX, BX and BIMG (#10750)
* Update to bgfx a93a714632b79b5ddbf5c86ac323fa9b76ed3433 Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/cmd.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/cmd.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/cmd.cpp b/3rdparty/bgfx/examples/common/entry/cmd.cpp
index 1e86df2a4dd..51742b8eb89 100644
--- a/3rdparty/bgfx/examples/common/entry/cmd.cpp
+++ b/3rdparty/bgfx/examples/common/entry/cmd.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2010-2021 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) );
+ 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];