[8718] Remove most GetObjectInWorld functions and move some map local to Map

Also mape pet guid counter per-map (in different expecte to be global pet number)
This commit is contained in:
VladimirMangos 2009-10-23 03:56:46 +04:00
parent 40b0a2cd92
commit d7ae5e3af0
20 changed files with 135 additions and 132 deletions

View file

@ -71,13 +71,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER); uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
// kick if player currently // kick if player currently
if(Player* p = ObjectAccessor::GetObjectInWorld(guid, (Player*)NULL)) ObjectAccessor::KickPlayer(guid);
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accid, false); // no need to update realm characters Player::DeleteFromDB(guid, accid, false); // no need to update realm characters
} while (result->NextRow()); } while (result->NextRow());

View file

@ -126,7 +126,7 @@ void Corpse::SaveToDB()
void Corpse::DeleteBonesFromWorld() void Corpse::DeleteBonesFromWorld()
{ {
assert(GetType() == CORPSE_BONES); assert(GetType() == CORPSE_BONES);
Corpse* corpse = ObjectAccessor::GetCorpse(*this, GetGUID()); Corpse* corpse = GetMap()->GetCorpse(GetGUID());
if (!corpse) if (!corpse)
{ {

View file

@ -603,7 +603,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{ {
objmgr.RemoveCreatureFromGrid(*itr, data); objmgr.RemoveCreatureFromGrid(*itr, data);
if( Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT), (Creature*)NULL) ) if( Creature* pCreature = ObjectAccessor::GetCreatureInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT)) )
pCreature->AddObjectToRemoveList(); pCreature->AddObjectToRemoveList();
} }
} }
@ -621,7 +621,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{ {
objmgr.RemoveGameobjectFromGrid(*itr, data); objmgr.RemoveGameobjectFromGrid(*itr, data);
if( GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL) ) if( GameObject* pGameobject = ObjectAccessor::Instance().GetGameObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_GAMEOBJECT)) )
pGameobject->AddObjectToRemoveList(); pGameobject->AddObjectToRemoveList();
} }
} }
@ -647,7 +647,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
continue; continue;
// Update if spawned // Update if spawned
Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(itr->first, data->id,HIGHGUID_UNIT), (Creature*)NULL); Creature* pCreature = ObjectAccessor::GetCreatureInWorld(MAKE_NEW_GUID(itr->first, data->id,HIGHGUID_UNIT));
if (pCreature) if (pCreature)
{ {
if (activate) if (activate)

View file

@ -129,7 +129,7 @@ VisibleNotifier::Notify()
if(!IS_PLAYER_GUID(*iter)) if(!IS_PLAYER_GUID(*iter))
continue; continue;
if (Player* plr = ObjectAccessor::GetPlayer(i_player,*iter)) if (Player* plr = ObjectAccessor::FindPlayer(*iter))
plr->UpdateVisibilityOf(plr->GetViewPoint(),&i_player); plr->UpdateVisibilityOf(plr->GetViewPoint(),&i_player);
} }
} }

View file

@ -67,7 +67,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
} }
else if (IS_CORPSE_GUID(lguid)) else if (IS_CORPSE_GUID(lguid))
{ {
Corpse *bones = ObjectAccessor::GetCorpse(*player, lguid); Corpse *bones = player->GetMap()->GetCorpse(lguid);
if (!bones) if (!bones)
{ {
player->SendLootRelease(lguid); player->SendLootRelease(lguid);
@ -180,7 +180,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
} }
case HIGHGUID_CORPSE: // remove insignia ONLY in BG case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{ {
Corpse *bones = ObjectAccessor::GetCorpse(*GetPlayer(), guid); Corpse *bones = _player->GetMap()->GetCorpse(guid);
if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE) )
pLoot = &bones->loot; pLoot = &bones->loot;
@ -367,7 +367,7 @@ void WorldSession::DoLootRelease( uint64 lguid )
} }
else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG
{ {
Corpse *corpse = ObjectAccessor::GetCorpse(*player, lguid); Corpse *corpse = _player->GetMap()->GetCorpse(lguid);
if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE) )
return; return;

View file

