From eec456be63f6fee8604f7a9c40aa41a1af3f1fac Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 8 Jul 2014 20:04:37 +0200 Subject: Move MapBlock (de)serializing code out of Database class --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 8a9d14d0a..bb2ac5faf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1296,9 +1296,13 @@ int main(int argc, char *argv[]) new_db->beginSave(); for (std::list::iterator i = blocks.begin(); i != blocks.end(); i++) { MapBlock *block = old_map.loadBlock(*i); - new_db->saveBlock(block); - MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z)); - sector->deleteBlock(block); + if (!block) { + errorstream << "Failed to load block " << PP(*i) << ", skipping it."; + } else { + old_map.saveBlock(block, new_db); + MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z)); + sector->deleteBlock(block); + } ++count; if (count % 500 == 0) actionstream << "Migrated " << count << " blocks " @@ -1947,4 +1951,3 @@ int main(int argc, char *argv[]) } //END - -- cgit v1.2.3