summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp63
1 files changed, 35 insertions, 28 deletions
diff --git a/src/map.cpp b/src/map.cpp
index f74011933..0dbfd42f4 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2832,32 +2832,23 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
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);
- MapBlock *block = getBlockNoCreateNoEx(p);
- block->weather_update_time = 0;
- 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;
}
}
@@ -3181,6 +3172,22 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
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
@@ -3930,7 +3937,7 @@ s16 ServerMap::updateBlockHeat(ServerEnvironment *env, v3s16 p, MapBlock *block)
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));
@@ -3941,7 +3948,7 @@ s16 ServerMap::updateBlockHeat(ServerEnvironment *env, v3s16 p, MapBlock *block)
if(block) {
block->heat = heat;
- block->weather_update_time = gametime;
+ block->heat_last_update = gametime;
}
return heat;
}
@@ -3951,7 +3958,7 @@ s16 ServerMap::updateBlockHumidity(ServerEnvironment *env, v3s16 p, MapBlock *bl
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));
@@ -3962,7 +3969,7 @@ s16 ServerMap::updateBlockHumidity(ServerEnvironment *env, v3s16 p, MapBlock *bl
if(block) {
block->humidity = humidity;
- block->weather_update_time = gametime;
+ block->humidity_last_update = gametime;
}
return humidity;
}