Switch android to leveldb as sqlite3 is broken and fails to save any mapblock there
authorsapier <Sapier at GMX dot net>
Sun, 6 Jul 2014 19:24:31 +0000 (21:24 +0200)
committersapier <Sapier at GMX dot net>
Sun, 6 Jul 2014 19:27:54 +0000 (21:27 +0200)
build/android/Makefile
build/android/jni/Android.mk
src/database-sqlite3.cpp
src/subgame.cpp

index 9e693432b0d7acc49018422f0cde132c93820f5e..d75c6a409fc2c5f7a2b98bdb3989cdb12a1c492d 100644 (file)
@@ -628,7 +628,7 @@ assets : $(ASSETS_TIMESTAMP)
 clean_assets :
        @$(RM) -r assets
        
-apk: $(PATHCFGFILE) assets $(IRRLICHT_LIB) $(CURL_LIB)                   \
+apk: $(PATHCFGFILE) assets $(IRRLICHT_LIB) $(CURL_LIB) $(LEVELDB_LIB)              \
        $(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ROOT)/jni/src/android_version.h
        @export NDEBUG=$$NDEBUG; $(MAKE) -j${PARALLEL} manifest;                   \
        export PATH=$$PATH:${SDKFOLDER}/platform-tools:${ANDROID_NDK};             \
index 3559c2b6d7e4e11b0dae528441fe85a0ec8c5807..f349631443ba99fd001679b2b17976bb75270f35 100644 (file)
@@ -7,10 +7,10 @@ LOCAL_MODULE := Irrlicht
 LOCAL_SRC_FILES := deps/irrlicht/lib/Android/libIrrlicht.a
 include $(PREBUILT_STATIC_LIBRARY)
 
-#include $(CLEAR_VARS)
-#LOCAL_MODULE := LevelDB
-#LOCAL_SRC_FILES := deps/leveldb/libleveldb.a
-#include $(PREBUILT_STATIC_LIBRARY)
+include $(CLEAR_VARS)
+LOCAL_MODULE := LevelDB
+LOCAL_SRC_FILES := deps/leveldb/libleveldb.a
+include $(PREBUILT_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := curl
@@ -62,6 +62,7 @@ LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
                                -DUSE_CURL=1             \
                                -DUSE_SOUND=1            \
                                -DUSE_FREETYPE=1         \
+                               -DUSE_LEVELDB=1          \
                                $(GPROF_DEF)             \
                                -pipe -fstrict-aliasing
 
@@ -93,9 +94,8 @@ LOCAL_C_INCLUDES :=                               \
                deps/freetype2-android/include            \
                deps/curl-7.35.0/include                  \
                deps/openal-soft/jni/OpenAL/include       \
-               deps/libvorbis-libogg-android/jni/include
-               
-#              deps/leveldb/include                      \
+               deps/libvorbis-libogg-android/jni/include \
+               deps/leveldb/include                      \
 
 LOCAL_SRC_FILES :=                                \
                jni/src/ban.cpp                           \
@@ -205,9 +205,8 @@ LOCAL_SRC_FILES :=                                \
                jni/src/util/serialize.cpp                \
                jni/src/util/string.cpp                   \
                jni/src/util/timetaker.cpp                \
-               jni/src/touchscreengui.cpp
-               
-#              jni/src/database-leveldb.cpp              \
+               jni/src/touchscreengui.cpp                \
+               jni/src/database-leveldb.cpp
 
 # lua api
 LOCAL_SRC_FILES +=                                \
@@ -297,8 +296,7 @@ LOCAL_SRC_FILES +=                                \
 LOCAL_SRC_FILES += jni/src/json/jsoncpp.cpp
 
 LOCAL_SHARED_LIBRARIES := openal ogg vorbis ssl crypto
-LOCAL_STATIC_LIBRARIES := Irrlicht freetype curl android_native_app_glue $(PROFILER_LIBS)
-# LevelDB
+LOCAL_STATIC_LIBRARIES := Irrlicht freetype curl LevelDB android_native_app_glue $(PROFILER_LIBS)
 LOCAL_LDLIBS := -lEGL -llog -lGLESv1_CM -lGLESv2 -lz -landroid
 
 include $(BUILD_SHARED_LIBRARY)
index 7f7850719ee4e0116986dcbf5ddd6f3247c3f0d1..3ec13a1a26acdcc3ee5e0613ae7bbed8ce8891a2 100644 (file)
@@ -187,12 +187,12 @@ void Database_SQLite3::saveBlock(MapBlock *block)
        const char *bytes = tmp.c_str();
 
        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;
+               errorstream<<"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
-               infostream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
+               errorstream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
        int written = sqlite3_step(m_database_write);
        if(written != SQLITE_DONE)
-               infostream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") "
+               errorstream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") "
                <<sqlite3_errmsg(m_database)<<std::endl;
        // Make ready for later reuse
        sqlite3_reset(m_database_write);
index 95ae9ef9856ea9bc651c6a7842dac012dcb9df33..1030d535a7b51613c3e1bd2350b4edb939153c92 100644 (file)
@@ -242,7 +242,12 @@ bool initializeWorld(const std::string &path, const std::string &gameid)
                infostream<<"Creating world.mt ("<<worldmt_path<<")"<<std::endl;
                fs::CreateAllDirs(path);
                std::ostringstream ss(std::ios_base::binary);
-               ss<<"gameid = "<<gameid<<"\nbackend = sqlite3\n";
+               ss<<"gameid = "<<gameid<<
+#ifdef __ANDROID__
+                               "\nbackend = leveldb\n";
+#else
+                               "\nbackend = sqlite3\n";
+#endif
                fs::safeWriteToFile(worldmt_path, ss.str());
        }
        return true;