[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
This commit is contained in:
SilverIce 2011-02-23 17:04:54 +02:00
parent 6529e69924
commit fcc09483ad
5 changed files with 10 additions and 48 deletions

View file

@ -199,23 +199,6 @@ void Map::DeleteFromWorld(Player* pl)
delete pl;
}
template<class T>
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<MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > 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());

View file

@ -263,8 +263,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
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<NGridType>
template<class T>
void AddToGrid(T*, NGridType *, Cell const&);
template<class T>
void AddNotifier(T*, Cell const&, CellPair const&);
template<class T>
void RemoveFromGrid(T*, NGridType *, Cell const&);
};

View file

@ -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));
}

View file

@ -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

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11201"
#define REVISION_NR "11202"
#endif // __REVISION_NR_H__