Fixes cross save problems due to architecture differences

This commit is contained in:
Linus Probert 2020-03-04 17:03:02 +01:00
parent de770ccc9f
commit 4edeb17ddc
1 changed files with 17 additions and 6 deletions

View File

@ -34,6 +34,7 @@ DbQuery MIGRATE_COMMAND = {
"major_version INTEGER, "
"minor_version INTEGER, "
"patch_version INTEGER, "
"arch INTEGER, "
"save BLOB)",
NULL, NULL
};
@ -53,9 +54,14 @@ save_load(void)
debug("Loading save");
const char *query =
"SELECT save FROM saves "
"WHERE major_version = ?"
"AND minor_version = ?"
"AND patch_version = ?"
"WHERE major_version = ? "
"AND minor_version = ? "
"AND patch_version = ? "
#ifdef _WIN32
"AND arch = 1 "
#else // _WIN32
"AND arch = 2 "
#endif // _WIN32
"LIMIT 1";
sqlite3_stmt *stmt = db_prepare(db, query);
@ -122,14 +128,19 @@ save_save(unsigned int seed,
const char *query =
"INSERT INTO saves"
"(major_version, minor_version, patch_version, save) "
"VALUES(?, ?, ?, ?)";
"(major_version, minor_version, patch_version, arch, save) "
"VALUES(?, ?, ?, ?, ?)";
sqlite3_stmt *stmt = db_prepare(db, query);
sqlite3_bind_int(stmt, 1, MAJOR_VERSION);
sqlite3_bind_int(stmt, 2, MINOR_VERSION);
sqlite3_bind_int(stmt, 3, PATCH_VERSION);
sqlite3_bind_blob(stmt, 4, &save, sizeof(Save), SQLITE_STATIC);
#ifdef _WIN32
sqlite3_bind_int(stmt, 4, 1);
#else // _WIN32
sqlite3_bind_int(stmt, 4, 2);
#endif // _WIN32
sqlite3_bind_blob(stmt, 5, &save, sizeof(Save), SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}