Skip to content

Commit

Permalink
Remove liquid_finite and weather
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Apr 18, 2014
1 parent 674be38 commit 0279f32
Show file tree
Hide file tree
Showing 18 changed files with 8 additions and 836 deletions.
6 changes: 0 additions & 6 deletions builtin/mainmenu.lua
Expand Up @@ -714,9 +714,6 @@ function tabbuilder.handle_settings_buttons(fields)
if fields["cb_particles"] then
engine.setting_set("enable_particles", fields["cb_particles"])
end
if fields["cb_finite_liquid"] then
engine.setting_set("liquid_finite", fields["cb_finite_liquid"])
end
if fields["cb_bumpmapping"] then
engine.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
end
Expand Down Expand Up @@ -997,9 +994,6 @@ function tabbuilder.tab_settings()
.. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
"checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";"
.. dump(engine.setting_getbool("enable_particles")) .. "]"..
"checkbox[1,3.0;cb_finite_liquid;".. fgettext("Finite Liquid") .. ";"
.. dump(engine.setting_getbool("liquid_finite")) .. "]"..

"checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
.. dump(engine.setting_getbool("mip_map")) .. "]"..
"checkbox[4.5,0.5;cb_anisotrophic;".. fgettext("Anisotropic Filtering") .. ";"
Expand Down
4 changes: 0 additions & 4 deletions doc/lua_api.txt
Expand Up @@ -1443,10 +1443,6 @@ minetest.set_node_level(pos, level)
^ set level of leveled node, default level = 1, if totallevel > maxlevel returns rest (total-max).
minetest.add_node_level(pos, level)
^ increase level of leveled node by level, default level = 1, if totallevel > maxlevel returns rest (total-max). can be negative for decreasing
minetest.get_heat(pos)
^ heat at pos
minetest.get_humidity(pos)
^ humidity at pos

Inventory:
minetest.get_inventory(location) -> InvRef
Expand Down
14 changes: 0 additions & 14 deletions minetest.conf.example
Expand Up @@ -93,24 +93,10 @@
#enable_fog = true
# Enable a bit lower water surface; disable for speed (not quite optimized)
#new_style_water = false
# Constant volume liquids
#liquid_finite = false
# Max liquids processed per step
#liquid_loop_max = 10000
# Update liquids every .. recommend for finite: 0.2
#liquid_update = 1.0
# Relax flowing blocks to source if level near max and N nearby
# source blocks, more realistic, but not true constant.
# values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive
# (for finite liquids)
#liquid_relax = 2
# Optimization: faster cave flood (and not true constant)
# (for finite liquids)
#liquid_fast_flood = 1
# Underground water and lava springs, its infnity sources if liquid_finite enabled
#underground_springs = 1
# Enable weather (cold-hot, water freeze-melt). use only with liquid_finite=1
#weather = false
# Enable nice leaves; disable for speed
#new_style_leaves = true
# Enable smooth lighting with simple ambient occlusion;
Expand Down
51 changes: 0 additions & 51 deletions src/biome.cpp
Expand Up @@ -203,54 +203,3 @@ u8 BiomeDefManager::getBiomeIdByName(const char *name) {

return 0;
}


///////////////////////////// Weather


s16 BiomeDefManager::calcBlockHeat(v3s16 p, u64 seed, float timeofday, float totaltime) {
//variant 1: full random
//f32 heat = NoisePerlin3D(np_heat, p.X, env->getGameTime()/100, p.Z, seed);

//variant 2: season change based on default heat map
const f32 offset = 20; // = np_heat->offset
const f32 scale = 20; // = np_heat->scale
const f32 range = 20;
f32 heat = NoisePerlin2D(np_heat, p.X, p.Z, seed); // 0..50..100

heat -= np_heat->offset; // -50..0..+50

// normalizing - todo REMOVE after fixed NoiseParams nparams_biome_def_heat = {50, 50, -> 20, 50,
if (np_heat->scale)
heat /= np_heat->scale / scale; // -20..0..+20

f32 seasonv = totaltime;
seasonv /= 86400 * g_settings->getS16("year_days"); // season change speed
seasonv += (f32)p.X / 3000; // you can walk to area with other season
seasonv = sin(seasonv * M_PI);
heat += (range * (heat < 0 ? 2 : 0.5)) * seasonv; // -60..0..30

heat += offset; // -40..0..50
heat += p.Y / -333; // upper=colder, lower=hotter, 3c per 1000

// daily change, hotter at sun +4, colder at night -4
heat += 8 * (sin(cycle_shift(timeofday, -0.25) * M_PI) - 0.5); //-44..20..54

return heat;
}


s16 BiomeDefManager::calcBlockHumidity(v3s16 p, u64 seed, float timeofday, float totaltime) {

f32 humidity = NoisePerlin2D(np_humidity, p.X, p.Z, seed);

f32 seasonv = totaltime;
seasonv /= 86400 * 2; // bad weather change speed (2 days)
seasonv += (f32)p.Z / 300;
humidity += 30 * sin(seasonv * M_PI);

humidity += -12 * (sin(cycle_shift(timeofday, -0.1) * M_PI) - 0.5);
humidity = rangelim(humidity, 0, 100);

return humidity;
}
6 changes: 0 additions & 6 deletions src/constants.h
Expand Up @@ -89,11 +89,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Maximum hit points of a player
#define PLAYER_MAX_HP 20

