[8678] Move objects updates store and proccessing for send to client in per map way.

This commit is contained in:
VladimirMangos 2009-10-19 23:24:41 +04:00
parent abb77cfdbf
commit 8bf52f7c63
10 changed files with 80 additions and 61 deletions

View file

@ -697,6 +697,9 @@ void Map::Update(const uint32 &t_diff)
}
}
// Send world objects and item update field changes
SendObjectUpdates();
// Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load !
// This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
if (!IsBattleGroundOrArena())
@ -3415,3 +3418,25 @@ DynamicObject* Map::GetDynamicObject(uint64 guid)
{
return m_objectsStore.find<DynamicObject>(guid, (DynamicObject*)NULL);
}
void Map::SendObjectUpdates()
{
UpdateDataMapType update_players;
while(!i_objectsToClientUpdate.empty())
{
Object* obj = *i_objectsToClientUpdate.begin();
i_objectsToClientUpdate.erase(i_objectsToClientUpdate.begin());
if (!obj)
continue;
obj->BuildUpdateData(update_players);
}
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
}
}