MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DebugSendRemoteMessages

Function DebugSendRemoteMessages

src/debug.cpp:235–250  ·  view source on GitHub ↗

* Send the queued Debug messages to either NetworkAdminConsole or IConsolePrint from the * GameLoop thread to prevent concurrent accesses to both the NetworkAdmin's packet queue * as well as IConsolePrint's buffers. * * This is to be called from the GameLoop thread. */

Source from the content-addressed store, hash-verified

233 * This is to be called from the GameLoop thread.
234 */
235void DebugSendRemoteMessages()
236{
237 if (!_debug_remote_console.load()) return;
238
239 {
240 std::lock_guard<std::mutex> lock(_debug_remote_console_mutex);
241 std::swap(_debug_remote_console_queue, _debug_remote_console_queue_spare);
242 }
243
244 for (auto &item : _debug_remote_console_queue_spare) {
245 NetworkAdminConsole(item.level, item.message);
246 if (_settings_client.gui.developer >= 2) IConsolePrint(CC_DEBUG, "dbg: [{}] {}", item.level, item.message);
247 }
248
249 _debug_remote_console_queue_spare.clear();
250}
251
252/**
253 * Reconsider whether we need to send debug messages to either NetworkAdminConsole

Callers 1

GameLoopFunction · 0.85

Calls 4

swapFunction · 0.85
NetworkAdminConsoleFunction · 0.85
IConsolePrintFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected