From a5268beb14ceb2b0c07e3431b5715e67ca3832ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 4 Nov 2023 14:14:07 +0100 Subject: [PATCH 1/4] test --- .gitignore | 3 --- .gitmodules | 3 +++ builtin/settingtypes.txt | 4 ++++ cmake/Modules/GenerateVersion.cmake | 6 ------ lib/irrlichtmt | 1 + minetest.conf.example | 5 +++++ src/defaultsettings.cpp | 1 + src/light.cpp | 6 ++++++ 8 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .gitmodules create mode 160000 lib/irrlichtmt diff --git a/.gitignore b/.gitignore index 5405a74e9..fe3686d57 100644 --- a/.gitignore +++ b/.gitignore @@ -121,8 +121,5 @@ compile_commands.json *.sln .vs/ -# Optional user provided library folder -lib/irrlichtmt - # Generated mod storage database client/mod_storage.sqlite diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..932b64bf3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/irrlichtmt"] + path = lib/irrlichtmt + url = git@brn.systems:BRNSystems/irrlicht.git diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 56a9a3111..45d009742 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -256,6 +256,10 @@ connected_glass (Connect glass) bool false # Disable for speed or for different looks. smooth_lighting (Smooth lighting) bool true +# Enable full brightness for great visibility in the dark +# Disable if you think this is cheating +full_brightness (Full brightness) bool false + # Enables tradeoffs that reduce CPU load or increase rendering performance # at the expense of minor visual glitches that do not impact game playability. performance_tradeoffs (Tradeoffs for performance) bool false diff --git a/cmake/Modules/GenerateVersion.cmake b/cmake/Modules/GenerateVersion.cmake index ad0e38263..c61a2ea09 100644 --- a/cmake/Modules/GenerateVersion.cmake +++ b/cmake/Modules/GenerateVersion.cmake @@ -7,12 +7,6 @@ if(DEVELOPMENT_BUILD) ERROR_QUIET) if(VERSION_GITHASH) set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}") - execute_process(COMMAND git diff-index --quiet HEAD - WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}" - RESULT_VARIABLE IS_DIRTY) - if(IS_DIRTY) - set(VERSION_GITHASH "${VERSION_GITHASH}-dirty") - endif() message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***") endif() endif() diff --git a/lib/irrlichtmt b/lib/irrlichtmt new file mode 160000 index 000000000..85081d6fe --- /dev/null +++ b/lib/irrlichtmt @@ -0,0 +1 @@ +Subproject commit 85081d6fe0c422cf47f74714ee25562715528aa2 diff --git a/minetest.conf.example b/minetest.conf.example index a8b33c619..fd457e7a5 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -187,6 +187,11 @@ # type: bool # smooth_lighting = true +# Enable full brightness for great visibility in the dark +# Disable if you think this is cheating +# type: bool +full_brightness (Full brightness) bool false + # Enables tradeoffs that reduce CPU load or increase rendering performance # at the expense of minor visual glitches that do not impact game playability. # type: bool diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 8ca079357..f9ba4e1fd 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -197,6 +197,7 @@ void set_default_settings() settings->setDefault("leaves_style", "fancy"); settings->setDefault("connected_glass", "false"); settings->setDefault("smooth_lighting", "true"); + settings->setDefault("full_brightness", "false"); settings->setDefault("performance_tradeoffs", "false"); settings->setDefault("lighting_alpha", "0.0"); settings->setDefault("lighting_beta", "1.5"); diff --git a/src/light.cpp b/src/light.cpp index d5389b450..82da00876 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -35,6 +35,7 @@ struct LightingParams { float a, b, c; // Lighting curve polynomial coefficients float boost, center, sigma; // Lighting curve parametric boost float gamma; // Lighting curve gamma correction + bool full_brightness; //Full brightness }; static LightingParams params; @@ -42,6 +43,9 @@ static LightingParams params; float decode_light_f(float x) { + if (params.full_brightness){ + return 1.0f; + } if (x >= 1.0f) // x is often 1.0f return 1.0f; x = std::fmax(x, 0.0f); @@ -62,6 +66,8 @@ void set_light_table(float gamma) // Lighting curve bounding gradients const float alpha = rangelim(g_settings->getFloat("lighting_alpha"), 0.0f, 3.0f); const float beta = rangelim(g_settings->getFloat("lighting_beta"), 0.0f, 3.0f); + const bool full_brightness = g_settings->getBool("full_brightness"); + params.full_brightness = full_brightness; // Lighting curve polynomial coefficients params.a = alpha + beta - 2.0f; params.b = 3.0f - 2.0f * alpha - beta; From a3c1115277ff3623b662fda8d055f128944a5f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 25 Nov 2023 09:27:52 +0100 Subject: [PATCH 2/4] add_stuff --- builtin/settingtypes.txt | 19 ++++++++++-- minetest.conf.example | 27 ++++++++++++++--- src/client/game.cpp | 20 ++++++------ src/defaultsettings.cpp | 2 ++ src/light.cpp | 42 ++++++++++++++------------ src/network/clientpackethandler.cpp | 47 ++++++++++++++++++----------- 6 files changed, 102 insertions(+), 55 deletions(-) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 45d009742..398f91bb2 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -83,6 +83,22 @@ # modified by the "average user" should be in (sub-)categories called "Advanced". +[Enhancements] +[*Rendering] +# Enable minimap everywhere +# Disable if you think this is cheating +force_minimap (Force minimap) bool false + +# Enable full brightness for great visibility in the dark +# Disable if you think this is cheating +full_brightness (Full brightness) bool false + +[*Scripting] +# Enable client-side mods without restrictions +# Disable if you think this is cheating +force_csm (Force client-side mods) bool false + + [Controls] [*General] @@ -256,9 +272,6 @@ connected_glass (Connect glass) bool false # Disable for speed or for different looks. smooth_lighting (Smooth lighting) bool true -# Enable full brightness for great visibility in the dark -# Disable if you think this is cheating -full_brightness (Full brightness) bool false # Enables tradeoffs that reduce CPU load or increase rendering performance # at the expense of minor visual glitches that do not impact game playability. diff --git a/minetest.conf.example b/minetest.conf.example index 1679632f5..717a69381 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -12,6 +12,28 @@ # Further documentation: # https://wiki.minetest.net/ +# +# Enhancements +# + +## Rendering + +# Enable full brightness for great visibility in the dark +# Disable if you think this is cheating +# type: bool +# full_brightness (Full brightness) bool false + +# Enable minimap everywhere +# Disable if you think this is cheating +# type: bool +# force_minimap (Force minimap) bool false + +## Scripting +# Enable client-side mods without restrictions +# Disable if you think this is cheating +#force_csm (Force client-side mods) bool false + + # # Controls # @@ -187,11 +209,6 @@ # type: bool # smooth_lighting = true -# Enable full brightness for great visibility in the dark -# Disable if you think this is cheating -# type: bool -full_brightness (Full brightness) bool false - # Enables tradeoffs that reduce CPU load or increase rendering performance # at the expense of minor visual glitches that do not impact game playability. # type: bool diff --git a/src/client/game.cpp b/src/client/game.cpp index cc8891547..1edbc1ede 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2404,22 +2404,22 @@ void Game::toggleMinimap(bool shift_pressed) m_game_ui->m_flags.show_minimap = false; } else { - // If radar is disabled, try to find a non radar mode or fall back to 0 + // If radar is disabled, try to find a non radar mode or fall back to 0 if (!(hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE)) while (mapper->getModeIndex() && mapper->getModeDef().type == MINIMAP_TYPE_RADAR) mapper->nextMode(); - m_game_ui->m_flags.show_minimap = mapper->getModeDef().type != - MINIMAP_TYPE_OFF; + m_game_ui->m_flags.show_minimap = mapper->getModeDef().type != MINIMAP_TYPE_OFF; + // <-- + // End of 'not so satifying code' + if ((hud_flags & HUD_FLAG_MINIMAP_VISIBLE) || + (hud && hud->hasElementOfType(HUD_ELEM_MINIMAP))) + m_game_ui->showStatusText(utf8_to_wide(mapper->getModeDef().label)); + else + m_game_ui->showTranslatedStatusText( + "Minimap currently disabled by game or mod"); } - // <-- - // End of 'not so satifying code' - if ((hud_flags & HUD_FLAG_MINIMAP_VISIBLE) || - (hud && hud->hasElementOfType(HUD_ELEM_MINIMAP))) - m_game_ui->showStatusText(utf8_to_wide(mapper->getModeDef().label)); - else - m_game_ui->showTranslatedStatusText("Minimap currently disabled by game or mod"); } void Game::toggleFog() diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f9ba4e1fd..9384680b0 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -198,6 +198,8 @@ void set_default_settings() settings->setDefault("connected_glass", "false"); settings->setDefault("smooth_lighting", "true"); settings->setDefault("full_brightness", "false"); + settings->setDefault("force_minimap", "false"); + settings->setDefault("force_csm", "false"); settings->setDefault("performance_tradeoffs", "false"); settings->setDefault("lighting_alpha", "0.0"); settings->setDefault("lighting_beta", "1.5"); diff --git a/src/light.cpp b/src/light.cpp index 82da00876..47f2f6794 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -3,19 +3,19 @@ Minetest Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #include "light.h" #include @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SERVER -static u8 light_LUT[LIGHT_SUN + 1]; + static u8 light_LUT[LIGHT_SUN + 1]; // The const ref to light_LUT is what is actually used in the code const u8 *light_decode_table = light_LUT; @@ -43,15 +43,12 @@ static LightingParams params; float decode_light_f(float x) { - if (params.full_brightness){ - return 1.0f; - } if (x >= 1.0f) // x is often 1.0f return 1.0f; x = std::fmax(x, 0.0f); float brightness = ((params.a * x + params.b) * x + params.c) * x; brightness += params.boost * - std::exp(-0.5f * sqr((x - params.center) / params.sigma)); + std::exp(-0.5f * sqr((x - params.center) / params.sigma)); if (brightness <= 0.0f) // May happen if parameters are extreme return 0.0f; if (brightness >= 1.0f) @@ -63,23 +60,28 @@ float decode_light_f(float x) // Initialize or update the light value tables using the specified gamma void set_light_table(float gamma) { -// Lighting curve bounding gradients + const bool full_brightness = g_settings->getBool("full_brightness"); + if (full_brightness) { + for (size_t i = 0; i <= LIGHT_SUN; i++) { + light_LUT[i] = 255; + } + return; + } + // Lighting curve bounding gradients const float alpha = rangelim(g_settings->getFloat("lighting_alpha"), 0.0f, 3.0f); const float beta = rangelim(g_settings->getFloat("lighting_beta"), 0.0f, 3.0f); - const bool full_brightness = g_settings->getBool("full_brightness"); - params.full_brightness = full_brightness; -// Lighting curve polynomial coefficients + // Lighting curve polynomial coefficients params.a = alpha + beta - 2.0f; params.b = 3.0f - 2.0f * alpha - beta; params.c = alpha; -// Lighting curve parametric boost + // Lighting curve parametric boost params.boost = rangelim(g_settings->getFloat("lighting_boost"), 0.0f, 0.4f); params.center = rangelim(g_settings->getFloat("lighting_boost_center"), 0.0f, 1.0f); params.sigma = rangelim(g_settings->getFloat("lighting_boost_spread"), 0.0f, 0.4f); -// Lighting curve gamma correction + // Lighting curve gamma correction params.gamma = rangelim(gamma, 0.33f, 3.0f); -// Boundary values should be fixed + // Boundary values should be fixed light_LUT[0] = 0; light_LUT[LIGHT_SUN] = 255; @@ -96,4 +98,4 @@ void set_light_table(float gamma) } } -#endif +#endif \ No newline at end of file diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 2cb3b20ed..9e8dc11ee 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1270,24 +1270,31 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt) player->hud_flags &= ~mask; player->hud_flags |= flags; - m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE); - bool m_minimap_radar_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE); + const 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; + } + else { + m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE); + bool m_minimap_radar_disabled_by_server = + !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE); - // Not so satisying code to keep compatibility with old fixed mode system - // --> + // Not so satisying code to keep compatibility with old fixed mode system + // --> - // Hide minimap if it has been disabled by the server - if (m_minimap && m_minimap_disabled_by_server && was_minimap_visible) - // defers a minimap update, therefore only call it if really - // needed, by checking that minimap was visible before - m_minimap->setModeIndex(0); + // Hide minimap if it has been disabled by the server + if (m_minimap && m_minimap_disabled_by_server && was_minimap_visible) + // defers a minimap update, therefore only call it if really + // needed, by checking that minimap was visible before + m_minimap->setModeIndex(0); - // If radar has been disabled, try to find a non radar mode or fall back to 0 - if (m_minimap && m_minimap_radar_disabled_by_server - && was_minimap_radar_visible) { - while (m_minimap->getModeIndex() > 0 && - m_minimap->getModeDef().type == MINIMAP_TYPE_RADAR) - m_minimap->nextMode(); + // If radar has been disabled, try to find a non radar mode or fall back to 0 + if (m_minimap && m_minimap_radar_disabled_by_server && + was_minimap_radar_visible) { + while (m_minimap->getModeIndex() > 0 && + m_minimap->getModeDef().type == MINIMAP_TYPE_RADAR) + m_minimap->nextMode(); + } } // <-- // End of 'not so satifying code' @@ -1591,8 +1598,14 @@ void Client::handleCommand_FormspecPrepend(NetworkPacket *pkt) void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt) { - *pkt >> m_csm_restriction_flags >> m_csm_restriction_noderange; - + const bool force_csm = g_settings->getBool("force_csm"); + if(force_csm) { + m_csm_restriction_flags = 0; + m_csm_restriction_noderange = 4294967295; + } + else { + *pkt >> m_csm_restriction_flags >> m_csm_restriction_noderange; + } // Restrictions were received -> load mods if it's enabled // Note: this should be moved after mods receptions from server instead loadMods(); 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 3/4] 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; From 83c2d31af5c50ff20aba525414615258b4aa9b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Wed, 13 Dec 2023 19:57:36 +0100 Subject: [PATCH 4/4] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e7582e9c..f6b868dfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ set(VERSION_PATCH 0) set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string") # Change to false for releases -set(DEVELOPMENT_BUILD TRUE) +set(DEVELOPMENT_BUILD FALSE) set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") if(VERSION_EXTRA)