From 8b3ed78e53d8ad19d8dee3968430be258559214c Mon Sep 17 00:00:00 2001 From: kwolekr Date: Mon, 7 Jul 2014 01:20:25 -0400 Subject: Don't unload blocks if save failed Improve error handling in saveBlock() --- src/database-sqlite3.cpp | 55 ++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/database-sqlite3.cpp') diff --git a/src/database-sqlite3.cpp b/src/database-sqlite3.cpp index 3ec13a1a2..fb76d8eae 100644 --- a/src/database-sqlite3.cpp +++ b/src/database-sqlite3.cpp @@ -136,25 +136,24 @@ void Database_SQLite3::verifyDatabase() { infostream<<"ServerMap: SQLite3 database opened"<getPos(); + /* - Dummy blocks are not written + Dummy blocks are not written, but is not a save failure */ if(block->isDummy()) { - /*v3s16 p = block->getPos(); - infostream<<"Database_SQLite3::saveBlock(): WARNING: Not writing dummy block " - <<"("<getPos(); - #if 0 v2s16 p2d(p3d.X, p3d.Z); @@ -176,29 +175,39 @@ void Database_SQLite3::saveBlock(MapBlock *block) std::ostringstream o(std::ios_base::binary); - o.write((char*)&version, 1); + o.write((char *)&version, 1); // Write basic data block->serialize(o, version, true); // Write block to database - std::string tmp = o.str(); - const char *bytes = tmp.c_str(); - - if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) - errorstream<<"WARNING: Block position failed to bind: "<resetModified(); + sqlite3_reset(m_database_write); + return true; } MapBlock* Database_SQLite3::loadBlock(v3s16 blockpos) -- cgit v1.2.3