-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SQLite+Compressed save format (Phase 2 of v2 save format) (#5777)
* fix: clang-tidy should ignore changes to non-source files The `clang-tidy` CI step is breaking because it's trying to interpret all files in src/ and tests/ as CPP files. Thus when src/CMakeLists.txt is changed, it tries to parse that file as C++ and fails. Signed-off-by: David Li <[email protected]> * feat: V2 save format Implement new SQLite-based save format. New worlds can be configured to use V2. Existing worlds can be converted from the main menu. Existing V1 worlds should load exactly the same as before until converted. Signed-off-by: David Li <[email protected]> # Conflicts: # .github/workflows/manual-release.yml # .github/workflows/release.yml # Conflicts: # msvc-full-features/vcpkg.json * fix: Compiler warnings, OSX+Android Build Signed-off-by: David Li <[email protected]> * docs: Update docs with build instructions for v2 saves Signed-off-by: David Li <[email protected]> * Avoid ever-growing world names from the V2 conversion Ask the user to rename the backup world before they attempt another conversion. Signed-off-by: David Li <[email protected]> --------- Signed-off-by: David Li <[email protected]> Co-authored-by: Chaosvolt <[email protected]> Co-authored-by: scarf <[email protected]>
- Loading branch information
1 parent
e075571
commit cac9b08
Showing
27 changed files
with
724 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Reference: https://developer.android.com/ndk/guides/android_mk.html | ||
|
||
# Based on https://sqlite.org/android/file?name=sqlite3/src/main/jni/sqlite/Android.mk&ci=tip | ||
|
||
LOCAL_PATH:= $(call my-dir) | ||
include $(CLEAR_VARS) | ||
|
||
# If using SEE, uncomment the following: | ||
# LOCAL_CFLAGS += -DSQLITE_HAS_CODEC | ||
|
||
#Define HAVE_USLEEP, otherwise ALL sleep() calls take at least 1000ms | ||
LOCAL_CFLAGS += -DHAVE_USLEEP=1 | ||
|
||
# Enable SQLite extensions. | ||
LOCAL_CFLAGS += -DSQLITE_ENABLE_FTS5 | ||
LOCAL_CFLAGS += -DSQLITE_ENABLE_RTREE | ||
LOCAL_CFLAGS += -DSQLITE_ENABLE_FTS3 | ||
LOCAL_CFLAGS += -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE | ||
|
||
# This is important - it causes SQLite to use memory for temp files. Since | ||
# Android has no globally writable temp directory, if this is not defined the | ||
# application throws an exception when it tries to create a temp file. | ||
# | ||
LOCAL_CFLAGS += -DSQLITE_TEMP_STORE=3 | ||
|
||
LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA | ||
LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL | ||
LOCAL_CFLAGS += -U__APPLE__ | ||
LOCAL_CFLAGS += -DHAVE_STRCHRNUL=0 | ||
LOCAL_CFLAGS += -DSQLITE_USE_URI=1 | ||
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-int-to-pointer-cast | ||
LOCAL_CFLAGS += -Wno-uninitialized -Wno-parentheses | ||
LOCAL_CPPFLAGS += -Wno-conversion-null | ||
|
||
ifeq ($(TARGET_ARCH), arm) | ||
LOCAL_CFLAGS += -DPACKED="__attribute__ ((packed))" | ||
else | ||
LOCAL_CFLAGS += -DPACKED="" | ||
endif | ||
|
||
LOCAL_SRC_FILES := sqlite3.c | ||
|
||
LOCAL_C_INCLUDES += $(LOCAL_PATH) | ||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) | ||
|
||
LOCAL_MODULE := libsqlite3 | ||
LOCAL_LDLIBS += -ldl -llog | ||
|
||
include $(BUILD_SHARED_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "compress.h" | ||
|
||
#include <zlib.h> | ||
#include <vector> | ||
#include <string> | ||
#include <stdexcept> | ||
#include <cstddef> | ||
|
||
void zlib_compress( const std::string &input, std::vector<std::byte> &output ) | ||
{ | ||
uLongf compressedSize = compressBound( input.size() ); | ||
output.resize( compressedSize ); | ||
|
||
int result = compress2( | ||
reinterpret_cast<Bytef *>( output.data() ), | ||
&compressedSize, | ||
reinterpret_cast<const Bytef *>( input.data() ), | ||
input.size(), | ||
Z_BEST_SPEED | ||
); | ||
|
||
if( result != Z_OK ) { | ||
throw std::runtime_error( "Zlib compression error" ); | ||
} | ||
|
||
output.resize( compressedSize ); | ||
} | ||
|
||
void zlib_decompress( const void *compressed_data, int compressed_size, std::string &output ) | ||
{ | ||
// We need to guess at the decompressed size - we expect things to compress fairly well. | ||
uLongf decompressedSize = static_cast<uLongf>( compressed_size ) * 8; | ||
output.resize( decompressedSize ); | ||
|
||
int result; | ||
do { | ||
result = uncompress( | ||
reinterpret_cast<Bytef *>( output.data() ), | ||
&decompressedSize, | ||
reinterpret_cast<const Bytef *>( compressed_data ), | ||
compressed_size | ||
); | ||
|
||
if( result == Z_BUF_ERROR ) { | ||
decompressedSize *= 2; // Double the buffer size and retry | ||
output.resize( decompressedSize ); | ||
} else if( result != Z_OK ) { | ||
throw std::runtime_error( "Zlib decompression failed" ); | ||
} | ||
} while( result == Z_BUF_ERROR ); | ||
|
||
output.resize( decompressedSize ); | ||
} |
Oops, something went wrong.