From 941176cd65219afac81ea5bb2add425f69913142 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 21 Nov 2011 14:13:28 +0200 Subject: Default to saving stuff more often to minimize lag caused by a single save --- src/map.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index 13f2a0e98..7d5bd700d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2836,7 +2836,9 @@ void ServerMap::save(bool only_changed) u32 block_count = 0; u32 block_count_all = 0; // Number of blocks in memory - beginSave(); + // Don't do anything with sqlite unless something is really saved + bool save_started = false; + core::map::Iterator i = m_sectors.getIterator(); for(; i.atEnd() == false; i++) { @@ -2852,7 +2854,6 @@ void ServerMap::save(bool only_changed) sector->getBlocks(blocks); core::list::Iterator j; - //sqlite3_exec(m_database, "BEGIN;", NULL, NULL, NULL); for(j=blocks.begin(); j!=blocks.end(); j++) { MapBlock *block = *j; @@ -2862,7 +2863,14 @@ void ServerMap::save(bool only_changed) if(block->getModified() >= MOD_STATE_WRITE_NEEDED || only_changed == false) { + // Lazy beginSave() + if(!save_started){ + beginSave(); + save_started = true; + } + modprofiler.add(block->getModifiedReason(), 1); + saveBlock(block); block_count++; @@ -2872,10 +2880,10 @@ void ServerMap::save(bool only_changed) <getPos().Z<<")" <