@ -203,7 +203,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par
m_activeNonPlayersIter(m_activeNonPlayers.end()), m_activeNonPlayersIter(m_activeNonPlayers.end()),
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this), i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this),
m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
m_hiDynObjectGuid(1), m_hiVehicleGuid(1) m_hiDynObjectGuid(1), m_hiPetGuid(1), m_hiVehicleGuid(1)
{ {
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
{ {
@ -776,8 +776,8 @@ bool Map::RemoveBones(uint64 guid, float x, float y)
{ {
if (IsRemovalGrid(x, y)) if (IsRemovalGrid(x, y))
{ {
Corpse* corpse = ObjectAccessor::GetObjectInWorld(guid, (Corpse*)NULL); Corpse* corpse = ObjectAccessor::GetCorpseInMap(guid,GetId());
if(!corpse || corpse->GetMapId() != GetId()) if (!corpse)
return false; return false;
CellPair p = MaNGOS::ComputeCellPair(x,y); CellPair p = MaNGOS::ComputeCellPair(x,y);
@ -2146,7 +2146,8 @@ void Map::RemoveAllObjectsInRemoveList()
{ {
case TYPEID_CORPSE: case TYPEID_CORPSE:
{ {
Corpse* corpse = ObjectAccessor::Instance().GetCorpse(*obj, obj->GetGUID()); // ??? WTF
Corpse* corpse = GetCorpse(obj->GetGUID());
if (!corpse) if (!corpse)
sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow());
else else
@ -3425,6 +3426,16 @@ Pet* Map::GetPet(uint64 guid)
return m_objectsStore.find<Pet>(guid, (Pet*)NULL); return m_objectsStore.find<Pet>(guid, (Pet*)NULL);
} }
Corpse* Map::GetCorpse(uint64 guid)
{
Corpse * ret = ObjectAccessor::GetCorpseInMap(guid,GetId());
if (!ret)
return NULL;
if (ret->GetInstanceId() != GetInstanceId())
return NULL;
return ret;
}
Creature* Map::GetCreatureOrPetOrVehicle(uint64 guid) Creature* Map::GetCreatureOrPetOrVehicle(uint64 guid)
{ {
if (IS_PLAYER_GUID(guid)) if (IS_PLAYER_GUID(guid))
@ -3449,6 +3460,25 @@ DynamicObject* Map::GetDynamicObject(uint64 guid)
return m_objectsStore.find<DynamicObject>(guid, (DynamicObject*)NULL); return m_objectsStore.find<DynamicObject>(guid, (DynamicObject*)NULL);
} }
WorldObject* Map::GetWorldObject(uint64 guid)
{
switch(GUID_HIPART(guid))
{
case HIGHGUID_PLAYER: return ObjectAccessor::FindPlayer(guid);
case HIGHGUID_GAMEOBJECT: return GetGameObject(guid);
case HIGHGUID_UNIT: return GetCreature(guid);
case HIGHGUID_PET: return GetPet(guid);
case HIGHGUID_VEHICLE: return GetVehicle(guid);
case HIGHGUID_DYNAMICOBJECT:return GetDynamicObject(guid);
case HIGHGUID_CORPSE: return GetCorpse(guid);
case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_TRANSPORT:
default: break;
}
return NULL;
}
void Map::SendObjectUpdates() void Map::SendObjectUpdates()
{ {
UpdateDataMapType update_players; UpdateDataMapType update_players;
@ -3483,6 +3513,13 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh)
World::StopNow(ERROR_EXIT_CODE); World::StopNow(ERROR_EXIT_CODE);
} }
return m_hiDynObjectGuid++; return m_hiDynObjectGuid++;
case HIGHGUID_PET:
if(m_hiPetGuid>=0x00FFFFFE)
{
sLog.outError("Pet guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiPetGuid++;
case HIGHGUID_VEHICLE: case HIGHGUID_VEHICLE:
if(m_hiVehicleGuid>=0x00FFFFFF) if(m_hiVehicleGuid>=0x00FFFFFF)
{ {

View file

@ -433,6 +433,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
Creature* GetCreatureOrPetOrVehicle(uint64 guid); Creature* GetCreatureOrPetOrVehicle(uint64 guid);
GameObject* GetGameObject(uint64 guid); GameObject* GetGameObject(uint64 guid);
DynamicObject* GetDynamicObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid);
Corpse* GetCorpse(uint64 guid);
WorldObject* GetWorldObject(uint64 guid);
TypeUnorderedMapContainer<AllMapStoredObjectTypes>& GetObjectsStore() { return m_objectsStore; } TypeUnorderedMapContainer<AllMapStoredObjectTypes>& GetObjectsStore() { return m_objectsStore; }
@ -532,6 +534,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
// Map local low guid counters // Map local low guid counters
uint32 m_hiDynObjectGuid; uint32 m_hiDynObjectGuid;
uint32 m_hiPetGuid;
uint32 m_hiVehicleGuid; uint32 m_hiVehicleGuid;
// Type specific code for add/remove to/from grid // Type specific code for add/remove to/from grid

View file

@ -65,38 +65,17 @@ ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
return u.GetMap()->GetCreatureOrPetOrVehicle(guid); return u.GetMap()->GetCreatureOrPetOrVehicle(guid);
} }
Corpse* Corpse* ObjectAccessor::GetCorpseInMap( uint64 guid, uint32 mapid )
ObjectAccessor::GetCorpse(WorldObject const &u, uint64 guid)
{ {
Corpse * ret = GetObjectInWorld(guid, (Corpse*)NULL); Corpse * ret = HashMapHolder<Corpse>::Find(guid);
if(!ret) if(!ret)
return NULL; return NULL;
if(ret->GetMapId() != u.GetMapId()) if(ret->GetMapId() != mapid)
return NULL;
if(ret->GetInstanceId() != u.GetInstanceId())
return NULL; return NULL;
return ret; return ret;
} }
WorldObject* ObjectAccessor::GetWorldObject(WorldObject const &p, uint64 guid)
{
switch(GUID_HIPART(guid))
{
case HIGHGUID_PLAYER: return FindPlayer(guid);
case HIGHGUID_GAMEOBJECT: return p.GetMap()->GetGameObject(guid);
case HIGHGUID_UNIT: return p.GetMap()->GetCreature(guid);
case HIGHGUID_PET: return p.GetMap()->GetPet(guid);
case HIGHGUID_VEHICLE: return p.GetMap()->GetVehicle(guid);
case HIGHGUID_DYNAMICOBJECT:return p.GetMap()->GetDynamicObject(guid);
case HIGHGUID_TRANSPORT: return NULL;
case HIGHGUID_CORPSE: return GetCorpse(p,guid);
case HIGHGUID_MO_TRANSPORT: return NULL;
default: break;
}
return NULL;
}
Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, uint32 typemask) Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, uint32 typemask)
{ {
switch(GUID_HIPART(guid)) switch(GUID_HIPART(guid))
@ -141,7 +120,7 @@ Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, u
Player* Player*
ObjectAccessor::FindPlayer(uint64 guid) ObjectAccessor::FindPlayer(uint64 guid)
{ {
Player * plr = GetObjectInWorld(guid, (Player*)NULL); Player * plr = HashMapHolder<Player>::Find(guid);;
if(!plr || !plr->IsInWorld()) if(!plr || !plr->IsInWorld())
return NULL; return NULL;
@ -170,6 +149,16 @@ ObjectAccessor::SaveAllPlayers()
itr->second->SaveToDB(); itr->second->SaveToDB();
} }
void ObjectAccessor::KickPlayer(uint64 guid)
{
if (Player* p = HashMapHolder<Player>::Find(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
}
Corpse* Corpse*
ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid) ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
{ {

View file

@ -88,46 +88,43 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
public: public:
typedef UNORDERED_MAP<uint64, Corpse* > Player2CorpsesMapType; typedef UNORDERED_MAP<uint64, Corpse* > Player2CorpsesMapType;
// global // global (obj used for map only location local guid objects (pets currently)
static Player* GetObjectInWorld(uint64 guid, Player* /*fake*/) { return HashMapHolder<Player>::Find(guid); } static Unit* GetUnitInWorld(WorldObject const& obj, uint64 guid);
static Corpse* GetObjectInWorld(uint64 guid, Corpse* /*fake*/) { return HashMapHolder<Corpse>::Find(guid); }
static Unit* GetObjectInWorld(uint64 guid, Unit* /*fake*/);
// map local object with global search // FIXME: map local object with global search
static Creature* GetObjectInWorld(uint64 guid, Creature* /*fake*/) { return FindHelper<Creature>(guid); } static Creature* GetCreatureInWorld(uint64 guid) { return FindHelper<Creature>(guid); }
static GameObject* GetObjectInWorld(uint64 guid, GameObject* /*fake*/) { return FindHelper<GameObject>(guid); } static GameObject* GetGameObjectInWorld(uint64 guid) { return FindHelper<GameObject>(guid); }
static Pet* GetObjectInWorld(uint64 guid, Pet* /*fake*/) { return FindHelper<Pet>(guid); }
static Vehicle* GetObjectInWorld(uint64 guid, Vehicle* /*fake*/); // no implementation, link error trap until creature move to Map
static WorldObject* GetWorldObject(WorldObject const &, uint64); // possible local search for specific object map
static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask); static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask);
static Unit* GetUnit(WorldObject const &, uint64); static Unit* GetUnit(WorldObject const &, uint64);
static Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); }
static Corpse* GetCorpse(WorldObject const &u, uint64 guid);
static Pet* GetPet(uint64 guid) { return GetObjectInWorld(guid, (Pet*)NULL); }
static Player* FindPlayer(uint64);
Player* FindPlayerByName(const char *name) ; // Player access
static Player* FindPlayer(uint64 guid);
static Player* FindPlayerByName(const char *name);
static void KickPlayer(uint64 guid);
HashMapHolder<Player>::MapType& GetPlayers() HashMapHolder<Player>::MapType& GetPlayers()
{ {
return HashMapHolder<Player>::GetContainer(); return HashMapHolder<Player>::GetContainer();
} }
void SaveAllPlayers();
// Corpse access
Corpse* GetCorpseForPlayerGUID(uint64 guid);
static Corpse* GetCorpseInMap(uint64 guid, uint32 mapid);
void RemoveCorpse(Corpse *corpse);
void AddCorpse(Corpse* corpse);
void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map);
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
// For call from Player/Corpse AddToWorld/RemoveFromWorld only // For call from Player/Corpse AddToWorld/RemoveFromWorld only
void AddObject(Corpse *object) { HashMapHolder<Corpse>::Insert(object); } void AddObject(Corpse *object) { HashMapHolder<Corpse>::Insert(object); }
void AddObject(Player *object) { HashMapHolder<Player>::Insert(object); } void AddObject(Player *object) { HashMapHolder<Player>::Insert(object); }
void RemoveObject(Corpse *object) { HashMapHolder<Corpse>::Remove(object); } void RemoveObject(Corpse *object) { HashMapHolder<Corpse>::Remove(object); }
void RemoveObject(Player *object) { HashMapHolder<Player>::Remove(object); } void RemoveObject(Player *object) { HashMapHolder<Player>::Remove(object); }
void SaveAllPlayers();
Corpse* GetCorpseForPlayerGUID(uint64 guid);
void RemoveCorpse(Corpse *corpse);
void AddCorpse(Corpse* corpse);
void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map);
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
// TODO: This methods will need lock in MT environment // TODO: This methods will need lock in MT environment
static void LinkMap(Map* map) { i_mapList.push_back(map); } static void LinkMap(Map* map) { i_mapList.push_back(map); }
static void DelinkMap(Map* map) { i_mapList.remove(map); } static void DelinkMap(Map* map) { i_mapList.remove(map); }
@ -159,24 +156,18 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
LockType i_corpseGuard; LockType i_corpseGuard;
}; };
inline Unit* ObjectAccessor::GetObjectInWorld(uint64 guid, Unit* /*fake*/) inline Unit* ObjectAccessor::GetUnitInWorld(WorldObject const& obj, uint64 guid)
{ {
if(!guid) if(!guid)
return NULL; return NULL;
if (IS_PLAYER_GUID(guid)) if (IS_PLAYER_GUID(guid))
{ return FindPlayer(guid);
Unit * u = (Unit*)HashMapHolder<Player>::Find(guid);
if(!u || !u->IsInWorld())
return NULL;
return u;
}
if (IS_PET_GUID(guid)) if (IS_PET_GUID(guid))
return GetObjectInWorld(guid, (Pet*)NULL); return obj.IsInWorld() ? obj.GetMap()->GetPet(guid) : NULL;
return GetObjectInWorld(guid, (Creature*)NULL); return GetCreatureInWorld(guid);
} }
#endif #endif

View file

@ -129,7 +129,6 @@ ObjectMgr::ObjectMgr()
{ {
m_hiCharGuid = 1; m_hiCharGuid = 1;
m_hiCreatureGuid = 1; m_hiCreatureGuid = 1;
m_hiPetGuid = 1;
m_hiItemGuid = 1; m_hiItemGuid = 1;
m_hiGoGuid = 1; m_hiGoGuid = 1;
m_hiCorpseGuid = 1; m_hiCorpseGuid = 1;
@ -5677,13 +5676,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
World::StopNow(ERROR_EXIT_CODE); World::StopNow(ERROR_EXIT_CODE);
} }
return m_hiCreatureGuid++; return m_hiCreatureGuid++;
case HIGHGUID_PET:
if(m_hiPetGuid>=0x00FFFFFE)
{
sLog.outError("Pet guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiPetGuid++;
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
if(m_hiCharGuid>=0xFFFFFFFE) if(m_hiCharGuid>=0xFFFFFFFE)
{ {

View file

@ -787,7 +787,6 @@ class ObjectMgr
// first free low guid for seelcted guid type // first free low guid for seelcted guid type
uint32 m_hiCharGuid; uint32 m_hiCharGuid;
uint32 m_hiCreatureGuid; uint32 m_hiCreatureGuid;
uint32 m_hiPetGuid;
uint32 m_hiItemGuid; uint32 m_hiItemGuid;
uint32 m_hiGoGuid; uint32 m_hiGoGuid;
uint32 m_hiCorpseGuid; uint32 m_hiCorpseGuid;

View file

@ -156,7 +156,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
} }
Map *map = owner->GetMap(); Map *map = owner->GetMap();
uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_PET); uint32 guid = map->GenerateLocalLowGuid(HIGHGUID_PET);
if (!Create(guid, map, owner->GetPhaseMask(), petentry, pet_number)) if (!Create(guid, map, owner->GetPhaseMask(), petentry, pet_number))
{ {
delete result; delete result;
@ -743,7 +743,8 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
sLog.outError("CRITICAL: NULL pointer parsed into CreateBaseAtCreature()"); sLog.outError("CRITICAL: NULL pointer parsed into CreateBaseAtCreature()");
return false; return false;
} }
uint32 guid=objmgr.GenerateLowGuid(HIGHGUID_PET);
uint32 guid = creature->GetMap()->GenerateLocalLowGuid(HIGHGUID_PET);
sLog.outBasic("Create pet"); sLog.outBasic("Create pet");
uint32 pet_number = objmgr.GeneratePetNumber(); uint32 pet_number = objmgr.GeneratePetNumber();

View file

@ -380,9 +380,9 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
recv_data >> name; recv_data >> name;
recv_data >> isdeclined; recv_data >> isdeclined;
Pet* pet = ObjectAccessor::GetPet(petguid); Pet* pet = _player->GetMap()->GetPet(petguid);
// check it! // check it!
if( !pet || !pet->isPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET || if( !pet || pet->getPetType() != HUNTER_PET ||
pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED || pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED ||
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() ) pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() )
return; return;
@ -402,9 +402,8 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
pet->SetName(name); pet->SetName(name);
Unit *owner = pet->GetOwner(); if(_player->GetGroup())
if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) _player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED); pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED);

View file

@ -7488,7 +7488,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
} }
else if (IS_CORPSE_GUID(guid)) // remove insignia else if (IS_CORPSE_GUID(guid)) // remove insignia
{ {
Corpse *bones = ObjectAccessor::GetCorpse(*this, guid); Corpse *bones = GetMap()->GetCorpse(guid);
if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) ) if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) )
{ {
@ -16504,7 +16504,7 @@ Pet* Player::GetMiniPet()
{ {
if(!m_miniPet) if(!m_miniPet)
return NULL; return NULL;
return ObjectAccessor::GetPet(m_miniPet); return GetMap()->GetPet(m_miniPet);
} }
void Player::Uncharm() void Player::Uncharm()
@ -18053,7 +18053,7 @@ WorldObject const* Player::GetViewPoint() const
{ {
if(uint64 far_sight = GetFarSight()) if(uint64 far_sight = GetFarSight())
{ {
WorldObject const* viewPoint = ObjectAccessor::GetWorldObject(*this,far_sight); WorldObject const* viewPoint = GetMap()->GetWorldObject(far_sight);
return viewPoint ? viewPoint : this; // always expected not NULL return viewPoint ? viewPoint : this; // always expected not NULL
} }
else else

View file

@ -147,7 +147,7 @@ void PoolGroup<Creature>::Despawn1Object(uint32 guid)
{ {
objmgr.RemoveCreatureFromGrid(guid, data); objmgr.RemoveCreatureFromGrid(guid, data);
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)NULL)) if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
pCreature->AddObjectToRemoveList(); pCreature->AddObjectToRemoveList();
} }
} }
@ -160,7 +160,7 @@ void PoolGroup<GameObject>::Despawn1Object(uint32 guid)
{ {
objmgr.RemoveGameobjectFromGrid(guid, data); objmgr.RemoveGameobjectFromGrid(guid, data);
if (GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL)) if (GameObject* pGameobject = ObjectAccessor::GetGameObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT)))
pGameobject->AddObjectToRemoveList(); pGameobject->AddObjectToRemoveList();
} }
} }
@ -314,7 +314,7 @@ bool PoolGroup<Creature>::ReSpawn1Object(uint32 guid)
{ {
if (CreatureData const* data = objmgr.GetCreatureData(guid)) if (CreatureData const* data = objmgr.GetCreatureData(guid))
{ {
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)NULL)) if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
pCreature->GetMap()->Add(pCreature); pCreature->GetMap()->Add(pCreature);
return true; return true;
} }
@ -327,7 +327,7 @@ bool PoolGroup<GameObject>::ReSpawn1Object(uint32 guid)
{ {
if (GameObjectData const* data = objmgr.GetGOData(guid)) if (GameObjectData const* data = objmgr.GetGOData(guid))
{ {
if (GameObject* pGameobject = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)NULL)) if (GameObject* pGameobject = ObjectAccessor::GetGameObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT)))
pGameobject->GetMap()->Add(pGameobject); pGameobject->GetMap()->Add(pGameobject);
return true; return true;
} }

