[11466] Use ObjectGuid in Map::m_objectsStore

This commit is contained in:
VladimirMangos 2011-05-10 21:58:20 +04:00
parent ef6a48fe03
commit b8bb108757
7 changed files with 16 additions and 15 deletions

View file

@ -191,7 +191,7 @@ void Creature::AddToWorld()
{ {
///- Register the creature for guid lookup ///- Register the creature for guid lookup
if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().insert<Creature>(GetGUID(), (Creature*)this); GetMap()->GetObjectsStore().insert<Creature>(GetObjectGuid(), (Creature*)this);
Unit::AddToWorld(); Unit::AddToWorld();
} }
@ -200,7 +200,7 @@ void Creature::RemoveFromWorld()
{ {
///- Remove the creature from the accessor ///- Remove the creature from the accessor
if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().erase<Creature>(GetGUID(), (Creature*)NULL); GetMap()->GetObjectsStore().erase<Creature>(GetObjectGuid(), (Creature*)NULL);
Unit::RemoveFromWorld(); Unit::RemoveFromWorld();
} }

View file

@ -41,7 +41,7 @@ void DynamicObject::AddToWorld()
{ {
///- Register the dynamicObject for guid lookup ///- Register the dynamicObject for guid lookup
if(!IsInWorld()) if(!IsInWorld())
GetMap()->GetObjectsStore().insert<DynamicObject>(GetGUID(), (DynamicObject*)this); GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this);
Object::AddToWorld(); Object::AddToWorld();
} }
@ -51,7 +51,7 @@ void DynamicObject::RemoveFromWorld()
///- Remove the dynamicObject from the accessor ///- Remove the dynamicObject from the accessor
if(IsInWorld()) if(IsInWorld())
{ {
GetMap()->GetObjectsStore().erase<DynamicObject>(GetGUID(), (DynamicObject*)NULL); GetMap()->GetObjectsStore().erase<DynamicObject>(GetObjectGuid(), (DynamicObject*)NULL);
GetViewPoint().Event_RemovedFromWorld(); GetViewPoint().Event_RemovedFromWorld();
} }

View file

@ -68,7 +68,7 @@ void GameObject::AddToWorld()
{ {
///- Register the gameobject for guid lookup ///- Register the gameobject for guid lookup
if(!IsInWorld()) if(!IsInWorld())
GetMap()->GetObjectsStore().insert<GameObject>(GetGUID(), (GameObject*)this); GetMap()->GetObjectsStore().insert<GameObject>(GetObjectGuid(), (GameObject*)this);
Object::AddToWorld(); Object::AddToWorld();
} }
@ -91,7 +91,7 @@ void GameObject::RemoveFromWorld()
} }
} }
GetMap()->GetObjectsStore().erase<GameObject>(GetGUID(), (GameObject*)NULL); GetMap()->GetObjectsStore().erase<GameObject>(GetObjectGuid(), (GameObject*)NULL);
} }
Object::RemoveFromWorld(); Object::RemoveFromWorld();

View file

@ -2902,7 +2902,7 @@ Player* Map::GetPlayer(ObjectGuid guid)
*/ */
Creature* Map::GetCreature(ObjectGuid guid) Creature* Map::GetCreature(ObjectGuid guid)
{ {
return m_objectsStore.find<Creature>(guid.GetRawValue(), (Creature*)NULL); return m_objectsStore.find<Creature>(guid, (Creature*)NULL);
} }
/** /**
@ -2912,7 +2912,7 @@ Creature* Map::GetCreature(ObjectGuid guid)
*/ */
Pet* Map::GetPet(ObjectGuid guid) Pet* Map::GetPet(ObjectGuid guid)
{ {
return m_objectsStore.find<Pet>(guid.GetRawValue(), (Pet*)NULL); return m_objectsStore.find<Pet>(guid, (Pet*)NULL);
} }
/** /**
@ -2953,7 +2953,7 @@ Creature* Map::GetAnyTypeCreature(ObjectGuid guid)
*/ */
GameObject* Map::GetGameObject(ObjectGuid guid) GameObject* Map::GetGameObject(ObjectGuid guid)
{ {
return m_objectsStore.find<GameObject>(guid.GetRawValue(), (GameObject*)NULL); return m_objectsStore.find<GameObject>(guid, (GameObject*)NULL);
} }
/** /**
@ -2963,7 +2963,7 @@ GameObject* Map::GetGameObject(ObjectGuid guid)
*/ */
DynamicObject* Map::GetDynamicObject(ObjectGuid guid) DynamicObject* Map::GetDynamicObject(ObjectGuid guid)
{ {
return m_objectsStore.find<DynamicObject>(guid.GetRawValue(), (DynamicObject*)NULL); return m_objectsStore.find<DynamicObject>(guid, (DynamicObject*)NULL);
} }
/** /**

View file

@ -230,7 +230,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
Unit* GetUnit(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case Unit* GetUnit(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case
WorldObject* GetWorldObject(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case WorldObject* GetWorldObject(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case
TypeUnorderedMapContainer<AllMapStoredObjectTypes>& GetObjectsStore() { return m_objectsStore; } typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer;
MapStoredObjectTypesContainer& GetObjectsStore() { return m_objectsStore; }
void AddUpdateObject(Object *obj) void AddUpdateObject(Object *obj)
{ {
@ -304,7 +305,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
typedef std::set<WorldObject*> ActiveNonPlayers; typedef std::set<WorldObject*> ActiveNonPlayers;
ActiveNonPlayers m_activeNonPlayers; ActiveNonPlayers m_activeNonPlayers;
ActiveNonPlayers::iterator m_activeNonPlayersIter; ActiveNonPlayers::iterator m_activeNonPlayersIter;
TypeUnorderedMapContainer<AllMapStoredObjectTypes> m_objectsStore; MapStoredObjectTypesContainer m_objectsStore;
private: private:
time_t i_gridExpiry; time_t i_gridExpiry;

View file

@ -58,7 +58,7 @@ void Pet::AddToWorld()
{ {
///- Register the pet for guid lookup ///- Register the pet for guid lookup
if(!IsInWorld()) if(!IsInWorld())
GetMap()->GetObjectsStore().insert<Pet>(GetGUID(), (Pet*)this); GetMap()->GetObjectsStore().insert<Pet>(GetObjectGuid(), (Pet*)this);
Unit::AddToWorld(); Unit::AddToWorld();
} }
@ -67,7 +67,7 @@ void Pet::RemoveFromWorld()
{ {
///- Remove the pet from the accessor ///- Remove the pet from the accessor
if(IsInWorld()) if(IsInWorld())
GetMap()->GetObjectsStore().erase<Pet>(GetGUID(), (Pet*)NULL); GetMap()->GetObjectsStore().erase<Pet>(GetObjectGuid(), (Pet*)NULL);
///- Don't call the function for Creature, normal mobs + totems go in a different storage ///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld(); Unit::RemoveFromWorld();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11465" #define REVISION_NR "11466"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__