* Implement reputation spillover via the database
* Remove the nasty hack that we had to handle Vanguard Alliance / Horde * Expedition, and city spillover. * Needs DB data * Original patch by NoFantasy --HG-- branch : trunk
This commit is contained in:
@@ -6889,6 +6889,124 @@ void ObjectMgr::LoadReputationOnKill()
|
||||
sLog.outString(">> Loaded %u creature award reputation definitions", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadReputationSpilloverTemplate()
|
||||
{
|
||||
m_RepSpilloverTemplateMap.clear(); // for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
QueryResult_AutoPtr 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");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outErrorDb(">> Loaded `reputation_spillover_template`, table is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar((int)result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
bar.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 factionId = fields[0].GetUInt32();
|
||||
|
||||
RepSpilloverTemplate repTemplate;
|
||||
|
||||
repTemplate.faction[0] = fields[1].GetUInt32();
|
||||
repTemplate.faction_rate[0] = fields[2].GetFloat();
|
||||
repTemplate.faction_rank[0] = fields[3].GetUInt32();
|
||||
repTemplate.faction[1] = fields[4].GetUInt32();
|
||||
repTemplate.faction_rate[1] = fields[5].GetFloat();
|
||||
repTemplate.faction_rank[1] = fields[6].GetUInt32();
|
||||
repTemplate.faction[2] = fields[7].GetUInt32();
|
||||
repTemplate.faction_rate[2] = fields[8].GetFloat();
|
||||
repTemplate.faction_rank[2] = fields[9].GetUInt32();
|
||||
repTemplate.faction[3] = fields[10].GetUInt32();
|
||||
repTemplate.faction_rate[3] = fields[11].GetFloat();
|
||||
repTemplate.faction_rank[3] = fields[12].GetUInt32();
|
||||
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId);
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (factionEntry->team == 0)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u in `reputation_spillover_template` does not belong to any team, skipping", factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
|
||||
{
|
||||
if (repTemplate.faction[i])
|
||||
{
|
||||
FactionEntry const *factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
|
||||
|
||||
if (!factionSpillover)
|
||||
{
|
||||
sLog.outErrorDb("Spillover faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template` for faction %u, skipping", repTemplate.faction[i], factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (factionSpillover->reputationListID < 0)
|
||||
{
|
||||
sLog.outErrorDb("Spillover faction (faction.dbc) %u for faction %u in `reputation_spillover_template` can not be listed for client, and then useless, skipping", repTemplate.faction[i], factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
|
||||
{
|
||||
sLog.outErrorDb("Rank %u used in `reputation_spillover_template` for spillover faction %u is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FactionEntry const *factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
|
||||
if (repTemplate.faction[0] && !factionEntry0)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
|
||||
if (repTemplate.faction[1] && !factionEntry1)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
|
||||
if (repTemplate.faction[2] && !factionEntry2)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
|
||||
if (repTemplate.faction[3] && !factionEntry3)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_RepSpilloverTemplateMap[factionId] = repTemplate;
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u reputation_spillover_template", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPointsOfInterest()
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
@@ -219,6 +219,13 @@ struct ReputationOnKillEntry
|
||||
bool team_dependent;
|
||||
};
|
||||
|
||||
struct RepSpilloverTemplate
|
||||
{
|
||||
uint32 faction[MAX_SPILLOVER_FACTIONS];
|
||||
float faction_rate[MAX_SPILLOVER_FACTIONS];
|
||||
uint32 faction_rank[MAX_SPILLOVER_FACTIONS];
|
||||
};
|
||||
|
||||
struct PointOfInterest
|
||||
{
|
||||
uint32 entry;
|
||||
@@ -387,6 +394,7 @@ class ObjectMgr
|
||||
|
||||
typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateMap;
|
||||
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
|
||||
typedef UNORDERED_MAP<uint32, RepSpilloverTemplate> RepSpilloverTemplateMap;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
|
||||
|
||||
@@ -552,6 +560,15 @@ class ObjectMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RepSpilloverTemplate const* GetRepSpilloverTemplate(uint32 factionId) const
|
||||
{
|
||||
RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId);
|
||||
if (itr != m_RepSpilloverTemplateMap.end())
|
||||
return &itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PointOfInterest const* GetPointOfInterest(uint32 id) const
|
||||
{
|
||||
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
|
||||
@@ -664,6 +681,7 @@ class ObjectMgr
|
||||
|
||||
void LoadReputationRewardRate();
|
||||
void LoadReputationOnKill();
|
||||
void LoadReputationSpilloverTemplate();
|
||||
|
||||
void LoadPointsOfInterest();
|
||||
void LoadQuestPOI();
|
||||
@@ -1009,6 +1027,7 @@ class ObjectMgr
|
||||
|
||||
RepRewardRateMap m_RepRewardRateMap;
|
||||
RepOnKillMap mRepOnKill;
|
||||
RepSpilloverTemplateMap m_RepSpilloverTemplateMap;
|
||||
|
||||
GossipMenusMap m_mGossipMenusMap;
|
||||
GossipMenuItemsMap m_mGossipMenuItemsMap;
|
||||
|
||||
Reference in New Issue
Block a user