View file

@ -2197,7 +2197,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
TagUnitMap.push_back(m_targets.getUnitTarget()); TagUnitMap.push_back(m_targets.getUnitTarget());
if (m_targets.getCorpseTargetGUID()) if (m_targets.getCorpseTargetGUID())
{ {
Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
if(corpse) if(corpse)
{ {
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID());
@ -2262,7 +2262,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap)
TagUnitMap.push_back(m_targets.getUnitTarget()); TagUnitMap.push_back(m_targets.getUnitTarget());
else if (m_targets.getCorpseTargetGUID()) else if (m_targets.getCorpseTargetGUID())
{ {
if (Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID())) if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()))
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID())) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()))
TagUnitMap.push_back(owner); TagUnitMap.push_back(owner);
} }
@ -5788,7 +5788,7 @@ bool Spell::CheckTarget( Unit* target, uint32 eff )
if(!m_targets.getCorpseTargetGUID()) if(!m_targets.getCorpseTargetGUID())
return false; return false;
Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
if(!corpse) if(!corpse)
return false; return false;

View file

@ -577,7 +577,7 @@ Unit* Aura::GetCaster() const
//return ObjectAccessor::GetUnit(*m_target,m_caster_guid); //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
//must return caster even if it's in another grid/map //must return caster even if it's in another grid/map
Unit *unit = ObjectAccessor::GetObjectInWorld(m_caster_guid, (Unit*)NULL); Unit *unit = ObjectAccessor::GetUnitInWorld(*m_target,m_caster_guid);
return unit && unit->IsInWorld() ? unit : NULL; return unit && unit->IsInWorld() ? unit : NULL;
} }

