*/
void Map::timerUpdate(float dtime)
{
- //JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
-
core::map<v2s16, MapSector*>::Iterator si;
si = m_sectors.getIterator();
}
}
-void Map::deleteSectors(core::list<v2s16> &list, bool only_blocks)
+void Map::deleteSectors(core::list<v2s16> &list)
{
core::list<v2s16>::Iterator j;
for(j=list.begin(); j!=list.end(); j++)
{
MapSector *sector = m_sectors[*j];
- if(only_blocks)
- {
- sector->deleteBlocks();
- }
- else
- {
- /*
- If sector is in sector cache, remove it from there
- */
- if(m_sector_cache == sector)
- {
- m_sector_cache = NULL;
- }
- /*
- Remove from map and delete
- */
- m_sectors.remove(*j);
- delete sector;
- }
+ // If sector is in sector cache, remove it from there
+ if(m_sector_cache == sector)
+ m_sector_cache = NULL;
+ // Remove from map and delete
+ m_sectors.remove(*j);
+ delete sector;
}
}
-u32 Map::unloadUnusedData(float timeout, bool only_blocks,
+void Map::unloadUnusedData(float timeout,
core::list<v3s16> *deleted_blocks)
{
core::list<v2s16> sector_deletion_queue;
+ u32 deleted_blocks_count = 0;
+ u32 saved_blocks_count = 0;
core::map<v2s16, MapSector*>::Iterator si = m_sectors.getIterator();
for(; si.atEnd() == false; si++)
i != blocks.end(); i++)
{
MapBlock *block = (*i);
-
+
if(block->getUsageTimer() > timeout)
{
// Save if modified
if(block->getModified() != MOD_STATE_CLEAN)
+ {
saveBlock(block);
+ saved_blocks_count++;
+ }
// Delete from memory
sector->deleteBlock(block);
+ deleted_blocks_count++;
}
else
{
}
}
-#if 0
- core::map<v2s16, MapSector*>::Iterator i = m_sectors.getIterator();
- for(; i.atEnd() == false; i++)
- {
- MapSector *sector = i.getNode()->getValue();
- /*
- Delete sector from memory if it hasn't been used in a long time
- */
- if(sector->usage_timer > timeout)
- {
- sector_deletion_queue.push_back(i.getNode()->getKey());
+ deleteSectors(sector_deletion_queue);
- if(deleted_blocks != NULL)
- {
- // Collect positions of blocks of sector
- MapSector *sector = i.getNode()->getValue();
- core::list<MapBlock*> blocks;
- sector->getBlocks(blocks);
- for(core::list<MapBlock*>::Iterator i = blocks.begin();
- i != blocks.end(); i++)
- {
- deleted_blocks->push_back((*i)->getPos());
- }
- }
- }
- }
-#endif
+ dstream<<"Map: Unloaded "<<deleted_blocks_count<<" blocks from memory"
+ <<", of which "<<saved_blocks_count<<" were wr."
+ <<std::endl;
- deleteSectors(sector_deletion_queue, only_blocks);
- return sector_deletion_queue.getSize();
+ //return sector_deletion_queue.getSize();
+ //return deleted_blocks_count;
}
void Map::PrintInfo(std::ostream &out)
return NULL;
}
+ bool enable_mapgen_debug_info = g_settings.getBool("enable_mapgen_debug_info");
+
/*dstream<<"Resulting vmanip:"<<std::endl;
data->vmanip.print(dstream);*/
//TimeTaker timer("finishBlockMake() blitBackAll");
data->vmanip->blitBackAll(&changed_blocks);
}
-#if 1
- dstream<<"finishBlockMake: changed_blocks.size()="
- <<changed_blocks.size()<<std::endl;
-#endif
+
+ if(enable_mapgen_debug_info)
+ dstream<<"finishBlockMake: changed_blocks.size()="
+ <<changed_blocks.size()<<std::endl;
+
/*
Copy transforming liquid information
*/
}
#endif
updateLighting(lighting_update_blocks, changed_blocks);
+
+ if(enable_mapgen_debug_info == false)
+ t.stop(true); // Hide output
}
/*
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
+ bool enable_mapgen_debug_info = g_settings.getBool("enable_mapgen_debug_info");
+
TimeTaker timer("generateBlock");
//MapBlock *block = original_dummy;
{
TimeTaker t("mapgen::make_block()");
mapgen::make_block(&data);
+
+ if(enable_mapgen_debug_info == false)
+ t.stop(true); // Hide output
}
/*
}
#endif
+ if(enable_mapgen_debug_info == false)
+ timer.stop(true); // Hide output
+
return block;
}
Updates usage timers
*/
void timerUpdate(float dtime);
-
+
+ // Deletes sectors and their blocks from memory
// Takes cache into account
- // sector mutex should be locked when calling
- void deleteSectors(core::list<v2s16> &list, bool only_blocks);
+ // If deleted sector is in sector cache, clears cache
+ void deleteSectors(core::list<v2s16> &list);
- // Returns count of deleted sectors
- u32 unloadUnusedData(float timeout, bool only_blocks=false,
+ /*
+ Unload unused data
+ = flush changed to disk and delete from memory, if usage timer of
+ block is more than timeout
+ */
+ void unloadUnusedData(float timeout,
core::list<v3s16> *deleted_blocks=NULL);
// For debug printing
JMutexAutoLock lock(m_env_mutex);
if(((ServerMap*)(&m_env.getMap()))->isSavingEnabled() == true)
{
+ // Unload unused data (delete from memory)
+ m_env.getMap().unloadUnusedData(
+ g_settings.getFloat("server_unload_unused_sectors_timeout"));
+ /*u32 deleted_count = m_env.getMap().unloadUnusedData(
+ g_settings.getFloat("server_unload_unused_sectors_timeout"));
+ */
+
// Save only changed parts
m_env.getMap().save(true);
- // Delete unused sectors
- u32 deleted_count = m_env.getMap().unloadUnusedData(
- g_settings.getFloat("server_unload_unused_sectors_timeout"));
- if(deleted_count > 0)
+ /*if(deleted_count > 0)
{
dout_server<<"Server: Unloaded "<<deleted_count
- <<" sectors from memory"<<std::endl;
- }
+ <<" blocks from memory"<<std::endl;
+ }*/
// Save players
m_env.serializePlayers(m_mapsavedir);