From f37e0ee838fbebee80303b2ee915a6696c124bec Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 4 Mar 2013 14:15:52 +0100 Subject: 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 --- src/server/game/Globals/ObjectMgr.cpp | 83 +++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 24 deletions(-) (limited to 'src/server/game/Globals/ObjectMgr.cpp') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index c82ea46f0f7..b421bca7d00 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7684,13 +7684,13 @@ uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) return 0; } -SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds(uint32 spell_id) +SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds(uint32 spellId) const { - return SpellScriptsBounds(_spellScriptsStore.lower_bound(spell_id), _spellScriptsStore.upper_bound(spell_id)); + return SpellScriptsBounds(_spellScriptsStore.equal_range(spellId)); } // this allows calculating base reputations to offline players, just by race and class -int32 ObjectMgr::GetBaseReputationOff(FactionEntry const* factionEntry, uint8 race, uint8 playerClass) +int32 ObjectMgr::GetBaseReputationOf(FactionEntry const* factionEntry, uint8 race, uint8 playerClass) { if (!factionEntry) return 0; @@ -8600,11 +8600,11 @@ void ObjectMgr::LoadFactionChangeAchievements() uint32 horde = fields[1].GetUInt32(); if (!sAchievementMgr->GetAchievement(alliance)) - sLog->outError(LOG_FILTER_SQL, "Achievement %u referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance); + sLog->outError(LOG_FILTER_SQL, "Achievement %u (alliance_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", alliance); else if (!sAchievementMgr->GetAchievement(horde)) - sLog->outError(LOG_FILTER_SQL, "Achievement %u referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde); + sLog->outError(LOG_FILTER_SQL, "Achievement %u (horde_id) referenced in `player_factionchange_achievement` does not exist, pair skipped!", horde); else - FactionChange_Achievements[alliance] = horde; + FactionChangeAchievements[alliance] = horde; ++count; } @@ -8635,11 +8635,11 @@ void ObjectMgr::LoadFactionChangeItems() uint32 horde = fields[1].GetUInt32(); if (!GetItemTemplate(alliance)) - sLog->outError(LOG_FILTER_SQL, "Item %u referenced in `player_factionchange_items` does not exist, pair skipped!", alliance); + sLog->outError(LOG_FILTER_SQL, "Item %u (alliance_id) referenced in `player_factionchange_items` does not exist, pair skipped!", alliance); else if (!GetItemTemplate(horde)) - sLog->outError(LOG_FILTER_SQL, "Item %u referenced in `player_factionchange_items` does not exist, pair skipped!", horde); + sLog->outError(LOG_FILTER_SQL, "Item %u (horde_id) referenced in `player_factionchange_items` does not exist, pair skipped!", horde); else - FactionChange_Items[alliance] = horde; + FactionChangeItems[alliance] = horde; ++count; } @@ -8648,15 +8648,15 @@ void ObjectMgr::LoadFactionChangeItems() sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u faction change item pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::LoadFactionChangeSpells() +void ObjectMgr::LoadFactionChangeQuests() { uint32 oldMSTime = getMSTime(); - QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells"); + QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_quests"); if (!result) { - sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty."); + sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 faction change quest pairs. DB table `player_factionchange_quests` is empty."); return; } @@ -8669,18 +8669,18 @@ void ObjectMgr::LoadFactionChangeSpells() uint32 alliance = fields[0].GetUInt32(); uint32 horde = fields[1].GetUInt32(); - if (!sSpellMgr->GetSpellInfo(alliance)) - sLog->outError(LOG_FILTER_SQL, "Spell %u referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance); - else if (!sSpellMgr->GetSpellInfo(horde)) - sLog->outError(LOG_FILTER_SQL, "Spell %u referenced in `player_factionchange_spells` does not exist, pair skipped!", horde); + if (!sObjectMgr->GetQuestTemplate(alliance)) + sLog->outError(LOG_FILTER_SQL, "Quest %u (alliance_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", alliance); + else if (!sObjectMgr->GetQuestTemplate(horde)) + sLog->outError(LOG_FILTER_SQL, "Quest %u (horde_id) referenced in `player_factionchange_quests` does not exist, pair skipped!", horde); else - FactionChange_Spells[alliance] = horde; + FactionChangeQuests[alliance] = horde; ++count; } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u faction change spell pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u faction change quest pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadFactionChangeReputations() @@ -8705,11 +8705,11 @@ void ObjectMgr::LoadFactionChangeReputations() uint32 horde = fields[1].GetUInt32(); if (!sFactionStore.LookupEntry(alliance)) - sLog->outError(LOG_FILTER_SQL, "Reputation %u referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance); + sLog->outError(LOG_FILTER_SQL, "Reputation %u (alliance_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", alliance); else if (!sFactionStore.LookupEntry(horde)) - sLog->outError(LOG_FILTER_SQL, "Reputation %u referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde); + sLog->outError(LOG_FILTER_SQL, "Reputation %u (horde_id) referenced in `player_factionchange_reputations` does not exist, pair skipped!", horde); else - FactionChange_Reputation[alliance] = horde; + FactionChangeReputation[alliance] = horde; ++count; } @@ -8718,6 +8718,41 @@ void ObjectMgr::LoadFactionChangeReputations() sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u faction change reputation pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadFactionChangeSpells() +{ + uint32 oldMSTime = getMSTime(); + + QueryResult result = WorldDatabase.Query("SELECT alliance_id, horde_id FROM player_factionchange_spells"); + + if (!result) + { + sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 faction change spell pairs. DB table `player_factionchange_spells` is empty."); + return; + } + + uint32 count = 0; + + do + { + Field* fields = result->Fetch(); + + uint32 alliance = fields[0].GetUInt32(); + uint32 horde = fields[1].GetUInt32(); + + if (!sSpellMgr->GetSpellInfo(alliance)) + sLog->outError(LOG_FILTER_SQL, "Spell %u (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance); + else if (!sSpellMgr->GetSpellInfo(horde)) + sLog->outError(LOG_FILTER_SQL, "Spell %u (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde); + else + FactionChangeSpells[alliance] = horde; + + ++count; + } + while (result->NextRow()); + + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u faction change spell pairs in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadFactionChangeTitles() { uint32 oldMSTime = getMSTime(); @@ -8740,11 +8775,11 @@ void ObjectMgr::LoadFactionChangeTitles() uint32 horde = fields[1].GetUInt32(); if (!sCharTitlesStore.LookupEntry(alliance)) - sLog->outError(LOG_FILTER_SQL, "Title %u referenced in `player_factionchange_title` does not exist, pair skipped!", alliance); + sLog->outError(LOG_FILTER_SQL, "Title %u (alliance_id) referenced in `player_factionchange_title` does not exist, pair skipped!", alliance); else if (!sCharTitlesStore.LookupEntry(horde)) - sLog->outError(LOG_FILTER_SQL, "Title %u referenced in `player_factionchange_title` does not exist, pair skipped!", horde); + sLog->outError(LOG_FILTER_SQL, "Title %u (horde_id) referenced in `player_factionchange_title` does not exist, pair skipped!", horde); else - FactionChange_Titles[alliance] = horde; + FactionChangeTitles[alliance] = horde; ++count; } -- cgit v1.2.3 From ae4d2845c945e885a766f0c3560ec23397bf427b Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 4 Mar 2013 16:47:39 +0100 Subject: Core: Fixed compile warnings and errors --- src/server/game/Globals/ObjectMgr.cpp | 4 ++-- src/server/game/Scripting/ScriptMgr.cpp | 8 ++++---- src/server/game/Scripting/ScriptMgr.h | 2 +- src/server/scripts/World/areatrigger_scripts.cpp | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/server/game/Globals/ObjectMgr.cpp') diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b421bca7d00..643b0b7a91b 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4919,11 +4919,11 @@ void ObjectMgr::ValidateSpellScripts() for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();) { SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->first); - std::vector > SpellScriptLoaders; + std::vector > SpellScriptLoaders; sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders); itr = _spellScriptsStore.upper_bound(itr->first); - for (std::vector >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr) + for (std::vector >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr) { SpellScript* spellScript = sitr->first->GetSpellScript(); AuraScript* auraScript = sitr->first->GetAuraScript(); diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 32fe5d2ef33..14da3389c2c 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -322,7 +322,7 @@ void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list& scri { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) @@ -343,7 +343,7 @@ void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& script { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) @@ -360,12 +360,12 @@ void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& script } } -void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector >& scriptVector) +void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector >& scriptVector) { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); scriptVector.reserve(std::distance(bounds.first, bounds.second)); - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index b13c2da7f6c..8f8f696e452 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -861,7 +861,7 @@ class ScriptMgr void CreateSpellScripts(uint32 spellId, std::list& scriptVector); void CreateAuraScripts(uint32 spellId, std::list& scriptVector); - void CreateSpellScriptLoaders(uint32 spellId, std::vector::iterator> >& scriptVector); + void CreateSpellScriptLoaders(uint32 spellId, std::vector::const_iterator> >& scriptVector); public: /* ServerScript */ diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 65ebb46c5dd..c8436dfa1f0 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -465,7 +465,8 @@ public: if (stormforgedEradictor) return false; - if ((stormforgedMonitor = player->SummonCreature(NPC_STORMFORGED_MONITOR, stormforgedMonitorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))) + stormforgedMonitor = player->SummonCreature(NPC_STORMFORGED_MONITOR, stormforgedMonitorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + if (stormforgedMonitor) { stormforgedMonitorGUID = stormforgedMonitor->GetGUID(); stormforgedMonitor->SetWalk(false); @@ -474,7 +475,8 @@ public: stormforgedMonitor->GetMotionMaster()->MovePath(NPC_STORMFORGED_MONITOR * 100, false); } - if ((stormforgedEradictor = player->SummonCreature(NPC_STORMFORGED_ERADICTOR, stormforgedEradictorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))) + stormforgedEradictor = player->SummonCreature(NPC_STORMFORGED_ERADICTOR, stormforgedEradictorPosition, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + if (stormforgedEradictor) { stormforgedEradictorGUID = stormforgedEradictor->GetGUID(); stormforgedEradictor->GetMotionMaster()->MovePath(NPC_STORMFORGED_ERADICTOR * 100, false); -- cgit v1.2.3 From 226e0fdd1b08e315cb7f534b97a7d48e33bbf4fe Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 4 Mar 2013 17:08:07 +0100 Subject: Unbreak the build and renamed sql file to proper date --- .../2012_03_04_00_characters_character_queststatus_rewarded.sql | 1 - .../2013_03_04_00_characters_character_queststatus_rewarded.sql | 1 + src/server/game/Globals/ObjectMgr.cpp | 6 +++--- src/server/game/Globals/ObjectMgr.h | 4 ++-- src/server/game/Scripting/ScriptMgr.cpp | 8 ++++---- src/server/game/Scripting/ScriptMgr.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 sql/updates/characters/2012_03_04_00_characters_character_queststatus_rewarded.sql create mode 100644 sql/updates/characters/2013_03_04_00_characters_character_queststatus_rewarded.sql (limited to 'src/server/game/Globals/ObjectMgr.cpp') diff --git a/sql/updates/characters/2012_03_04_00_characters_character_queststatus_rewarded.sql b/sql/updates/characters/2012_03_04_00_characters_character_queststatus_rewarded.sql deleted file mode 100644 index e4dbf73ad7a..00000000000 --- a/sql/updates/characters/2012_03_04_00_characters_character_queststatus_rewarded.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `character_queststatus_rewarded` ADD `active` tinyint(3) unsigned NOT NULL DEFAULT '1' AFTER `quest`; diff --git a/sql/updates/characters/2013_03_04_00_characters_character_queststatus_rewarded.sql b/sql/updates/characters/2013_03_04_00_characters_character_queststatus_rewarded.sql new file mode 100644 index 00000000000..e4dbf73ad7a --- /dev/null +++ b/sql/updates/characters/2013_03_04_00_characters_character_queststatus_rewarded.sql @@ -0,0 +1 @@ +ALTER TABLE `character_queststatus_rewarded` ADD `active` tinyint(3) unsigned NOT NULL DEFAULT '1' AFTER `quest`; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 643b0b7a91b..08b05b1a7e3 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4919,11 +4919,11 @@ void ObjectMgr::ValidateSpellScripts() for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();) { SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->first); - std::vector > SpellScriptLoaders; + std::vector > SpellScriptLoaders; sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders); itr = _spellScriptsStore.upper_bound(itr->first); - for (std::vector >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr) + for (std::vector >::iterator sitr = SpellScriptLoaders.begin(); sitr != SpellScriptLoaders.end(); ++sitr) { SpellScript* spellScript = sitr->first->GetSpellScript(); AuraScript* auraScript = sitr->first->GetAuraScript(); @@ -7684,7 +7684,7 @@ uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) return 0; } -SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds(uint32 spellId) const +SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds(uint32 spellId) { return SpellScriptsBounds(_spellScriptsStore.equal_range(spellId)); } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index e621cf96696..f219b2feb5f 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -379,7 +379,7 @@ struct ScriptInfo typedef std::multimap ScriptMap; typedef std::map ScriptMapMap; typedef std::multimap SpellScriptsContainer; -typedef std::pair SpellScriptsBounds; +typedef std::pair SpellScriptsBounds; extern ScriptMapMap sSpellScripts; extern ScriptMapMap sEventScripts; extern ScriptMapMap sWaypointScripts; @@ -780,7 +780,7 @@ class ObjectMgr AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const; uint32 GetAreaTriggerScriptId(uint32 trigger_id); - SpellScriptsBounds GetSpellScriptsBounds(uint32 spellId) const; + SpellScriptsBounds GetSpellScriptsBounds(uint32 spellId); RepRewardRate const* GetRepRewardRate(uint32 factionId) const { diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 14da3389c2c..32fe5d2ef33 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -322,7 +322,7 @@ void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list& scri { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) @@ -343,7 +343,7 @@ void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& script { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) @@ -360,12 +360,12 @@ void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& script } } -void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector >& scriptVector) +void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector >& scriptVector) { SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); scriptVector.reserve(std::distance(bounds.first, bounds.second)); - for (SpellScriptsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) { SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); if (!tmpscript) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 8f8f696e452..b13c2da7f6c 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -861,7 +861,7 @@ class ScriptMgr void CreateSpellScripts(uint32 spellId, std::list& scriptVector); void CreateAuraScripts(uint32 spellId, std::list& scriptVector); - void CreateSpellScriptLoaders(uint32 spellId, std::vector::const_iterator> >& scriptVector); + void CreateSpellScriptLoaders(uint32 spellId, std::vector::iterator> >& scriptVector); public: /* ServerScript */ -- cgit v1.2.3