mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Terminate if existing DB doesn't have meta table
This commit is contained in:
parent
156e9bf902
commit
166bfdfc4f
@ -64,12 +64,26 @@ void Database::checkMetaTable() {
|
|||||||
sqlite3_stmt* stmt;
|
sqlite3_stmt* stmt;
|
||||||
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
||||||
if (sqlite3_step(stmt) != SQLITE_ROW) {
|
if (sqlite3_step(stmt) != SQLITE_ROW) {
|
||||||
|
sqlite3_finalize(stmt);
|
||||||
std::cout << "[FATAL] Failed to check meta table" << std::endl;
|
std::cout << "[FATAL] Failed to check meta table" << std::endl;
|
||||||
terminate(0);
|
terminate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = sqlite3_column_int(stmt, 0);
|
int count = sqlite3_column_int(stmt, 0);
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
|
// check if there's other non-internal tables first
|
||||||
|
sql = R"(
|
||||||
|
SELECT COUNT (*) FROM sqlite_master WHERE type="table" AND name NOT LIKE "sqlite_%";
|
||||||
|
)";
|
||||||
|
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
||||||
|
if (sqlite3_step(stmt) != SQLITE_ROW || sqlite3_column_int(stmt, 0) != 0) {
|
||||||
|
sqlite3_finalize(stmt);
|
||||||
|
std::cout << "[FATAL] Existing DB is outdated" << std::endl;
|
||||||
|
terminate(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create meta table
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return createMetaTable();
|
return createMetaTable();
|
||||||
}
|
}
|
||||||
@ -608,7 +622,7 @@ bool Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character, int accountI
|
|||||||
"SkinColor" = ?
|
"SkinColor" = ?
|
||||||
WHERE "PlayerID" = ? ;
|
WHERE "PlayerID" = ? ;
|
||||||
)";
|
)";
|
||||||
sqlite3_prepare_v2(db, sql, -1, &stmt, 0);
|
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
||||||
|
|
||||||
sqlite3_bind_int(stmt, 1, character->PCStyle.iBody);
|
sqlite3_bind_int(stmt, 1, character->PCStyle.iBody);
|
||||||
sqlite3_bind_int(stmt, 2, character->PCStyle.iEyeColor);
|
sqlite3_bind_int(stmt, 2, character->PCStyle.iEyeColor);
|
||||||
|
Loading…
Reference in New Issue
Block a user