Core/Objects: Changed how update fields changes are identified, no longer storing old value to compare with new. Instead fields are now simply marked if changed. This means that even if a field changes back to its original value, packet will be sent anyway (client expects it for some fields like shapeshift)
This commit is contained in:
@@ -69,8 +69,8 @@ Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
||||
m_objectTypeId = TYPEID_OBJECT;
|
||||
m_objectType = TYPEMASK_OBJECT;
|
||||
|
||||
m_uint32Values = 0;
|
||||
m_uint32Values_mirror = 0;
|
||||
m_uint32Values = NULL;
|
||||
_changedFields = NULL;
|
||||
m_valuesCount = 0;
|
||||
|
||||
m_inWorld = false;
|
||||
@@ -112,7 +112,7 @@ Object::~Object()
|
||||
}
|
||||
|
||||
delete [] m_uint32Values;
|
||||
delete [] m_uint32Values_mirror;
|
||||
delete [] _changedFields;
|
||||
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ void Object::_InitValues()
|
||||
m_uint32Values = new uint32[m_valuesCount];
|
||||
memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32));
|
||||
|
||||
m_uint32Values_mirror = new uint32[ m_valuesCount ];
|
||||
memset(m_uint32Values_mirror, 0, m_valuesCount*sizeof(uint32));
|
||||
_changedFields = new bool[m_valuesCount];
|
||||
memset(_changedFields, 0, sizeof(_changedFields));
|
||||
|
||||
m_objectUpdated = false;
|
||||
}
|
||||
@@ -750,7 +750,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
|
||||
|
||||
void Object::ClearUpdateMask(bool remove)
|
||||
{
|
||||
memcpy(m_uint32Values_mirror, m_uint32Values, m_valuesCount*sizeof(uint32));
|
||||
memset(_changedFields, 0, sizeof(_changedFields));
|
||||
|
||||
if (m_objectUpdated)
|
||||
{
|
||||
@@ -774,7 +774,7 @@ void Object::BuildFieldsUpdate(Player* pl, UpdateDataMapType& data_map) const
|
||||
BuildValuesUpdateBlockForPlayer(&iter->second, iter->first);
|
||||
}
|
||||
|
||||
void Object::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count)
|
||||
void Object::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 count)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
@@ -785,17 +785,19 @@ void Object::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou
|
||||
return;
|
||||
|
||||
for (uint32 index = 0; index < count; ++index)
|
||||
{
|
||||
m_uint32Values[startOffset + index] = atol(tokens[index]);
|
||||
_changedFields[startOffset + index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Object::_SetUpdateBits(UpdateMask* updateMask, Player* /*target*/) const
|
||||
{
|
||||
uint32 *value = m_uint32Values;
|
||||
uint32 *mirror = m_uint32Values_mirror;
|
||||
bool* indexes = _changedFields;
|
||||
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index, ++value, ++mirror)
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index, ++indexes)
|
||||
{
|
||||
if (*mirror != *value)
|
||||
if (*indexes)
|
||||
updateMask->SetBit(index);
|
||||
}
|
||||
}
|
||||
@@ -818,6 +820,7 @@ void Object::SetInt32Value(uint16 index, int32 value)
|
||||
if (m_int32Values[index] != value)
|
||||
{
|
||||
m_int32Values[index] = value;
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -837,6 +840,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
|
||||
if (m_uint32Values[index] != value)
|
||||
{
|
||||
m_uint32Values[index] = value;
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -854,6 +858,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
m_uint32Values[index] = value;
|
||||
_changedFields[index] = true;
|
||||
}
|
||||
|
||||
void Object::SetUInt64Value(uint16 index, uint64 const value)
|
||||
@@ -863,6 +868,8 @@ void Object::SetUInt64Value(uint16 index, uint64 const value)
|
||||
{
|
||||
m_uint32Values[index] = *((uint32*)&value);
|
||||
m_uint32Values[index + 1] = *(((uint32*)&value) + 1);
|
||||
_changedFields[index] = true;
|
||||
_changedFields[index + 1] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -882,6 +889,8 @@ bool Object::AddUInt64Value(uint16 index, uint64 const value)
|
||||
{
|
||||
m_uint32Values[index] = *((uint32*)&value);
|
||||
m_uint32Values[index + 1] = *(((uint32*)&value) + 1);
|
||||
_changedFields[index] = true;
|
||||
_changedFields[index + 1] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -903,6 +912,8 @@ bool Object::RemoveUInt64Value(uint16 index, const uint64 value)
|
||||
{
|
||||
m_uint32Values[index] = 0;
|
||||
m_uint32Values[index + 1] = 0;
|
||||
_changedFields[index] = true;
|
||||
_changedFields[index + 1] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -926,6 +937,7 @@ void Object::SetFloatValue(uint16 index, float value)
|
||||
if (m_floatValues[index] != value)
|
||||
{
|
||||
m_floatValues[index] = value;
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -952,6 +964,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
|
||||
{
|
||||
m_uint32Values[index] &= ~uint32(uint32(0xFF) << (offset * 8));
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 8));
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -978,6 +991,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
|
||||
{
|
||||
m_uint32Values[index] &= ~uint32(uint32(0xFFFF) << (offset * 16));
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 16));
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -1047,6 +1061,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
|
||||
if (oldval != newval)
|
||||
{
|
||||
m_uint32Values[index] = newval;
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -1070,6 +1085,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
|
||||
if (oldval != newval)
|
||||
{
|
||||
m_uint32Values[index] = newval;
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -1095,6 +1111,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
||||
if (!(uint8(m_uint32Values[index] >> (offset * 8)) & newFlag))
|
||||
{
|
||||
m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8));
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -1120,6 +1137,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
|
||||
if (uint8(m_uint32Values[index] >> (offset * 8)) & oldFlag)
|
||||
{
|
||||
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8));
|
||||
_changedFields[index] = true;
|
||||
|
||||
if (m_inWorld)
|
||||
{
|
||||
@@ -1821,7 +1839,7 @@ void WorldObject::SendPlaySound(uint32 Sound, bool OnlySelf)
|
||||
|
||||
void Object::ForceValuesUpdateAtIndex(uint32 i)
|
||||
{
|
||||
m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed
|
||||
_changedFields[i] = true;
|
||||
if (m_inWorld)
|
||||
{
|
||||
if (!m_objectUpdated)
|
||||
|
||||
@@ -358,7 +358,7 @@ class Object
|
||||
float *m_floatValues;
|
||||
};
|
||||
|
||||
uint32 *m_uint32Values_mirror;
|
||||
bool* _changedFields;
|
||||
|
||||
uint16 m_valuesCount;
|
||||
|
||||
|
||||
@@ -1866,11 +1866,6 @@ class Unit : public WorldObject
|
||||
void SetShapeshiftForm(ShapeshiftForm form)
|
||||
{
|
||||
SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
|
||||
|
||||
// force update as too quick shapeshifting and back
|
||||
// causes the value to stay the same serverside
|
||||
// causes issues clientside (player gets stuck)
|
||||
ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2);
|
||||
}
|
||||
|
||||
inline bool IsInFeralForm() const
|
||||
|
||||
Reference in New Issue
Block a user