From 2e55cad450815788c503fe2902dd248902e6d85b Mon Sep 17 00:00:00 2001 From: Alyst3r <59404251+Alyst3r@users.noreply.github.com> Date: Sun, 22 Oct 2023 04:45:50 +0200 Subject: [PATCH] refactor(DB/reputation_spillover_template): Reputation spillover table expansion (#14763) * Update ObjectMgr.cpp Rework to `ObjectMgr::LoadReputationSpilloverTemplate()` allowing more factons to be added. * Create reputation_spillover_template-update.sql Alteration to `reputation_spillover_template` table, update allowing to add two more factions. * Update SharedDefines.h `MAX_SPILLOVER_FACTIONS` is now equal 6 instead of 4. * Update reputation_spillover_template-update.sql Now it alters table instead recreating it. --- .../reputation_spillover_template-update.sql | 7 +++++++ src/server/game/Globals/ObjectMgr.cpp | 10 ++++++++-- src/server/shared/SharedDefines.h | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 data/sql/updates/pending_db_world/reputation_spillover_template-update.sql diff --git a/data/sql/updates/pending_db_world/reputation_spillover_template-update.sql b/data/sql/updates/pending_db_world/reputation_spillover_template-update.sql new file mode 100644 index 000000000..5433bc121 --- /dev/null +++ b/data/sql/updates/pending_db_world/reputation_spillover_template-update.sql @@ -0,0 +1,7 @@ +ALTER TABLE `reputation_spillover_template` + ADD COLUMN `faction5` SMALLINT UNSIGNED NOT NULL DEFAULT '0', + ADD COLUMN `rate_5` FLOAT NOT NULL DEFAULT '0', + ADD COLUMN `rank_5` TINYINT UNSIGNED NOT NULL DEFAULT '0', + ADD COLUMN `faction6` SMALLINT UNSIGNED NOT NULL DEFAULT '0', + ADD COLUMN `rate_6` FLOAT NOT NULL DEFAULT '0', + ADD COLUMN `rank_6` TINYINT UNSIGNED NOT NULL DEFAULT '0'; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 80804e9b5..ca07350a2 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7676,8 +7676,8 @@ void ObjectMgr::LoadReputationSpilloverTemplate() _repSpilloverTemplateStore.clear(); // for reload case - uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4 FROM reputation_spillover_template"); + uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 + QueryResult result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4, faction5, rate_5, rank_5, faction6, rate_6, rank_6 FROM reputation_spillover_template"); if (!result) { @@ -7706,6 +7706,12 @@ void ObjectMgr::LoadReputationSpilloverTemplate() repTemplate.faction[3] = fields[10].Get(); repTemplate.faction_rate[3] = fields[11].Get(); repTemplate.faction_rank[3] = fields[12].Get(); + repTemplate.faction[4] = fields[13].Get(); + repTemplate.faction_rate[4] = fields[14].Get(); + repTemplate.faction_rank[4] = fields[15].Get(); + repTemplate.faction[5] = fields[16].Get(); + repTemplate.faction_rate[5] = fields[17].Get(); + repTemplate.faction_rank[5] = fields[18].Get(); FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); diff --git a/src/server/shared/SharedDefines.h b/src/server/shared/SharedDefines.h index be1179b06..314f2d6c4 100644 --- a/src/server/shared/SharedDefines.h +++ b/src/server/shared/SharedDefines.h @@ -216,7 +216,7 @@ enum FactionTemplates #define MIN_REPUTATION_RANK (REP_HATED) #define MAX_REPUTATION_RANK 8 -#define MAX_SPILLOVER_FACTIONS 4 +#define MAX_SPILLOVER_FACTIONS 6 enum MoneyConstants {