Changeset 279 for trunk/src/game/ObjectAccessor.cpp
- Timestamp:
- 11/22/08 00:36:22 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/ObjectAccessor.cpp
r272 r279 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 { 522 { 504 505 { 506 //Player update now in MapManager -> UpdatePlayers 507 /* 523 508 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 524 509 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 529 514 iter->second->Update(diff); 530 515 } 531 } 532 516 }*/ 517 518 // TODO: move this to Map::Update 533 519 // clone the active object list, because update might remove from it 534 520 std::set<WorldObject *> activeobjects(i_activeobjects); … … 591 577 } 592 578 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 602 void 603 ObjectAccessor::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); 594 609 } 595 610 … … 678 693 Cell cell(p); 679 694 680 MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p);695 obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 681 696 } 682 697 … … 685 700 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 686 701 Cell cell(p); 687 Map* m = MapManager::Instance().GetMap(player->GetMapId(),player);702 Map* m = player->GetMap(); 688 703 689 704 m->UpdatePlayerVisibility(player,cell,p);