diff options
author | megamage <none@none> | 2008-11-29 13:08:23 -0600 |
---|---|---|
committer | megamage <none@none> | 2008-11-29 13:08:23 -0600 |
commit | 3d8d45c57a84538afbf716fc9304ea3207ea1948 (patch) | |
tree | d0dd806cae116e624bb6d999123c8dd70b411736 /src | |
parent | f2814351afa9c3b14eb6d055e655ccbb762589e2 (diff) |
*Do unit relocation notification only once per update. Hope this can solve the stealth crash problem once for all.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/GridNotifiersImpl.h | 6 | ||||
-rw-r--r-- | src/game/Map.cpp | 49 | ||||
-rw-r--r-- | src/game/Map.h | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 9 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
5 files changed, 59 insertions, 9 deletions
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 41f7cc6c068..a4ad5a51bf7 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -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); } } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index b1f22a63e78..5f98cffde2b 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -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; + } +}
\ No newline at end of file diff --git a/src/game/Map.h b/src/game/Map.h index 5f2212e53a7..554b43217e1 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -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 diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f23f450c201..645ff194eba 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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); +}
\ No newline at end of file diff --git a/src/game/Unit.h b/src/game/Unit.h index 7b2ddc22631..3b2656b539a 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -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 (); |