From d4682bea115e87b9f8318cfa5a0cfe2438b17cee Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 23 Oct 2009 03:56:46 +0400 Subject: [PATCH] [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) --- src/game/AccountMgr.cpp | 8 +---- src/game/Corpse.cpp | 2 +- src/game/GameEventMgr.cpp | 6 ++-- src/game/GridNotifiers.cpp | 2 +- src/game/LootHandler.cpp | 6 ++-- src/game/Map.cpp | 75 +++++++++++++++++++++++++++++++++------------ src/game/Map.h | 3 ++ src/game/ObjectAccessor.cpp | 41 +++++++++---------------- src/game/ObjectAccessor.h | 59 +++++++++++++++-------------------- src/game/ObjectMgr.cpp | 8 ----- src/game/ObjectMgr.h | 1 - src/game/Pet.cpp | 5 +-- src/game/PetHandler.cpp | 9 +++--- src/game/Player.cpp | 6 ++-- src/game/PoolHandler.cpp | 8 ++--- src/game/Spell.cpp | 6 ++-- src/game/SpellAuras.cpp | 2 +- src/game/SpellEffects.cpp | 8 ++--- src/game/Unit.cpp | 10 +++--- src/shared/revision_nr.h | 2 +- 20 files changed, 135 insertions(+), 132 deletions(-) diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index 0e95766b7..1bb61b006 100644 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -71,13 +71,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER); // kick if player currently - if(Player* p = ObjectAccessor::GetObjectInWorld(guid, (Player*)NULL)) - { - 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 - } - + ObjectAccessor::KickPlayer(guid); Player::DeleteFromDB(guid, accid, false); // no need to update realm characters } while (result->NextRow()); diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 17f76c74d..166bc34ce 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -126,7 +126,7 @@ void Corpse::SaveToDB() void Corpse::DeleteBonesFromWorld() { assert(GetType() == CORPSE_BONES); - Corpse* corpse = ObjectAccessor::GetCorpse(*this, GetGUID()); + Corpse* corpse = GetMap()->GetCorpse(GetGUID()); if (!corpse) { diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 99b77722f..140aa7880 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -603,7 +603,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) { 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(); } } @@ -621,7 +621,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) { 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(); } } @@ -647,7 +647,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) continue; // 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 (activate) diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 5ff6d5d79..858abdd18 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -129,7 +129,7 @@ VisibleNotifier::Notify() if(!IS_PLAYER_GUID(*iter)) continue; - if (Player* plr = ObjectAccessor::GetPlayer(i_player,*iter)) + if (Player* plr = ObjectAccessor::FindPlayer(*iter)) plr->UpdateVisibilityOf(plr->GetViewPoint(),&i_player); } } diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 14dead0a4..f607775f1 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -67,7 +67,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) } else if (IS_CORPSE_GUID(lguid)) { - Corpse *bones = ObjectAccessor::GetCorpse(*player, lguid); + Corpse *bones = player->GetMap()->GetCorpse(lguid); if (!bones) { player->SendLootRelease(lguid); @@ -180,7 +180,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) } 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) ) pLoot = &bones->loot; @@ -367,7 +367,7 @@ void WorldSession::DoLootRelease( uint64 lguid ) } 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) ) return; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 83c3143e2..c8ecdcf0c 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -203,7 +203,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par m_activeNonPlayersIter(m_activeNonPlayers.end()), i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this), 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) { @@ -776,8 +776,8 @@ bool Map::RemoveBones(uint64 guid, float x, float y) { if (IsRemovalGrid(x, y)) { - Corpse* corpse = ObjectAccessor::GetObjectInWorld(guid, (Corpse*)NULL); - if(!corpse || corpse->GetMapId() != GetId()) + Corpse* corpse = ObjectAccessor::GetCorpseInMap(guid,GetId()); + if (!corpse) return false; CellPair p = MaNGOS::ComputeCellPair(x,y); @@ -2146,28 +2146,29 @@ void Map::RemoveAllObjectsInRemoveList() { case TYPEID_CORPSE: { - Corpse* corpse = ObjectAccessor::Instance().GetCorpse(*obj, obj->GetGUID()); + // ??? WTF + Corpse* corpse = GetCorpse(obj->GetGUID()); if (!corpse) sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); else Remove(corpse,true); break; } - case TYPEID_DYNAMICOBJECT: - Remove((DynamicObject*)obj,true); - break; - case TYPEID_GAMEOBJECT: - Remove((GameObject*)obj,true); - break; - case TYPEID_UNIT: - // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call - // make sure that like sources auras/etc removed before destructor start - ((Creature*)obj)->CleanupsBeforeDelete (); - Remove((Creature*)obj,true); - break; - default: - sLog.outError("Non-grid object (TypeId: %u) in grid object removing list, ignored.",obj->GetTypeId()); - break; + case TYPEID_DYNAMICOBJECT: + Remove((DynamicObject*)obj,true); + break; + case TYPEID_GAMEOBJECT: + Remove((GameObject*)obj,true); + break; + case TYPEID_UNIT: + // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call + // make sure that like sources auras/etc removed before destructor start + ((Creature*)obj)->CleanupsBeforeDelete (); + Remove((Creature*)obj,true); + break; + default: + sLog.outError("Non-grid object (TypeId: %u) in grid object removing list, ignored.",obj->GetTypeId()); + break; } } //sLog.outDebug("Object remover 2 check."); @@ -3425,6 +3426,16 @@ Pet* Map::GetPet(uint64 guid) return m_objectsStore.find(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) { if (IS_PLAYER_GUID(guid)) @@ -3449,6 +3460,25 @@ DynamicObject* Map::GetDynamicObject(uint64 guid) return m_objectsStore.find(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() { UpdateDataMapType update_players; @@ -3483,6 +3513,13 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh) World::StopNow(ERROR_EXIT_CODE); } 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: if(m_hiVehicleGuid>=0x00FFFFFF) { diff --git a/src/game/Map.h b/src/game/Map.h index d6fb2d5a8..569231368 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -433,6 +433,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj Creature* GetCreatureOrPetOrVehicle(uint64 guid); GameObject* GetGameObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid); + Corpse* GetCorpse(uint64 guid); + WorldObject* GetWorldObject(uint64 guid); TypeUnorderedMapContainer& GetObjectsStore() { return m_objectsStore; } @@ -532,6 +534,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj // Map local low guid counters uint32 m_hiDynObjectGuid; + uint32 m_hiPetGuid; uint32 m_hiVehicleGuid; // Type specific code for add/remove to/from grid diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 3959d4afb..9e7789e20 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -65,36 +65,15 @@ ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid) return u.GetMap()->GetCreatureOrPetOrVehicle(guid); } -Corpse* -ObjectAccessor::GetCorpse(WorldObject const &u, uint64 guid) +Corpse* ObjectAccessor::GetCorpseInMap( uint64 guid, uint32 mapid ) { - Corpse * ret = GetObjectInWorld(guid, (Corpse*)NULL); + Corpse * ret = HashMapHolder::Find(guid); if(!ret) return NULL; - if(ret->GetMapId() != u.GetMapId()) - return NULL; - if(ret->GetInstanceId() != u.GetInstanceId()) + if(ret->GetMapId() != mapid) return NULL; - 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; + return ret; } Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, uint32 typemask) @@ -141,7 +120,7 @@ Object* ObjectAccessor::GetObjectByTypeMask(WorldObject const &p, uint64 guid, u Player* ObjectAccessor::FindPlayer(uint64 guid) { - Player * plr = GetObjectInWorld(guid, (Player*)NULL); + Player * plr = HashMapHolder::Find(guid);; if(!plr || !plr->IsInWorld()) return NULL; @@ -170,6 +149,16 @@ ObjectAccessor::SaveAllPlayers() itr->second->SaveToDB(); } +void ObjectAccessor::KickPlayer(uint64 guid) +{ + if (Player* p = HashMapHolder::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* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid) { diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 931610226..9c58222f4 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -88,46 +88,43 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton Player2CorpsesMapType; - // global - static Player* GetObjectInWorld(uint64 guid, Player* /*fake*/) { return HashMapHolder::Find(guid); } - static Corpse* GetObjectInWorld(uint64 guid, Corpse* /*fake*/) { return HashMapHolder::Find(guid); } - static Unit* GetObjectInWorld(uint64 guid, Unit* /*fake*/); - - // map local object with global search - static Creature* GetObjectInWorld(uint64 guid, Creature* /*fake*/) { return FindHelper(guid); } - static GameObject* GetObjectInWorld(uint64 guid, GameObject* /*fake*/) { return FindHelper(guid); } - static Pet* GetObjectInWorld(uint64 guid, Pet* /*fake*/) { return FindHelper(guid); } - static Vehicle* GetObjectInWorld(uint64 guid, Vehicle* /*fake*/); // no implementation, link error trap until creature move to Map - - static WorldObject* GetWorldObject(WorldObject const &, uint64); - static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask); + // global (obj used for map only location local guid objects (pets currently) + static Unit* GetUnitInWorld(WorldObject const& obj, uint64 guid); + + // FIXME: map local object with global search + static Creature* GetCreatureInWorld(uint64 guid) { return FindHelper(guid); } + static GameObject* GetGameObjectInWorld(uint64 guid) { return FindHelper(guid); } + + // possible local search for specific object map + static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask); 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::MapType& GetPlayers() { return HashMapHolder::GetContainer(); } - // For call from Player/Corpse AddToWorld/RemoveFromWorld only - void AddObject(Corpse *object) { HashMapHolder::Insert(object); } - void AddObject(Player *object) { HashMapHolder::Insert(object); } - void RemoveObject(Corpse *object) { HashMapHolder::Remove(object); } - void RemoveObject(Player *object) { HashMapHolder::Remove(object); } - 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 + void AddObject(Corpse *object) { HashMapHolder::Insert(object); } + void AddObject(Player *object) { HashMapHolder::Insert(object); } + void RemoveObject(Corpse *object) { HashMapHolder::Remove(object); } + void RemoveObject(Player *object) { HashMapHolder::Remove(object); } + // TODO: This methods will need lock in MT environment static void LinkMap(Map* map) { i_mapList.push_back(map); } static void DelinkMap(Map* map) { i_mapList.remove(map); } @@ -159,24 +156,18 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton::Find(guid); - if(!u || !u->IsInWorld()) - return NULL; - - return u; - } + return FindPlayer(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 diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f21cfdbd1..8dc836d4a 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -129,7 +129,6 @@ ObjectMgr::ObjectMgr() { m_hiCharGuid = 1; m_hiCreatureGuid = 1; - m_hiPetGuid = 1; m_hiItemGuid = 1; m_hiGoGuid = 1; m_hiCorpseGuid = 1; @@ -5677,13 +5676,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) World::StopNow(ERROR_EXIT_CODE); } 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: if(m_hiCharGuid>=0xFFFFFFFE) { diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index f1c69b261..c58f196ec 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -787,7 +787,6 @@ class ObjectMgr // first free low guid for seelcted guid type uint32 m_hiCharGuid; uint32 m_hiCreatureGuid; - uint32 m_hiPetGuid; uint32 m_hiItemGuid; uint32 m_hiGoGuid; uint32 m_hiCorpseGuid; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 97bb876c3..994d7ae83 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -156,7 +156,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool } 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)) { delete result; @@ -743,7 +743,8 @@ bool Pet::CreateBaseAtCreature(Creature* creature) sLog.outError("CRITICAL: NULL pointer parsed into CreateBaseAtCreature()"); return false; } - uint32 guid=objmgr.GenerateLowGuid(HIGHGUID_PET); + + uint32 guid = creature->GetMap()->GenerateLocalLowGuid(HIGHGUID_PET); sLog.outBasic("Create pet"); uint32 pet_number = objmgr.GeneratePetNumber(); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 83741cfec..057dbc077 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -380,9 +380,9 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) recv_data >> name; recv_data >> isdeclined; - Pet* pet = ObjectAccessor::GetPet(petguid); + Pet* pet = _player->GetMap()->GetPet(petguid); // 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->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() ) return; @@ -402,9 +402,8 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) pet->SetName(name); - Unit *owner = pet->GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME); + if(_player->GetGroup()) + _player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME); pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0d6bd4b76..3d79f8ee3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -7488,7 +7488,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) } 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) ) { @@ -16504,7 +16504,7 @@ Pet* Player::GetMiniPet() { if(!m_miniPet) return NULL; - return ObjectAccessor::GetPet(m_miniPet); + return GetMap()->GetPet(m_miniPet); } void Player::Uncharm() @@ -18053,7 +18053,7 @@ WorldObject const* Player::GetViewPoint() const { 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 } else diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp index 7824654cb..44c6cabeb 100644 --- a/src/game/PoolHandler.cpp +++ b/src/game/PoolHandler.cpp @@ -147,7 +147,7 @@ void PoolGroup::Despawn1Object(uint32 guid) { 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(); } } @@ -160,7 +160,7 @@ void PoolGroup::Despawn1Object(uint32 guid) { 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(); } } @@ -314,7 +314,7 @@ bool PoolGroup::ReSpawn1Object(uint32 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); return true; } @@ -327,7 +327,7 @@ bool PoolGroup::ReSpawn1Object(uint32 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); return true; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 827aa3063..e3e520757 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2197,7 +2197,7 @@ void Spell::SetTargetMap(uint32 effIndex,uint32 targetMode,UnitList& TagUnitMap) TagUnitMap.push_back(m_targets.getUnitTarget()); if (m_targets.getCorpseTargetGUID()) { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); + Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); if(corpse) { 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()); 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())) TagUnitMap.push_back(owner); } @@ -5788,7 +5788,7 @@ bool Spell::CheckTarget( Unit* target, uint32 eff ) if(!m_targets.getCorpseTargetGUID()) return false; - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.getCorpseTargetGUID()); + Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); if(!corpse) return false; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 2cf57a851..4aa6c7b48 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -577,7 +577,7 @@ Unit* Aura::GetCaster() const //return ObjectAccessor::GetUnit(*m_target,m_caster_guid); //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; } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index f03f5d5db..268577939 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3386,7 +3386,7 @@ void Spell::EffectSummon(uint32 i) Map *map = m_caster->GetMap(); 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)) { 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(); 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)) { 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(); 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)) { delete NewSummon; @@ -6291,7 +6291,7 @@ void Spell::EffectSummonCritter(uint32 i) Map *map = m_caster->GetMap(); 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)) { sLog.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo->Id, pet_entry); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 77dfe50cf..de5669324 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7957,7 +7957,7 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() { uint64 guid = GetCharmerOrOwnerGUID(); if(IS_PLAYER_GUID(guid)) - return ObjectAccessor::GetPlayer(*this, guid); + return ObjectAccessor::FindPlayer(guid); return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; } @@ -7966,7 +7966,7 @@ Pet* Unit::GetPet() const { if(uint64 pet_guid = GetPetGUID()) { - if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) + if(Pet* pet = GetMap()->GetPet(pet_guid)) return pet; sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); @@ -8030,7 +8030,7 @@ void Unit::RemoveGuardians() while(!m_guardianPets.empty()) { uint64 guid = *m_guardianPets.begin(); - if(Pet* pet = ObjectAccessor::GetPet(guid)) + if(Pet* pet = GetMap()->GetPet(guid)) pet->Remove(PET_SAVE_AS_DELETED); m_guardianPets.erase(guid); @@ -8042,11 +8042,9 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry) // pet guid middle part is entry (and creature also) // and in guardian list must be guardians with same entry _always_ for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) - { - if(Pet* pet = ObjectAccessor::GetPet(*itr)) + if(Pet* pet = GetMap()->GetPet(*itr)) if (pet->GetEntry() == entry) return pet; - } return NULL; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 674719724..8fd47f530 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8717" + #define REVISION_NR "8718" #endif // __REVISION_NR_H__ -- 2.11.4.GIT