From 0c9be8ecc99bb4b295907f08a26234b873be2378 Mon Sep 17 00:00:00 2001 From: JJBcku <154745800+JJBcku@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:38:25 +0200 Subject: [PATCH] Added reputation spillover to quest_template I have added per quest reputation spillover data, and changed the code to utilize that data. Current changes are made to perfectly mimic previous behavior. The purpose of this commit is only to create basis for future changes of quest's reputation spillover. --- .../z2825_01_mangos_reputation_spillover.sql | 3 +++ src/game/Entities/Player.cpp | 2 +- src/game/Globals/ObjectMgr.cpp | 4 ++-- src/game/Quests/QuestDef.cpp | 1 + src/game/Quests/QuestDef.h | 2 ++ src/game/Reputation/ReputationMgr.cpp | 21 +++++++++++-------- src/game/Reputation/ReputationMgr.h | 10 ++++----- src/shared/revision_sql.h | 2 +- 8 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql diff --git a/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql b/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql new file mode 100644 index 0000000000..7a7600f025 --- /dev/null +++ b/sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql @@ -0,0 +1,3 @@ +ALTER TABLE db_version CHANGE COLUMN required_z2824_01_mangos_model_unification required_z2825_01_mangos_reputation_spillover bit; + +ALTER TABLE quest_template ADD COLUMN ReputationSpillover tinyint unsigned NOT NULL DEFAULT '1'; diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index c02b06108d..b93115c13e 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -6395,7 +6395,7 @@ void Player::RewardReputation(Quest const* pQuest) int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i], pQuest->RewRepFaction[i], GetQuestLevelForPlayer(pQuest)); if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) - GetReputationMgr().ModifyReputation(factionEntry, rep); + GetReputationMgr().ModifyReputation(factionEntry, rep, pQuest->GetReputationSpillover() == 1); } } diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index d46e86d88d..cbb1151ef5 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -4138,8 +4138,8 @@ void ObjectMgr::LoadQuests() "IncompleteEmote, IncompleteEmoteDelay, CompleteEmote, CompleteEmoteDelay, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," // 122 123 124 125 "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4," - // 126 127 128 129 - "StartScript, CompleteScript, RequiredCondition, BreadcrumbForQuestId" + // 126 127 128 129 130 + "StartScript, CompleteScript, RequiredCondition, BreadcrumbForQuestId, ReputationSpillover" " FROM quest_template"); if (!queryResult) { diff --git a/src/game/Quests/QuestDef.cpp b/src/game/Quests/QuestDef.cpp index cf470f9a3a..3ba27bfd29 100644 --- a/src/game/Quests/QuestDef.cpp +++ b/src/game/Quests/QuestDef.cpp @@ -137,6 +137,7 @@ Quest::Quest(Field* questRecord) QuestCompleteScript = questRecord[127].GetUInt32(); RequiredCondition = questRecord[128].GetUInt32(); + ReputationSpillover = questRecord[130].GetUInt32(); m_isActive = true; diff --git a/src/game/Quests/QuestDef.h b/src/game/Quests/QuestDef.h index 4374ad53a3..0972a15124 100644 --- a/src/game/Quests/QuestDef.h +++ b/src/game/Quests/QuestDef.h @@ -241,6 +241,7 @@ class Quest uint32 GetDetailsEmoteCount() const { return m_detailsemotecount; } uint32 GetQuestStartScript() const { return QuestStartScript; } uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } + uint32 GetReputationSpillover() const { return ReputationSpillover; } bool IsRepeatable() const { return (m_SpecialFlags & QUEST_SPECIAL_FLAG_REPEATABLE) != 0; } bool IsAutoComplete() const { return !QuestMethod; } @@ -346,6 +347,7 @@ class Quest uint32 CompleteEmoteDelay; uint32 QuestStartScript; uint32 QuestCompleteScript; + uint32 ReputationSpillover; }; enum QuestUpdateState diff --git a/src/game/Reputation/ReputationMgr.cpp b/src/game/Reputation/ReputationMgr.cpp index d49fdcdb4c..36cf56b321 100644 --- a/src/game/Reputation/ReputationMgr.cpp +++ b/src/game/Reputation/ReputationMgr.cpp @@ -263,24 +263,27 @@ void ReputationMgr::Initialize() } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool reputationSpillover) { if (!factionEntry) return false; bool res = false; - // if spillover definition exists in DB - if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) + if (reputationSpillover) { - for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) + // if spillover definition exists in DB + if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) { - if (repTemplate->faction[i]) + for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) { - if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i])) + if (repTemplate->faction[i]) { - // bonuses are already given, so just modify standing by rate - int32 spilloverRep = standing * repTemplate->faction_rate[i]; - SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental); + if (m_player->GetReputationRank(repTemplate->faction[i]) <= ReputationRank(repTemplate->faction_rank[i])) + { + // bonuses are already given, so just modify standing by rate + int32 spilloverRep = standing * repTemplate->faction_rate[i]; + SetOneFactionReputation(sFactionStore.LookupEntry(repTemplate->faction[i]), spilloverRep, incremental); + } } } } diff --git a/src/game/Reputation/ReputationMgr.h b/src/game/Reputation/ReputationMgr.h index 30be71da04..5afccadeb3 100644 --- a/src/game/Reputation/ReputationMgr.h +++ b/src/game/Reputation/ReputationMgr.h @@ -87,13 +87,13 @@ class ReputationMgr ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const; public: // modifiers - bool SetReputation(FactionEntry const* factionEntry, int32 standing) + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool reputationSpillover = true) { - return SetReputation(factionEntry, standing, false); + return SetReputation(factionEntry, standing, false, reputationSpillover); } - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing) + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool reputationSpillover = true) { - return SetReputation(factionEntry, standing, true); + return SetReputation(factionEntry, standing, true, reputationSpillover); } void SetVisible(FactionTemplateEntry const* factionTemplateEntry); @@ -111,7 +111,7 @@ class ReputationMgr private: // internal helper functions void Initialize(); uint32 GetDefaultStateFlags(const FactionEntry* factionEntry) const; - bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool reputationSpillover); bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); void SetVisible(FactionState* faction); void SetAtWar(FactionState* faction, bool atWar); diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 26f9881b16..22199e995b 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -3,5 +3,5 @@ #define REVISION_DB_REALMD "required_z2820_01_realmd_joindate_datetime" #define REVISION_DB_LOGS "required_z2778_01_logs_anticheat" #define REVISION_DB_CHARACTERS "required_z2819_01_characters_item_instance_text_id_fix" - #define REVISION_DB_MANGOS "required_z2824_01_mangos_model_unification" + #define REVISION_DB_MANGOS "required_z2825_01_mangos_reputation_spillover" #endif // __REVISION_SQL_H__