Skip to content

Commit

Permalink
[z2825] Added reputation spillover to quest_template
Browse files Browse the repository at this point in the history
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.

Closes #575
  • Loading branch information
JJBcku authored and killerwife committed Jan 3, 2025
1 parent e593dbc commit 1208bca
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion sql/base/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';

--
Expand Down Expand Up @@ -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',
Expand Down
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 ReputationSpilloverMask tinyint unsigned NOT NULL DEFAULT '0' AFTER `RewRepValue5`;
6 changes: 3 additions & 3 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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)
{
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();
ReputationSpilloverMask = 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 @@ -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; }
Expand Down Expand Up @@ -349,6 +350,7 @@ class Quest
uint32 CompleteEmoteDelay;
uint32 QuestStartScript;
uint32 QuestCompleteScript;
uint32 ReputationSpilloverMask;

MaNGOS::unique_weak_ptr<Quest> m_weakRef;
};
Expand Down
22 changes: 13 additions & 9 deletions src/game/Reputation/ReputationMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
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 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);
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__

0 comments on commit 1208bca

Please sign in to comment.