/*
Environmental condition constants
*/
#define HEAT_UNDEFINED (-0x7fff-1)
#define HUMIDITY_UNDEFINED (-0x7fff-1)

#endif

212 changes: 1 addition & 211 deletions src/content_abm.cpp
Expand Up @@ -32,216 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"

class LiquidFlowABM : public ActiveBlockModifier {
private:
std::set<std::string> contents;

public:
LiquidFlowABM(ServerEnvironment *env, INodeDefManager *nodemgr) {
std::set<content_t> liquids;
nodemgr->getIds("group:liquid", liquids);
for(std::set<content_t>::const_iterator k = liquids.begin(); k != liquids.end(); k++)
contents.insert(nodemgr->get(*k).liquid_alternative_flowing);
}
virtual std::set<std::string> getTriggerContents() {
return contents;
}
virtual float getTriggerInterval()
{ return 10.0; }
virtual u32 getTriggerChance()
{ return 10; }
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) {
ServerMap *map = &env->getServerMap();
if (map->transforming_liquid_size() > 500)
return;
map->transforming_liquid_add(p);
}
};

class LiquidDropABM : public ActiveBlockModifier {
private:
std::set<std::string> contents;

public:
LiquidDropABM(ServerEnvironment *env, INodeDefManager *nodemgr) {
std::set<content_t> liquids;
nodemgr->getIds("group:liquid", liquids);
for(std::set<content_t>::const_iterator k = liquids.begin(); k != liquids.end(); k++)
contents.insert(nodemgr->get(*k).liquid_alternative_source);
}
virtual std::set<std::string> getTriggerContents()
{ return contents; }
virtual std::set<std::string> getRequiredNeighbors() {
std::set<std::string> neighbors;
neighbors.insert("air");
return neighbors;
}
virtual float getTriggerInterval()
{ return 20.0; }
virtual u32 getTriggerChance()
{ return 10; }
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) {
ServerMap *map = &env->getServerMap();
if (map->transforming_liquid_size() > 500)
return;
if ( map->getNodeNoEx(p - v3s16(0, 1, 0 )).getContent() != CONTENT_AIR // below
&& map->getNodeNoEx(p - v3s16(1, 0, 0 )).getContent() != CONTENT_AIR // right
&& map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent() != CONTENT_AIR // left
&& map->getNodeNoEx(p - v3s16(0, 0, 1 )).getContent() != CONTENT_AIR // back
&& map->getNodeNoEx(p - v3s16(0, 0, -1)).getContent() != CONTENT_AIR // front
)
return;
map->transforming_liquid_add(p);
}
};

class LiquidFreeze : public ActiveBlockModifier {
public:
LiquidFreeze(ServerEnvironment *env, INodeDefManager *nodemgr) { }
virtual std::set<std::string> getTriggerContents() {
std::set<std::string> s;
s.insert("group:freezes");
return s;
}
virtual std::set<std::string> getRequiredNeighbors() {
std::set<std::string> s;
s.insert("air");
s.insert("group:melts");
return s;
}
virtual float getTriggerInterval()
{ return 10.0; }
virtual u32 getTriggerChance()
{ return 20; }
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) {
ServerMap *map = &env->getServerMap();
INodeDefManager *ndef = env->getGameDef()->ndef();

float heat = map->updateBlockHeat(env, p);
//heater = rare
content_t c = map->getNodeNoEx(p - v3s16(0, -1, 0 )).getContent(); // top
//more chance to freeze if air at top
if (heat <= -1 && (heat <= -50 || (myrand_range(-50, heat) <= (c == CONTENT_AIR ? -10 : -40)))) {
content_t c_self = n.getContent();
// making freeze not annoying, do not freeze random blocks in center of ocean
// todo: any block not water (dont freeze _source near _flowing)
bool allow = heat < -40;
// todo: make for(...)
if (!allow) {
c = map->getNodeNoEx(p - v3s16(0, 1, 0 )).getContent(); // below
if (c == CONTENT_AIR || c == CONTENT_IGNORE)
return; // do not freeze when falling
if (c != c_self && c != CONTENT_IGNORE) allow = 1;
if (!allow) {
c = map->getNodeNoEx(p - v3s16(1, 0, 0 )).getContent(); // right
if (c != c_self && c != CONTENT_IGNORE) allow = 1;
if (!allow) {
c = map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent(); // left
if (c != c_self && c != CONTENT_IGNORE) allow = 1;
if (!allow) {
c = map->getNodeNoEx(p - v3s16(0, 0, 1 )).getContent(); // back
if (c != c_self && c != CONTENT_IGNORE) allow = 1;
if (!allow) {
c = map->getNodeNoEx(p - v3s16(0, 0, -1)).getContent(); // front
if (c != c_self && c != CONTENT_IGNORE) allow = 1;
}
}
}
}
}
if (allow) {
n.freezeMelt(ndef);
map->addNodeWithEvent(p, n);
}
}
}
};

