| 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 |
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 | | |
588 | | void |
589 | | ObjectAccessor::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); |
| 591 | } |
| 592 | |
| 593 | _update(); |
| 594 | } |
| 595 | |
| 596 | bool |
| 597 | ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_id) const |
| 598 | { |
| 599 | CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); |
| 600 | CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); |
| 601 | cell_min << 2; |
| 602 | cell_min -= 2; |
| 603 | cell_max >> 2; |
| 604 | cell_max += 2; |
| 605 | |
| 606 | for(std::set<WorldObject*>::const_iterator itr = i_activeobjects.begin(); itr != i_activeobjects.end(); ++itr) |
| 607 | { |
| 608 | if( m_id != (*itr)->GetMapId() || i_id != (*itr)->GetInstanceId() ) |
| 609 | continue; |
| 610 | |
| 611 | CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY()); |
| 612 | if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && |
| 613 | (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) |
| 614 | return true; |
| 615 | } |
| 616 | |
| 617 | return false; |