Show
Ignore:
Timestamp:
11/21/08 08:48:50 (17 years ago)
Author:
yumileroy
Message:

*Fix the bug that updatepacket is not sent to players.
*TODO: move creature::update to map::update. This requires that move activeobjectlist to map.

Original author: megamage
Date: 2008-11-20 20:28:17-06:00

Files:
1 modified

Legend:

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

    r257 r266  
    504504 
    505505    { 
     506        //Player update now in MapManager -> UpdatePlayers 
     507        /* 
    506508        // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 
    507509        HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 
     
    512514                iter->second->Update(diff); 
    513515            } 
    514         } 
    515  
     516        }*/ 
     517 
     518        // TODO: move this to Map::Update 
    516519        // clone the active object list, because update might remove from it 
    517520        std::set<WorldObject *> activeobjects(i_activeobjects); 
     
    573576        } 
    574577    } 
     578 
     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    } 
    575600} 
    576601