Core/Players: Implemented converting quests on faction change (keeping old faction quests in disabled state - not loaded during login) and restoring them if changing back to original faction
Closes #890 Closes #9248
This commit is contained in:
1 parent
e7d333f708
commit
f37e0ee838
8 files changed
+144
-81
No files matched your search
@@ -1896,44 +1896,6 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
// Delete all current quests
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS);
|
||||
stmt->setUInt32(0, GUID_LOPART(guid));
|
||||
trans->Append(stmt);
|
||||
|
||||
// Delete record of the faction old completed quests
|
||||
{
|
||||
std::ostringstream quests;
|
||||
ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates();
|
||||
for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter)
|
||||
{
|
||||
Quest *qinfo = iter->second;
|
||||
uint32 requiredRaces = qinfo->GetRequiredRaces();
|
||||
if (team == TEAM_ALLIANCE)
|
||||
{
|
||||
if (requiredRaces & RACEMASK_ALLIANCE)
|
||||
{
|
||||
quests << uint32(qinfo->GetQuestId());
|
||||
quests << ',';
|
||||
}
|
||||
}
|
||||
else // if (team == TEAM_HORDE)
|
||||
{
|
||||
if (requiredRaces & RACEMASK_HORDE)
|
||||
{
|
||||
quests << uint32(qinfo->GetQuestId());
|
||||
quests << ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string questsStr = quests.str();
|
||||
questsStr = questsStr.substr(0, questsStr.length() - 1);
|
||||
|
||||
if (!questsStr.empty())
|
||||
trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str());
|
||||
}
|
||||
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
|
||||
{
|
||||
// Reset guild
|
||||
@@ -1991,7 +1953,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
trans->Append(stmt);
|
||||
|
||||
// Achievement conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it)
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeAchievements.begin(); it != sObjectMgr->FactionChangeAchievements.end(); ++it)
|
||||
{
|
||||
uint32 achiev_alliance = it->first;
|
||||
uint32 achiev_horde = it->second;
|
||||
@@ -2009,7 +1971,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// Item conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it)
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeItems.begin(); it != sObjectMgr->FactionChangeItems.end(); ++it)
|
||||
{
|
||||
uint32 item_alliance = it->first;
|
||||
uint32 item_horde = it->second;
|
||||
@@ -2021,8 +1983,53 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
// Delete all current quests
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS);
|
||||
stmt->setUInt32(0, GUID_LOPART(guid));
|
||||
trans->Append(stmt);
|
||||
|
||||
// Quest conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeQuests.begin(); it != sObjectMgr->FactionChangeQuests.end(); ++it)
|
||||
{
|
||||
uint32 quest_alliance = it->first;
|
||||
uint32 quest_horde = it->second;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, (team == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, (team == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
stmt->setUInt32(1, (team == TEAM_ALLIANCE ? quest_horde : quest_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
// Mark all rewarded quests as "active" (will count for completed quests achievements)
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Disable all old-faction specific quests
|
||||
{
|
||||
ObjectMgr::QuestMap const& questTemplates = sObjectMgr->GetQuestTemplates();
|
||||
for (ObjectMgr::QuestMap::const_iterator iter = questTemplates.begin(); iter != questTemplates.end(); ++iter)
|
||||
{
|
||||
Quest const* quest = iter->second;
|
||||
uint32 newRaceMask = (team == TEAM_ALLIANCE) ? RACEMASK_ALLIANCE : RACEMASK_HORDE;
|
||||
if (!(quest->GetRequiredRaces() & newRaceMask))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE_BY_QUEST);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, quest->GetQuestId());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spell conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it)
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeSpells.begin(); it != sObjectMgr->FactionChangeSpells.end(); ++it)
|
||||
{
|
||||
uint32 spell_alliance = it->first;
|
||||
uint32 spell_horde = it->second;
|
||||
@@ -2040,7 +2047,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// Reputation conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it)
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeReputation.begin(); it != sObjectMgr->FactionChangeReputation.end(); ++it)
|
||||
{
|
||||
uint32 reputation_alliance = it->first;
|
||||
uint32 reputation_horde = it->second;
|
||||
@@ -2066,10 +2073,10 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation);
|
||||
|
||||
// old base reputation
|
||||
int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass);
|
||||
int32 oldBaseRep = sObjectMgr->GetBaseReputationOf(factionEntry, oldRace, playerClass);
|
||||
|
||||
// new base reputation
|
||||
int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass);
|
||||
int32 newBaseRep = sObjectMgr->GetBaseReputationOf(sFactionStore.LookupEntry(newReputation), race, playerClass);
|
||||
|
||||
// final reputation shouldnt change
|
||||
int32 FinalRep = oldDBRep + oldBaseRep;
|
||||
@@ -2101,7 +2108,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
for (uint32 index = 0; index < ktcount; ++index)
|
||||
knownTitles[index] = atol(tokens[index]);
|
||||
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it)
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeTitles.begin(); it != sObjectMgr->FactionChangeTitles.end(); ++it)
|
||||
{
|
||||
uint32 title_alliance = it->first;
|
||||
uint32 title_horde = it->second;
|
||||
|
||||
Reference in new issue
Block a user