Reenable fog toggle unless server restricts fog distance (#14634)

see comments in #14539
This commit is contained in:
sfan5 2024-05-14 18:31:51 +02:00 committed by GitHub
parent 5a4d7fb0d6
commit c38e0d05bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 22 deletions

View File

@ -381,8 +381,7 @@ crosshair_alpha (Crosshair alpha) int 255 0 255
[**Fog]
# Whether to fog out the end of the visible area. This option only works
# with the 'debug' privilege.
# Whether to fog out the end of the visible area.
enable_fog (Fog) bool true
# Make fog and sky colors depend on daytime (dawn/sunset) and view direction.
@ -2511,7 +2510,7 @@ keymap_toggle_chat (Chat toggle key) key KEY_F2
# Key for toggling the display of the large chat console.
keymap_console (Large chat console key) key KEY_F10
# Key for toggling the display of fog. Only usable with 'debug' privilege.
# Key for toggling the display of fog.
keymap_toggle_fog (Fog toggle key) key KEY_F3
# Key for toggling the camera update. Only usable with 'debug' privilege.

View File

@ -8257,14 +8257,13 @@ child will follow movement and rotation of that bone.
`"default"` uses the classic Minetest sun and moon tinting.
Will use tonemaps, if set to `"default"`. (default: `"default"`)
* `fog`: A table with following optional fields:
* `fog_distance`: integer, set an upper bound the client's viewing_range (inluding range_all).
By default, fog_distance is controlled by the client's viewing_range, and this field is not set.
Any value >= 0 sets the desired upper bound for the client's viewing_range and disables range_all.
Any value < 0, resets the behavior to being client-controlled.
* `fog_distance`: integer, set an upper bound for the client's viewing_range.
Any value >= 0 sets the desired upper bound for viewing_range,
disables range_all and prevents disabling fog (F3 key by default).
Any value < 0 resets the behavior to being client-controlled.
(default: -1)
* `fog_start`: float, override the client's fog_start.
Fraction of the visible distance at which fog starts to be rendered.
By default, fog_start is controlled by the client's `fog_start` setting, and this field is not set.
Any value between [0.0, 0.99] set the fog_start as a fraction of the viewing_range.
Any value < 0, resets the behavior to being client-controlled.
(default: -1)

View File

@ -792,6 +792,14 @@ protected:
void showOverlayMessage(const char *msg, float dtime, int percent,
bool draw_clouds = true);
inline bool fogEnabled()
{
// Client setting only takes effect if fog distance unlimited or debug priv
if (sky->getFogDistance() < 0 || client->checkPrivilege("debug"))
return m_cache_enable_fog;
return true;
}
static void settingChangedCallback(const std::string &setting_name, void *data);
void readSettings();
@ -2467,15 +2475,12 @@ void Game::toggleMinimap(bool shift_pressed)
void Game::toggleFog()
{
bool flag;
// do not modify setting if no privilege
if (!client->checkPrivilege("debug")) {
flag = true;
} else {
flag = !g_settings->getBool("enable_fog");
g_settings->setBool("enable_fog", flag);
}
if (flag)
bool flag = !g_settings->getBool("enable_fog");
g_settings->setBool("enable_fog", flag);
bool allowed = sky->getFogDistance() < 0 || client->checkPrivilege("debug");
if (!allowed)
m_game_ui->showTranslatedStatusText("Fog enabled by game or mod");
else if (flag)
m_game_ui->showTranslatedStatusText("Fog enabled");
else
m_game_ui->showTranslatedStatusText("Fog disabled");
@ -4230,8 +4235,7 @@ void Game::updateClouds(float dtime)
camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS;
camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS;
this->clouds->update(camera_node_position, this->sky->getCloudColor());
bool enable_fog = this->m_cache_enable_fog || !client->checkPrivilege("debug");
if (this->clouds->isCameraInsideCloud() && enable_fog) {
if (this->clouds->isCameraInsideCloud() && this->fogEnabled()) {
// If camera is inside cloud and fog is enabled, use cloud's colors as sky colors.
video::SColor clouds_dark = this->clouds->getColor().getInterpolated(
video::SColor(255, 0, 0, 0), 0.9);
@ -4291,7 +4295,7 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
/*
Fog
*/
if (this->m_cache_enable_fog || !client->checkPrivilege("debug")) {
if (this->fogEnabled()) {
this->driver->setFog(
fog_color,
video::EFT_FOG_LINEAR,

View File

@ -172,11 +172,10 @@ void set_default_settings()
settings->setDefault("keymap_toggle_block_bounds", "");
settings->setDefault("keymap_toggle_hud", "KEY_F1");
settings->setDefault("keymap_toggle_chat", "KEY_F2");
#ifndef NDEBUG
settings->setDefault("keymap_toggle_fog", "KEY_F3");
#ifndef NDEBUG
settings->setDefault("keymap_toggle_update_camera", "KEY_F4");
#else
settings->setDefault("keymap_toggle_fog", "");
settings->setDefault("keymap_toggle_update_camera", "");
#endif
settings->setDefault("keymap_toggle_debug", "KEY_F5");