class LiquidMeltWeather : public ActiveBlockModifier {
public:
LiquidMeltWeather(ServerEnvironment *env, INodeDefManager *nodemgr) { }
virtual std::set<std::string> getTriggerContents() {
std::set<std::string> s;
s.insert("group:melts");
return s;
}
virtual std::set<std::string> getRequiredNeighbors() {
std::set<std::string> s;
s.insert("air");
s.insert("group:freezes");
return s;
}
virtual float getTriggerInterval()
{ return 10.0; }
virtual u32 getTriggerChance()
{ return 20; }
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) {
ServerMap *map = &env->getServerMap();
INodeDefManager *ndef = env->getGameDef()->ndef();

float heat = map->updateBlockHeat(env, p);
content_t c = map->getNodeNoEx(p - v3s16(0, -1, 0 )).getContent(); // top
if (heat >= 1 && (heat >= 40 || ((myrand_range(heat, 40)) >= (c == CONTENT_AIR ? 10 : 20)))) {
n.freezeMelt(ndef);
map->addNodeWithEvent(p, n);
env->getScriptIface()->node_falling_update(p);
}
}
};

class LiquidMeltHot : public ActiveBlockModifier {
public:
LiquidMeltHot(ServerEnvironment *env, INodeDefManager *nodemgr) { }
virtual std::set<std::string> getTriggerContents() {
std::set<std::string> s;
s.insert("group:melts");
return s;
}
virtual std::set<std::string> getRequiredNeighbors() {
std::set<std::string> s;
s.insert("group:igniter");
s.insert("group:hot");
return s;
}
virtual float getTriggerInterval()
{ return 2.0; }
virtual u32 getTriggerChance()
{ return 4; }
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) {
ServerMap *map = &env->getServerMap();
INodeDefManager *ndef = env->getGameDef()->ndef();
n.freezeMelt(ndef);
map->addNodeWithEvent(p, n);
env->getScriptIface()->node_falling_update(p);
}
};

/* too buggy, later via liquid flow code
class LiquidMeltAround : public LiquidMeltHot {
public:
LiquidMeltAround(ServerEnvironment *env, INodeDefManager *nodemgr)
: LiquidMeltHot(env, nodemgr) { }
virtual std::set<std::string> getRequiredNeighbors() {
std::set<std::string> s;
s.insert("group:melt_around");
return s;
}
virtual float getTriggerInterval()
{ return 40.0; }
virtual u32 getTriggerChance()
{ return 60; }
};
*/

void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) {
if (g_settings->getBool("liquid_finite")) {
env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef));
env->addActiveBlockModifier(new LiquidDropABM(env, nodedef));
env->addActiveBlockModifier(new LiquidMeltHot(env, nodedef));
//env->addActiveBlockModifier(new LiquidMeltAround(env, nodedef));
if (env->m_use_weather) {
env->addActiveBlockModifier(new LiquidFreeze(env, nodedef));
env->addActiveBlockModifier(new LiquidMeltWeather(env, nodedef));
}
}

}
5 changes: 0 additions & 5 deletions src/defaultsettings.cpp
Expand Up @@ -244,13 +244,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("movement_gravity", "9.81");

//liquid stuff
settings->setDefault("liquid_finite", "false");
settings->setDefault("liquid_loop_max", "10000");
settings->setDefault("liquid_update", "1.0");
settings->setDefault("liquid_relax", "2");
settings->setDefault("liquid_fast_flood", "1");
settings->setDefault("underground_springs", "1");
settings->setDefault("weather", "false");

//mapgen stuff
settings->setDefault("mg_name", "v6");
Expand Down
1 change: 0 additions & 1 deletion src/environment.cpp
Expand Up @@ -321,7 +321,6 @@ ServerEnvironment::ServerEnvironment(ServerMap *map,
m_recommended_send_interval(0.1),
m_max_lag_estimate(0.1)
{
m_use_weather = g_settings->getBool("weather");
}

ServerEnvironment::~ServerEnvironment()
Expand Down
3 changes: 0 additions & 3 deletions src/environment.h
Expand Up @@ -314,9 +314,6 @@ class ServerEnvironment : public Environment
void reportMaxLagEstimate(float f) { m_max_lag_estimate = f; }
float getMaxLagEstimate() { return m_max_lag_estimate; }

// is weather active in this environment?
bool m_use_weather;

std::set<v3s16>* getForceloadedBlocks() { return &m_active_blocks.m_forceloaded_list; };

private:
Expand Down

1 comment on commit 0279f32

@MirceaKitsune
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally against such feature removals as a principle. Mods might have already been using this, apart from weather being a great feature! I also planned / plan to use area humidity and temperature in some of my mods. Please reconsider this removal, at least the weather part!

https://forum.minetest.net/viewtopic.php?f=7&t=9215

Please sign in to comment.