View file

@ -3386,7 +3386,7 @@ void Spell::EffectSummon(uint32 i)
Map *map = m_caster->GetMap(); Map *map = m_caster->GetMap();
uint32 pet_number = objmgr.GeneratePetNumber(); uint32 pet_number = objmgr.GeneratePetNumber();
if (!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(), if (!spawnCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[i], pet_number)) m_spellInfo->EffectMiscValue[i], pet_number))
{ {
sLog.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo->EffectMiscValue[i]); sLog.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo->EffectMiscValue[i]);
@ -3801,7 +3801,7 @@ void Spell::EffectSummonGuardian(uint32 i)
Map *map = m_caster->GetMap(); Map *map = m_caster->GetMap();
uint32 pet_number = objmgr.GeneratePetNumber(); uint32 pet_number = objmgr.GeneratePetNumber();
if (!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(), if (!spawnCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map,m_caster->GetPhaseMask(),
m_spellInfo->EffectMiscValue[i], pet_number)) m_spellInfo->EffectMiscValue[i], pet_number))
{ {
sLog.outError("no such creature entry %u", m_spellInfo->EffectMiscValue[i]); sLog.outError("no such creature entry %u", m_spellInfo->EffectMiscValue[i]);
@ -4270,7 +4270,7 @@ void Spell::EffectSummonPet(uint32 i)
Map *map = m_caster->GetMap(); Map *map = m_caster->GetMap();
uint32 pet_number = objmgr.GeneratePetNumber(); uint32 pet_number = objmgr.GeneratePetNumber();
if(!NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(), if(!NewSummon->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
petentry, pet_number)) petentry, pet_number))
{ {
delete NewSummon; delete NewSummon;
@ -6291,7 +6291,7 @@ void Spell::EffectSummonCritter(uint32 i)
Map *map = m_caster->GetMap(); Map *map = m_caster->GetMap();
uint32 pet_number = objmgr.GeneratePetNumber(); uint32 pet_number = objmgr.GeneratePetNumber();
if(!critter->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(), if(!critter->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), map, m_caster->GetPhaseMask(),
pet_entry, pet_number)) pet_entry, pet_number))
{ {
sLog.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo->Id, pet_entry); sLog.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo->Id, pet_entry);

