Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quest: Fixed the lack of quest's reputation spillover data #575

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sql/updates/mangos/z2825_01_mangos_reputation_spillover.sql
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/game/Quests/QuestDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Quest::Quest(Field* questRecord)
QuestCompleteScript = questRecord[127].GetUInt32();

RequiredCondition = questRecord[128].GetUInt32();
ReputationSpillover = questRecord[130].GetUInt32();

m_isActive = true;

Expand Down
2 changes: 2 additions & 0 deletions src/game/Quests/QuestDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -346,6 +347,7 @@ class Quest
uint32 CompleteEmoteDelay;
uint32 QuestStartScript;
uint32 QuestCompleteScript;
uint32 ReputationSpillover;
};

enum QuestUpdateState
Expand Down
21 changes: 12 additions & 9 deletions src/game/Reputation/ReputationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/game/Reputation/ReputationMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__