Selaa lähdekoodia

Unify index out of bounds message

Daniele Bartolini 12 vuotta sitten
vanhempi
sitoutus
35e5d480ce

+ 2 - 0
engine/core/math/Quaternion.h

@@ -169,12 +169,14 @@ inline Quaternion::Quaternion(const Vector3& axis, float angle)
 //-----------------------------------------------------------------------------	
 inline float& Quaternion::operator[](uint32_t i)
 {
+	CE_ASSERT(i < 4, "Index out of bounds");
 	return (&x)[i];
 }
 
 //-----------------------------------------------------------------------------	
 inline const float& Quaternion::operator[](uint32_t i) const
 {
+	CE_ASSERT(i < 4, "Index out of bounds");
 	return (&x)[i];
 }
 

+ 2 - 2
engine/core/math/Vector2.h

@@ -220,7 +220,7 @@ inline Vector2::Vector2(const float a[2]) : x(a[0]), y(a[1])
 //-----------------------------------------------------------------------------
 inline const float& Vector2::operator[](uint32_t i) const
 {
-	CE_ASSERT(i < 2, "Index must be < 2");
+	CE_ASSERT(i < 2, "Index out of bounds");
 
 	return (&x)[i];
 }
@@ -228,7 +228,7 @@ inline const float& Vector2::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline float& Vector2::operator[](uint32_t i)
 {
-	CE_ASSERT(i < 2, "Index must be < 2");
+	CE_ASSERT(i < 2, "Index out of bounds");
 
 	return (&x)[i];
 }

+ 2 - 2
engine/core/math/Vector3.h

@@ -243,7 +243,7 @@ inline Vector3::Vector3(const float v[3]) : x(v[0]), y(v[1]), z(v[2])
 //-----------------------------------------------------------------------------
 inline const float& Vector3::operator[](uint32_t i) const
 {
-	CE_ASSERT(i < 3, "Index must be < 3");
+	CE_ASSERT(i < 3, "Index out of bounds");
 
 	return (&x)[i];
 }
@@ -251,7 +251,7 @@ inline const float& Vector3::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline float& Vector3::operator[](uint32_t i)
 {
-	CE_ASSERT(i < 3, "Index must be < 3");
+	CE_ASSERT(i < 3, "Index out of bounds");
 
 	return (&x)[i];
 }

+ 2 - 2
engine/core/math/Vector4.h

@@ -241,7 +241,7 @@ inline Vector4::Vector4(const float a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3])
 //-----------------------------------------------------------------------------
 inline const float& Vector4::operator[](uint32_t i) const
 {
-	CE_ASSERT(i < 4, "Index must be < 4");
+	CE_ASSERT(i < 4, "Index out of bounds");
 
 	return (&x)[i];
 }
@@ -249,7 +249,7 @@ inline const float& Vector4::operator[](uint32_t i) const
 //-----------------------------------------------------------------------------
 inline float& Vector4::operator[](uint32_t i)
 {
-	CE_ASSERT(i < 4, "Index must be < 4");
+	CE_ASSERT(i < 4, "Index out of bounds");
 
 	return (&x)[i];
 }