content_t new_node_content;
s8 new_node_level = -1;
s8 max_node_level = -1;
+ u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
// or the flowing alternative of the first of the surrounding sources (if it's air), so
// liquid_kind is set properly, see above
new_node_content = liquid_kind;
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
+ if (new_node_level < (LIQUID_LEVEL_MAX+1-range))
+ new_node_content = CONTENT_AIR;
} else {
// no surrounding sources, so get the maximum level that can flow into this node
for (u16 i = 0; i < num_flows; i++) {
} else
new_node_level = max_node_level;
- u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
- if (new_node_level >= (LIQUID_LEVEL_MAX+1-range))
+ if (max_node_level >= (LIQUID_LEVEL_MAX+1-range))
new_node_content = liquid_kind;
else
new_node_content = CONTENT_AIR;
Update weather data in blocks
*/
ServerEnvironment *senv = &((Server *)m_gamedef)->getEnv();
- if (senv->m_use_weather) {
- for(s16 x=blockpos_min.X-extra_borders.X;
- x<=blockpos_max.X+extra_borders.X; x++)
- for(s16 z=blockpos_min.Z-extra_borders.Z;
- z<=blockpos_max.Z+extra_borders.Z; z++)
- for(s16 y=blockpos_min.Y-extra_borders.Y;
- y<=blockpos_max.Y+extra_borders.Y; y++)
- {
- v3s16 p(x, y, z);
- updateBlockHeat(senv, p * MAP_BLOCKSIZE, NULL);
- updateBlockHumidity(senv, p * MAP_BLOCKSIZE, NULL);
- }
- } else {
- for(s16 x=blockpos_min.X-extra_borders.X;
- x<=blockpos_max.X+extra_borders.X; x++)
- for(s16 z=blockpos_min.Z-extra_borders.Z;
- z<=blockpos_max.Z+extra_borders.Z; z++)
- for(s16 y=blockpos_min.Y-extra_borders.Y;
- y<=blockpos_max.Y+extra_borders.Y; y++)
- {
- MapBlock *block = getBlockNoCreateNoEx(v3s16(x, y, z));
+ for(s16 x=blockpos_min.X-extra_borders.X;
+ x<=blockpos_max.X+extra_borders.X; x++)
+ for(s16 z=blockpos_min.Z-extra_borders.Z;
+ z<=blockpos_max.Z+extra_borders.Z; z++)
+ for(s16 y=blockpos_min.Y-extra_borders.Y;
+ y<=blockpos_max.Y+extra_borders.Y; y++)
+ {
+ v3s16 p(x, y, z);
+ MapBlock *block = getBlockNoCreateNoEx(p);
+ block->heat_last_update = 0;
+ block->humidity_last_update = 0;
+ if (senv->m_use_weather) {
+ updateBlockHeat(senv, p * MAP_BLOCKSIZE, block);
+ updateBlockHumidity(senv, p * MAP_BLOCKSIZE, block);
+ } else {
block->heat = HEAT_UNDEFINED;
block->humidity = HUMIDITY_UNDEFINED;
- block->weather_update_time = 0;
}
}
return NULL;
}
+void ServerMap::prepareBlock(MapBlock *block) {
+ ServerEnvironment *senv = &((Server *)m_gamedef)->getEnv();
+
+ // Calculate weather conditions
+ block->heat_last_update = 0;
+ block->humidity_last_update = 0;
+ if (senv->m_use_weather) {
+ v3s16 p = block->getPos() * MAP_BLOCKSIZE;
+ updateBlockHeat(senv, p, block);
+ updateBlockHumidity(senv, p, block);
+ } else {
+ block->heat = HEAT_UNDEFINED;
+ block->humidity = HUMIDITY_UNDEFINED;
+ }
+}
+
s16 ServerMap::findGroundLevel(v2s16 p2d)
{
#if 0
m_seed = mgparams->seed;
} else {
if (params.exists("seed")) {
- m_seed = params.getU64("seed");
+ m_seed = read_seed(params.get("seed").c_str());
m_mgparams->seed = m_seed;
}
}
u32 gametime = env->getGameTime();
if (block) {
- if (gametime - block->weather_update_time < 10)
+ if (gametime - block->heat_last_update < 10)
return block->heat;
} else {
block = getBlockNoCreateNoEx(getNodeBlockPos(p));
if(block) {
block->heat = heat;
- block->weather_update_time = gametime;
+ block->heat_last_update = gametime;
}
return heat;
}
u32 gametime = env->getGameTime();
if (block) {
- if (gametime - block->weather_update_time < 10)
+ if (gametime - block->humidity_last_update < 10)
return block->humidity;
} else {
block = getBlockNoCreateNoEx(getNodeBlockPos(p));
if(block) {
block->humidity = humidity;
- block->weather_update_time = gametime;
+ block->humidity_last_update = gametime;
}
return humidity;
}