diff options
author | megamage <none@none> | 2008-11-20 20:28:17 -0600 |
---|---|---|
committer | megamage <none@none> | 2008-11-20 20:28:17 -0600 |
commit | 5528b7c512ef7968b11ea93a48364a58b629b18b (patch) | |
tree | 92dde452da86b70d73af90c3acfecf64b4bc04ca /src/game/ObjectAccessor.cpp | |
parent | 2c95ee4b31962198e3e6803bf56fe604724a2111 (diff) |
*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
Diffstat (limited to 'src/game/ObjectAccessor.cpp')
-rw-r--r-- | src/game/ObjectAccessor.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
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<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); for(HashMapHolder<Player>::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<WorldObject *> 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 |