From 9e242995e93d4134b39aee792fc221f861d292e3 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Fri, 15 Nov 2024 01:05:05 -0800 Subject: [PATCH] use SQLite types --- .../MySQL/Tables/MigrationHistory.cpp | 2 +- dGame/EntityManager.cpp | 1 - migrations/dlu/0_initial.sql | 140 +++++++++--------- migrations/dlu/10_Security_updates.sql | 4 +- .../dlu/11_fix_cheat_detection_table.sql | 4 +- migrations/dlu/14_reward_codes.sql | 4 +- migrations/dlu/16_big_behaviors.sql | 2 +- migrations/dlu/2_reporter_id.sql | 2 +- migrations/dlu/3_add_performance_cost.sql | 2 +- migrations/dlu/6_property_behaviors.sql | 12 +- .../dlu/7_make_play_key_id_nullable.sql | 2 +- migrations/dlu/8_foreign_play_key.sql | 2 +- .../dlu/9_Update_Leaderboard_Storage.sql | 14 +- 13 files changed, 95 insertions(+), 96 deletions(-) diff --git a/dDatabase/GameDatabase/MySQL/Tables/MigrationHistory.cpp b/dDatabase/GameDatabase/MySQL/Tables/MigrationHistory.cpp index e8b1d549..a0afc341 100644 --- a/dDatabase/GameDatabase/MySQL/Tables/MigrationHistory.cpp +++ b/dDatabase/GameDatabase/MySQL/Tables/MigrationHistory.cpp @@ -5,7 +5,7 @@ void MySQLDatabase::CreateMigrationHistoryTable() { } bool MySQLDatabase::IsMigrationRun(const std::string_view str) { - return ExecuteSelect("SELECT name FROM migration_history WHERE name = \"%?%\";", str)->next(); + return ExecuteSelect("SELECT name FROM migration_history WHERE name = ?;", str)->next(); } void MySQLDatabase::InsertMigration(const std::string_view str) { diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index c95af3d7..aa83f69a 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -505,7 +505,6 @@ void EntityManager::UpdateGhosting(Entity* player) { if (collectionId != 0) { collectionId = static_cast(collectionId) + static_cast(Game::server->GetZoneID() << 8); - if (missionComponent->HasCollectible(collectionId)) { continue; } diff --git a/migrations/dlu/0_initial.sql b/migrations/dlu/0_initial.sql index 522e556f..4a454067 100644 --- a/migrations/dlu/0_initial.sql +++ b/migrations/dlu/0_initial.sql @@ -1,152 +1,152 @@ CREATE TABLE IF NOT EXISTS accounts ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(35) NOT NULL UNIQUE, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name TEXT NOT NULL UNIQUE, password TEXT NOT NULL, - gm_level INT UNSIGNED NOT NULL DEFAULT 0, - locked BOOLEAN NOT NULL DEFAULT FALSE, - banned BOOLEAN NOT NULL DEFAULT FALSE, - play_key_id INT NOT NULL DEFAULT 0, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), - mute_expire BIGINT UNSIGNED NOT NULL DEFAULT 0 + gm_level BIGINT NOT NULL DEFAULT 0, + locked INTEGER NOT NULL DEFAULT FALSE, + banned INTEGER NOT NULL DEFAULT FALSE, + play_key_id INTEGER NOT NULL DEFAULT 0, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), + mute_expire BIGINT NOT NULL DEFAULT 0 ); CREATE TABLE IF NOT EXISTS charinfo ( id BIGINT NOT NULL PRIMARY KEY, - account_id INT NOT NULL REFERENCES accounts(id), - name VARCHAR(35) NOT NULL, - pending_name VARCHAR(35) NOT NULL, - needs_rename BOOLEAN NOT NULL DEFAULT FALSE, - prop_clone_id BIGINT UNSIGNED AUTO_INCREMENT UNIQUE, - last_login BIGINT UNSIGNED NOT NULL DEFAULT 0, - permission_map BIGINT UNSIGNED NOT NULL DEFAULT 0 + account_id INTEGER NOT NULL REFERENCES accounts(id), + name TEXT NOT NULL, + pending_name TEXT NOT NULL, + needs_rename INTEGER NOT NULL DEFAULT FALSE, + prop_clone_id BIGINT AUTO_INCREMENT UNIQUE, + last_login BIGINT NOT NULL DEFAULT 0, + permission_map BIGINT NOT NULL DEFAULT 0 ); CREATE TABLE IF NOT EXISTS charxml ( id BIGINT NOT NULL PRIMARY KEY REFERENCES charinfo(id), - xml_data LONGTEXT NOT NULL + xml_data TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS command_log ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, character_id BIGINT NOT NULL REFERENCES charinfo(id), - command VARCHAR(256) NOT NULL + command TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS friends ( player_id BIGINT NOT NULL REFERENCES charinfo(id), friend_id BIGINT NOT NULL REFERENCES charinfo(id), - best_friend BOOLEAN NOT NULL DEFAULT FALSE, + best_friend INTEGER NOT NULL DEFAULT FALSE, PRIMARY KEY (player_id, friend_id) ); CREATE TABLE IF NOT EXISTS leaderboard ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - game_id INT UNSIGNED NOT NULL DEFAULT 0, - last_played TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + game_id INTEGER NOT NULL DEFAULT 0, + last_played DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), character_id BIGINT NOT NULL REFERENCES charinfo(id), - time BIGINT UNSIGNED NOT NULL, - score BIGINT UNSIGNED NOT NULL DEFAULT 0 + time BIGINT NOT NULL, + score BIGINT NOT NULL DEFAULT 0 ); CREATE TABLE IF NOT EXISTS mail ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - sender_id INT NOT NULL DEFAULT 0, - sender_name VARCHAR(35) NOT NULL DEFAULT '', + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + sender_id INTEGER NOT NULL DEFAULT 0, + sender_name TEXT NOT NULL DEFAULT '', receiver_id BIGINT NOT NULL REFERENCES charinfo(id), - receiver_name VARCHAR(35) NOT NULL, - time_sent BIGINT UNSIGNED NOT NULL, + receiver_name TEXT NOT NULL, + time_sent BIGINT NOT NULL, subject TEXT NOT NULL, body TEXT NOT NULL, attachment_id BIGINT NOT NULL DEFAULT 0, - attachment_lot INT NOT NULL DEFAULT 0, + attachment_lot INTEGER NOT NULL DEFAULT 0, attachment_subkey BIGINT NOT NULL DEFAULT 0, - attachment_count INT NOT NULL DEFAULT 0, - was_read BOOLEAN NOT NULL DEFAULT FALSE + attachment_count INTEGER NOT NULL DEFAULT 0, + was_read INTEGER NOT NULL DEFAULT FALSE ); CREATE TABLE IF NOT EXISTS object_id_tracker ( - last_object_id BIGINT UNSIGNED NOT NULL DEFAULT 0 PRIMARY KEY + last_object_id BIGINT NOT NULL DEFAULT 0 PRIMARY KEY ); CREATE TABLE IF NOT EXISTS pet_names ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, pet_name TEXT NOT NULL, - approved INT UNSIGNED NOT NULL + approved INTEGER NOT NULL ); CREATE TABLE IF NOT EXISTS play_keys ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - key_string CHAR(19) NOT NULL UNIQUE, - key_uses INT NOT NULL DEFAULT 1, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), - active BOOLEAN NOT NULL DEFAULT TRUE + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + key_string TEXT NOT NULL UNIQUE, + key_uses INTEGER NOT NULL DEFAULT 1, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), + active INTEGER NOT NULL DEFAULT TRUE ); CREATE TABLE IF NOT EXISTS properties ( id BIGINT NOT NULL PRIMARY KEY, owner_id BIGINT NOT NULL REFERENCES charinfo(id), - template_id INT UNSIGNED NOT NULL, - clone_id BIGINT UNSIGNED REFERENCES charinfo(prop_clone_id), + template_id INTEGER NOT NULL, + clone_id BIGINT REFERENCES charinfo(prop_clone_id), name TEXT NOT NULL, description TEXT NOT NULL, - rent_amount INT NOT NULL, + rent_amount INTEGER NOT NULL, rent_due BIGINT NOT NULL, - privacy_option INT NOT NULL, - mod_approved BOOLEAN NOT NULL DEFAULT FALSE, + privacy_option INTEGER NOT NULL, + mod_approved INTEGER NOT NULL DEFAULT FALSE, last_updated BIGINT NOT NULL, time_claimed BIGINT NOT NULL, rejection_reason TEXT NOT NULL, - reputation BIGINT UNSIGNED NOT NULL, - zone_id INT NOT NULL + reputation BIGINT NOT NULL, + zone_id INTEGER NOT NULL ); CREATE TABLE IF NOT EXISTS ugc ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - account_id INT NOT NULL REFERENCES accounts(id), + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + account_id INTEGER NOT NULL REFERENCES accounts(id), character_id BIGINT NOT NULL REFERENCES charinfo(id), - is_optimized BOOLEAN NOT NULL DEFAULT FALSE, - lxfml MEDIUMBLOB NOT NULL, - bake_ao BOOLEAN NOT NULL DEFAULT FALSE, + is_optimized INTEGER NOT NULL DEFAULT FALSE, + lxfml BLOB NOT NULL, + bake_ao INTEGER NOT NULL DEFAULT FALSE, filename TEXT NOT NULL DEFAULT ('') ); CREATE TABLE IF NOT EXISTS properties_contents ( id BIGINT NOT NULL PRIMARY KEY, property_id BIGINT NOT NULL REFERENCES properties(id), - ugc_id INT NULL REFERENCES ugc(id), - lot INT NOT NULL, - x FLOAT NOT NULL, - y FLOAT NOT NULL, - z FLOAT NOT NULL, - rx FLOAT NOT NULL, - ry FLOAT NOT NULL, - rz FLOAT NOT NULL, - rw FLOAT NOT NULL + ugc_id INTEGER NULL REFERENCES ugc(id), + lot INTEGER NOT NULL, + x DOUBLE NOT NULL, + y DOUBLE NOT NULL, + z DOUBLE NOT NULL, + rx DOUBLE NOT NULL, + ry DOUBLE NOT NULL, + rz DOUBLE NOT NULL, + rw DOUBLE NOT NULL ); CREATE TABLE IF NOT EXISTS activity_log ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, character_id BIGINT NOT NULL REFERENCES charinfo(id), - activity INT NOT NULL, - time BIGINT UNSIGNED NOT NULL, - map_id INT NOT NULL + activity INTEGER NOT NULL, + time BIGINT NOT NULL, + map_id INTEGER NOT NULL ); CREATE TABLE IF NOT EXISTS bug_reports ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, body TEXT NOT NULL, client_version TEXT NOT NULL, other_player_id TEXT NOT NULL, selection TEXT NOT NULL, - submitted TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() + submitted DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP() ); CREATE TABLE IF NOT EXISTS servers ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name TEXT NOT NULL, ip TEXT NOT NULL, - port INT NOT NULL, - state INT NOT NULL, - version INT NOT NULL DEFAULT 0 + port INTEGER NOT NULL, + state INTEGER NOT NULL, + version INTEGER NOT NULL DEFAULT 0 ); diff --git a/migrations/dlu/10_Security_updates.sql b/migrations/dlu/10_Security_updates.sql index 4cbf51a0..d63012eb 100644 --- a/migrations/dlu/10_Security_updates.sql +++ b/migrations/dlu/10_Security_updates.sql @@ -1,8 +1,8 @@ CREATE TABLE IF NOT EXISTS player_cheat_detections ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, - account_id INT REFERENCES accounts(id), + account_id INTEGER REFERENCES accounts(id), name TEXT REFERENCES charinfo(name), violation_msg TEXT NOT NULL, - violation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), + violation_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), violation_system_address TEXT NOT NULL ); diff --git a/migrations/dlu/11_fix_cheat_detection_table.sql b/migrations/dlu/11_fix_cheat_detection_table.sql index 21464834..942b07e3 100644 --- a/migrations/dlu/11_fix_cheat_detection_table.sql +++ b/migrations/dlu/11_fix_cheat_detection_table.sql @@ -1,9 +1,9 @@ DROP TABLE IF EXISTS `player_cheat_detections`; CREATE TABLE IF NOT EXISTS player_cheat_detections ( id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, - account_id INT REFERENCES accounts(id), + account_id INTEGER REFERENCES accounts(id), name TEXT NOT NULL, violation_msg TEXT NOT NULL, - violation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), + violation_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), violation_system_address TEXT NOT NULL ); diff --git a/migrations/dlu/14_reward_codes.sql b/migrations/dlu/14_reward_codes.sql index a439df2e..ddadd7f2 100644 --- a/migrations/dlu/14_reward_codes.sql +++ b/migrations/dlu/14_reward_codes.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS accounts_rewardcodes ( - account_id INT NOT NULL REFERENCES accounts(id) ON DELETE CASCADE, - rewardcode INT NOT NULL, + account_id INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE, + rewardcode INTEGER NOT NULL, PRIMARY KEY (account_id, rewardcode) ); diff --git a/migrations/dlu/16_big_behaviors.sql b/migrations/dlu/16_big_behaviors.sql index 12edc0bc..fbc96e5e 100644 --- a/migrations/dlu/16_big_behaviors.sql +++ b/migrations/dlu/16_big_behaviors.sql @@ -1 +1 @@ -ALTER TABLE behaviors MODIFY behavior_info LONGTEXT DEFAULT NULL; +ALTER TABLE behaviors MODIFY behavior_info TEXT DEFAULT NULL; diff --git a/migrations/dlu/2_reporter_id.sql b/migrations/dlu/2_reporter_id.sql index 26103342..d386a8b9 100644 --- a/migrations/dlu/2_reporter_id.sql +++ b/migrations/dlu/2_reporter_id.sql @@ -1 +1 @@ -ALTER TABLE bug_reports ADD reporter_id INT NOT NULL DEFAULT 0; +ALTER TABLE bug_reports ADD reporter_id INTEGER NOT NULL DEFAULT 0; diff --git a/migrations/dlu/3_add_performance_cost.sql b/migrations/dlu/3_add_performance_cost.sql index 15da4470..cea7c076 100644 --- a/migrations/dlu/3_add_performance_cost.sql +++ b/migrations/dlu/3_add_performance_cost.sql @@ -1 +1 @@ -ALTER TABLE properties ADD COLUMN performance_cost DOUBLE(20, 15) DEFAULT 0.0; \ No newline at end of file +ALTER TABLE properties ADD COLUMN performance_cost DOUBLE DEFAULT 0.0; diff --git a/migrations/dlu/6_property_behaviors.sql b/migrations/dlu/6_property_behaviors.sql index b858db67..223ff536 100644 --- a/migrations/dlu/6_property_behaviors.sql +++ b/migrations/dlu/6_property_behaviors.sql @@ -1,11 +1,11 @@ ALTER TABLE properties_contents ADD COLUMN model_name TEXT NOT NULL DEFAULT "", ADD COLUMN model_description TEXT NOT NULL DEFAULT "", - ADD COLUMN behavior_1 INT NOT NULL DEFAULT 0, - ADD COLUMN behavior_2 INT NOT NULL DEFAULT 0, - ADD COLUMN behavior_3 INT NOT NULL DEFAULT 0, - ADD COLUMN behavior_4 INT NOT NULL DEFAULT 0, - ADD COLUMN behavior_5 INT NOT NULL DEFAULT 0; + ADD COLUMN behavior_1 INTEGER NOT NULL DEFAULT 0, + ADD COLUMN behavior_2 INTEGER NOT NULL DEFAULT 0, + ADD COLUMN behavior_3 INTEGER NOT NULL DEFAULT 0, + ADD COLUMN behavior_4 INTEGER NOT NULL DEFAULT 0, + ADD COLUMN behavior_5 INTEGER NOT NULL DEFAULT 0; UPDATE properties_contents SET model_name = CONCAT("Objects_", lot, "_name") WHERE model_name = ""; -CREATE TABLE IF NOT EXISTS behaviors (id INT NOT NULL, behavior_info TEXT NOT NULL); +CREATE TABLE IF NOT EXISTS behaviors (id INTEGER NOT NULL, behavior_info TEXT NOT NULL); diff --git a/migrations/dlu/7_make_play_key_id_nullable.sql b/migrations/dlu/7_make_play_key_id_nullable.sql index 11239967..0fb62ca2 100644 --- a/migrations/dlu/7_make_play_key_id_nullable.sql +++ b/migrations/dlu/7_make_play_key_id_nullable.sql @@ -1 +1 @@ -ALTER TABLE accounts MODIFY play_key_id INT DEFAULT 0; +ALTER TABLE accounts MODIFY play_key_id INTEGER DEFAULT 0; diff --git a/migrations/dlu/8_foreign_play_key.sql b/migrations/dlu/8_foreign_play_key.sql index 6f171bb5..0c2d453e 100644 --- a/migrations/dlu/8_foreign_play_key.sql +++ b/migrations/dlu/8_foreign_play_key.sql @@ -1 +1 @@ -ALTER TABLE accounts MODIFY play_key_id INT DEFAULT NULL; +ALTER TABLE accounts MODIFY play_key_id INTEGER DEFAULT NULL; diff --git a/migrations/dlu/9_Update_Leaderboard_Storage.sql b/migrations/dlu/9_Update_Leaderboard_Storage.sql index 9b5098eb..259e136a 100644 --- a/migrations/dlu/9_Update_Leaderboard_Storage.sql +++ b/migrations/dlu/9_Update_Leaderboard_Storage.sql @@ -1,12 +1,12 @@ ALTER TABLE leaderboard - ADD COLUMN tertiaryScore FLOAT NOT NULL DEFAULT 0, - ADD COLUMN numWins INT NOT NULL DEFAULT 0, - ADD COLUMN timesPlayed INT NOT NULL DEFAULT 1, - MODIFY time INT NOT NULL DEFAULT 0; + ADD COLUMN tertiaryScore DOUBLE NOT NULL DEFAULT 0, + ADD COLUMN numWins INTEGER NOT NULL DEFAULT 0, + ADD COLUMN timesPlayed INTEGER NOT NULL DEFAULT 1, + MODIFY time INTEGER NOT NULL DEFAULT 0; /* Can only ALTER one column at a time... */ -ALTER TABLE leaderboard CHANGE score primaryScore FLOAT NOT NULL DEFAULT 0; -ALTER TABLE leaderboard CHANGE time secondaryScore FLOAT NOT NULL DEFAULT 0 AFTER primaryScore; +ALTER TABLE leaderboard CHANGE score primaryScore DOUBLE NOT NULL DEFAULT 0; +ALTER TABLE leaderboard CHANGE time secondaryScore DOUBLE NOT NULL DEFAULT 0 AFTER primaryScore; /* A bit messy, but better than going through a bunch of code fixes all to be run once. */ UPDATE leaderboard SET @@ -15,4 +15,4 @@ UPDATE leaderboard SET /* Do this last so we dont update entry times erroneously */ ALTER TABLE leaderboard - CHANGE last_played last_played TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP(); + CHANGE last_played last_played DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP();