From c24e3363876a0fbec2f554d9e3b5bd2370760ff9 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 17 Mar 2009 10:30:39 -0600 Subject: [PATCH 1/7] *Remove an assert and use error log instead. --HG-- branch : trunk --- src/game/Player.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 78ac6dc3958..28dc950abcd 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16332,7 +16332,10 @@ void Player::Uncharm() charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS); } - assert(!GetCharmGUID()); + if(GetCharmGUID()) + { + sLog.outError("CRASH ALARM! Player %s is not able to uncharm unit (Entry: %u, Type: %u)", GetName(), charm->GetEntry(), charm->GetTypeId()); + } } void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const From d4b52d5bbcd966da58e03db11442bee995c11e98 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 17 Mar 2009 10:40:28 -0600 Subject: [PATCH 2/7] *Move movementinform to finalize function to prevent error log spams. --HG-- branch : trunk --- src/game/PointMovementGenerator.cpp | 16 ++++++++++++---- src/game/PointMovementGenerator.h | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 4aa21d32d55..6117dbf903d 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -57,15 +57,22 @@ bool PointMovementGenerator::Update(T &unit, const uint32 &diff) if(i_destinationHolder.HasArrived()) { - //unit.StopMoving(); - if(!unit.hasUnitState(UNIT_STAT_CHARGING)) - MovementInform(unit); + arrived = true; return false; } return true; } +template +void PointMovementGenerator:: Finalize(T &unit) +{ + if(unit.hasUnitState(UNIT_STAT_CHARGING)) + unit.clearUnitState(UNIT_STAT_CHARGING); + else if(arrived) + MovementInform(unit); +} + template void PointMovementGenerator::MovementInform(T &unit) { @@ -79,7 +86,8 @@ template <> void PointMovementGenerator::MovementInform(Creature &unit template void PointMovementGenerator::Initialize(Player&); template bool PointMovementGenerator::Update(Player &, const uint32 &diff); template void PointMovementGenerator::MovementInform(Player&); +template void PointMovementGenerator::Finalize(Player&); template void PointMovementGenerator::Initialize(Creature&); template bool PointMovementGenerator::Update(Creature&, const uint32 &diff); - +template void PointMovementGenerator::Finalize(Creature&); diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index 5d0bb4e80e7..5f1bf33c348 100644 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -32,10 +32,10 @@ class TRINITY_DLL_SPEC PointMovementGenerator { public: PointMovementGenerator(uint32 _id, float _x, float _y, float _z) : id(_id), - i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0) {} + i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0), arrived(false) {} void Initialize(T &); - void Finalize(T &unit){unit.clearUnitState(UNIT_STAT_CHARGING);} + void Finalize(T &unit); void Reset(T &unit){unit.StopMoving();} bool Update(T &, const uint32 &diff); @@ -49,6 +49,7 @@ class TRINITY_DLL_SPEC PointMovementGenerator float i_x,i_y,i_z; uint32 id; DestinationHolder< Traveller > i_destinationHolder; + bool arrived; }; #endif From 5fb7a0585c0fcc417811aae23ced3dd577aadcd3 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 17 Mar 2009 14:35:11 -0600 Subject: [PATCH 3/7] *Fix a bug that redundant packets are sent to clients which may cause freeze. --HG-- branch : trunk --- src/game/GridNotifiers.cpp | 13 +------------ src/game/GridNotifiers.h | 5 ----- src/game/GridNotifiersImpl.h | 4 ++-- src/game/Object.cpp | 1 - src/game/Player.cpp | 13 ++++++------- src/game/Player.h | 2 +- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index fcb4e376b26..f52932df83d 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -54,7 +54,7 @@ PlayerVisibilityNotifier::Notify() if(i_clientGUIDs.find((*itr)->GetGUID())!=i_clientGUIDs.end()) { (*itr)->UpdateVisibilityOf(&i_player); - i_player.UpdateVisibilityOf((*itr),i_data,i_data_updates,i_visibleNow); + i_player.UpdateVisibilityOf((*itr),i_data,i_visibleNow); i_clientGUIDs.erase((*itr)->GetGUID()); } } @@ -72,17 +72,6 @@ PlayerVisibilityNotifier::Notify() #endif } - // send update to other players (except player updates that already sent using SendUpdateToPlayer) - for(UpdateDataMapType::iterator iter = i_data_updates.begin(); iter != i_data_updates.end(); ++iter) - { - if(iter->first==&i_player) - continue; - - WorldPacket packet; - iter->second.BuildPacket(&packet); - iter->first->GetSession()->SendPacket(&packet); - } - if( i_data.HasData() ) { // send create/outofrange packet to player (except player create updates that already sent using SendUpdateToPlayer) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index daa8296674a..b34eee36e7b 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -42,17 +42,12 @@ namespace Trinity { Player &i_player; UpdateData i_data; - UpdateDataMapType i_data_updates; Player::ClientGUIDs i_clientGUIDs; std::set i_visibleNow; PlayerVisibilityNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {} template inline void Visit(GridRefManager &); - /*#ifdef WIN32 - template<> inline void Visit(PlayerMapType &); - template<> inline void Visit(CreatureMapType &); - #endif*/ void Notify(void); }; diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index b7660d90c3b..5c071567f9a 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -87,7 +87,7 @@ Trinity::PlayerRelocationNotifier::Visit(PlayerMapType &m) if(iter->getSource()->m_Notified) //self is also skipped in this check continue; - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_visibleNow); iter->getSource()->UpdateVisibilityOf(&i_player); //if (!i_player.GetSharedVisionList().empty()) @@ -112,7 +112,7 @@ Trinity::PlayerRelocationNotifier::Visit(CreatureMapType &m) if(iter->getSource()->m_Notified) continue; - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_visibleNow); PlayerCreatureRelocationWorker(&i_player, iter->getSource()); } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 10eafcba93d..23db2319cf9 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -214,7 +214,6 @@ void Object::SendUpdateToPlayer(Player* player) UpdateData upd; WorldPacket packet; - upd.Clear(); BuildCreateUpdateBlockForPlayer(&upd, player); upd.BuildPacket(&packet); player->GetSession()->SendPacket(&packet); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 28dc950abcd..cdec0f53eca 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17810,7 +17810,7 @@ inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) } template -void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow) +void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set& visibleNow) { if(HaveAtClient(target)) { @@ -17830,7 +17830,6 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& if(target->isVisibleForInState(this,false)) { visibleNow.insert(target); - target->BuildUpdate(data_updates); target->BuildCreateUpdateBlockForPlayer(&data, this); UpdateVisibilityOf_helper(m_clientGUIDs,target); @@ -17877,11 +17876,11 @@ void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, Up } }*/ -template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, std::set& visibleNow); +template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, std::set& visibleNow); +template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, std::set& visibleNow); +template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, std::set& visibleNow); +template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, std::set& visibleNow); void Player::InitPrimaryProffesions() { diff --git a/src/game/Player.h b/src/game/Player.h index 0003c6d85bc..7cedab880f2 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2026,7 +2026,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SendInitialVisiblePackets(Unit* target); template - void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); + void UpdateVisibilityOf(T* target, UpdateData& data, std::set& visibleNow); // Stealth detection system uint32 m_DetectInvTimer; From 8a21e4199b85fbc4658b11afc67e5c99587d9e0b Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 17 Mar 2009 15:55:27 -0600 Subject: [PATCH 4/7] *Fix build. --HG-- branch : trunk --- src/game/GridNotifiersImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 5c071567f9a..5f4fe8cb05b 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -71,7 +71,7 @@ Trinity::PlayerVisibilityNotifier::Visit(GridRefManager &m) { for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) { - i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow); + i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_visibleNow); i_clientGUIDs.erase(iter->getSource()->GetGUID()); } } From e440f13402ff379794616cb29c11d5dc17025511 Mon Sep 17 00:00:00 2001 From: megamage Date: Wed, 18 Mar 2009 15:26:32 -0600 Subject: [PATCH 5/7] *Fixed possible crash and wrong data in instance state save (or not save). Author: zhenya --HG-- branch : trunk --- src/game/InstanceSaveMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 21d806db921..ba34f949a5f 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -163,7 +163,7 @@ void InstanceSave::SaveToDB() // save instance data too std::string data; - Map *map = MapManager::Instance().FindMap(m_instanceid, GetMapId()); + Map *map = MapManager::Instance().FindMap(GetMapId(),m_instanceid); if(map) { assert(map->IsDungeon()); From f11d41b9ceb0fabe8055b2e798a31aac019ba3c7 Mon Sep 17 00:00:00 2001 From: megamage Date: Wed, 18 Mar 2009 15:28:19 -0600 Subject: [PATCH 6/7] *Do not always add target to aoe map with target number limit. --HG-- branch : trunk --- src/game/Spell.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 04310f2c6c8..a0b6b79a15b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1990,14 +1990,10 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) break; } - if(unMaxTargets && TagUnitMap.size() > 1) + if(unMaxTargets && !EffectChainTarget && TagUnitMap.size() > 1) { - if(m_targets.getUnitTarget()) - { + if(m_spellInfo->Id == 5246) //Intimidating Shout TagUnitMap.remove(m_targets.getUnitTarget()); - if(m_spellInfo->Id != 5246) //Intimidating Shout - --unMaxTargets; - } // remove random units from the map std::list::iterator itr; @@ -2007,10 +2003,6 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) advance(itr, urand(0, TagUnitMap.size() - 1)); TagUnitMap.erase(itr); } - - // the player's target will always be added to the map - if(m_targets.getUnitTarget() && m_spellInfo->Id != 5246) - TagUnitMap.push_back(m_targets.getUnitTarget()); } } From dbd69bda613faed2cc30ba95de5c07235ae73653 Mon Sep 17 00:00:00 2001 From: megamage Date: Wed, 18 Mar 2009 15:29:25 -0600 Subject: [PATCH 7/7] *Fix chain heal. Heal target even when it has full health. --HG-- branch : trunk --- src/game/Spell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index a0b6b79a15b..dd63041e63c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1361,8 +1361,8 @@ void Spell::SearchChainTarget(std::list &TagUnitMap, float max_range, uin { SearchAreaTarget(tempUnitMap, max_range, PUSH_TARGET_CENTER, SPELL_TARGETS_ALLY); tempUnitMap.sort(ChainHealingOrder(m_caster)); - if(cur->GetHealth() == cur->GetMaxHealth() && tempUnitMap.size()) - cur = tempUnitMap.front(); + //if(cur->GetHealth() == cur->GetMaxHealth() && tempUnitMap.size()) + // cur = tempUnitMap.front(); } else SearchAreaTarget(tempUnitMap, max_range, PUSH_TARGET_CENTER, TargetType);