[7690] Move GetCreature/GetGameobject to class Map.

* This let get objects at map without reference to player or another object.
* Simplify future implementation for per-map storage for like objects
This commit is contained in:
VladimirMangos 2009-04-20 18:53:08 +04:00
parent ee9ea143d1
commit fc0e1ecdf1
20 changed files with 118 additions and 127 deletions

View file

@ -1596,7 +1596,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// ObjectAccessor won't find the flag.
if (duel && GetMapId()!=mapid)
{
GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER));
GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
if (obj)
DuelComplete(DUEL_FLED);
}
@ -1962,7 +1962,7 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
return NULL;
// exist
Creature *unit = ObjectAccessor::GetCreature(*this,guid);
Creature *unit = GetMap()->GetCreature(guid);
if (!unit)
return NULL;
@ -2002,7 +2002,7 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const
{
if(GameObject *go = ObjectAccessor::GetGameObject(*this,guid))
if(GameObject *go = GetMap()->GetGameObject(guid))
{
if(go->GetGoType() == type)
{
@ -6129,7 +6129,7 @@ void Player::CheckDuelDistance(time_t currTime)
return;
uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER);
GameObject* obj = ObjectAccessor::GetGameObject(*this, duelFlagGUID);
GameObject* obj = GetMap()->GetGameObject(duelFlagGUID);
if(!obj)
return;
@ -6196,7 +6196,7 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->GetSession()->SendPacket(&data);*/
//Remove Duel Flag object
GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER));
GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
if(obj)
duel->initiator->RemoveGameObject(obj,true);
@ -7101,8 +7101,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
if (IS_GAMEOBJECT_GUID(guid))
{
sLog.outDebug(" IS_GAMEOBJECT_GUID(guid)");
GameObject *go =
ObjectAccessor::GetGameObject(*this, guid);
GameObject *go = GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example)
// And permit out of range GO with no owner in case fishing hole
@ -7215,7 +7214,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
}
else
{
Creature *creature = ObjectAccessor::GetCreature(*this, guid);
Creature *creature = GetMap()->GetCreature(guid);
// must be in range and creature must be alive for pickpocket and must be dead for another loot
if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE))
@ -11835,7 +11834,7 @@ void Player::PrepareQuestMenu( uint64 guid )
Object *pObject;
QuestRelations* pObjectQR;
QuestRelations* pObjectQIR;
Creature *pCreature = ObjectAccessor::GetCreature(*this, guid);
Creature *pCreature = GetMap()->GetCreature(guid);
if( pCreature )
{
pObject = (Object*)pCreature;
@ -11844,7 +11843,7 @@ void Player::PrepareQuestMenu( uint64 guid )
}
else
{
GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid);
GameObject *pGameObject = GetMap()->GetGameObject(guid);
if( pGameObject )
{
pObject = (Object*)pGameObject;
@ -11921,7 +11920,7 @@ void Player::SendPreparedQuest( uint64 guid )
qe._Delay = 0;
qe._Emote = 0;
std::string title = "";
Creature *pCreature = ObjectAccessor::GetCreature(*this, guid);
Creature *pCreature = GetMap()->GetCreature(guid);
if( pCreature )
{
uint32 textid = pCreature->GetNpcTextId();
@ -11985,7 +11984,7 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
QuestRelations* pObjectQR;
QuestRelations* pObjectQIR;
Creature *pCreature = ObjectAccessor::GetCreature(*this, guid);
Creature *pCreature = GetMap()->GetCreature(guid);
if( pCreature )
{
pObject = (Object*)pCreature;
@ -11994,7 +11993,7 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
}
else
{
GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid);
GameObject *pGameObject = GetMap()->GetGameObject(guid);
if( pGameObject )
{
pObject = (Object*)pGameObject;