mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[8677] Move most client update data functions to object itself from ObjectAccessor.
Also use virtual function BuildUpdateData (old ObjectAccessor::_buildUpdateObject) that different for world objects and items.
This commit is contained in:
parent
a2ff999fd3
commit
abb77cfdbf
7 changed files with 73 additions and 79 deletions
|
|
@ -128,7 +128,7 @@ void Object::BuildMovementUpdateBlock(UpdateData * data, uint32 flags ) const
|
|||
buf << uint8( UPDATETYPE_MOVEMENT );
|
||||
buf.append(GetPackGUID());
|
||||
|
||||
_BuildMovementUpdate(&buf, flags, 0x00000000);
|
||||
BuildMovementUpdate(&buf, flags, 0x00000000);
|
||||
|
||||
data->AddUpdateBlock(buf);
|
||||
}
|
||||
|
|
@ -189,12 +189,12 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c
|
|||
buf.append(GetPackGUID());
|
||||
buf << (uint8)m_objectTypeId;
|
||||
|
||||
_BuildMovementUpdate(&buf, flags, flags2);
|
||||
BuildMovementUpdate(&buf, flags, flags2);
|
||||
|
||||
UpdateMask updateMask;
|
||||
updateMask.SetCount( m_valuesCount );
|
||||
_SetCreateBits( &updateMask, target );
|
||||
_BuildValuesUpdate(updatetype, &buf, &updateMask, target);
|
||||
BuildValuesUpdate(updatetype, &buf, &updateMask, target);
|
||||
data->AddUpdateBlock(buf);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) c
|
|||
updateMask.SetCount( m_valuesCount );
|
||||
|
||||
_SetUpdateBits( &updateMask, target );
|
||||
_BuildValuesUpdate(UPDATETYPE_VALUES, &buf, &updateMask, target);
|
||||
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, &updateMask, target);
|
||||
|
||||
data->AddUpdateBlock(buf);
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ void Object::DestroyForPlayer( Player *target, bool anim ) const
|
|||
target->GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2) const
|
||||
void Object::BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2) const
|
||||
{
|
||||
uint16 unk_flags = ((GetTypeId() == TYPEID_PLAYER) ? ((Player*)this)->m_movementInfo.unk1 : 0);
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2
|
|||
}
|
||||
}
|
||||
|
||||
void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *updateMask, Player *target) const
|
||||
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *updateMask, Player *target) const
|
||||
{
|
||||
if(!target)
|
||||
return;
|
||||
|
|
@ -1065,6 +1065,20 @@ bool Object::PrintIndexError(uint32 index, bool set) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players)
|
||||
{
|
||||
UpdateDataMapType::iterator iter = update_players.find(pl);
|
||||
|
||||
if (iter == update_players.end())
|
||||
{
|
||||
std::pair<UpdateDataMapType::iterator, bool> p = update_players.insert( UpdateDataMapType::value_type(pl, UpdateData()) );
|
||||
assert(p.second);
|
||||
iter = p.first;
|
||||
}
|
||||
|
||||
BuildValuesUpdateBlockForPlayer(&iter->second, iter->first);
|
||||
}
|
||||
|
||||
WorldObject::WorldObject()
|
||||
: m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
|
||||
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f), m_currMap(NULL)
|
||||
|
|
@ -1857,3 +1871,33 @@ void WorldObject::UpdateObjectVisibility()
|
|||
GetMap()->UpdateObjectVisibility(this, cell, p);
|
||||
}
|
||||
|
||||
struct WorldObjectChangeAccumulator
|
||||
{
|
||||
UpdateDataMapType &i_updateDatas;
|
||||
WorldObject &i_object;
|
||||
WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) {}
|
||||
void Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if(iter->getSource()->HaveAtClient(&i_object))
|
||||
i_object.BuildUpdateDataForPlayer(iter->getSource(), i_updateDatas);
|
||||
}
|
||||
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
|
||||
};
|
||||
|
||||
void WorldObject::BuildUpdateData( UpdateDataMapType & update_players)
|
||||
{
|
||||
CellPair p = MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
WorldObjectChangeAccumulator notifier(*this, update_players);
|
||||
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
Map* aMap = GetMap();
|
||||
//we must build packets for all visible players
|
||||
cell_lock->Visit(cell_lock, player_notifier, *aMap, *this, aMap->GetVisibilityDistance());
|
||||
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue