diff --git a/sql/base/mangos.sql b/sql/base/mangos.sql index e6fa539ca0..6dec088615 100644 --- a/sql/base/mangos.sql +++ b/sql/base/mangos.sql @@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `version` varchar(120) DEFAULT NULL, `creature_ai_version` varchar(120) DEFAULT NULL, - `required_z2824_01_mangos_model_unification` bit(1) DEFAULT NULL + `required_z2825_01_mangos_reputation_spillover` bit(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes'; -- @@ -10211,6 +10211,7 @@ CREATE TABLE `quest_template` ( `RewRepValue3` mediumint(9) NOT NULL DEFAULT '0', `RewRepValue4` mediumint(9) NOT NULL DEFAULT '0', `RewRepValue5` mediumint(9) NOT NULL DEFAULT '0', + `ReputationSpilloverMask` tinyint unsigned NOT NULL DEFAULT '0', `RewOrReqMoney` int(11) NOT NULL DEFAULT '0', `RewMoneyMaxLevel` int(10) unsigned NOT NULL DEFAULT '0', `RewSpell` mediumint(8) unsigned NOT NULL DEFAULT '0', 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..63c20f4975 --- /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 ReputationSpilloverMask tinyint unsigned NOT NULL DEFAULT '0' AFTER `RewRepValue5`; diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index 95be3184ad..2cda2b5cba 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -6387,12 +6387,12 @@ void Player::RewardReputation(Quest const* pQuest) { int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i], pQuest->RewRepFaction[i], GetQuestLevelForPlayer(pQuest)); + bool noSpillover = (pQuest->GetReputationSpilloverMask() & (1 << i)) != 0; + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) - GetReputationMgr().ModifyReputation(factionEntry, rep); + GetReputationMgr().ModifyReputation(factionEntry, rep, noSpillover); } } - - // TODO: implement reputation spillover } // Update honor fields , cleanKills is only used during char saving diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index 36a0564c1f..ac90d8159b 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -4132,8 +4132,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, ReputationSpilloverMask" " FROM quest_template"); if (!queryResult) { diff --git a/src/game/Quests/QuestDef.cpp b/src/game/Quests/QuestDef.cpp index cf470f9a3a..67d86220e3 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(); + ReputationSpilloverMask = questRecord[130].GetUInt32(); m_isActive = true; diff --git a/src/game/Quests/QuestDef.h b/src/game/Quests/QuestDef.h index cbf5a58770..4455b56605 100644 --- a/src/game/Quests/QuestDef.h +++ b/src/game/Quests/QuestDef.h @@ -242,6 +242,7 @@ class Quest uint32 GetDetailsEmoteCount() const { return m_detailsemotecount; } uint32 GetQuestStartScript() const { return QuestStartScript; } uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } + uint32 GetReputationSpilloverMask() const { return ReputationSpilloverMask; } bool IsRepeatable() const { return (m_SpecialFlags & QUEST_SPECIAL_FLAG_REPEATABLE) != 0; } bool IsAutoComplete() const { return !QuestMethod; } @@ -349,6 +350,7 @@ class Quest uint32 CompleteEmoteDelay; uint32 QuestStartScript; uint32 QuestCompleteScript; + uint32 ReputationSpilloverMask; MaNGOS::unique_weak_ptr m_weakRef; }; diff --git a/src/game/Reputation/ReputationMgr.cpp b/src/game/Reputation/ReputationMgr.cpp index d49fdcdb4c..591908ab50 100644 --- a/src/game/Reputation/ReputationMgr.cpp +++ b/src/game/Reputation/ReputationMgr.cpp @@ -263,28 +263,32 @@ void ReputationMgr::Initialize() } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool noSpillover) { if (!factionEntry) return false; bool res = false; - // if spillover definition exists in DB - if (const RepSpilloverTemplate* repTemplate = sObjectMgr.GetRepSpilloverTemplate(factionEntry->ID)) + if (!noSpillover) { - 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); + } } } } } + // spillover done, update faction itself FactionStateList::iterator faction = m_factions.find(RepListID(factionEntry->reputationListID)); if (faction != m_factions.end()) diff --git a/src/game/Reputation/ReputationMgr.h b/src/game/Reputation/ReputationMgr.h index 30be71da04..2c8819bf15 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 noSpillover = false) { - return SetReputation(factionEntry, standing, false); + return SetReputation(factionEntry, standing, false, noSpillover); } - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing) + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing, bool noSpillover = false) { - return SetReputation(factionEntry, standing, true); + return SetReputation(factionEntry, standing, true, noSpillover); } 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__