mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
*Do unit relocation notification only once per update. Hope this can solve the stealth crash problem once for all.
--HG-- branch : trunk
This commit is contained in:
@@ -101,7 +101,7 @@ Trinity::PlayerRelocationNotifier::Visit(CreatureMapType &m)
|
||||
return;
|
||||
|
||||
for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
if( iter->getSource()->isAlive())
|
||||
if( !iter->getSource()->m_Notified && iter->getSource()->isAlive())
|
||||
PlayerCreatureRelocationWorker(&i_player,iter->getSource());
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ Trinity::CreatureRelocationNotifier::Visit(PlayerMapType &m)
|
||||
return;
|
||||
|
||||
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
if( iter->getSource()->isAlive() && !iter->getSource()->isInFlight())
|
||||
if( !iter->getSource()->m_Notified && iter->getSource()->isAlive() && !iter->getSource()->isInFlight())
|
||||
PlayerCreatureRelocationWorker(iter->getSource(), &i_creature);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ Trinity::CreatureRelocationNotifier::Visit(CreatureMapType &m)
|
||||
for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Creature* c = iter->getSource();
|
||||
if( c != &i_creature && c->isAlive())
|
||||
if( !iter->getSource()->m_Notified && c != &i_creature && c->isAlive())
|
||||
CreatureCreatureRelocationWorker(c, &i_creature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,7 +466,8 @@ bool Map::Add(Player *player)
|
||||
UpdatePlayerVisibility(player,cell,p);
|
||||
UpdateObjectsVisibilityFor(player,cell,p);
|
||||
|
||||
AddNotifier(player,cell,p);
|
||||
//AddNotifier(player,cell,p);
|
||||
AddUnitToNotify(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -496,7 +497,9 @@ Map::Add(T *obj)
|
||||
|
||||
UpdateObjectVisibility(obj,cell,p);
|
||||
|
||||
AddNotifier(obj,cell,p);
|
||||
//AddNotifier(obj,cell,p);
|
||||
if(obj->GetTypeId() == TYPEID_UNIT || obj->GetTypeId() == TYPEID_PLAYER)
|
||||
AddUnitToNotify((Unit*)obj);
|
||||
}
|
||||
|
||||
void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self, bool to_possessor)
|
||||
@@ -639,6 +642,25 @@ bool Map::loaded(const GridPair &p) const
|
||||
|
||||
void Map::Update(const uint32 &t_diff)
|
||||
{
|
||||
for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
|
||||
{
|
||||
(*iter)->m_Notified = true;
|
||||
if(!(*iter)->IsInWorld())
|
||||
continue;
|
||||
CellPair val = Trinity::ComputeCellPair((*iter)->GetPositionX(), (*iter)->GetPositionY());
|
||||
Cell cell(val);
|
||||
if((*iter)->GetTypeId() == TYPEID_PLAYER)
|
||||
PlayerRelocationNotify((Player*)(*iter), cell, val);
|
||||
else
|
||||
CreatureRelocationNotify((Creature*)(*iter), cell, val);
|
||||
}
|
||||
for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
|
||||
{
|
||||
(*iter)->m_IsInNotifyList = false;
|
||||
(*iter)->m_Notified = false;
|
||||
}
|
||||
i_unitsToNotify.clear();
|
||||
|
||||
resetMarkedCells();
|
||||
|
||||
//TODO: is there a better way to update activeobjects?
|
||||
@@ -845,7 +867,8 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati
|
||||
if(player->isPossessedByPlayer())
|
||||
UpdateObjectsVisibilityFor((Player*)player->GetCharmer(), new_cell, new_val);
|
||||
|
||||
PlayerRelocationNotify(player,new_cell,new_val);
|
||||
//PlayerRelocationNotify(player,new_cell,new_val);
|
||||
AddUnitToNotify(player);
|
||||
NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY());
|
||||
if( !same_cell && newGrid->GetGridState()!= GRID_STATE_ACTIVE )
|
||||
{
|
||||
@@ -888,7 +911,8 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
|
||||
if(creature->isPossessedByPlayer())
|
||||
UpdateObjectsVisibilityFor((Player*)creature->GetCharmer(), new_cell, new_val);
|
||||
|
||||
CreatureRelocationNotify(creature,new_cell,new_val);
|
||||
//CreatureRelocationNotify(creature,new_cell,new_val);
|
||||
AddUnitToNotify(creature);
|
||||
}
|
||||
assert(CheckGridIntegrity(creature,true));
|
||||
}
|
||||
@@ -920,7 +944,8 @@ void Map::MoveAllCreaturesInMoveList()
|
||||
{
|
||||
// update pos
|
||||
c->Relocate(cm.x, cm.y, cm.z, cm.ang);
|
||||
CreatureRelocationNotify(c,new_cell,new_cell.cellPair());
|
||||
//CreatureRelocationNotify(c,new_cell,new_cell.cellPair());
|
||||
AddUnitToNotify(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1015,7 +1040,8 @@ bool Map::CreatureRespawnRelocation(Creature *c)
|
||||
{
|
||||
c->Relocate(resp_x, resp_y, resp_z, resp_o);
|
||||
c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
|
||||
CreatureRelocationNotify(c,resp_cell,resp_cell.cellPair());
|
||||
//CreatureRelocationNotify(c,resp_cell,resp_cell.cellPair());
|
||||
AddUnitToNotify(c);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -2022,3 +2048,14 @@ void BattleGroundMap::UnloadAll(bool pForce)
|
||||
|
||||
Map::UnloadAll(pForce);
|
||||
}
|
||||
|
||||
/*--------------------------TRINITY-------------------------*/
|
||||
|
||||
void Map::AddUnitToNotify(Unit* u)
|
||||
{
|
||||
if(!u->m_IsInNotifyList)
|
||||
{
|
||||
i_unitsToNotify.push_back(u);
|
||||
u->m_IsInNotifyList = true;
|
||||
}
|
||||
}
|
||||
@@ -246,6 +246,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
||||
|
||||
void AddActiveObject(WorldObject* obj) { i_activeObjects.insert(obj); }
|
||||
void RemoveActiveObject(WorldObject* obj) { i_activeObjects.erase(obj); }
|
||||
void AddUnitToNotify(Unit* unit);
|
||||
|
||||
void SendToPlayers(WorldPacket const* data) const;
|
||||
|
||||
@@ -314,6 +315,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
|
||||
time_t i_gridExpiry;
|
||||
|
||||
std::set<WorldObject *> i_activeObjects;
|
||||
std::vector<Unit*> i_unitsToNotify;
|
||||
std::set<WorldObject *> i_objectsToRemove;
|
||||
|
||||
// Type specific code for add/remove to/from grid
|
||||
|
||||
@@ -148,6 +148,7 @@ bool IsPassiveStackableSpell( uint32 spellId )
|
||||
|
||||
Unit::Unit()
|
||||
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this)
|
||||
, m_IsInNotifyList(false), m_Notified(false)
|
||||
{
|
||||
m_objectType |= TYPEMASK_UNIT;
|
||||
m_objectTypeId = TYPEID_UNIT;
|
||||
@@ -12562,3 +12563,11 @@ void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo)
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------TRINITY-----------------------------*/
|
||||
|
||||
void Unit::SetToNotify()
|
||||
{
|
||||
if(Map *map = GetMap())
|
||||
map->AddUnitToNotify(this);
|
||||
}
|
||||
@@ -1374,6 +1374,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
void AddPetAura(PetAura const* petSpell);
|
||||
void RemovePetAura(PetAura const* petSpell);
|
||||
|
||||
void SetToNotify();
|
||||
bool m_Notified, m_IsInNotifyList;
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user