Changeset 257 for trunk/src/game/ObjectAccessor.cpp
- Timestamp:
- 11/19/08 13:51:33 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/ObjectAccessor.cpp
r237 r257 143 143 { 144 144 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 146 154 return ret; 147 155 } … … 249 257 250 258 void 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 0x10000268 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 string273 }274 }275 276 void277 259 ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 278 260 { … … 362 344 TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 363 345 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()); 365 347 } 366 348 … … 520 502 ObjectAccessor::Update(uint32 diff) 521 503 { 504 522 505 { 523 506 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. … … 590 573 } 591 574 } 592 593 _update(); 575 } 576 577 void 578 ObjectAccessor::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); 594 584 } 595 585 … … 678 668 Cell cell(p); 679 669 680 MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p);670 obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 681 671 } 682 672 … … 685 675 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 686 676 Cell cell(p); 687 Map* m = MapManager::Instance().GetMap(player->GetMapId(),player);677 Map* m = player->GetMap(); 688 678 689 679 m->UpdatePlayerVisibility(player,cell,p);