Skip to content

Commit

Permalink
Rename "opaque_water" setting to "translucent_liquids" with inverted …
Browse files Browse the repository at this point in the history
…meaning (#14660)

The old setting will be migrated properly.

---------

Co-authored-by: grorp <gregor.parzefall@posteo.de>
  • Loading branch information
Xeno333 and grorp committed May 22, 2024
1 parent bd4572c commit a078cfe
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ undersampling (Undersampling) int 1 1 8

[**Graphics Effects]

# Makes all liquids opaque
opaque_water (Opaque liquids) bool false
# Allows liquids to be translucent.
translucent_liquids (Translucent liquids) bool true

# Leaves style:
# - Fancy: all faces visible
Expand Down
2 changes: 1 addition & 1 deletion src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void set_default_settings()
settings->setDefault("enable_3d_clouds", "true");
settings->setDefault("cloud_radius", "12");
settings->setDefault("menu_clouds", "true");
settings->setDefault("opaque_water", "false");
settings->setDefault("translucent_liquids", "true");
settings->setDefault("console_height", "0.6");
settings->setDefault("console_color", "(0,0,0)");
settings->setDefault("console_alpha", "200");
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "version.h"
#include "defaultsettings.h"
#include "migratesettings.h"
#include "gettext.h"
#include "log.h"
#include "util/quicktune.h"
Expand Down Expand Up @@ -687,6 +688,8 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
if (!read_config_file(cmd_args))
return false;

migrate_settings();

init_log_streams(cmd_args);

// Initialize random seed
Expand Down
14 changes: 14 additions & 0 deletions src/migratesettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Minetest
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "settings.h"

void migrate_settings()
{
// Converts opaque_water to translucent_liquids
if (g_settings->existsLocal("opaque_water")) {
g_settings->set("translucent_liquids",
g_settings->getBool("opaque_water") ? "false" : "true");
g_settings->remove("opaque_water");
}
}
8 changes: 4 additions & 4 deletions src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void TileDef::deSerialize(std::istream &is, NodeDrawType drawtype, u16 protocol_
void TextureSettings::readSettings()
{
connected_glass = g_settings->getBool("connected_glass");
opaque_water = g_settings->getBool("opaque_water");
translucent_liquids = g_settings->getBool("translucent_liquids");
bool smooth_lighting = g_settings->getBool("smooth_lighting");
enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
enable_minimap = g_settings->getBool("enable_minimap");
Expand Down Expand Up @@ -683,7 +683,7 @@ void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
if (is.eof())
throw SerializationError("");
post_effect_color_shaded = tmp;
} catch(SerializationError &e) {};
} catch (SerializationError &e) {};
}

#ifndef SERVER
Expand Down Expand Up @@ -825,14 +825,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
solidness = 0;
break;
case NDT_LIQUID:
if (tsettings.opaque_water)
if (!tsettings.translucent_liquids)
alpha = ALPHAMODE_OPAQUE;
solidness = 1;
is_liquid = true;
break;
case NDT_FLOWINGLIQUID:
solidness = 0;
if (tsettings.opaque_water)
if (!tsettings.translucent_liquids)
alpha = ALPHAMODE_OPAQUE;
is_liquid = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/nodedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class TextureSettings {
WorldAlignMode world_aligned_mode;
AutoScale autoscale_mode;
int node_texture_size;
bool opaque_water;
bool translucent_liquids;
bool connected_glass;
bool enable_mesh_cache;
bool enable_minimap;
Expand Down

0 comments on commit a078cfe

Please sign in to comment.