Change SkyWayFlags to blob for consistency

This commit is contained in:
Kamil 2020-12-07 13:56:05 +01:00 committed by Gent S
parent 7aef973ef1
commit 66ecc45fce

View File

@ -212,8 +212,7 @@ void Database::createTables() {
"BatteryN" INTEGER DEFAULT 0 NOT NULL, "BatteryN" INTEGER DEFAULT 0 NOT NULL,
"Mentor" INTEGER DEFAULT 5 NOT NULL, "Mentor" INTEGER DEFAULT 5 NOT NULL,
"WarpLocationFlag" INTEGER DEFAULT 0 NOT NULL, "WarpLocationFlag" INTEGER DEFAULT 0 NOT NULL,
"SkywayLocationFlag1" INTEGER DEFAULT 0 NOT NULL, "SkywayLocationFlag" BLOB NOT NULL,
"SkywayLocationFlag2" INTEGER DEFAULT 0 NOT NULL,
"CurrentMissionID" INTEGER DEFAULT 0 NOT NULL, "CurrentMissionID" INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY("PlayerID" AUTOINCREMENT), PRIMARY KEY("PlayerID" AUTOINCREMENT),
FOREIGN KEY("AccountID") REFERENCES "Accounts"("AccountID") ON DELETE CASCADE, FOREIGN KEY("AccountID") REFERENCES "Accounts"("AccountID") ON DELETE CASCADE,
@ -513,8 +512,8 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
const char* sql = R"( const char* sql = R"(
INSERT INTO "Players" INSERT INTO "Players"
("AccountID", "Slot", "Firstname", "LastName", "XCoordinates" , "YCoordinates", "ZCoordinates", "Angle", ("AccountID", "Slot", "Firstname", "LastName", "XCoordinates" , "YCoordinates", "ZCoordinates", "Angle",
"HP", "NameCheck", "Quests") "HP", "NameCheck", "Quests", "SkywayLocationFlag")
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
)"; )";
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
std::string firstName = U16toU8(save->szFirstName); std::string firstName = U16toU8(save->szFirstName);
@ -535,9 +534,10 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
int nameCheck = (settings::APPROVEALLNAMES || save->iFNCode) ? 1 : 0; int nameCheck = (settings::APPROVEALLNAMES || save->iFNCode) ? 1 : 0;
sqlite3_bind_int(stmt, 10, nameCheck); sqlite3_bind_int(stmt, 10, nameCheck);
// 128 byte blob for completed quests // blobs
unsigned char blobBuffer[128] = { 0 }; unsigned char blobBuffer[128] = { 0 };
sqlite3_bind_blob(stmt, 11, blobBuffer, sizeof(blobBuffer), 0); sqlite3_bind_blob(stmt, 11, blobBuffer, 128, 0);
sqlite3_bind_blob(stmt, 12, blobBuffer, 16, 0);
int rc = sqlite3_step(stmt); int rc = sqlite3_step(stmt);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
@ -932,7 +932,7 @@ void Database::getPlayer(Player* plr, int id) {
p.XCoordinates, p.YCoordinates, p.ZCoordinates, p.NameCheck, p.XCoordinates, p.YCoordinates, p.ZCoordinates, p.NameCheck,
p.Angle, p.HP, acc.AccountLevel, p.FusionMatter, p.Taros, p.Quests, p.Angle, p.HP, acc.AccountLevel, p.FusionMatter, p.Taros, p.Quests,
p.BatteryW, p.BatteryN, p.Mentor, p.WarpLocationFlag, p.BatteryW, p.BatteryN, p.Mentor, p.WarpLocationFlag,
p.SkywayLocationFlag1, p.SkywayLocationFlag2, p.CurrentMissionID, p.SkywayLocationFlag, p.CurrentMissionID,
a.Body, a.EyeColor, a.FaceStyle, a.Gender, a.HairColor, a.HairStyle, a.Height, a.SkinColor a.Body, a.EyeColor, a.FaceStyle, a.Gender, a.HairColor, a.HairStyle, a.Height, a.SkinColor
FROM "Players" as p FROM "Players" as p
INNER JOIN "Appearances" as a ON p.PlayerID = a.PlayerID INNER JOIN "Appearances" as a ON p.PlayerID = a.PlayerID
@ -988,18 +988,18 @@ void Database::getPlayer(Player* plr, int id) {
plr->mentor = sqlite3_column_int(stmt, 23); plr->mentor = sqlite3_column_int(stmt, 23);
plr->iWarpLocationFlag = sqlite3_column_int(stmt, 24); plr->iWarpLocationFlag = sqlite3_column_int(stmt, 24);
plr->aSkywayLocationFlag[0] = sqlite3_column_int64(stmt, 25); memcpy(plr->aSkywayLocationFlag, sqlite3_column_blob(stmt, 25), sizeof(plr->aSkywayLocationFlag));
plr->aSkywayLocationFlag[1] = sqlite3_column_int64(stmt, 26);
plr->CurrentMissionID = sqlite3_column_int(stmt, 27); plr->CurrentMissionID = sqlite3_column_int(stmt, 26);
plr->PCStyle.iBody = sqlite3_column_int(stmt, 28); plr->PCStyle.iBody = sqlite3_column_int(stmt, 27);
plr->PCStyle.iEyeColor = sqlite3_column_int(stmt, 29); plr->PCStyle.iEyeColor = sqlite3_column_int(stmt, 28);
plr->PCStyle.iFaceStyle = sqlite3_column_int(stmt, 30); plr->PCStyle.iFaceStyle = sqlite3_column_int(stmt, 29);
plr->PCStyle.iGender = sqlite3_column_int(stmt, 31); plr->PCStyle.iGender = sqlite3_column_int(stmt, 30);
plr->PCStyle.iHairColor = sqlite3_column_int(stmt, 32); plr->PCStyle.iHairColor = sqlite3_column_int(stmt, 31);
plr->PCStyle.iHairStyle = sqlite3_column_int(stmt, 33); plr->PCStyle.iHairStyle = sqlite3_column_int(stmt, 32);
plr->PCStyle.iHeight = sqlite3_column_int(stmt, 34); plr->PCStyle.iHeight = sqlite3_column_int(stmt, 33);
plr->PCStyle.iSkinColor = sqlite3_column_int(stmt, 35); plr->PCStyle.iSkinColor = sqlite3_column_int(stmt, 34);
// get inventory // get inventory
@ -1147,7 +1147,7 @@ void Database::updatePlayer(Player *player) {
"XCoordinates" = ?, "YCoordinates" = ?, "ZCoordinates" = ?, "XCoordinates" = ?, "YCoordinates" = ?, "ZCoordinates" = ?,
"Angle" = ?, "HP" = ?, "FusionMatter" = ?, "Taros" = ?, "Quests" = ?, "Angle" = ?, "HP" = ?, "FusionMatter" = ?, "Taros" = ?, "Quests" = ?,
"BatteryW" = ?, "BatteryN" = ?, "WarplocationFlag" = ?, "BatteryW" = ?, "BatteryN" = ?, "WarplocationFlag" = ?,
"SkywayLocationFlag1" = ?, "SkywayLocationFlag2" = ?, "CurrentMissionID" = ?, "SkywayLocationFlag" = ?, "CurrentMissionID" = ?,
"PayZoneFlag" = ? "PayZoneFlag" = ?
WHERE "PlayerID" = ? WHERE "PlayerID" = ?
)"; )";
@ -1178,13 +1178,13 @@ void Database::updatePlayer(Player *player) {
sqlite3_bind_int(stmt, 13, player->batteryW); sqlite3_bind_int(stmt, 13, player->batteryW);
sqlite3_bind_int(stmt, 14, player->batteryN); sqlite3_bind_int(stmt, 14, player->batteryN);
sqlite3_bind_int(stmt, 15, player->iWarpLocationFlag); sqlite3_bind_int(stmt, 15, player->iWarpLocationFlag);
sqlite3_bind_int64(stmt, 16, player->aSkywayLocationFlag[0]); sqlite3_bind_blob(stmt, 16, player->aSkywayLocationFlag, sizeof(player->aSkywayLocationFlag), 0);
sqlite3_bind_int64(stmt, 17, player->aSkywayLocationFlag[1]); sqlite3_bind_int(stmt, 17, player->CurrentMissionID);
sqlite3_bind_int(stmt, 18, player->CurrentMissionID); sqlite3_bind_int(stmt, 18, player->PCStyle2.iPayzoneFlag);
sqlite3_bind_int(stmt, 19, player->PCStyle2.iPayzoneFlag); sqlite3_bind_int(stmt, 19, player->iID);
sqlite3_bind_int(stmt, 20, player->iID);
if (sqlite3_step(stmt) != SQLITE_DONE) { int rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
std::cout << "[WARN] Database: Failed to save player to database" << std::endl; std::cout << "[WARN] Database: Failed to save player to database" << std::endl;