From 9876ef723eb3a83ab3654ff6f8d39e3de51027f6 Mon Sep 17 00:00:00 2001 From: Svannon Date: Sat, 26 Nov 2011 14:59:56 -0700 Subject: [PATCH 01/18] [Spell] Make Spell 29200 (Purify Helboar Meat) use caster as casting target --- src/server/game/Spells/SpellMgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 55a70066a8d..fe6e52848a9 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2968,6 +2968,7 @@ void SpellMgr::LoadDbcDataCorrections() case 51904: // Summon Ghouls On Scarlet Crusade (this should use conditions table, script for this spell needs to be fixed) case 2895: // Wrath of Air Totem rank 1 (Aura) case 68933: // Wrath of Air Totem rank 2 (Aura) + case 29200: // Purify Helboar Meat spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER; spellInfo->EffectImplicitTargetB[0] = 0; break; From 64e21f76bb2fd210783d4696e3d2414106f82503 Mon Sep 17 00:00:00 2001 From: PKX Date: Sun, 27 Nov 2011 18:49:39 +0100 Subject: [PATCH 02/18] Correction to previous commit 61866831caca9f2c980e518bf6b0b8b8691ad151 Closes #4100 --- .../2011_11_27_01_world_spell_script.sql | 4 ++ src/server/game/Spells/Auras/SpellAuras.cpp | 2 +- src/server/game/Spells/SpellMgr.cpp | 3 + src/server/scripts/Spells/spell_generic.cpp | 17 +++--- src/server/scripts/Spells/spell_warrior.cpp | 60 +++++++++++++++++++ 5 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 sql/updates/world/2011_11_27_01_world_spell_script.sql diff --git a/sql/updates/world/2011_11_27_01_world_spell_script.sql b/sql/updates/world/2011_11_27_01_world_spell_script.sql new file mode 100644 index 00000000000..933566c5f99 --- /dev/null +++ b/sql/updates/world/2011_11_27_01_world_spell_script.sql @@ -0,0 +1,4 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_damage_reduction_aura' AND `spell_id`=50720; +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_warr_vigilance'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(50720,'spell_warr_vigilance'); -- Vigilance \ No newline at end of file diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 525084a70ed..523f5afb096 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1555,7 +1555,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b // mods at aura apply or remove switch (GetSpellInfo()->SpellFamilyName) { - case SPELLFAMILY_GENERIC: + case SPELLFAMILY_WARRIOR: switch (GetId()) { case 50720: // Vigilance diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 55a70066a8d..481050356e3 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3480,6 +3480,9 @@ void SpellMgr::LoadDbcDataCorrections() case 72405: // Broken Frostmourne spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd break; + case 50720: // Vigilance + spellInfo->SpellFamilyName = SPELLFAMILY_WARRIOR; + break; default: break; } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 90abf2073ee..260b0c57563 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -1373,9 +1373,9 @@ class spell_gen_damage_reduction_aura : public SpellScriptLoader public: spell_gen_damage_reduction_aura() : SpellScriptLoader("spell_gen_damage_reduction_aura") { } - class spell_gen_damage_reduction_auraScript : public AuraScript + class spell_gen_damage_reduction_AuraScript : public AuraScript { - PrepareAuraScript(spell_gen_damage_reduction_auraScript); + PrepareAuraScript(spell_gen_damage_reduction_AuraScript); bool Validate(SpellInfo const* /*SpellEntry*/) { @@ -1387,19 +1387,16 @@ public: void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - if (!target || target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) - return; - target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - if (!target || !target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) + if (!target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) return; - if (target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || + if (target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || target->HasAura(SPELL_RENEWED_HOPE) || target->HasAura(SPELL_VIGILANCE)) @@ -1410,15 +1407,15 @@ public: void Register() { - OnEffectApply += AuraEffectApplyFn(spell_gen_damage_reduction_auraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_gen_damage_reduction_auraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectApply += AuraEffectApplyFn(spell_gen_damage_reduction_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_damage_reduction_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); } }; AuraScript* GetAuraScript() const { - return new spell_gen_damage_reduction_auraScript(); + return new spell_gen_damage_reduction_AuraScript(); } }; diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index be6e1c49ee7..b9def701fca 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -89,8 +89,68 @@ class spell_warr_improved_spell_reflection : public SpellScriptLoader } }; +enum DamageReductionAura +{ + SPELL_BLESSING_OF_SANCTUARY = 20911, + SPELL_GREATER_BLESSING_OF_SANCTUARY = 25899, + SPELL_RENEWED_HOPE = 63944, + SPELL_DAMAGE_REDUCTION_AURA = 68066, +}; + +class spell_warr_vigilance : public SpellScriptLoader +{ +public: + spell_warr_vigilance() : SpellScriptLoader("spell_warr_vigilance") { } + + class spell_warr_vigilance_AuraScript : public AuraScript + { + PrepareAuraScript(spell_warr_vigilance_AuraScript); + + bool Validate(SpellInfo const* /*SpellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_DAMAGE_REDUCTION_AURA)) + return false; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->CastSpell(target, SPELL_DAMAGE_REDUCTION_AURA, true); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + + if (!target->HasAura(SPELL_DAMAGE_REDUCTION_AURA)) + return; + + if (target->HasAura(SPELL_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_GREATER_BLESSING_OF_SANCTUARY) || + target->HasAura(SPELL_RENEWED_HOPE)) + return; + + target->RemoveAurasDueToSpell(SPELL_DAMAGE_REDUCTION_AURA); + } + + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_warr_vigilance_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_warr_vigilance_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } + + }; + + AuraScript* GetAuraScript() const + { + return new spell_warr_vigilance_AuraScript(); + } +}; + void AddSC_warrior_spell_scripts() { new spell_warr_last_stand(); new spell_warr_improved_spell_reflection(); + new spell_warr_vigilance(); } From 01a39f33a3aee43528efe7c793a155e17aa6a298 Mon Sep 17 00:00:00 2001 From: PKX Date: Sun, 27 Nov 2011 22:18:20 +0100 Subject: [PATCH 03/18] Removed wrong code --- src/server/game/Spells/Auras/SpellAuras.cpp | 2 +- src/server/game/Spells/SpellMgr.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 523f5afb096..525084a70ed 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1555,7 +1555,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b // mods at aura apply or remove switch (GetSpellInfo()->SpellFamilyName) { - case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_GENERIC: switch (GetId()) { case 50720: // Vigilance diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 481050356e3..55a70066a8d 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3480,9 +3480,6 @@ void SpellMgr::LoadDbcDataCorrections() case 72405: // Broken Frostmourne spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd break; - case 50720: // Vigilance - spellInfo->SpellFamilyName = SPELLFAMILY_WARRIOR; - break; default: break; } From 5a4dfbf300bdd27f928e73437eebd71773f30426 Mon Sep 17 00:00:00 2001 From: horn Date: Mon, 28 Nov 2011 00:47:18 +0100 Subject: [PATCH 04/18] Core/Achievements: Some achievements can now be obtained in random chosen battlegrounds too (not only in specific battlegrounds). Removed unneeded script for Storm Glory achievement. Signed-off-by: horn --- ..._28_00_world_achievement_criteria_data.sql | 3 ++ .../scripts/World/achievement_scripts.cpp | 32 +++++-------------- 2 files changed, 11 insertions(+), 24 deletions(-) create mode 100644 sql/updates/world/2011_11_28_00_world_achievement_criteria_data.sql diff --git a/sql/updates/world/2011_11_28_00_world_achievement_criteria_data.sql b/sql/updates/world/2011_11_28_00_world_achievement_criteria_data.sql new file mode 100644 index 00000000000..9fea807a97c --- /dev/null +++ b/sql/updates/world/2011_11_28_00_world_achievement_criteria_data.sql @@ -0,0 +1,3 @@ +DELETE FROM achievement_criteria_data WHERE criteria_id = 3693; +INSERT INTO achievement_criteria_data VALUES +(3693, 11, 0, 0, 'achievement_bg_control_all_nodes'); diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 2dbbd949526..29cb6c082a2 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -24,24 +24,6 @@ #include "BattlegroundAV.h" #include "Vehicle.h" -class achievement_storm_glory : public AchievementCriteriaScript -{ - public: - achievement_storm_glory() : AchievementCriteriaScript("achievement_storm_glory") { } - - bool OnCheck(Player* source, Unit* /*target*/) - { - if (source->GetBattlegroundTypeId() != BATTLEGROUND_EY) - return false; - - Battleground* pEotS = source->GetBattleground(); - if (!pEotS) - return false; - - return pEotS->IsAllNodesConrolledByTeam(source->GetTeam()); - } -}; - class achievement_resilient_victory : public AchievementCriteriaScript { public: @@ -93,11 +75,14 @@ class achievement_save_the_day : public AchievementCriteriaScript if (Player const* player = target->ToPlayer()) { - if (source->GetBattlegroundTypeId() != BATTLEGROUND_WS || !source->GetBattleground()) + Battleground* bg = source->GetBattleground(); + if (!bg) return false; - BattlegroundWS* pWSG = static_cast(source->GetBattleground()); - if (pWSG->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE) + if (bg->GetTypeID(true) != BATTLEGROUND_WS) + return false; + + if (static_cast(bg)->GetFlagState(player->GetTeam()) == BG_WS_FLAG_STATE_ON_BASE) return true; } return false; @@ -219,7 +204,7 @@ class achievement_everything_counts : public AchievementCriteriaScript if (!bg) return false; - if (source->GetBattlegroundTypeId() != BATTLEGROUND_AV) + if (bg->GetTypeID(true) != BATTLEGROUND_AV) return false; if (static_cast(bg)->IsBothMinesControlledByTeam(source->GetTeam())) @@ -240,7 +225,7 @@ class achievement_bg_av_perfection : public AchievementCriteriaScript if (!bg) return false; - if (source->GetBattlegroundTypeId() != BATTLEGROUND_AV) + if (bg->GetTypeID(true) != BATTLEGROUND_AV) return false; if (static_cast(bg)->IsAllTowersControlledAndCaptainAlive(source->GetTeam())) @@ -302,7 +287,6 @@ class achievement_bg_sa_defense_of_ancients : public AchievementCriteriaScript void AddSC_achievement_scripts() { - new achievement_storm_glory(); new achievement_resilient_victory(); new achievement_bg_control_all_nodes(); new achievement_save_the_day(); From 49b24070771493625fe3ada260b3ecf0aa2581ad Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 11:32:52 -0500 Subject: [PATCH 05/18] Add an ASSERT to find out the reasons of some crashes. --- src/server/game/Maps/Map.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index bd419482b5b..d5be15ee012 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -426,6 +426,10 @@ void Map::AddToMap(T *obj) } CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); + //It will create many problems (including crashes) if an object is not added to grid after creation + //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid + //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause + ASSERT(cellCoord.IsCoordValid()); if (!cellCoord.IsCoordValid()) { sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); From cde7ea260eae5c7676411c848131f91e5648ec28 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 13:23:20 -0500 Subject: [PATCH 06/18] Make AddToMap return bool. --- src/server/game/Maps/Map.cpp | 18 +++++++++--------- src/server/game/Maps/Map.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index d5be15ee012..13a47633b53 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -415,14 +415,14 @@ void Map::InitializeObject(Creature* obj) } template -void Map::AddToMap(T *obj) +bool Map::AddToMap(T *obj) { //TODO: Needs clean up. An object should not be added to map twice. if (obj->IsInWorld()) { ASSERT(obj->IsInGrid()); obj->UpdateObjectVisibility(true); - return; + return true; } CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); @@ -433,7 +433,7 @@ void Map::AddToMap(T *obj) if (!cellCoord.IsCoordValid()) { sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); - return; + return false; //Should delete object } Cell cell(cellCoord); @@ -456,6 +456,7 @@ void Map::AddToMap(T *obj) //something, such as vehicle, needs to be update immediately //also, trigger needs to cast spell, if not update, cannot see visual obj->UpdateObjectVisibility(true); + return true; } bool Map::IsGridLoaded(const GridCoord &p) const @@ -664,8 +665,7 @@ void Map::RemovePlayerFromMap(Player* player, bool remove) } template -void -Map::RemoveFromMap(T *obj, bool remove) +void Map::RemoveFromMap(T *obj, bool remove) { obj->RemoveFromWorld(); if (obj->isActiveObject()) @@ -2141,10 +2141,10 @@ void Map::RemoveFromActive(Creature* c) } } -template void Map::AddToMap(Corpse*); -template void Map::AddToMap(Creature*); -template void Map::AddToMap(GameObject*); -template void Map::AddToMap(DynamicObject*); +template bool Map::AddToMap(Corpse*); +template bool Map::AddToMap(Creature*); +template bool Map::AddToMap(GameObject*); +template bool Map::AddToMap(DynamicObject*); template void Map::RemoveFromMap(Corpse*, bool); template void Map::RemoveFromMap(Creature*, bool); diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 9caef8457b8..5b652a2524a 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -246,7 +246,7 @@ class Map : public GridRefManager virtual bool AddPlayerToMap(Player*); virtual void RemovePlayerFromMap(Player*, bool); - template void AddToMap(T *); + template bool AddToMap(T *); template void RemoveFromMap(T *, bool); void VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor &gridVisitor, TypeContainerVisitor &worldVisitor); From 529af3cd092972c2d5204308a5ba573bad8e0b1f Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 14:05:25 -0500 Subject: [PATCH 07/18] Delete obj if it is not successfully added to grid. More to fix. --- .../game/Battlegrounds/Battleground.cpp | 13 ++++++-- .../game/Entities/Creature/Creature.cpp | 4 ++- src/server/game/Entities/Creature/Creature.h | 3 +- .../game/Entities/GameObject/GameObject.cpp | 5 ++- .../game/Entities/GameObject/GameObject.h | 3 +- src/server/game/Events/GameEventMgr.cpp | 7 ++-- src/server/game/Globals/ObjectMgr.cpp | 9 ++--- src/server/game/Pools/PoolMgr.cpp | 6 ++-- src/server/scripts/Commands/cs_gobject.cpp | 4 +-- src/server/scripts/Commands/cs_npc.cpp | 7 ++-- src/server/scripts/Commands/cs_wp.cpp | 33 ++++++++++++++----- .../scripts/OutdoorPvP/OutdoorPvPSI.cpp | 27 ++++++++++----- 12 files changed, 79 insertions(+), 42 deletions(-) diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index af350ac39d6..4ad00f5d7aa 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1454,7 +1454,11 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float data.go_state = 1; */ // Add to world, so it can be later looked up from HashMapHolder - map->AddToMap(go); + if (!map->AddToMap(go)) + { + delete go; + return false; + } m_BgObjects[type] = go->GetGUID(); return true; } @@ -1557,7 +1561,12 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f creature->SetSpeed(MOVE_WALK, cinfo->speed_walk); creature->SetSpeed(MOVE_RUN, cinfo->speed_run); - map->AddToMap(creature); + if (!map->AddToMap(creature)) + { + delete creature; + return NULL; + } + m_BgCreatures[type] = creature->GetGUID(); if (respawntime) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 922db88bcd0..3238d9873a9 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1241,7 +1241,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint3 return true; } -bool Creature::LoadFromDB(uint32 guid, Map* map) +bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap) { CreatureData const* data = sObjectMgr->GetCreatureData(guid); @@ -1310,6 +1310,8 @@ bool Creature::LoadFromDB(uint32 guid, Map* map) m_creatureData = data; + if (addToMap && !GetMap()->AddToMap(this)) + return false; return true; } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 665942e134a..6ae9fa97462 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -575,7 +575,8 @@ class Creature : public Unit, public GridObject, public MapCreature void setDeathState(DeathState s); // override virtual Unit::setDeathState bool FallGround(); - bool LoadFromDB(uint32 guid, Map* map); + bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); } + bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true); void SaveToDB(); // overriden in Pet virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 9e514ad34bb..de1b0f84871 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -695,7 +695,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) WorldDatabase.CommitTransaction(trans); } -bool GameObject::LoadFromDB(uint32 guid, Map* map) +bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) { GameObjectData const* data = sObjectMgr->GetGOData(guid); @@ -760,6 +760,9 @@ bool GameObject::LoadFromDB(uint32 guid, Map* map) m_goData = data; + if (addToMap && !GetMap()->AddToMap(this)) + return false; + return true; } diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 9167b40d285..c47587177c8 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -648,7 +648,8 @@ class GameObject : public WorldObject, public GridObject void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); - bool LoadFromDB(uint32 guid, Map* map); + bool LoadFromDB(uint32 guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); } + bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true); void DeleteFromDB(); void SetOwnerGUID(uint64 owner) diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index dbcb07e88f5..d3cc27c9e6c 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1176,10 +1176,8 @@ void GameEventMgr::GameEventSpawn(int16 event_id) { Creature* creature = new Creature; //sLog->outDebug("Spawning creature %u", *itr); - if (!creature->LoadFromDB(*itr, map)) + if (!creature->LoadCreatureFromDB(*itr, map)) delete creature; - else - map->AddToMap(creature); } } } @@ -1205,7 +1203,8 @@ void GameEventMgr::GameEventSpawn(int16 event_id) { GameObject* pGameobject = new GameObject; //sLog->outDebug("Spawning gameobject %u", *itr); - if (!pGameobject->LoadFromDB(*itr, map)) + //TODO: find out when it is add to map + if (!pGameobject->LoadGameObjectFromDB(*itr, map, false)) delete pGameobject; else { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 6b0601d9663..6201a932a60 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1630,13 +1630,12 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float if (!map->Instanceable() && map->IsGridLoaded(x, y)) { GameObject* go = new GameObject; - if (!go->LoadFromDB(guid, map)) + if (!go->LoadGameObjectFromDB(guid, map)) { sLog->outError("AddGOData: cannot add gameobject entry %u to map", entry); delete go; return 0; } - map->AddToMap(go); } sLog->outDebug(LOG_FILTER_MAPS, "AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o); @@ -1666,13 +1665,12 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY)) { Creature* creature = new Creature; - if (!creature->LoadFromDB(guid, map)) + if (!creature->LoadCreatureFromDB(guid, map)) { sLog->outError("AddCreature: cannot add creature entry %u to map", guid); delete creature; return false; } - map->AddToMap(creature); } } return true; @@ -1719,13 +1717,12 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float if (!map->Instanceable() && !map->IsRemovalGrid(x, y)) { Creature* creature = new Creature; - if (!creature->LoadFromDB(guid, map)) + if (!creature->LoadCreatureFromDB(guid, map)) { sLog->outError("AddCreature: cannot add creature entry %u to map", entry); delete creature; return 0; } - map->AddToMap(creature); } } diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index bd8840ff8a8..96bb4a211eb 100755 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -365,13 +365,11 @@ void PoolGroup::Spawn1Object(PoolObject* obj) { Creature* creature = new Creature; //sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning creature %u", guid); - if (!creature->LoadFromDB(obj->guid, map)) + if (!creature->LoadCreatureFromDB(obj->guid, map)) { delete creature; return; } - else - map->AddToMap(creature); } } } @@ -391,7 +389,7 @@ void PoolGroup::Spawn1Object(PoolObject* obj) { GameObject* pGameobject = new GameObject; //sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning gameobject %u", guid); - if (!pGameobject->LoadFromDB(obj->guid, map)) + if (!pGameobject->LoadGameObjectFromDB(obj->guid, map, false)) { delete pGameobject; return; diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 4c9960992e1..eb1ccc543f3 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -165,14 +165,12 @@ public: object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn()); // this will generate a new guid if the object is in an instance - if (!object->LoadFromDB(guidLow, map)) + if (!object->LoadGameObjectFromDB(guidLow, map)) { delete object; return false; } - map->AddToMap(object); - // TODO: is it really necessary to add both the real and DB table guid here ? sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow)); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 20d0994b911..bfa8b76f295 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -147,9 +147,12 @@ public: uint32 db_guid = creature->GetDBTableGUIDLow(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - creature->LoadFromDB(db_guid, map); + if (!creature->LoadCreatureFromDB(db_guid, map)) + { + delete creature; + return false; + } - map->AddToMap(creature); sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid)); return true; } diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index ebeb7b8f4f4..d34ee801e50 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -578,8 +578,13 @@ public: wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->AddToMap(wpCreature2); + //TODO: Should we first use "Create" then use "LoadFromDB"? + if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map)) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); + delete wpCreature2; + return false; + } //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2); } @@ -777,8 +782,12 @@ public: wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); - map->AddToMap(wpCreature); + if (!wpCreature->LoadCreatureFromDB(wpCreature->GetDBTableGUIDLow(), map)) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete wpCreature; + return false; + } if (target) { @@ -824,8 +833,12 @@ public: } creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->AddToMap(creature); + if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map)) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete creature; + return false; + } if (target) { @@ -872,8 +885,12 @@ public: } creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - creature->LoadFromDB(creature->GetDBTableGUIDLow(), map); - map->AddToMap(creature); + if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map)) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); + delete creature; + return false; + } if (target) { diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index 23477741ba1..bcdcc69181a 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -166,11 +166,15 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY)) { delete go; + return true; } - else + + go->SetRespawnTime(0); + + if (!map->AddToMap(go)) { - go->SetRespawnTime(0); - map->AddToMap(go); + delete go; + return true; } } } @@ -189,17 +193,22 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) Map* map = player->GetMap(); if (!map) { - delete go; - return true; - } + delete go; + return true; + } + if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY)) { delete go; + return true; } - else + + go->SetRespawnTime(0); + + if (!map->AddToMap(go)) { - go->SetRespawnTime(0); - map->AddToMap(go); + delete go; + return true; } } } From 81fea2d7b51549c340866050f93e3780503112f7 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 14:10:56 -0500 Subject: [PATCH 08/18] Fix some memory leak from CreateTamedPetFrom. --- src/server/game/Spells/SpellEffects.cpp | 6 ++++++ src/server/scripts/Commands/cs_npc.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a4cf8e6a469..bcc791ac3fd 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3828,7 +3828,10 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id); if (!pet) // in very specific state like near world end/etc. + { + delete pet; return; + } // "kill" original creature creatureTarget->DespawnOrUnsummon(); @@ -7014,7 +7017,10 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id); if (!pet) + { + delete pet; return; + } // add to world pet->GetMap()->AddToMap(pet->ToCreature()); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index bfa8b76f295..46b6c1cb16b 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -1131,6 +1131,7 @@ public: { handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry); handler->SetSentErrorMessage (true); + delete pet; return false; } From 1f70fd2851c52d7bbfeb58af8180cf3ad39af290 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 14:19:29 -0500 Subject: [PATCH 09/18] Delete DynamicObject if AddToMap fails. --- src/server/game/Entities/DynamicObject/DynamicObject.cpp | 8 +++++++- src/server/game/Entities/DynamicObject/DynamicObject.h | 2 +- src/server/game/Spells/SpellEffects.cpp | 9 ++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 4fc463e6e88..30afd43cf14 100755 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -79,7 +79,7 @@ void DynamicObject::RemoveFromWorld() } } -bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type) +bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type) { SetMap(caster->GetMap()); Relocate(pos); @@ -106,6 +106,12 @@ bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Positio SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime()); m_isWorldObject = active; + if (active) + setActive(true); //must before add to map to be put in world container + + if (!GetMap()->AddToMap(this)) + return false; + return true; } diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index 419aaf9e83b..c178fe98d14 100755 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -41,7 +41,7 @@ class DynamicObject : public WorldObject, public GridObject void AddToWorld(); void RemoveFromWorld(); - bool Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type); + bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type); void Update(uint32 p_time); void Remove(); void SetDuration(int32 newDuration); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index bcc791ac3fd..faac7acece5 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2589,14 +2589,12 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) if (!caster->IsInWorld()) return; DynamicObject* dynObj = new DynamicObject(); - if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, false, DYNAMIC_OBJECT_AREA_SPELL)) + if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, false, DYNAMIC_OBJECT_AREA_SPELL)) { delete dynObj; return; } - dynObj->GetMap()->AddToMap(dynObj); - if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0])) { m_spellAura = aura; @@ -3440,16 +3438,13 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) return; DynamicObject* dynObj = new DynamicObject(); - if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) + if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) { delete dynObj; return; } dynObj->SetDuration(duration); - - dynObj->setActive(true); //must before add to map to be put in world container - dynObj->GetMap()->AddToMap(dynObj); //grid will also be loaded dynObj->SetCasterViewpoint(); } From 5b034ee631822f71c6504944963aaa17c6a29b68 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 28 Nov 2011 14:34:30 -0500 Subject: [PATCH 10/18] Revert 81fea2d7b51549c340866050f93e3780503112f7. --- src/server/game/Chat/Commands/Level2.cpp | 4 ---- src/server/game/Spells/SpellEffects.cpp | 6 ------ src/server/scripts/Commands/cs_npc.cpp | 3 +-- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 1dd603094f6..41bc564759c 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -861,10 +861,6 @@ bool ChatHandler::HandleCreatePetCommand(const char* /*args*/) // Everything looks OK, create new pet Pet* pet = new Pet(player, HUNTER_PET); - - if (!pet) - return false; - if (!pet->CreateBaseAtCreature(creatureTarget)) { delete pet; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index faac7acece5..e42294f59ae 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3823,10 +3823,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id); if (!pet) // in very specific state like near world end/etc. - { - delete pet; return; - } // "kill" original creature creatureTarget->DespawnOrUnsummon(); @@ -7012,10 +7009,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id); if (!pet) - { - delete pet; return; - } // add to world pet->GetMap()->AddToMap(pet->ToCreature()); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 46b6c1cb16b..b9ac21cc040 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -1126,12 +1126,11 @@ public: } // Everything looks OK, create new pet - Pet* pet = player->CreateTamedPetFrom (creatureTarget); + Pet* pet = player->CreateTamedPetFrom(creatureTarget); if (!pet) { handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry); handler->SetSentErrorMessage (true); - delete pet; return false; } From 5ea9931f75ce5a64a2920ab4a763e9f06fe35151 Mon Sep 17 00:00:00 2001 From: tobmaps Date: Tue, 29 Nov 2011 19:41:19 +0700 Subject: [PATCH 11/18] SQL: File namings after recent pull --- ...ld_spell_script.sql => 2011_11_29_00_world_spell_script.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sql/updates/world/{2011_11_27_01_world_spell_script.sql => 2011_11_29_00_world_spell_script.sql} (84%) diff --git a/sql/updates/world/2011_11_27_01_world_spell_script.sql b/sql/updates/world/2011_11_29_00_world_spell_script.sql similarity index 84% rename from sql/updates/world/2011_11_27_01_world_spell_script.sql rename to sql/updates/world/2011_11_29_00_world_spell_script.sql index 933566c5f99..ff87ebff788 100644 --- a/sql/updates/world/2011_11_27_01_world_spell_script.sql +++ b/sql/updates/world/2011_11_29_00_world_spell_script.sql @@ -1,4 +1,4 @@ DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_damage_reduction_aura' AND `spell_id`=50720; DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_warr_vigilance'; INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES -(50720,'spell_warr_vigilance'); -- Vigilance \ No newline at end of file +(50720,'spell_warr_vigilance'); -- Vigilance From 8f8d45fdaf103358597b3b9cb2512b1c05574a3b Mon Sep 17 00:00:00 2001 From: mns Date: Thu, 1 Dec 2011 04:19:38 +0330 Subject: [PATCH 12/18] Fix vmapassembler Signed-off-by: mns --- src/server/collision/Maps/TileAssembler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index 533a7ca825c..55051fda4bb 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -500,7 +500,7 @@ namespace VMAP { model.setGroupModels(groupsArray); - std::string worldModelFileName(iSrcDir); + std::string worldModelFileName(iDestDir); worldModelFileName.push_back('/'); worldModelFileName.append(pModelFilename).append(".vmo"); success = model.writeFile(worldModelFileName); From a0226ec5d19dac3bb953a2128cb827fea60b69ec Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 3 Dec 2011 21:30:30 +0000 Subject: [PATCH 13/18] Core/Quests: Fix some variable renaming fails in quest related code Closes #4183 --- src/server/game/Entities/Creature/GossipDef.cpp | 2 +- src/server/game/Entities/Player/Player.cpp | 16 ++++++++-------- src/server/game/Globals/ObjectMgr.cpp | 10 +++++----- src/server/game/Quests/QuestDef.cpp | 4 ++-- src/server/game/Quests/QuestDef.h | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 5bf7910466c..398deb04723 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -516,7 +516,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const data << uint32(quest->RequiredNpcOrGo[i]); data << uint32(quest->RequiredNpcOrGoCount[i]); - data << uint32(quest->RequiredSourceItemid[i]); + data << uint32(quest->RequiredSourceItemId[i]); data << uint32(0); // req source count? } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 401e965f816..d32980bf72d 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14855,10 +14855,10 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) { - if (quest->RequiredSourceItemid[i]) + if (quest->RequiredSourceItemId[i]) { - uint32 count = quest->RequiredSourceItemId[i]; - DestroyItemCount(quest->RequiredSourceItemid[i], count ? count : 9999, true); + uint32 count = quest->RequiredSourceItemIdCount[i]; + DestroyItemCount(quest->RequiredSourceItemId[i], count ? count : 9999, true); } } @@ -15055,9 +15055,9 @@ void Player::FailQuest(uint32 questId) // Destroy items recieved on starting the quest. DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true, true); for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - if (quest->RequiredSourceItemid[i] > 0 && quest->RequiredSourceItemId[i] > 0) + if (quest->RequiredSourceItemId[i] > 0 && quest->RequiredSourceItemIdCount[i] > 0) // Destroy items recieved during the quest. - DestroyItemCount(quest->RequiredSourceItemid[i], quest->RequiredSourceItemId[i], true, true); + DestroyItemCount(quest->RequiredSourceItemId[i], quest->RequiredSourceItemIdCount[i], true, true); } } @@ -16108,7 +16108,7 @@ bool Player::HasQuestForItem(uint32 itemid) const for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) { // examined item is a source item - if (qinfo->RequiredSourceItemid[j] == itemid) + if (qinfo->RequiredSourceItemId[j] == itemid) { ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid); @@ -16117,9 +16117,9 @@ bool Player::HasQuestForItem(uint32 itemid) const return true; // allows custom amount drop when not 0 - if (qinfo->RequiredSourceItemId[j]) + if (qinfo->RequiredSourceItemIdCount[j]) { - if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemId[j]) + if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemIdCount[j]) return true; } else if (GetItemCount(itemid, true) < pProto->GetMaxStackSize()) return true; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 6201a932a60..294e83deeaa 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4024,22 +4024,22 @@ void ObjectMgr::LoadQuests() for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) { - uint32 id = qinfo->RequiredSourceItemid[j]; + uint32 id = qinfo->RequiredSourceItemId[j]; if (id) { if (!sObjectMgr->GetItemTemplate(id)) { - sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = %u but item with entry %u does not exist, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredSourceItemId%d` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(), j+1, id, id); // no changes, quest can't be done for this requirement } } else { - if (qinfo->RequiredSourceItemId[j]>0) + if (qinfo->RequiredSourceItemIdCount[j]>0) { - sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = 0 but `RequiredSourceItemId%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemId[j]); + sLog->outErrorDb("Quest %u has `RequiredSourceItemId%d` = 0 but `RequiredSourceItemIdCount%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemIdCount[j]); // no changes, quest ignore this data } } diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 29bd95a73a3..e6e95d90f5f 100755 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -106,10 +106,10 @@ Quest::Quest(Field* questRecord) RequiredNpcOrGoCount[i] = questRecord[93+i].GetUInt32(); for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - RequiredSourceItemid[i] = questRecord[97+i].GetUInt32(); + RequiredSourceItemId[i] = questRecord[97+i].GetUInt32(); for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - RequiredSourceItemId[i] = questRecord[101+i].GetUInt32(); + RequiredSourceItemIdCount[i] = questRecord[101+i].GetUInt32(); for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) RequiredItemId[i] = questRecord[105+i].GetUInt32(); diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index fc9a432a11b..8a34200ede2 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -262,8 +262,8 @@ class Quest std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]; uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; - uint32 RequiredSourceItemid[QUEST_SOURCE_ITEM_IDS_COUNT]; uint32 RequiredSourceItemId[QUEST_SOURCE_ITEM_IDS_COUNT]; + uint32 RequiredSourceItemIdCount[QUEST_SOURCE_ITEM_IDS_COUNT]; int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]; uint32 RequiredSpellCast[QUEST_OBJECTIVES_COUNT]; From 978f31bad6d9958d761c683f03a34ff0bf59dd00 Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 3 Dec 2011 21:43:12 +0000 Subject: [PATCH 14/18] DB/Quests: Re-fix 24559/24461; spawn needed GOs at correct places Ref #836 --- sql/updates/world/2011_12_03_00_world_gameobject.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sql/updates/world/2011_12_03_00_world_gameobject.sql diff --git a/sql/updates/world/2011_12_03_00_world_gameobject.sql b/sql/updates/world/2011_12_03_00_world_gameobject.sql new file mode 100644 index 00000000000..5707ee28d12 --- /dev/null +++ b/sql/updates/world/2011_12_03_00_world_gameobject.sql @@ -0,0 +1,4 @@ +DELETE FROM `gameobject` WHERE `guid` IN (207,215) AND `id`=300245; -- TEMP Forgemaster''s Anvil +INSERT INTO `gameobject` (`guid`, `id`, `map`, `spawnMask`, `phaseMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`) VALUES +(207, 300245, 658, 3, 1, 637.954, -209.544, 533.269, 3.53903, 0, 0, 0.980321, -0.197413, 300, 0, 1), +(215, 300245, 658, 3, 1, 726.268, -237.654, 534.13, 5.5732, 0, 0, 0.347582, -0.93765, 300, 0, 1); From d6f2359e205db305b829eb09ce4f4ce75492e271 Mon Sep 17 00:00:00 2001 From: kandera Date: Mon, 5 Dec 2011 10:20:06 -0500 Subject: [PATCH 15/18] Core/Spells: Fix Ravage (was able to attack from any side. now only from back) --- src/server/game/Spells/SpellMgr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 55a70066a8d..a40779f3479 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2824,6 +2824,13 @@ void SpellMgr::LoadSpellCustomAttr() case 48689: case 48690: case 48691: + case 6785: // Ravage + case 6787: + case 9866: + case 9867 + case 27005: + case 48578: + case 48579: case 21987: // Lash of Pain case 23959: // Test Stab R50 case 24825: // Test Backstab From ea7ec9e7a6b6f677a458789e1ec80aadbd24ef24 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 5 Dec 2011 19:25:52 +0100 Subject: [PATCH 16/18] Core/Spells: Fixed resurrection order (teleport, then set alive), fixes aggroing creatures nearby and during The Lich King's outro - players who fell off the platform --- src/server/game/Entities/Player/Player.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d32980bf72d..3a7f763d3ea 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5087,6 +5087,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0)) SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND); + setDeathState(ALIVE); + SetMovement(MOVE_LAND_WALK); SetMovement(MOVE_UNROOT); @@ -5116,8 +5118,6 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // update visibility UpdateObjectVisibility(); - setDeathState(ALIVE); - if (!applySickness) return; @@ -18300,7 +18300,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setFloat(index++, finiteAlways(GetPositionY())); stmt->setFloat(index++, finiteAlways(GetPositionZ())); stmt->setFloat(index++, finiteAlways(GetOrientation())); - + std::ostringstream ss; ss << m_taxi; stmt->setString(index++, ss.str()); @@ -18322,7 +18322,7 @@ void Player::SaveToDB(bool create /*=false*/) ss.str(""); ss << m_taxi.SaveTaxiDestinationsToString(); - + stmt->setString(index++, ss.str()); stmt->setUInt32(index++, GetArenaPoints()); stmt->setUInt32(index++, GetHonorPoints()); @@ -22478,12 +22478,9 @@ uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const void Player::ResurectUsingRequestData() { /// Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse - if (IS_PLAYER_GUID(m_resurrectGUID)) - TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); + TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); - //we cannot resurrect player when we triggered far teleport - //player will be resurrected upon teleportation - if (IsBeingTeleportedFar()) + if (IsBeingTeleported()) { ScheduleDelayedOperation(DELAYED_RESURRECT_PLAYER); return; From f43e8a937f5dd6051f02c7f292a02740d97bae8b Mon Sep 17 00:00:00 2001 From: Shocker Date: Mon, 5 Dec 2011 23:11:53 +0200 Subject: [PATCH 17/18] Core/Spells: Typo fix in recent commit --- src/server/game/Spells/SpellMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index fbdbc9816cd..058ddf7d269 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2827,7 +2827,7 @@ void SpellMgr::LoadSpellCustomAttr() case 6785: // Ravage case 6787: case 9866: - case 9867 + case 9867: case 27005: case 48578: case 48579: From 15c24a4e971e2808976d9844a60767442b51ae5e Mon Sep 17 00:00:00 2001 From: Nay Date: Tue, 6 Dec 2011 10:56:37 +0000 Subject: [PATCH 18/18] Core/Quest: Consistency, god damn.. (RequiredSourceItemIdCount -> RequiredSourceItemCount; quest_template did not change) --- src/server/game/Entities/Player/Player.cpp | 10 +++++----- src/server/game/Globals/ObjectMgr.cpp | 6 +++--- src/server/game/Quests/QuestDef.cpp | 2 +- src/server/game/Quests/QuestDef.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 3a7f763d3ea..0e98eb27596 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14857,7 +14857,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, { if (quest->RequiredSourceItemId[i]) { - uint32 count = quest->RequiredSourceItemIdCount[i]; + uint32 count = quest->RequiredSourceItemCount[i]; DestroyItemCount(quest->RequiredSourceItemId[i], count ? count : 9999, true); } } @@ -15055,9 +15055,9 @@ void Player::FailQuest(uint32 questId) // Destroy items recieved on starting the quest. DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true, true); for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - if (quest->RequiredSourceItemId[i] > 0 && quest->RequiredSourceItemIdCount[i] > 0) + if (quest->RequiredSourceItemId[i] > 0 && quest->RequiredSourceItemCount[i] > 0) // Destroy items recieved during the quest. - DestroyItemCount(quest->RequiredSourceItemId[i], quest->RequiredSourceItemIdCount[i], true, true); + DestroyItemCount(quest->RequiredSourceItemId[i], quest->RequiredSourceItemCount[i], true, true); } } @@ -16117,9 +16117,9 @@ bool Player::HasQuestForItem(uint32 itemid) const return true; // allows custom amount drop when not 0 - if (qinfo->RequiredSourceItemIdCount[j]) + if (qinfo->RequiredSourceItemCount[j]) { - if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemIdCount[j]) + if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemCount[j]) return true; } else if (GetItemCount(itemid, true) < pProto->GetMaxStackSize()) return true; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 294e83deeaa..3b62a4217b3 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4036,10 +4036,10 @@ void ObjectMgr::LoadQuests() } else { - if (qinfo->RequiredSourceItemIdCount[j]>0) + if (qinfo->RequiredSourceItemCount[j]>0) { - sLog->outErrorDb("Quest %u has `RequiredSourceItemId%d` = 0 but `RequiredSourceItemIdCount%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemIdCount[j]); + sLog->outErrorDb("Quest %u has `RequiredSourceItemId%d` = 0 but `RequiredSourceItemCount%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemCount[j]); // no changes, quest ignore this data } } diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index e6e95d90f5f..feb1c071b6d 100755 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -109,7 +109,7 @@ Quest::Quest(Field* questRecord) RequiredSourceItemId[i] = questRecord[97+i].GetUInt32(); for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - RequiredSourceItemIdCount[i] = questRecord[101+i].GetUInt32(); + RequiredSourceItemCount[i] = questRecord[101+i].GetUInt32(); for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) RequiredItemId[i] = questRecord[105+i].GetUInt32(); diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 8a34200ede2..989c63d2a64 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -263,7 +263,7 @@ class Quest uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]; uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; uint32 RequiredSourceItemId[QUEST_SOURCE_ITEM_IDS_COUNT]; - uint32 RequiredSourceItemIdCount[QUEST_SOURCE_ITEM_IDS_COUNT]; + uint32 RequiredSourceItemCount[QUEST_SOURCE_ITEM_IDS_COUNT]; int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]; uint32 RequiredSpellCast[QUEST_OBJECTIVES_COUNT];