diff options
| author | Shauren <shauren.trinity@gmail.com> | 2019-01-08 23:03:53 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-01-08 23:03:53 +0100 |
| commit | c4f2c88a9c76f2ed2d5ecc693239e135f182dae9 (patch) | |
| tree | 18403f22dc18be220b294c99a4ffa33942255061 | |
| parent | d12f0841f198045e80a6bca52c03507df8db5b6d (diff) | |
Core/Objects: Properly ASSERT when trying to access invalid updatefields
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index ece49ddbed6..292092ddc92 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -688,12 +688,7 @@ void Object::SetFloatValue(uint16 index, float value) void Object::SetByteValue(uint16 index, uint8 offset, uint8 value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - - if (offset > 3) - { - TC_LOG_ERROR("misc", "Object::SetByteValue: wrong offset %u", offset); - return; - } + ASSERT(offset < 4); if (uint8(m_uint32Values[index] >> (offset * 8)) != value) { @@ -709,12 +704,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value) void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - - if (offset > 1) - { - TC_LOG_ERROR("misc", "Object::SetUInt16Value: wrong offset %u", offset); - return; - } + ASSERT(offset < 2); if (uint16(m_uint32Values[index] >> (offset * 16)) != value) { @@ -805,7 +795,6 @@ void Object::SetFlag(uint16 index, uint32 newFlag) void Object::RemoveFlag(uint16 index, uint32 oldFlag) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - ASSERT(m_uint32Values); uint32 oldval = m_uint32Values[index]; uint32 newval = oldval & ~oldFlag; @@ -829,9 +818,7 @@ void Object::ToggleFlag(uint16 index, uint32 flag) bool Object::HasFlag(uint16 index, uint32 flag) const { - if (index >= m_valuesCount && !PrintIndexError(index, false)) - return false; - + ASSERT(index < m_valuesCount || PrintIndexError(index, true)); return (m_uint32Values[index] & flag) != 0; } @@ -843,12 +830,7 @@ void Object::ApplyModFlag(uint16 index, uint32 flag, bool apply) void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - - if (offset > 3) - { - TC_LOG_ERROR("misc", "Object::SetByteFlag: wrong offset %u", offset); - return; - } + ASSERT(offset < 4); if (!(uint8(m_uint32Values[index] >> (offset * 8)) & newFlag)) { @@ -862,12 +844,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag) void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - - if (offset > 3) - { - TC_LOG_ERROR("misc", "Object::RemoveByteFlag: wrong offset %u", offset); - return; - } + ASSERT(offset < 4); if (uint8(m_uint32Values[index] >> (offset * 8)) & oldFlag) { |
