diff options
author | kwolekr <mirrorisim@gmail.com> | 2012-10-28 22:02:51 -0400 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2013-01-21 21:41:09 +0200 |
commit | a785522194f98f2a0d7799c20dbfaaa55730870e (patch) | |
tree | 41e4af1341d1a78e378f81ff909aade0d01b4d04 /src | |
parent | 8e50e256e68960fa857a8d0eb83eb3b9b7bd28b5 (diff) | |
download | minetest-a785522194f98f2a0d7799c20dbfaaa55730870e.tar.gz minetest-a785522194f98f2a0d7799c20dbfaaa55730870e.tar.bz2 minetest-a785522194f98f2a0d7799c20dbfaaa55730870e.zip |
Only clear block modified flag if writing to db was successful
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/map.cpp b/src/map.cpp index 0e9b121d7..6147bb635 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3344,19 +3344,27 @@ void ServerMap::saveBlock(MapBlock *block) std::string tmp = o.str(); const char *bytes = tmp.c_str(); - if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) + bool success = true; + if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) { infostream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl; - if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) // TODO this mught not be the right length + success = false; + } + if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) { // TODO this mught not be the right length infostream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl; + success = false; + } int written = sqlite3_step(m_database_write); - if(written != SQLITE_DONE) - infostream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") " - <<sqlite3_errmsg(m_database)<<std::endl; + if(written != SQLITE_DONE) { + errorstream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") " + <<sqlite3_errmsg(m_database)<<std::endl; + success = false; + } // Make ready for later reuse sqlite3_reset(m_database_write); // We just wrote it to the disk so clear modified flag - block->resetModified(); + if (success) + block->resetModified(); } void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSector *sector, bool save_after_load) |