Show
Ignore:
Timestamp:
11/19/08 13:51:33 (17 years ago)
Author:
yumileroy
Message:

*Merge from Mangos. Add MapReference?. Author: hunuza.
*Also re-commit the patches reverted in 255.

Original author: megamage
Date: 2008-11-18 19:40:06-06:00

Files:
1 modified

Legend:

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

    r237 r257  
    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{ 
     504 
    522505    { 
    523506        // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 
     
    590573        } 
    591574    } 
    592  
    593     _update(); 
     575} 
     576 
     577void 
     578ObjectAccessor::UpdatePlayers(uint32 diff) 
     579{ 
     580    HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 
     581    for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 
     582        if(iter->second->IsInWorld()) 
     583            iter->second->Update(diff); 
    594584} 
    595585 
     
    678668    Cell cell(p); 
    679669 
    680     MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); 
     670    obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 
    681671} 
    682672 
     
    685675    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    686676    Cell cell(p); 
    687     Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); 
     677    Map* m = player->GetMap(); 
    688678 
    689679    m->UpdatePlayerVisibility(player,cell,p);