From 375d3ba4eb986676fc9084a93414083a89d542a0 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 29 Nov 2008 23:07:23 -0600 Subject: *Fix crash bug in 353. Please do not use 353! --HG-- branch : trunk --- src/game/Map.cpp | 27 ++++++++++++++++----------- src/game/Map.h | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 5f98cffde2b..c807c6ab1a1 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -642,22 +642,27 @@ bool Map::loaded(const GridPair &p) const void Map::Update(const uint32 &t_diff) { - for(std::vector::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) + for(std::vector::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) { - (*iter)->m_Notified = true; - if(!(*iter)->IsInWorld()) + Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL); + if(!unit) continue; + unit->m_Notified = true; + if(!unit->IsInWorld()) continue; - CellPair val = Trinity::ComputeCellPair((*iter)->GetPositionX(), (*iter)->GetPositionY()); + CellPair val = Trinity::ComputeCellPair(unit->GetPositionX(), unit->GetPositionY()); Cell cell(val); - if((*iter)->GetTypeId() == TYPEID_PLAYER) - PlayerRelocationNotify((Player*)(*iter), cell, val); + if(unit->GetTypeId() == TYPEID_PLAYER) + PlayerRelocationNotify((Player*)unit, cell, val); else - CreatureRelocationNotify((Creature*)(*iter), cell, val); + CreatureRelocationNotify((Creature*)unit, cell, val); } - for(std::vector::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) + for(std::vector::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) { - (*iter)->m_IsInNotifyList = false; - (*iter)->m_Notified = false; + if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL)) + { + unit->m_IsInNotifyList = false; + unit->m_Notified = false; + } } i_unitsToNotify.clear(); @@ -2055,7 +2060,7 @@ void Map::AddUnitToNotify(Unit* u) { if(!u->m_IsInNotifyList) { - i_unitsToNotify.push_back(u); + i_unitsToNotify.push_back(u->GetGUID()); u->m_IsInNotifyList = true; } } \ No newline at end of file diff --git a/src/game/Map.h b/src/game/Map.h index 554b43217e1..167a34dcccd 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -315,7 +315,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager, public Trinity::O time_t i_gridExpiry; std::set i_activeObjects; - std::vector i_unitsToNotify; + std::vector i_unitsToNotify; std::set i_objectsToRemove; // Type specific code for add/remove to/from grid -- cgit v1.2.3