mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/PacketIO: Limited number of update fields sent to other players
This commit is contained in:
@@ -183,9 +183,13 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
uint8 updatetype = UPDATETYPE_CREATE_OBJECT;
|
||||
uint16 flags = m_updateFlag;
|
||||
|
||||
uint32 valCount = m_valuesCount;
|
||||
|
||||
/** lower flag1 **/
|
||||
if (target == this) // building packet for yourself
|
||||
flags |= UPDATEFLAG_SELF;
|
||||
else if (GetTypeId() == TYPEID_PLAYER)
|
||||
valCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
if (flags & UPDATEFLAG_STATIONARY_POSITION)
|
||||
{
|
||||
@@ -226,14 +230,14 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
//sLog->outDebug("BuildCreateUpdate: update-type: %u, object-type: %u got flags: %X, flags2: %X", updatetype, m_objectTypeId, flags, flags2);
|
||||
|
||||
ByteBuffer buf(500);
|
||||
buf << (uint8)updatetype;
|
||||
buf << uint8(updatetype);
|
||||
buf.append(GetPackGUID());
|
||||
buf << (uint8)m_objectTypeId;
|
||||
buf << uint8(m_objectTypeId);
|
||||
|
||||
_BuildMovementUpdate(&buf, flags);
|
||||
|
||||
UpdateMask updateMask;
|
||||
updateMask.SetCount(m_valuesCount);
|
||||
updateMask.SetCount(valCount);
|
||||
_SetCreateBits(&updateMask, target);
|
||||
_BuildValuesUpdate(updatetype, &buf, &updateMask, target);
|
||||
data->AddUpdateBlock(buf);
|
||||
@@ -254,11 +258,15 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
{
|
||||
ByteBuffer buf(500);
|
||||
|
||||
buf << (uint8) UPDATETYPE_VALUES;
|
||||
buf << uint8(UPDATETYPE_VALUES);
|
||||
buf.append(GetPackGUID());
|
||||
|
||||
UpdateMask updateMask;
|
||||
updateMask.SetCount(m_valuesCount);
|
||||
uint32 valCount = m_valuesCount;
|
||||
if (GetTypeId() == TYPEID_PLAYER && target != this)
|
||||
valCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
updateMask.SetCount(valCount);
|
||||
|
||||
_SetUpdateBits(&updateMask, target);
|
||||
_BuildValuesUpdate(UPDATETYPE_VALUES, &buf, &updateMask, target);
|
||||
@@ -332,7 +340,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
ObjectGuid transGuid = self->m_movementInfo.t_guid;
|
||||
|
||||
data->WriteBit(transGuid[1]);
|
||||
data->WriteBit(movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT);
|
||||
data->WriteBit(0); // Has transport time 2
|
||||
data->WriteBit(transGuid[4]);
|
||||
data->WriteBit(transGuid[0]);
|
||||
data->WriteBit(transGuid[6]);
|
||||
@@ -443,8 +451,8 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
data->WriteByteSeq(transGuid[7]);
|
||||
*data << uint32(self->GetTransTime());
|
||||
*data << float(self->GetTransOffsetO());
|
||||
if (movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT)
|
||||
*data << uint32(0);
|
||||
//if (hasTransportTime2)
|
||||
// *data << uint32(0);
|
||||
|
||||
*data << float(self->GetTransOffsetY());
|
||||
*data << float(self->GetTransOffsetX());
|
||||
@@ -561,6 +569,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
if (flags & UPDATEFLAG_HAS_TARGET)
|
||||
{
|
||||
ObjectGuid victimGuid = ToUnit()->getVictim()->GetGUID(); // checked in BuildCreateUpdateBlockForPlayer
|
||||
data->WriteByteSeq(victimGuid[4]);
|
||||
data->WriteByteSeq(victimGuid[0]);
|
||||
data->WriteByteSeq(victimGuid[3]);
|
||||
data->WriteByteSeq(victimGuid[5]);
|
||||
@@ -568,7 +577,6 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
data->WriteByteSeq(victimGuid[6]);
|
||||
data->WriteByteSeq(victimGuid[2]);
|
||||
data->WriteByteSeq(victimGuid[1]);
|
||||
data->WriteByteSeq(victimGuid[4]);
|
||||
}
|
||||
|
||||
//if (flags & UPDATEFLAG_ANIMKITS)
|
||||
@@ -585,7 +593,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
*data << uint32(getMSTime()); // Unknown - getMSTime is wrong.
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -627,7 +635,11 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask*
|
||||
}
|
||||
}
|
||||
|
||||
WPAssert(updateMask && updateMask->GetCount() == m_valuesCount);
|
||||
uint32 valCount = m_valuesCount;
|
||||
if (GetTypeId() == TYPEID_PLAYER && target != this)
|
||||
valCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
WPAssert(updateMask && updateMask->GetCount() == valCount);
|
||||
|
||||
*data << (uint8)updateMask->GetBlockCount();
|
||||
data->append(updateMask->GetMask(), updateMask->GetLength());
|
||||
@@ -985,7 +997,11 @@ void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const
|
||||
|
||||
GetUpdateFieldData(target, flags, isOwner, isItemOwner, hasSpecialInfo, isPartyMember);
|
||||
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index, ++indexes)
|
||||
uint32 valCount = m_valuesCount;
|
||||
if (GetTypeId() == TYPEID_PLAYER && target != this)
|
||||
valCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
for (uint16 index = 0; index < valCount; ++index, ++indexes)
|
||||
if (_fieldNotifyFlags & flags[index] || (flags[index] & UF_FLAG_SPECIAL_INFO && hasSpecialInfo) || (*indexes && IsUpdateFieldVisible(flags[index], isSelf, isOwner, isItemOwner, isPartyMember)))
|
||||
updateMask->SetBit(index);
|
||||
}
|
||||
@@ -1002,7 +1018,11 @@ void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const
|
||||
|
||||
GetUpdateFieldData(target, flags, isOwner, isItemOwner, hasSpecialInfo, isPartyMember);
|
||||
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index, ++value)
|
||||
uint32 valCount = m_valuesCount;
|
||||
if (GetTypeId() == TYPEID_PLAYER && target != this)
|
||||
valCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
for (uint16 index = 0; index < valCount; ++index, ++value)
|
||||
if (_fieldNotifyFlags & flags[index] || (flags[index] & UF_FLAG_SPECIAL_INFO && hasSpecialInfo) || (*value && IsUpdateFieldVisible(flags[index], isSelf, isOwner, isItemOwner, isPartyMember)))
|
||||
updateMask->SetBit(index);
|
||||
}
|
||||
|
||||
@@ -935,7 +935,7 @@ class WorldObject : public Object, public WorldLocation
|
||||
|
||||
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
||||
|
||||
bool CanNeverSee(WorldObject const* obj) const { return !IsInMap(obj) || !InSamePhase(obj); }
|
||||
bool CanNeverSee(WorldObject const* obj) const { return GetMap() != obj->GetMap() || !InSamePhase(obj); }
|
||||
virtual bool CanAlwaysSee(WorldObject const* /*obj*/) const { return false; }
|
||||
bool CanDetect(WorldObject const* obj, bool ignoreStealth) const;
|
||||
bool CanDetectInvisibilityOf(WorldObject const* obj) const;
|
||||
|
||||
@@ -81,7 +81,7 @@ inline uint32 GUID_HIPART(uint64 guid)
|
||||
|
||||
// We have different low and middle part size for different guid types
|
||||
#define _GUID_ENPART_2(x) 0
|
||||
#define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x0000000000FFFFFF))
|
||||
#define _GUID_ENPART_3(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000000FFFFF))
|
||||
#define _GUID_LOPART_2(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
|
||||
#define _GUID_LOPART_3(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
|
||||
|
||||
|
||||
@@ -435,6 +435,8 @@ enum EPlayerFields
|
||||
PLAYER_CHOSEN_TITLE = UNIT_END + 0x012B, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_FAKE_INEBRIATION = UNIT_END + 0x012C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_FIELD_PAD_0 = UNIT_END + 0x012D, // Size: 1, Type: INT, Flags: NONE
|
||||
PLAYER_END_NOT_SELF = UNIT_END + 0x012E,
|
||||
|
||||
PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x012E, // Size: 46, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x015C, // Size: 32, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x017C, // Size: 56, Type: LONG, Flags: PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user