| 125 | } |
| 126 | |
| 127 | Object* RegisterCommand(CommandDesc const& desc) |
| 128 | { |
| 129 | if (IsValidName(desc.name)) |
| 130 | { |
| 131 | if (!desc.on_execute) |
| 132 | { |
| 133 | donut::log::fatal("attempting to register console command '%s' with no execution function", desc.name); |
| 134 | } |
| 135 | |
| 136 | std::lock_guard<std::mutex> lock(m_Mutex); |
| 137 | if (auto it = m_Dictionary.find(desc.name); it == m_Dictionary.end()) |
| 138 | { |
| 139 | auto* cmd = new Command(desc.description, desc.on_execute, desc.on_suggest); |
| 140 | m_Dictionary[desc.name] = cmd; |
| 141 | return cmd; |
| 142 | } |
| 143 | else |
| 144 | donut::log::error("console command with name '%s' already exists", desc.name); |
| 145 | } |
| 146 | else |
| 147 | donut::log::error("attempting to register a console command with invalid name '%s'", desc.name); |
| 148 | return nullptr; |
| 149 | } |
| 150 | |
| 151 | bool UnregisterCommand(std::string_view name) |
| 152 | { |
no test coverage detected