From c29f6c3f9e0bf7443513857078373690b5122a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 9 Dec 2023 21:40:20 +0100 Subject: [PATCH] add debug_force --- builtin/settingtypes.txt | 4 ++++ minetest.conf.example | 5 +++++ src/client/game.cpp | 12 +++++++++++- src/defaultsettings.cpp | 1 + src/light.cpp | 2 +- src/network/clientpackethandler.cpp | 4 ++-- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index edcac7c73..d2b864467 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -93,6 +93,10 @@ force_minimap (Force minimap) bool false # Disable if you think this is cheating full_brightness (Full brightness) bool false +# Enable debug everywhere +# Disable if you think this is cheating +force_debug (Force debug) bool false + [*Scripting] # Enable client-side mods without restrictions # Disable if you think this is cheating diff --git a/minetest.conf.example b/minetest.conf.example index 7f231067f..18c6fd19d 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -28,6 +28,11 @@ # type: bool # force_minimap (Force minimap) bool false +# Enable debug everywhere +# Disable if you think this is cheating +# type: bool +# force_debug (Force debug) bool false + ## Scripting # Enable client-side mods without restrictions # Disable if you think this is cheating diff --git a/src/client/game.cpp b/src/client/game.cpp index 1edbc1ede..4fb7f9fd3 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1842,8 +1842,13 @@ void Game::updateDebugState() LocalPlayer *player = client->getEnv().getLocalPlayer(); // debug UI and wireframe + bool force_debug = g_settings->getBool("force_debug"); bool has_debug = client->checkPrivilege("debug"); bool has_basic_debug = has_debug || (player->hud_flags & HUD_FLAG_BASIC_DEBUG); + if(force_debug){ + has_debug = true; + has_basic_debug = true; + } if (m_game_ui->m_flags.show_basic_debug) { if (!has_basic_debug) @@ -2436,8 +2441,13 @@ void Game::toggleFog() void Game::toggleDebug() { LocalPlayer *player = client->getEnv().getLocalPlayer(); + bool force_debug = g_settings->getBool("force_debug"); bool has_debug = client->checkPrivilege("debug"); bool has_basic_debug = has_debug || (player->hud_flags & HUD_FLAG_BASIC_DEBUG); + if(force_debug){ + has_debug = true; + has_basic_debug = true; + } // Initial: No debug info // 1x toggle: Debug text // 2x toggle: Debug text with profiler graph @@ -2461,7 +2471,7 @@ void Game::toggleDebug() m_game_ui->m_flags.show_basic_debug = true; m_game_ui->m_flags.show_profiler_graph = true; m_game_ui->showTranslatedStatusText("Profiler graph shown"); - } else if (!draw_control->show_wireframe && client->checkPrivilege("debug")) { + } else if (!draw_control->show_wireframe && has_debug) { if (has_basic_debug) m_game_ui->m_flags.show_basic_debug = true; m_game_ui->m_flags.show_profiler_graph = false; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 9384680b0..1bbfa9f39 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -199,6 +199,7 @@ void set_default_settings() settings->setDefault("smooth_lighting", "true"); settings->setDefault("full_brightness", "false"); settings->setDefault("force_minimap", "false"); + settings->setDefault("force_debug", "false"); settings->setDefault("force_csm", "false"); settings->setDefault("performance_tradeoffs", "false"); settings->setDefault("lighting_alpha", "0.0"); diff --git a/src/light.cpp b/src/light.cpp index 47f2f6794..3124da75d 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -60,7 +60,7 @@ float decode_light_f(float x) // Initialize or update the light value tables using the specified gamma void set_light_table(float gamma) { - const bool full_brightness = g_settings->getBool("full_brightness"); + bool full_brightness = g_settings->getBool("full_brightness"); if (full_brightness) { for (size_t i = 0; i <= LIGHT_SUN; i++) { light_LUT[i] = 255; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 9e8dc11ee..53c70b821 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1270,7 +1270,7 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt) player->hud_flags &= ~mask; player->hud_flags |= flags; - const bool force_minimap = g_settings->getBool("force_minimap"); + bool force_minimap = g_settings->getBool("force_minimap"); if (force_minimap){ player->hud_flags = player->hud_flags | HUD_FLAG_MINIMAP_VISIBLE | HUD_FLAG_MINIMAP_RADAR_VISIBLE; } @@ -1598,7 +1598,7 @@ void Client::handleCommand_FormspecPrepend(NetworkPacket *pkt) void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt) { - const bool force_csm = g_settings->getBool("force_csm"); + bool force_csm = g_settings->getBool("force_csm"); if(force_csm) { m_csm_restriction_flags = 0; m_csm_restriction_noderange = 4294967295;