root/trunk/src/game/ObjectAccessor.cpp @ 268

Revision 268, 21.7 kB (checked in by yumileroy, 17 years ago)

*Move object update from objectaccessor to map
*Move activeobject list from objectaccessor to map
*Open grid for all active creatures (previously only for possessed ones)

Original author: megamage
Date: 2008-11-21 15:41:18-06:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21#include "ObjectAccessor.h"
22#include "ObjectMgr.h"
23#include "Policies/SingletonImp.h"
24#include "Player.h"
25#include "Creature.h"
26#include "GameObject.h"
27#include "DynamicObject.h"
28#include "Corpse.h"
29#include "WorldSession.h"
30#include "WorldPacket.h"
31#include "Item.h"
32#include "Corpse.h"
33#include "GridNotifiers.h"
34#include "MapManager.h"
35#include "Map.h"
36#include "CellImpl.h"
37#include "GridNotifiersImpl.h"
38#include "Opcodes.h"
39#include "ObjectDefines.h"
40#include "MapInstanced.h"
41
42#include <cmath>
43
44#define CLASS_LOCK Trinity::ClassLevelLockable<ObjectAccessor, ZThread::FastMutex>
45INSTANTIATE_SINGLETON_2(ObjectAccessor, CLASS_LOCK);
46INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ZThread::FastMutex);
47
48namespace Trinity
49{
50
51    struct TRINITY_DLL_DECL BuildUpdateForPlayer
52    {
53        Player &i_player;
54        UpdateDataMapType &i_updatePlayers;
55
56        BuildUpdateForPlayer(Player &player, UpdateDataMapType &data_map) : i_player(player), i_updatePlayers(data_map) {}
57
58        void Visit(PlayerMapType &m)
59        {
60            for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
61            {
62                if( iter->getSource() == &i_player )
63                    continue;
64
65                UpdateDataMapType::iterator iter2 = i_updatePlayers.find(iter->getSource());
66                if( iter2 == i_updatePlayers.end() )
67                {
68                    std::pair<UpdateDataMapType::iterator, bool> p = i_updatePlayers.insert( ObjectAccessor::UpdateDataValueType(iter->getSource(), UpdateData()) );
69                    assert(p.second);
70                    iter2 = p.first;
71                }
72
73                i_player.BuildValuesUpdateBlockForPlayer(&iter2->second, iter2->first);
74            }
75        }
76
77        template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
78    };
79}
80
81ObjectAccessor::ObjectAccessor() {}
82ObjectAccessor::~ObjectAccessor() {}
83
84Creature*
85ObjectAccessor::GetNPCIfCanInteractWith(Player const &player, uint64 guid, uint32 npcflagmask)
86{
87    // unit checks
88    if (!guid)
89        return NULL;
90
91    // exist
92    Creature *unit = GetCreature(player, guid);
93    if (!unit)
94        return NULL;
95
96    // player check
97    if(!player.CanInteractWithNPCs(!unit->isSpiritService()))
98        return NULL;
99
100    // appropriate npc type
101    if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
102        return NULL;
103
104    // alive or spirit healer
105    if(!unit->isAlive() && (!unit->isSpiritService() || player.isAlive() ))
106        return NULL;
107
108    // not allow interaction under control
109    if(unit->GetCharmerOrOwnerGUID())
110        return NULL;
111
112    // not enemy
113    if( unit->IsHostileTo(&player))
114        return NULL;
115
116    // not unfriendly
117    FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction());
118    if(factionTemplate)
119    {
120        FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction);
121        if( faction->reputationListID >= 0 && player.GetReputationRank(faction) <= REP_UNFRIENDLY)
122            return NULL;
123    }
124
125    // not too far
126    if(!unit->IsWithinDistInMap(&player,INTERACTION_DISTANCE))
127        return NULL;
128
129    return unit;
130}
131
132Creature*
133ObjectAccessor::GetCreatureOrPet(WorldObject const &u, uint64 guid)
134{
135    if(Creature *unit = GetPet(guid))
136        return unit;
137
138    return GetCreature(u, guid);
139}
140
141Creature*
142ObjectAccessor::GetCreature(WorldObject const &u, uint64 guid)
143{
144    Creature * ret = GetObjectInWorld(guid, (Creature*)NULL);
145    if(!ret)
146        return NULL;
147
148    if(ret->GetMapId() != u.GetMapId())
149        return NULL;
150
151    if(ret->GetInstanceId() != u.GetInstanceId())
152        return NULL;
153
154    return ret;
155}
156
157Unit*
158ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
159{
160    if(!guid)
161        return NULL;
162
163    if(IS_PLAYER_GUID(guid))
164        return FindPlayer(guid);
165
166    return GetCreatureOrPet(u, guid);
167}
168
169Corpse*
170ObjectAccessor::GetCorpse(WorldObject const &u, uint64 guid)
171{
172    Corpse * ret = GetObjectInWorld(guid, (Corpse*)NULL);
173    if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL;
174    return ret;
175}
176
177Object* ObjectAccessor::GetObjectByTypeMask(Player const &p, uint64 guid, uint32 typemask)
178{
179    Object *obj = NULL;
180
181    if(typemask & TYPEMASK_PLAYER)
182    {
183        obj = FindPlayer(guid);
184        if(obj) return obj;
185    }
186
187    if(typemask & TYPEMASK_UNIT)
188    {
189        obj = GetCreatureOrPet(p,guid);
190        if(obj) return obj;
191    }
192
193    if(typemask & TYPEMASK_GAMEOBJECT)
194    {
195        obj = GetGameObject(p,guid);
196        if(obj) return obj;
197    }
198
199    if(typemask & TYPEMASK_DYNAMICOBJECT)
200    {
201        obj = GetDynamicObject(p,guid);
202        if(obj) return obj;
203    }
204
205    if(typemask & TYPEMASK_ITEM)
206    {
207        obj = p.GetItemByGuid( guid );
208        if(obj) return obj;
209    }
210
211    return NULL;
212}
213
214GameObject*
215ObjectAccessor::GetGameObject(WorldObject const &u, uint64 guid)
216{
217    GameObject * ret = GetObjectInWorld(guid, (GameObject*)NULL);
218    if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL;
219    return ret;
220}
221
222DynamicObject*
223ObjectAccessor::GetDynamicObject(Unit const &u, uint64 guid)
224{
225    DynamicObject * ret = GetObjectInWorld(guid, (DynamicObject*)NULL);
226    if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL;
227    return ret;
228}
229
230Player*
231ObjectAccessor::FindPlayer(uint64 guid)
232{
233    return GetObjectInWorld(guid, (Player*)NULL);
234}
235
236Player*
237ObjectAccessor::FindPlayerByName(const char *name)
238{
239    //TODO: Player Guard
240    HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
241    HashMapHolder<Player>::MapType::iterator iter = m.begin();
242    for(; iter != m.end(); ++iter)
243        if( ::strcmp(name, iter->second->GetName()) == 0 )
244            return iter->second;
245    return NULL;
246}
247
248void
249ObjectAccessor::SaveAllPlayers()
250{
251    Guard guard(*HashMapHolder<Player*>::GetLock());
252    HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
253    HashMapHolder<Player>::MapType::iterator itr = m.begin();
254    for(; itr != m.end(); ++itr)
255        itr->second->SaveToDB();
256}
257
258void
259ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer)
260{
261    UpdateDataMapType update_players;
262    obj->BuildUpdate(update_players);
263
264    WorldPacket packet;
265    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
266    {
267        if(iter->first == exceptPlayer)
268            continue;
269
270        iter->second.BuildPacket(&packet);
271        iter->first->GetSession()->SendPacket(&packet);
272        packet.clear();
273    }
274}
275
276void
277ObjectAccessor::AddUpdateObject(Object *obj)
278{
279    Guard guard(i_updateGuard);
280    i_objects.insert(obj);
281}
282
283void
284ObjectAccessor::RemoveUpdateObject(Object *obj)
285{
286    Guard guard(i_updateGuard);
287    std::set<Object *>::iterator iter = i_objects.find(obj);
288    if( iter != i_objects.end() )
289        i_objects.erase( iter );
290}
291
292void
293ObjectAccessor::_buildUpdateObject(Object *obj, UpdateDataMapType &update_players)
294{
295    bool build_for_all = true;
296    Player *pl = NULL;
297    if( obj->isType(TYPEMASK_ITEM) )
298    {
299        Item *item = static_cast<Item *>(obj);
300        pl = item->GetOwner();
301        build_for_all = false;
302    }
303
304    if( pl != NULL )
305        _buildPacket(pl, obj, update_players);
306
307    // Capt: okey for all those fools who think its a real fix
308    //       THIS IS A TEMP FIX
309    if( build_for_all )
310    {
311        WorldObject * temp = dynamic_cast<WorldObject*>(obj);
312
313        //assert(dynamic_cast<WorldObject*>(obj)!=NULL);
314        if (temp)
315            _buildChangeObjectForPlayer(temp, update_players);
316        else
317            sLog.outDebug("ObjectAccessor: Ln 405 Temp bug fix");
318    }
319}
320
321void
322ObjectAccessor::_buildPacket(Player *pl, Object *obj, UpdateDataMapType &update_players)
323{
324    UpdateDataMapType::iterator iter = update_players.find(pl);
325
326    if( iter == update_players.end() )
327    {
328        std::pair<UpdateDataMapType::iterator, bool> p = update_players.insert( UpdateDataValueType(pl, UpdateData()) );
329        assert(p.second);
330        iter = p.first;
331    }
332
333    obj->BuildValuesUpdateBlockForPlayer(&iter->second, iter->first);
334}
335
336void
337ObjectAccessor::_buildChangeObjectForPlayer(WorldObject *obj, UpdateDataMapType &update_players)
338{
339    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
340    Cell cell(p);
341    cell.data.Part.reserved = ALL_DISTRICT;
342    cell.SetNoCreate();
343    WorldObjectChangeAccumulator notifier(*obj, update_players);
344    TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
345    CellLock<GridReadGuard> cell_lock(cell, p);
346    cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap());
347}
348
349Pet*
350ObjectAccessor::GetPet(uint64 guid)
351{
352    return GetObjectInWorld(guid, (Pet*)NULL);
353}
354
355Corpse*
356ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
357{
358    Guard guard(i_corpseGuard);
359
360    Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
361    if( iter == i_player2corpse.end() ) return NULL;
362
363    assert(iter->second->GetType() != CORPSE_BONES);
364
365    return iter->second;
366}
367
368void
369ObjectAccessor::RemoveCorpse(Corpse *corpse)
370{
371    assert(corpse && corpse->GetType() != CORPSE_BONES);
372
373    Guard guard(i_corpseGuard);
374    Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID());
375    if( iter == i_player2corpse.end() )
376        return;
377
378    // build mapid*cellid -> guid_set map
379    CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
380    uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
381
382    objmgr.DeleteCorpseCellData(corpse->GetMapId(),cell_id,corpse->GetOwnerGUID());
383    corpse->RemoveFromWorld();
384
385    i_player2corpse.erase(iter);
386}
387
388void
389ObjectAccessor::AddCorpse(Corpse *corpse)
390{
391    assert(corpse && corpse->GetType() != CORPSE_BONES);
392
393    Guard guard(i_corpseGuard);
394    assert(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end());
395    i_player2corpse[corpse->GetOwnerGUID()] = corpse;
396
397    // build mapid*cellid -> guid_set map
398    CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
399    uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
400
401    objmgr.AddCorpseCellData(corpse->GetMapId(),cell_id,corpse->GetOwnerGUID(),corpse->GetInstanceId());
402}
403
404void
405ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map)
406{
407    Guard guard(i_corpseGuard);
408    for(Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
409        if(iter->second->GetGrid()==gridpair)
410    {
411        // verify, if the corpse in our instance (add only corpses which are)
412        if (map->Instanceable())
413        {
414            if (iter->second->GetInstanceId() == map->GetInstanceId())
415            {
416                grid.AddWorldObject(iter->second,iter->second->GetGUID());
417            }
418        }
419        else
420        {
421            grid.AddWorldObject(iter->second,iter->second->GetGUID());
422        }
423    }
424}
425
426Corpse*
427ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid)
428{
429    Corpse *corpse = GetCorpseForPlayerGUID(player_guid);
430    if(!corpse)
431    {
432        //in fact this function is called from several places
433        //even when player doesn't have a corpse, not an error
434        //sLog.outError("ERROR: Try remove corpse that not in map for GUID %ul", player_guid);
435        return NULL;
436    }
437
438    DEBUG_LOG("Deleting Corpse and spawning bones.\n");
439
440    // remove corpse from player_guid -> corpse map
441    RemoveCorpse(corpse);
442
443    // remove resurrectble corpse from grid object registry (loaded state checked into call)
444    // do not load the map if it's not loaded
445    Map *map = MapManager::Instance().FindMap(corpse->GetMapId(), corpse->GetInstanceId());
446    if(map) map->Remove(corpse,false);
447
448    // remove corpse from DB
449    corpse->DeleteFromDB();
450
451    Corpse *bones = NULL;
452    // create the bones only if the map and the grid is loaded at the corpse's location
453    if(map && !map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
454    {
455        // Create bones, don't change Corpse
456        bones = new Corpse;
457        bones->Create(corpse->GetGUIDLow());
458
459        for (int i = 3; i < CORPSE_END; i++)                    // don't overwrite guid and object type
460            bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
461
462        bones->SetGrid(corpse->GetGrid());
463        // bones->m_time = m_time;                              // don't overwrite time
464        // bones->m_inWorld = m_inWorld;                        // don't overwrite world state
465        // bones->m_type = m_type;                              // don't overwrite type
466        bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
467        bones->SetMapId(corpse->GetMapId());
468        bones->SetInstanceId(corpse->GetInstanceId());
469
470        bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
471        bones->SetUInt64Value(CORPSE_FIELD_OWNER, 0);
472
473        for (int i = 0; i < EQUIPMENT_SLOT_END; i++)
474        {
475            if(corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
476                bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
477        }
478
479        // add bones in grid store if grid loaded where corpse placed
480        map->Add(bones);
481    }
482
483    // all references to the corpse should be removed at this point
484    delete corpse;
485
486    return bones;
487}
488
489void
490ObjectAccessor::Update(uint32 diff)
491{
492/*    {
493        //Player update now in MapManager -> UpdatePlayers
494        // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects.
495        HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer();
496        for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter)
497        {
498            if(iter->second->IsInWorld())
499            {
500                iter->second->Update(diff);
501            }
502        }
503
504        // TODO: move this to Map::Update
505        // clone the active object list, because update might remove from it
506        std::set<WorldObject *> activeobjects(i_activeobjects);
507
508        std::set<WorldObject *>::iterator itr, next;
509        for(itr = activeobjects.begin(); itr != activeobjects.end(); itr = next)
510        {
511            next = itr;
512            ++next;
513            if((*itr)->IsInWorld())
514                (*itr)->GetMap()->resetMarkedCells();
515            else
516                activeobjects.erase(itr);
517        }
518
519        Map *map;
520
521        Trinity::ObjectUpdater updater(diff);
522        // for creature
523        TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer  > grid_object_update(updater);
524        // for pets
525        TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);
526
527        for(itr = activeobjects.begin(); itr != activeobjects.end(); ++itr)
528        {
529            WorldObject *obj = (*itr);
530            map = obj->GetMap();
531
532            CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
533
534            // Check for correctness of standing_cell, it also avoids problems with update_cell
535            if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
536                continue;
537
538            // the overloaded operators handle range checking
539            // so ther's no need for range checking inside the loop
540            CellPair begin_cell(standing_cell), end_cell(standing_cell);
541            begin_cell << 1; begin_cell -= 1;               // upper left
542            end_cell >> 1; end_cell += 1;                   // lower right
543
544            for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
545            {
546                for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
547                {
548                    uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
549                    if( !map->isCellMarked(cell_id) )
550                    {
551                        CellPair cell_pair(x,y);
552                        map->markCell(cell_id);
553                        Cell cell(cell_pair);
554                        cell.data.Part.reserved = CENTER_DISTRICT;
555                        cell.SetNoCreate();
556                        CellLock<NullGuard> cell_lock(cell, cell_pair);
557                        cell_lock->Visit(cell_lock, grid_object_update,  *map);
558                        cell_lock->Visit(cell_lock, world_object_update, *map);
559                    }
560                }
561            }
562        }
563    }*/
564
565    UpdateDataMapType update_players;
566    {
567        Guard guard(i_updateGuard);
568        while(!i_objects.empty())
569        {
570            Object* obj = *i_objects.begin();
571            i_objects.erase(i_objects.begin());
572            if (!obj)
573                continue;
574            _buildUpdateObject(obj, update_players);
575            obj->ClearUpdateMask(false);
576        }
577    }
578
579    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
580    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
581    {
582        iter->second.BuildPacket(&packet);
583        iter->first->GetSession()->SendPacket(&packet);
584        packet.clear();                                     // clean the string
585    }
586}
587
588void
589ObjectAccessor::UpdatePlayers(uint32 diff)
590{
591    HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer();
592    for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter)
593        if(iter->second->IsInWorld())
594            iter->second->Update(diff);
595}
596
597void
598ObjectAccessor::WorldObjectChangeAccumulator::Visit(PlayerMapType &m)
599{
600    for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
601    {
602        BuildPacket(iter->getSource());
603        if (!iter->getSource()->GetSharedVisionList().empty())
604        {
605            SharedVisionList::const_iterator it = iter->getSource()->GetSharedVisionList().begin();
606            for ( ; it != iter->getSource()->GetSharedVisionList().end(); ++it)
607                BuildPacket(*it);
608        }
609    }
610}
611
612void
613ObjectAccessor::WorldObjectChangeAccumulator::Visit(CreatureMapType &m)
614{
615    for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
616    {
617        if (!iter->getSource()->GetSharedVisionList().empty())
618        {
619            SharedVisionList::const_iterator it = iter->getSource()->GetSharedVisionList().begin();
620            for ( ; it != iter->getSource()->GetSharedVisionList().end(); ++it)
621                BuildPacket(*it);
622        }
623    }
624}
625
626void
627ObjectAccessor::WorldObjectChangeAccumulator::Visit(DynamicObjectMapType &m)
628{
629    for(DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
630    {
631        if (IS_PLAYER_GUID(iter->getSource()->GetCasterGUID()))
632        {
633            Player* caster = (Player*)iter->getSource()->GetCaster();
634            if (caster->GetUInt64Value(PLAYER_FARSIGHT) == iter->getSource()->GetGUID())
635                BuildPacket(caster);
636        }
637    }
638}
639
640void
641ObjectAccessor::WorldObjectChangeAccumulator::BuildPacket(Player* plr)
642{
643    // Only send update once to a player
644    if (plr_list.find(plr->GetGUID()) == plr_list.end() && plr->HaveAtClient(&i_object))
645    {
646        ObjectAccessor::_buildPacket(plr, &i_object, i_updateDatas);
647        plr_list.insert(plr->GetGUID());
648    }
649}
650
651void
652ObjectAccessor::UpdateObjectVisibility(WorldObject *obj)
653{
654    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
655    Cell cell(p);
656
657    obj->GetMap()->UpdateObjectVisibility(obj,cell,p);
658}
659
660void ObjectAccessor::UpdateVisibilityForPlayer( Player* player )
661{
662    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
663    Cell cell(p);
664    Map* m = player->GetMap();
665
666    m->UpdatePlayerVisibility(player,cell,p);
667    m->UpdateObjectsVisibilityFor(player,cell,p);
668}
669
670/// Define the static member of HashMapHolder
671
672template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
673template <class T> ZThread::FastMutex HashMapHolder<T>::i_lock;
674
675/// Global defintions for the hashmap storage
676
677template class HashMapHolder<Player>;
678template class HashMapHolder<Pet>;
679template class HashMapHolder<GameObject>;
680template class HashMapHolder<DynamicObject>;
681template class HashMapHolder<Creature>;
682template class HashMapHolder<Corpse>;
683
684template Player* ObjectAccessor::GetObjectInWorld<Player>(uint32 mapid, float x, float y, uint64 guid, Player* /*fake*/);
685template Pet* ObjectAccessor::GetObjectInWorld<Pet>(uint32 mapid, float x, float y, uint64 guid, Pet* /*fake*/);
686template Creature* ObjectAccessor::GetObjectInWorld<Creature>(uint32 mapid, float x, float y, uint64 guid, Creature* /*fake*/);
687template Corpse* ObjectAccessor::GetObjectInWorld<Corpse>(uint32 mapid, float x, float y, uint64 guid, Corpse* /*fake*/);
688template GameObject* ObjectAccessor::GetObjectInWorld<GameObject>(uint32 mapid, float x, float y, uint64 guid, GameObject* /*fake*/);
689template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, uint64 guid, DynamicObject* /*fake*/);
Note: See TracBrowser for help on using the browser.