View file

@ -7957,7 +7957,7 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself()
{ {
uint64 guid = GetCharmerOrOwnerGUID(); uint64 guid = GetCharmerOrOwnerGUID();
if(IS_PLAYER_GUID(guid)) if(IS_PLAYER_GUID(guid))
return ObjectAccessor::GetPlayer(*this, guid); return ObjectAccessor::FindPlayer(guid);
return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL;
} }
@ -7966,7 +7966,7 @@ Pet* Unit::GetPet() const
{ {
if(uint64 pet_guid = GetPetGUID()) if(uint64 pet_guid = GetPetGUID())
{ {
if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) if(Pet* pet = GetMap()->GetPet(pet_guid))
return pet; return pet;
sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid));
@ -8030,7 +8030,7 @@ void Unit::RemoveGuardians()
while(!m_guardianPets.empty()) while(!m_guardianPets.empty())
{ {
uint64 guid = *m_guardianPets.begin(); uint64 guid = *m_guardianPets.begin();
if(Pet* pet = ObjectAccessor::GetPet(guid)) if(Pet* pet = GetMap()->GetPet(guid))
pet->Remove(PET_SAVE_AS_DELETED); pet->Remove(PET_SAVE_AS_DELETED);
m_guardianPets.erase(guid); m_guardianPets.erase(guid);
@ -8042,11 +8042,9 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry)
// pet guid middle part is entry (and creature also) // pet guid middle part is entry (and creature also)
// and in guardian list must be guardians with same entry _always_ // and in guardian list must be guardians with same entry _always_
for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr)
{ if(Pet* pet = GetMap()->GetPet(*itr))
if(Pet* pet = ObjectAccessor::GetPet(*itr))
if (pet->GetEntry() == entry) if (pet->GetEntry() == entry)
return pet; return pet;
}
return NULL; return NULL;
} }

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 "8717" #define REVISION_NR "8718"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__