Changeset 281 for trunk/src/game/ObjectAccessor.cpp
- Timestamp:
- 11/22/08 00:36:29 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/ObjectAccessor.cpp
r279 r281 488 488 489 489 void 490 ObjectAccessor::AddActiveObject( WorldObject * obj )491 {492 i_activeobjects.insert(obj);493 }494 495 void496 ObjectAccessor::RemoveActiveObject( WorldObject * obj )497 {498 i_activeobjects.erase(obj);499 }500 501 void502 490 ObjectAccessor::Update(uint32 diff) 503 491 { 504 505 { 492 /* { 506 493 //Player update now in MapManager -> UpdatePlayers 507 /*508 494 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 509 495 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 514 500 iter->second->Update(diff); 515 501 } 516 } */502 } 517 503 518 504 // TODO: move this to Map::Update … … 575 561 } 576 562 } 577 } 563 }*/ 578 564 579 565 UpdateDataMapType update_players; … … 609 595 } 610 596 611 bool612 ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_id) const613 {614 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);615 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);616 cell_min << 2;617 cell_min -= 2;618 cell_max >> 2;619 cell_max += 2;620 621 for(std::set<WorldObject*>::const_iterator itr = i_activeobjects.begin(); itr != i_activeobjects.end(); ++itr)622 {623 if( m_id != (*itr)->GetMapId() || i_id != (*itr)->GetInstanceId() )624 continue;625 626 CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY());627 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&628 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )629 return true;630 }631 632 return false;633 }634 635 597 void 636 598 ObjectAccessor::WorldObjectChangeAccumulator::Visit(PlayerMapType &m)