From 5528b7c512ef7968b11ea93a48364a58b629b18b Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 20 Nov 2008 20:28:17 -0600 Subject: *Fix the bug that updatepacket is not sent to players. *TODO: move creature::update to map::update. This requires that move activeobjectlist to map. --HG-- branch : trunk --- src/game/ObjectAccessor.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/game/ObjectAccessor.cpp') diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 8a7e8fbfa2c..8d9f3f63fc2 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -503,6 +503,8 @@ ObjectAccessor::Update(uint32 diff) { { + //Player update now in MapManager -> UpdatePlayers + /* // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. HashMapHolder::MapType& playerMap = HashMapHolder::GetContainer(); for(HashMapHolder::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) @@ -511,8 +513,9 @@ ObjectAccessor::Update(uint32 diff) { iter->second->Update(diff); } - } + }*/ + // TODO: move this to Map::Update // clone the active object list, because update might remove from it std::set activeobjects(i_activeobjects); @@ -572,6 +575,28 @@ ObjectAccessor::Update(uint32 diff) } } } + + UpdateDataMapType update_players; + { + Guard guard(i_updateGuard); + while(!i_objects.empty()) + { + Object* obj = *i_objects.begin(); + i_objects.erase(i_objects.begin()); + if (!obj) + continue; + _buildUpdateObject(obj, update_players); + obj->ClearUpdateMask(false); + } + } + + WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 + for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) + { + iter->second.BuildPacket(&packet); + iter->first->GetSession()->SendPacket(&packet); + packet.clear(); // clean the string + } } void -- cgit v1.2.3