Show
Ignore:
Timestamp:
11/22/08 00:36:22 (17 years ago)
Author:
yumileroy
Message:

Merged commit 269 (5f0e38da128a).

Original author: gvcoman
Date: 2008-11-21 14:34:05-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/ObjectAccessor.cpp

    r272 r279  
    143143{ 
    144144    Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); 
    145     if(ret && ret->GetMapId() != u.GetMapId()) ret = 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 
    146154    return ret; 
    147155} 
     
    249257 
    250258void 
    251 ObjectAccessor::_update() 
    252 { 
    253     UpdateDataMapType update_players; 
    254     { 
    255         Guard guard(i_updateGuard); 
    256         while(!i_objects.empty()) 
    257         { 
    258             Object* obj = *i_objects.begin(); 
    259             i_objects.erase(i_objects.begin()); 
    260             if (!obj) 
    261                 continue; 
    262             _buildUpdateObject(obj, update_players); 
    263             obj->ClearUpdateMask(false); 
    264         } 
    265     } 
    266  
    267     WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000 
    268     for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 
    269     { 
    270         iter->second.BuildPacket(&packet); 
    271         iter->first->GetSession()->SendPacket(&packet); 
    272         packet.clear();                                     // clean the string 
    273     } 
    274 } 
    275  
    276 void 
    277259ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 
    278260{ 
     
    362344    TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 
    363345    CellLock<GridReadGuard> cell_lock(cell, p); 
    364     cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj)); 
     346    cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); 
    365347} 
    366348 
     
    520502ObjectAccessor::Update(uint32 diff) 
    521503{ 
    522     { 
     504 
     505    { 
     506        //Player update now in MapManager -> UpdatePlayers 
     507        /* 
    523508        // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 
    524509        HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 
     
    529514                iter->second->Update(diff); 
    530515            } 
    531         } 
    532  
     516        }*/ 
     517 
     518        // TODO: move this to Map::Update 
    533519        // clone the active object list, because update might remove from it 
    534520        std::set<WorldObject *> activeobjects(i_activeobjects); 
     
    591577    } 
    592578 
    593     _update(); 
     579    UpdateDataMapType update_players; 
     580    { 
     581        Guard guard(i_updateGuard); 
     582        while(!i_objects.empty()) 
     583        { 
     584            Object* obj = *i_objects.begin(); 
     585            i_objects.erase(i_objects.begin()); 
     586            if (!obj) 
     587                continue; 
     588            _buildUpdateObject(obj, update_players); 
     589            obj->ClearUpdateMask(false); 
     590        } 
     591    } 
     592 
     593    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000 
     594    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 
     595    { 
     596        iter->second.BuildPacket(&packet); 
     597        iter->first->GetSession()->SendPacket(&packet); 
     598        packet.clear();                                     // clean the string 
     599    } 
     600} 
     601 
     602void 
     603ObjectAccessor::UpdatePlayers(uint32 diff) 
     604{ 
     605    HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 
     606    for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 
     607        if(iter->second->IsInWorld()) 
     608            iter->second->Update(diff); 
    594609} 
    595610 
     
    678693    Cell cell(p); 
    679694 
    680     MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); 
     695    obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 
    681696} 
    682697 
     
    685700    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    686701    Cell cell(p); 
    687     Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); 
     702    Map* m = player->GetMap(); 
    688703 
    689704    m->UpdatePlayerVisibility(player,cell,p);