Core/Objects: Properly ASSERT when trying to access invalid updatefields

This commit is contained in:
Shauren
2019-01-08 23:03:53 +01:00
parent d12f0841f1
commit c4f2c88a9c

View File

@@ -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)
{