From fcc09483adf5da3880cd802845d05481bcd19db2 Mon Sep 17 00:00:00 2001 From: SilverIce Date: Wed, 23 Feb 2011 17:04:54 +0200 Subject: [PATCH] [11202] Schedule AI notify at adding to world This fixes the problem, that creatures, added at grid loading, do not start attack each other More shedule -> schedule fixes added, removed unused Map::PlayerRelocationNotify function --- src/game/Map.cpp | 34 ---------------------------------- src/game/Map.h | 5 ----- src/game/Unit.cpp | 11 ++++++----- src/game/Unit.h | 6 +++--- src/shared/revision_nr.h | 2 +- 5 files changed, 10 insertions(+), 48 deletions(-) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 488b68c77..4e71c6aa3 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -199,23 +199,6 @@ void Map::DeleteFromWorld(Player* pl) delete pl; } -template -void Map::AddNotifier(T* , Cell const& , CellPair const& ) -{ -} - -template<> -void Map::AddNotifier(Player* obj, Cell const& cell, CellPair const& cellpair) -{ - obj->ScheduleAINotify(0); -} - -template<> -void Map::AddNotifier(Creature* obj, Cell const&, CellPair const&) -{ - obj->ScheduleAINotify(0); -} - void Map::EnsureGridCreated(const GridPair &p) { @@ -317,8 +300,6 @@ bool Map::Add(Player *player) player->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY())); UpdateObjectVisibility(player,cell,p); - AddNotifier(player,cell,p); - if (i_data) i_data->OnPlayerEnter(player); @@ -359,8 +340,6 @@ Map::Add(T *obj) obj->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY())); UpdateObjectVisibility(obj,cell,p); - - AddNotifier(obj,cell,p); } void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) @@ -953,19 +932,6 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair cell.Visit(cellpair, player_notifier, *this, *obj, GetVisibilityDistance()); } -void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair ) -{ - MaNGOS::PlayerRelocationNotifier relocationNotifier(*player); - - TypeContainerVisitor p2grid_relocation(relocationNotifier); - TypeContainerVisitor p2world_relocation(relocationNotifier); - - float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); - - cell.Visit(cellpair, p2grid_relocation, *this, *player, radius); - cell.Visit(cellpair, p2world_relocation, *this, *player, radius); -} - void Map::SendInitSelf( Player * player ) { DETAIL_LOG("Creating player data for himself %u", player->GetGUIDLow()); diff --git a/src/game/Map.h b/src/game/Map.h index 108e1ba74..2090a296f 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -263,8 +263,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager void SendInitTransports( Player * player ); void SendRemoveTransports( Player * player ); - void PlayerRelocationNotify(Player* player, Cell cell, CellPair cellpair); - bool CreatureCellRelocation(Creature *creature, Cell new_cell); bool loaded(const GridPair &) const; @@ -337,9 +335,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager template void AddToGrid(T*, NGridType *, Cell const&); - template - void AddNotifier(T*, Cell const&, CellPair const&); - template void RemoveFromGrid(T*, NGridType *, Cell const&); }; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0507a3279..46a15e529 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -218,7 +218,7 @@ Unit::Unit() m_AuraFlags = 0; m_Visibility = VISIBILITY_ON; - m_AINotifySheduled = false; + m_AINotifyScheduled = false; m_detectInvisibilityMask = 0; m_invisibilityMask = 0; @@ -9355,6 +9355,7 @@ uint32 Unit::GetCreatePowers( Powers power ) const void Unit::AddToWorld() { Object::AddToWorld(); + ScheduleAINotify(0); } void Unit::RemoveFromWorld() @@ -10831,7 +10832,7 @@ class RelocationNotifyEvent : public BasicEvent public: RelocationNotifyEvent(Unit& owner) : BasicEvent(), m_owner(owner) { - m_owner._SetAINotifySheduled(true); + m_owner._SetAINotifyScheduled(true); } bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) @@ -10847,13 +10848,13 @@ public: MaNGOS::CreatureRelocationNotifier notify((Creature&)m_owner); Cell::VisitAllObjects(&m_owner,notify,radius); } - m_owner._SetAINotifySheduled(false); + m_owner._SetAINotifyScheduled(false); return true; } void Abort(uint64) { - m_owner._SetAINotifySheduled(false); + m_owner._SetAINotifyScheduled(false); } private: @@ -10862,7 +10863,7 @@ private: void Unit::ScheduleAINotify(uint32 delay) { - if (!IsAINotifySheduled()) + if (!IsAINotifyScheduled()) m_Events.AddEvent(new RelocationNotifyEvent(*this), m_Events.CalculateTime(delay)); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 264031238..ffaed0a09 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1955,8 +1955,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject MovementInfo m_movementInfo; void ScheduleAINotify(uint32 delay); - bool IsAINotifySheduled() const { return m_AINotifySheduled;} - void _SetAINotifySheduled(bool on) { m_AINotifySheduled = on;} // only for call from RelocationNotifyEvent class code + bool IsAINotifyScheduled() const { return m_AINotifyScheduled;} + void _SetAINotifyScheduled(bool on) { m_AINotifyScheduled = on;} // only for call from RelocationNotifyEvent code void OnRelocated(); protected: @@ -2026,7 +2026,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject UnitVisibility m_Visibility; Position m_last_notified_position; - bool m_AINotifySheduled; + bool m_AINotifyScheduled; Diminishing m_Diminishing; // Manage all Units threatening us diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4f4e394bc..6d68267ff 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11201" + #define REVISION_NR "11202" #endif // __REVISION_NR_H__