]> git.lizzy.rs Git - minetest.git/blobdiff - src/database-sqlite3.cpp
Don't use msvc libs for mingw build
[minetest.git] / src / database-sqlite3.cpp
index 69795a1f26c4676a3d39b2b8a05e757a34e5d81b..9714d10351744ff5fd0b292adc7c66cc031a7e5f 100644 (file)
@@ -1,3 +1,22 @@
+/*
+Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
 /*
        SQLite format specification:
        - Initially only replaces sectors/ and sectors2/
                        BLOB data
 */
 
+
+#include "database-sqlite3.h"
+
 #include "map.h"
 #include "mapsector.h"
 #include "mapblock.h"
+#include "serialization.h"
 #include "main.h"
-#include "filesys.h"
-#include "voxel.h"
-#include "porting.h"
-#include "mapgen.h"
-#include "nodemetadata.h"
 #include "settings.h"
 #include "log.h"
-#include "profiler.h"
-#include "nodedef.h"
-#include "gamedef.h"
-#include "util/directiontables.h"
-#include "rollback_interface.h"
-
-#include "database-sqlite3.h"
 
 Database_SQLite3::Database_SQLite3(ServerMap *map, std::string savedir)
 {
@@ -97,7 +108,16 @@ void Database_SQLite3::verifyDatabase() {
                
                if(needs_create)
                        createDatabase();
-       
+
+               std::string querystr = std::string("PRAGMA synchronous = ")
+                                + itos(g_settings->getU16("sqlite_synchronous"));
+               d = sqlite3_exec(m_database, querystr.c_str(), NULL, NULL, NULL);
+               if(d != SQLITE_OK) {
+                       infostream<<"WARNING: Database pragma set failed: "
+                                       <<sqlite3_errmsg(m_database)<<std::endl;
+                       throw FileNotGoodException("Cannot set pragma");
+               }
+
                d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
                if(d != SQLITE_OK) {
                        infostream<<"WARNING: SQLite3 database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
@@ -294,7 +314,7 @@ void Database_SQLite3::createDatabase()
        
 }
 
-void Database_SQLite3::listAllLoadableBlocks(core::list<v3s16> &dst)
+void Database_SQLite3::listAllLoadableBlocks(std::list<v3s16> &dst)
 {
        verifyDatabase();