i.atEnd() == false; i++)
{
MapBlock *block = i.getNode()->getValue();
- block->updateDayNightDiff();
+ block->expireDayNightDiff();
}
}
i.atEnd() == false; i++)
{
MapBlock *block = i.getNode()->getValue();
- block->updateDayNightDiff();
+ block->expireDayNightDiff();
}
/*
i.atEnd() == false; i++)
{
MapBlock *block = i.getNode()->getValue();
- block->updateDayNightDiff();
+ block->expireDayNightDiff();
}
/*
bool Map::addNodeWithEvent(v3s16 p, MapNode n)
{
+ ScopeProfiler sp(g_profiler, "Map::addNodeWithEvent", SPT_AVG);
MapEditEvent event;
event.type = MEET_ADDNODE;
event.p = p;
return succeeded;
}
-bool Map::dayNightDiffed(v3s16 blockpos)
+bool Map::getDayNightDiff(v3s16 blockpos)
{
try{
v3s16 p = blockpos + v3s16(0,0,0);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(-1,0,0);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,-1,0);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,0,-1);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(1,0,0);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,1,0);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
try{
v3s16 p = blockpos + v3s16(0,0,1);
MapBlock *b = getBlockNoCreate(p);
- if(b->dayNightDiffed())
+ if(b->getDayNightDiff())
return true;
}
catch(InvalidPositionException &e){}
/*
Update day/night difference cache of the MapBlocks
*/
- block->updateDayNightDiff();
+ block->expireDayNightDiff();
/*
Set block as modified
*/
block->raiseModified(MOD_STATE_WRITE_NEEDED,
- "finishBlockMake updateDayNightDiff");
+ "finishBlockMake expireDayNightDiff");
}
/*
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),
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)
{
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())
u8 flags = 0;
if(is_underground)
flags |= 0x01;
- if(m_day_night_differs)
+ if(getDayNightDiff())
flags |= 0x02;
if(m_lighting_expired)
flags |= 0x04;
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);
u8 flags = 0;
if(is_underground)
flags |= 0x01;
- if(m_day_night_differs)
+ if(getDayNightDiff())
flags |= 0x02;
if(m_lighting_expired)
flags |= 0x04;
Sets m_day_night_differs to appropriate value.
These methods don't care about neighboring blocks.
*/
- void updateDayNightDiff();
+ void actuallyUpdateDayNightDiff();
+ /*
+ Call this to schedule what the previous function does to be done
+ when the value is actually needed.
+ */
+ void expireDayNightDiff();
- bool dayNightDiffed()
+ bool getDayNightDiff()
{
+ if(m_day_night_differs_expired)
+ actuallyUpdateDayNightDiff();
return m_day_night_differs;
}
// Whether day and night lighting differs
bool m_day_night_differs;
+ bool m_day_night_differs_expired;
bool m_generated;