summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-29 00:28:48 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-29 00:28:48 +0300
commit02c035c548787a589c2bb813112b080a638e2972 (patch)
tree66ae02a8c29b5396bc86392e004c39ccc671b434 /src/mapblock.cpp
parent418041d9067319431e4b6301851da117d2f4075b (diff)
downloadminetest-02c035c548787a589c2bb813112b080a638e2972.tar.gz
minetest-02c035c548787a589c2bb813112b080a638e2972.tar.bz2
minetest-02c035c548787a589c2bb813112b080a638e2972.zip
Reduce EnvRef:set_node() time tenfold by postponing the dayNightDiff update until it is actually needed
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 70cb0e370..5ad86fde4 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -49,6 +49,7 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
is_underground(false),
m_lighting_expired(true),
m_day_night_differs(false),
+ m_day_night_differs_expired(true),
m_generated(false),
m_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
m_disk_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
@@ -355,9 +356,11 @@ void MapBlock::copyFrom(VoxelManipulator &dst)
getPosRelative(), data_size);
}
-void MapBlock::updateDayNightDiff()
+void MapBlock::actuallyUpdateDayNightDiff()
{
INodeDefManager *nodemgr = m_gamedef->ndef();
+ // Running this function un-expires m_day_night_differs
+ m_day_night_differs_expired = false;
if(data == NULL)
{
@@ -404,6 +407,19 @@ void MapBlock::updateDayNightDiff()
m_day_night_differs = differs;
}
+void MapBlock::expireDayNightDiff()
+{
+ INodeDefManager *nodemgr = m_gamedef->ndef();
+
+ if(data == NULL){
+ m_day_night_differs = false;
+ m_day_night_differs_expired = false;
+ return;
+ }
+
+ m_day_night_differs_expired = true;
+}
+
s16 MapBlock::getGroundLevel(v2s16 p2d)
{
if(isDummy())
@@ -545,7 +561,7 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
u8 flags = 0;
if(is_underground)
flags |= 0x01;
- if(m_day_night_differs)
+ if(getDayNightDiff())
flags |= 0x02;
if(m_lighting_expired)
flags |= 0x04;
@@ -614,6 +630,8 @@ void MapBlock::deSerialize(std::istream &is, u8 version, bool disk)
if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapBlock format not supported");
+ m_day_night_differs_expired = false;
+
if(version <= 21)
{
deSerialize_pre22(is, version, disk);
@@ -800,7 +818,7 @@ void MapBlock::serialize_pre22(std::ostream &os, u8 version, bool disk)
u8 flags = 0;
if(is_underground)
flags |= 0x01;
- if(m_day_night_differs)
+ if(getDayNightDiff())
flags |= 0x02;
if(m_lighting_expired)
flags |= 0x04;