From 7dfda95d869a0c4b69a62a2bdf4b76545db7c5de Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:29:50 -0400 Subject: [PATCH] [Bug Fix] Fix Bot Spell Entries IDs Capping at 32,767 (#4444) * [Bug Fix] Fix Bot Spell Entries IDs Capping at 32,767 * Fix manifest --- .../database_update_manifest_bots.cpp | 11 +++++++ .../base/base_bot_spells_entries_repository.h | 24 +++++++-------- common/version.h | 2 +- zone/botspellsai.cpp | 29 ++++++++++--------- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/common/database/database_update_manifest_bots.cpp b/common/database/database_update_manifest_bots.cpp index 5aab3b782..48c9aa7f8 100644 --- a/common/database/database_update_manifest_bots.cpp +++ b/common/database/database_update_manifest_bots.cpp @@ -150,6 +150,17 @@ ADD COLUMN `augment_six` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_five .sql = R"( ALTER TABLE `bot_data` ADD COLUMN `extra_haste` mediumint(8) NOT NULL DEFAULT 0 AFTER `wis`; +)" + }, + ManifestEntry{ + .version = 9045, + .description = "2024_08_05_bot_spells_entries_unsigned_spell_id.sql", + .check = "SHOW COLUMNS FROM `bot_spells_entries` LIKE 'spell_id'", + .condition = "empty", + .match = "", + .sql = R"( +ALTER TABLE `bot_spells_entries` +CHANGE COLUMN `spellid` `spell_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `npc_spells_id`; )" } // -- template; copy/paste this when you need to create a new entry diff --git a/common/repositories/base/base_bot_spells_entries_repository.h b/common/repositories/base/base_bot_spells_entries_repository.h index b8c1fe5e1..f96d48745 100644 --- a/common/repositories/base/base_bot_spells_entries_repository.h +++ b/common/repositories/base/base_bot_spells_entries_repository.h @@ -21,7 +21,7 @@ public: struct BotSpellsEntries { uint32_t id; int32_t npc_spells_id; - int16_t spellid; + uint16_t spell_id; uint32_t type; uint8_t minlevel; uint8_t maxlevel; @@ -46,7 +46,7 @@ public: return { "id", "npc_spells_id", - "spellid", + "spell_id", "type", "minlevel", "maxlevel", @@ -67,7 +67,7 @@ public: return { "id", "npc_spells_id", - "spellid", + "spell_id", "type", "minlevel", "maxlevel", @@ -122,7 +122,7 @@ public: e.id = 0; e.npc_spells_id = 0; - e.spellid = 0; + e.spell_id = 0; e.type = 0; e.minlevel = 0; e.maxlevel = 255; @@ -173,7 +173,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -220,7 +220,7 @@ public: auto columns = Columns(); v.push_back(columns[1] + " = " + std::to_string(e.npc_spells_id)); - v.push_back(columns[2] + " = " + std::to_string(e.spellid)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); v.push_back(columns[3] + " = " + std::to_string(e.type)); v.push_back(columns[4] + " = " + std::to_string(e.minlevel)); v.push_back(columns[5] + " = " + std::to_string(e.maxlevel)); @@ -256,7 +256,7 @@ public: v.push_back(std::to_string(e.id)); v.push_back(std::to_string(e.npc_spells_id)); - v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.type)); v.push_back(std::to_string(e.minlevel)); v.push_back(std::to_string(e.maxlevel)); @@ -300,7 +300,7 @@ public: v.push_back(std::to_string(e.id)); v.push_back(std::to_string(e.npc_spells_id)); - v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.type)); v.push_back(std::to_string(e.minlevel)); v.push_back(std::to_string(e.maxlevel)); @@ -348,7 +348,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -387,7 +387,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -476,7 +476,7 @@ public: v.push_back(std::to_string(e.id)); v.push_back(std::to_string(e.npc_spells_id)); - v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.type)); v.push_back(std::to_string(e.minlevel)); v.push_back(std::to_string(e.maxlevel)); @@ -513,7 +513,7 @@ public: v.push_back(std::to_string(e.id)); v.push_back(std::to_string(e.npc_spells_id)); - v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.type)); v.push_back(std::to_string(e.minlevel)); v.push_back(std::to_string(e.maxlevel)); diff --git a/common/version.h b/common/version.h index 5b78b25af..b0d2ced90 100644 --- a/common/version.h +++ b/common/version.h @@ -43,7 +43,7 @@ */ #define CURRENT_BINARY_DATABASE_VERSION 9282 -#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9044 +#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9045 #endif diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 8bcd9ffd2..0050a58b2 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -3324,18 +3324,19 @@ DBbotspells_Struct* ZoneDatabase::GetBotSpells(uint32 bot_spell_id) if (!bse.empty()) { for (const auto& e : bse) { DBbotspells_entries_Struct entry; - entry.spellid = e.spellid; - entry.type = e.type; - entry.minlevel = e.minlevel; - entry.maxlevel = e.maxlevel; - entry.manacost = e.manacost; - entry.recast_delay = e.recast_delay; - entry.priority = e.priority; - entry.min_hp = e.min_hp; - entry.max_hp = e.max_hp; - entry.resist_adjust = e.resist_adjust; - entry.bucket_name = e.bucket_name; - entry.bucket_value = e.bucket_value; + + entry.spellid = e.spell_id; + entry.type = e.type; + entry.minlevel = e.minlevel; + entry.maxlevel = e.maxlevel; + entry.manacost = e.manacost; + entry.recast_delay = e.recast_delay; + entry.priority = e.priority; + entry.min_hp = e.min_hp; + entry.max_hp = e.max_hp; + entry.resist_adjust = e.resist_adjust; + entry.bucket_name = e.bucket_name; + entry.bucket_value = e.bucket_value; entry.bucket_comparison = e.bucket_comparison; // some spell types don't make much since to be priority 0, so fix that @@ -3345,8 +3346,8 @@ DBbotspells_Struct* ZoneDatabase::GetBotSpells(uint32 bot_spell_id) if (e.resist_adjust) { entry.resist_adjust = e.resist_adjust; - } else if (IsValidSpell(e.spellid)) { - entry.resist_adjust = spells[e.spellid].resist_difficulty; + } else if (IsValidSpell(e.spell_id)) { + entry.resist_adjust = spells[e.spell_id].resist_difficulty; } spell_set.entries.push_back(entry);