From 81d9ab3dd045216ab386a6bda969bb5709a3d0da Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:48:32 -0600 Subject: [PATCH] Change char_id to character_id for bot_settings --- .../database_update_manifest_bots.cpp | 4 +-- .../base/base_bot_settings_repository.h | 32 +++++++++---------- zone/bot_database.cpp | 14 ++++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/common/database/database_update_manifest_bots.cpp b/common/database/database_update_manifest_bots.cpp index 748ca5962..76f564baf 100644 --- a/common/database/database_update_manifest_bots.cpp +++ b/common/database/database_update_manifest_bots.cpp @@ -171,7 +171,7 @@ CHANGE COLUMN `spellid` `spell_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 AFTER .match = "", .sql = R"( CREATE TABLE `bot_settings` ( - `char_id` INT(10) UNSIGNED NOT NULL, + `character_id` INT(10) UNSIGNED NOT NULL, `bot_id` INT(10) UNSIGNED NOT NULL, `stance` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `setting_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', @@ -179,7 +179,7 @@ CREATE TABLE `bot_settings` ( `value` INT(10) UNSIGNED NOT NULL, `category_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', `setting_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci', - PRIMARY KEY (`char_id`, `bot_id`, `stance`, `setting_id`, `setting_type`) USING BTREE + PRIMARY KEY (`character_id`, `bot_id`, `stance`, `setting_id`, `setting_type`) USING BTREE ) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB diff --git a/common/repositories/base/base_bot_settings_repository.h b/common/repositories/base/base_bot_settings_repository.h index 7595a4933..8fbaff17d 100644 --- a/common/repositories/base/base_bot_settings_repository.h +++ b/common/repositories/base/base_bot_settings_repository.h @@ -19,7 +19,7 @@ class BaseBotSettingsRepository { public: struct BotSettings { - uint32_t char_id; + uint32_t character_id; uint32_t bot_id; uint8_t stance; uint16_t setting_id; @@ -31,13 +31,13 @@ public: static std::string PrimaryKey() { - return std::string("char_id"); + return std::string("character_id"); } static std::vector Columns() { return { - "char_id", + "character_id", "bot_id", "stance", "setting_id", @@ -51,7 +51,7 @@ public: static std::vector SelectColumns() { return { - "char_id", + "character_id", "bot_id", "stance", "setting_id", @@ -99,7 +99,7 @@ public: { BotSettings e{}; - e.char_id = 0; + e.character_id = 0; e.bot_id = 0; e.stance = 0; e.setting_id = 0; @@ -117,7 +117,7 @@ public: ) { for (auto &bot_settings : bot_settingss) { - if (bot_settings.char_id == bot_settings_id) { + if (bot_settings.character_id == bot_settings_id) { return bot_settings; } } @@ -143,7 +143,7 @@ public: if (results.RowCount() == 1) { BotSettings e{}; - e.char_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; @@ -184,7 +184,7 @@ public: auto columns = Columns(); - v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[0] + " = " + std::to_string(e.character_id)); v.push_back(columns[1] + " = " + std::to_string(e.bot_id)); v.push_back(columns[2] + " = " + std::to_string(e.stance)); v.push_back(columns[3] + " = " + std::to_string(e.setting_id)); @@ -199,7 +199,7 @@ public: TableName(), Strings::Implode(", ", v), PrimaryKey(), - e.char_id + e.character_id ) ); @@ -213,7 +213,7 @@ public: { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.stance)); v.push_back(std::to_string(e.setting_id)); @@ -231,7 +231,7 @@ public: ); if (results.Success()) { - e.char_id = results.LastInsertedID(); + e.character_id = results.LastInsertedID(); return e; } @@ -250,7 +250,7 @@ public: for (auto &e: entries) { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.stance)); v.push_back(std::to_string(e.setting_id)); @@ -291,7 +291,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotSettings e{}; - e.char_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; @@ -323,7 +323,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotSettings e{}; - e.char_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; @@ -405,7 +405,7 @@ public: { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.stance)); v.push_back(std::to_string(e.setting_id)); @@ -435,7 +435,7 @@ public: for (auto &e: entries) { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.stance)); v.push_back(std::to_string(e.setting_id)); diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 760108ad9..5313a2efb 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -2220,7 +2220,7 @@ bool BotDatabase::LoadBotSettings(Mob* m) std::string query = ""; if (m->IsClient()) { - query = fmt::format("`char_id` = {} AND `stance` = {}", mob_id, stance_id); + query = fmt::format("`character_id` = {} AND `stance` = {}", mob_id, stance_id); } else { query = fmt::format("`bot_id` = {} AND `stance` = {}", mob_id, stance_id); @@ -2274,7 +2274,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) } uint32 bot_id = (m->IsBot() ? m->CastToBot()->GetBotID() : 0); - uint32 char_id = (m->IsClient() ? m->CastToClient()->CharacterID() : 0); + uint32 character_id = (m->IsClient() ? m->CastToClient()->CharacterID() : 0); uint8 stance_id = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0); if (stance_id == Stance::Passive) { @@ -2285,7 +2285,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) std::string query = ""; if (m->IsClient()) { - query = fmt::format("`char_id` = {} AND `stance` = {}", char_id, stance_id); + query = fmt::format("`character_id` = {} AND `stance` = {}", character_id, stance_id); } else { query = fmt::format("`bot_id` = {} AND `stance` = {}", bot_id, stance_id); @@ -2301,7 +2301,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) for (uint16 i = BotBaseSettings::START_ALL; i <= BotBaseSettings::END; ++i) { if (m->CastToBot()->GetBotBaseSetting(i) != m->CastToBot()->GetDefaultBotBaseSetting(i, bot_stance)) { auto e = BotSettingsRepository::BotSettings{ - .char_id = char_id, + .character_id = character_id, .bot_id = bot_id, .stance = stance_id, .setting_id = static_cast(i), @@ -2321,7 +2321,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) for (uint16 x = BotSpellTypes::START; x <= BotSpellTypes::END; ++x) { if (m->CastToBot()->GetSetting(i, x) != m->CastToBot()->GetDefaultSetting(i, x, bot_stance)) { auto e = BotSettingsRepository::BotSettings{ - .char_id = char_id, + .character_id = character_id, .bot_id = bot_id, .stance = stance_id, .setting_id = static_cast(x), @@ -2342,7 +2342,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) if (m->IsClient()) { if (m->CastToClient()->GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock) != m->GetIllusionBlock()) { // Only illusion block supported auto e = BotSettingsRepository::BotSettings{ - .char_id = char_id, + .character_id = character_id, .bot_id = bot_id, .stance = stance_id, .setting_id = static_cast(BotBaseSettings::IllusionBlock), @@ -2362,7 +2362,7 @@ bool BotDatabase::SaveBotSettings(Mob* m) LogBotSettings("{} says, 'Checking {} {} [{}] - set to [{}] default [{}].'", m->GetCleanName(), m->GetBotSpellCategoryName(i), m->CastToBot()->GetSpellTypeNameByID(x), x, m->CastToClient()->GetBotSetting(i, x), m->CastToClient()->GetDefaultBotSettings(i, x)); if (m->CastToClient()->GetBotSetting(i, x) != m->CastToClient()->GetDefaultBotSettings(i, x)) { auto e = BotSettingsRepository::BotSettings{ - .char_id = char_id, + .character_id = character_id, .bot_id = bot_id, .stance = stance_id, .setting_id = static_cast(x),