mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Updated the exception system in the main plugin to also include the location in the source files in debug builds.
Moved the functions that extract base types from strings as static functions under the associated type. Revised some of the base shared code. Fixed some of the functions in the String library that did not take into account the null terminator.
This commit is contained in:
parent
e3315430ea
commit
8088ba94c2
@ -358,6 +358,37 @@ AABB AABB::Abs() const
|
||||
return AABB(min.Abs(), max.Abs());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const AABB & GetAABB(CSStr str)
|
||||
{
|
||||
return GetAABB(str, AABB::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const AABB & GetAABB(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f , %f , %f ");
|
||||
static AABB box;
|
||||
// Clear previous values, if any
|
||||
box.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return box; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
fs[19] = delim;
|
||||
fs[24] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
std::sscanf(str, fs, &box.min.x, &box.min.y, &box.min.z, &box.max.x, &box.max.y, &box.max.z);
|
||||
// Return the resulted value
|
||||
return box;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_AABB(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -438,6 +469,9 @@ void Register_AABB(HSQUIRRELVM vm)
|
||||
.Func<bool (AABB::*)(const AABB &) const>(_SC("opGreaterThan"), &AABB::operator >)
|
||||
.Func<bool (AABB::*)(const AABB &) const>(_SC("opLessEqual"), &AABB::operator <=)
|
||||
.Func<bool (AABB::*)(const AABB &) const>(_SC("opGreaterEqual"), &AABB::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const AABB & (*)(CSStr) >(_SC("FromStr"), &GetAABB)
|
||||
.StaticOverload< const AABB & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetAABB)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the AABB type from a string.
|
||||
*/
|
||||
const AABB & GetAABB(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the AABB type from a string.
|
||||
*/
|
||||
const AABB & GetAABB(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent an axis aligned bounding box in three-dimensional space.
|
||||
*/
|
||||
|
@ -382,7 +382,7 @@ void Circle::Generate()
|
||||
void Circle::Generate(Value min, Value max, bool r)
|
||||
{
|
||||
if (EpsLt(max, min))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
else if (r)
|
||||
rad = GetRandomFloat32(min, max);
|
||||
else
|
||||
@ -392,7 +392,7 @@ void Circle::Generate(Value min, Value max, bool r)
|
||||
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
pos.Generate(xmin, xmax, ymin, ymax);
|
||||
}
|
||||
@ -400,7 +400,7 @@ void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
||||
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(rmax, rmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
pos.Generate(xmin, xmax, ymin, ymax);
|
||||
rad = GetRandomFloat32(rmin, rmax);
|
||||
@ -412,6 +412,34 @@ Circle Circle::Abs() const
|
||||
return Circle(pos.Abs(), fabs(rad));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Circle & GetCircle(CSStr str)
|
||||
{
|
||||
return GetCircle(str, Circle::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Circle & GetCircle(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f ");
|
||||
static Circle circle;
|
||||
// Clear previous values, if any
|
||||
circle.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return circle; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
std::sscanf(str, fs, &circle.pos.x, &circle.pos.y, &circle.rad);
|
||||
// Return the resulted value
|
||||
return circle;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Circle(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -502,6 +530,9 @@ void Register_Circle(HSQUIRRELVM vm)
|
||||
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterThan"), &Circle::operator >)
|
||||
.Func<bool (Circle::*)(const Circle &) const>(_SC("opLessEqual"), &Circle::operator <=)
|
||||
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterEqual"), &Circle::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Circle & (*)(CSStr) >(_SC("FromStr"), &GetCircle)
|
||||
.StaticOverload< const Circle & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetCircle)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Circle type from a string.
|
||||
*/
|
||||
const Circle & GetCircle(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Circle type from a string.
|
||||
*/
|
||||
const Circle & GetCircle(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a two-dimensional circle.
|
||||
*/
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -530,7 +533,7 @@ void Color3::Generate()
|
||||
void Color3::Generate(Value min, Value max)
|
||||
{
|
||||
if (max < min)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
r = GetRandomUint8(min, max);
|
||||
g = GetRandomUint8(min, max);
|
||||
@ -540,7 +543,7 @@ void Color3::Generate(Value min, Value max)
|
||||
void Color3::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax)
|
||||
{
|
||||
if (rmax < rmin || gmax < gmin || bmax < bmin)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
r = GetRandomUint8(rmin, rmax);
|
||||
g = GetRandomUint8(gmin, gmax);
|
||||
@ -561,6 +564,43 @@ void Color3::Inverse()
|
||||
b = static_cast< Value >(~b);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color3 & GetColor3(CSStr str)
|
||||
{
|
||||
return GetColor3(str, Color3::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color3 & GetColor3(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %u , %u , %u ");
|
||||
static Color3 col;
|
||||
// The minimum and maximum values supported by the Color3 type
|
||||
static const Uint32 min = std::numeric_limits< Color3::Value >::min();
|
||||
static const Uint32 max = std::numeric_limits< Color3::Value >::max();
|
||||
// Clear previous values, if any
|
||||
col.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return col; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
// The sscanf function requires at least 32 bit integers
|
||||
Uint32 r = 0, g = 0, b = 0;
|
||||
// Attempt to extract the component values from the specified string
|
||||
std::sscanf(str, fs, &r, &g, &b);
|
||||
// Cast the extracted integers to the value used by the Color3 type
|
||||
col.r = static_cast< Color3::Value >(Clamp(r, min, max));
|
||||
col.g = static_cast< Color3::Value >(Clamp(g, min, max));
|
||||
col.b = static_cast< Color3::Value >(Clamp(b, min, max));
|
||||
// Return the resulted value
|
||||
return col;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Color3(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -667,6 +707,9 @@ void Register_Color3(HSQUIRRELVM vm)
|
||||
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opGreaterThan"), &Color3::operator >)
|
||||
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opLessEqual"), &Color3::operator <=)
|
||||
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opGreaterEqual"), &Color3::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Color3 & (*)(CSStr) >(_SC("FromStr"), &GetColor3)
|
||||
.StaticOverload< const Color3 & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetColor3)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color3 type from a string.
|
||||
*/
|
||||
const Color3 & GetColor3(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color3 type from a string.
|
||||
*/
|
||||
const Color3 & GetColor3(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent an opaque RGB color.
|
||||
*/
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -576,7 +579,7 @@ void Color4::Generate()
|
||||
void Color4::Generate(Value min, Value max)
|
||||
{
|
||||
if (max < min)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
r = GetRandomUint8(min, max);
|
||||
g = GetRandomUint8(min, max);
|
||||
@ -587,7 +590,7 @@ void Color4::Generate(Value min, Value max)
|
||||
void Color4::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax)
|
||||
{
|
||||
if (rmax < rmin || gmax < gmin || bmax < bmin || amax < amin)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
r = GetRandomUint8(rmin, rmax);
|
||||
g = GetRandomUint8(gmin, gmax);
|
||||
@ -610,6 +613,45 @@ void Color4::Inverse()
|
||||
a = static_cast< Value >(~a);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color4 & GetColor4(CSStr str)
|
||||
{
|
||||
return GetColor4(str, Color4::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color4 & GetColor4(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %u , %u , %u , %u ");
|
||||
static Color4 col;
|
||||
// The minimum and maximum values supported by the Color4 type
|
||||
static const Uint32 min = std::numeric_limits< Color4::Value >::min();
|
||||
static const Uint32 max = std::numeric_limits< Color4::Value >::max();
|
||||
// Clear previous values, if any
|
||||
col.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return col; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
// The sscanf function requires at least 32 bit integers
|
||||
Uint32 r = 0, g = 0, b = 0, a = 0;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, fs, &r, &g, &b, &a);
|
||||
// Cast the extracted integers to the value used by the Color4 type
|
||||
col.r = static_cast< Color4::Value >(Clamp(r, min, max));
|
||||
col.g = static_cast< Color4::Value >(Clamp(g, min, max));
|
||||
col.b = static_cast< Color4::Value >(Clamp(b, min, max));
|
||||
col.a = static_cast< Color4::Value >(Clamp(a, min, max));
|
||||
// Return the resulted value
|
||||
return col;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Color4(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -719,6 +761,9 @@ void Register_Color4(HSQUIRRELVM vm)
|
||||
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opGreaterThan"), &Color4::operator >)
|
||||
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opLessEqual"), &Color4::operator <=)
|
||||
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opGreaterEqual"), &Color4::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Color4 & (*)(CSStr) >(_SC("FromStr"), &GetColor4)
|
||||
.StaticOverload< const Color4 & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetColor4)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color4 type from a string.
|
||||
*/
|
||||
const Color4 & GetColor4(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color4 type from a string.
|
||||
*/
|
||||
const Color4 & GetColor4(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a transparent RGBA color.
|
||||
*/
|
||||
|
@ -393,7 +393,7 @@ void Quaternion::Generate()
|
||||
void Quaternion::Generate(Value min, Value max)
|
||||
{
|
||||
if (EpsLt(max, min))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(min, max);
|
||||
y = GetRandomFloat32(min, max);
|
||||
@ -404,7 +404,7 @@ void Quaternion::Generate(Value min, Value max)
|
||||
void Quaternion::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(xmin, xmax);
|
||||
y = GetRandomFloat32(ymin, ymax);
|
||||
@ -418,6 +418,35 @@ Quaternion Quaternion::Abs() const
|
||||
return Quaternion(fabs(x), fabs(y), fabs(z), fabs(w));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Quaternion & GetQuaternion(CSStr str)
|
||||
{
|
||||
return GetQuaternion(str, Quaternion::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Quaternion & GetQuaternion(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Quaternion quat;
|
||||
// Clear previous values, if any
|
||||
quat.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return quat; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, fs, &quat.x, &quat.y, &quat.z, &quat.w);
|
||||
// Return the resulted value
|
||||
return quat;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Quaternion(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -502,6 +531,9 @@ void Register_Quaternion(HSQUIRRELVM vm)
|
||||
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opGreaterThan"), &Quaternion::operator >)
|
||||
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opLessEqual"), &Quaternion::operator <=)
|
||||
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opGreaterEqual"), &Quaternion::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Quaternion & (*)(CSStr) >(_SC("FromStr"), &GetQuaternion)
|
||||
.StaticOverload< const Quaternion & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetQuaternion)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Quaternion type from a string.
|
||||
*/
|
||||
const Quaternion & GetQuaternion(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Quaternion type from a string.
|
||||
*/
|
||||
const Quaternion & GetQuaternion(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Quaternion class for representing rotations.
|
||||
*/
|
||||
|
@ -17,10 +17,11 @@
|
||||
#include "Base/Vector4.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <time.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctime>
|
||||
#include <cfloat>
|
||||
#include <limits>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -113,7 +114,7 @@ Object BufferToStrObj(const Buffer & b, Uint32 size)
|
||||
// Perform a range check on the specified buffer
|
||||
if (size > b.Capacity())
|
||||
{
|
||||
SqThrowF("The specified buffer size is out of range: %u >= %u", size, b.Capacity());
|
||||
STHROWF("The specified buffer size is out of range: %u >= %u", size, b.Capacity());
|
||||
}
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg(DefaultVM::Get());
|
||||
@ -138,7 +139,9 @@ void SqThrowF(CCStr fmt, ...)
|
||||
va_start (args, fmt);
|
||||
// Write the requested contents
|
||||
if (snprintf(g_Buffer, sizeof(g_Buffer), fmt, args) < 0)
|
||||
{
|
||||
strcpy(g_Buffer, "Unknown error has occurred");
|
||||
}
|
||||
// Release the argument list
|
||||
va_end(args);
|
||||
// Throw the exception with the resulted message
|
||||
@ -155,7 +158,9 @@ CSStr ToStrF(CCStr fmt, ...)
|
||||
int ret = vsnprintf(g_Buffer, sizeof(g_Buffer), fmt, args);
|
||||
// See if the format function failed
|
||||
if (ret < 0)
|
||||
SqThrowF("Failed to run the specified string format");
|
||||
{
|
||||
STHROWF("Failed to run the specified string format");
|
||||
}
|
||||
// Finalized the arguments list
|
||||
va_end(args);
|
||||
// Return the resulted string
|
||||
@ -172,8 +177,10 @@ CSStr ToStringF(CCStr fmt, ...)
|
||||
va_start (args, fmt);
|
||||
// Attempt to run the specified format
|
||||
if (b.WriteF(0, fmt, args) == 0)
|
||||
{
|
||||
// Make sure the string is null terminated
|
||||
b.At(0) = 0;
|
||||
}
|
||||
// Finalized the arguments list
|
||||
va_end(args);
|
||||
// Return the resulted string
|
||||
@ -336,15 +343,19 @@ Color3 GetColor(CSStr name)
|
||||
{
|
||||
// See if we actually have something to search for
|
||||
if(!name || *name == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
{
|
||||
STHROWF("Cannot extract values from an empty string");
|
||||
}
|
||||
// Clone the string into an editable version
|
||||
CCStr str = StrJustAlphaNum(name);
|
||||
str = StrToLowercase(str);
|
||||
// See if we still have a valid name after the cleanup
|
||||
if(!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an invalid string: %s", name);
|
||||
if(!str || *str == '\0')
|
||||
{
|
||||
STHROWF("Cannot extract values from an invalid string: %s", name);
|
||||
}
|
||||
// Calculate the name length
|
||||
const Uint32 len = strlen(str);
|
||||
const Uint32 len = std::strlen(str);
|
||||
// Get the most significant characters used to identify a weapon
|
||||
SQChar a = str[0], b = 0, c = 0, d = str[len-1];
|
||||
// Look for deeper specifiers
|
||||
@ -933,283 +944,6 @@ Color3 GetColor(CSStr name)
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const AABB & GetAABB(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f , %f , %f ");
|
||||
static AABB box;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
box.Clear();
|
||||
|
||||
if (delim != AABB::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
fs[19] = delim;
|
||||
fs[24] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = AABB::Delim;
|
||||
fs[9] = AABB::Delim;
|
||||
fs[14] = AABB::Delim;
|
||||
fs[19] = AABB::Delim;
|
||||
fs[24] = AABB::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &box.min.x, &box.min.y, &box.min.z, &box.max.x, &box.max.y, &box.max.z);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Circle & GetCircle(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f ");
|
||||
static Circle circle;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
circle.Clear();
|
||||
|
||||
if (delim != Circle::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Circle::Delim;
|
||||
fs[9] = Circle::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &circle.pos.x, &circle.pos.y, &circle.rad);
|
||||
|
||||
return circle;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color3 & GetColor3(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %u , %u , %u ");
|
||||
static Color3 col;
|
||||
|
||||
Uint32 r = 0, g = 0, b = 0;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
else if (delim != Color3::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Color3::Delim;
|
||||
fs[9] = Color3::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &r, &g, &b);
|
||||
|
||||
col.r = static_cast< Color4::Value >(r);
|
||||
col.g = static_cast< Color4::Value >(g);
|
||||
col.b = static_cast< Color4::Value >(b);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color4 & GetColor4(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %u , %u , %u , %u ");
|
||||
static Color4 col;
|
||||
|
||||
Uint32 r = 0, g = 0, b = 0, a = 0;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
else if (delim != Color4::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Color4::Delim;
|
||||
fs[9] = Color4::Delim;
|
||||
fs[14] = Color4::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &r, &g, &b, &a);
|
||||
|
||||
col.r = static_cast< Color4::Value >(r);
|
||||
col.g = static_cast< Color4::Value >(g);
|
||||
col.b = static_cast< Color4::Value >(b);
|
||||
col.a = static_cast< Color4::Value >(a);
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Quaternion & GetQuaternion(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Quaternion quat;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
quat.Clear();
|
||||
|
||||
if (delim != Quaternion::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Quaternion::Delim;
|
||||
fs[9] = Quaternion::Delim;
|
||||
fs[14] = Quaternion::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &quat.x, &quat.y, &quat.z, &quat.w);
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere & GetSphere(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Sphere sphere;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
sphere.Clear();
|
||||
|
||||
if (delim != Sphere::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Sphere::Delim;
|
||||
fs[9] = Sphere::Delim;
|
||||
fs[14] = Sphere::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &sphere.pos.x, &sphere.pos.y, &sphere.pos.z, &sphere.rad);
|
||||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2 & GetVector2(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f ");
|
||||
static Vector2 vec;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
vec.Clear();
|
||||
|
||||
if (delim != Vector2::Delim)
|
||||
fs[4] = delim;
|
||||
else
|
||||
fs[4] = Vector2::Delim;
|
||||
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
const Vector2i & GetVector2i(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %d , %d ");
|
||||
static Vector2i vec;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
vec.Clear();
|
||||
|
||||
if (delim != Vector2i::Delim)
|
||||
fs[4] = delim;
|
||||
else
|
||||
fs[4] = Vector2i::Delim;
|
||||
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector3 & GetVector3(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f ");
|
||||
static Vector3 vec;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
vec.Clear();
|
||||
|
||||
if (delim != Vector3::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Vector3::Delim;
|
||||
fs[9] = Vector3::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y, &vec.z);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
const Vector4 & GetVector4(CSStr str, SQChar delim)
|
||||
{
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Vector4 vec;
|
||||
|
||||
if (!str || *str == 0)
|
||||
SqThrowF("Cannot extract values from an empty string");
|
||||
|
||||
vec.Clear();
|
||||
|
||||
if (delim != Vector4::Delim)
|
||||
{
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs[4] = Vector4::Delim;
|
||||
fs[9] = Vector4::Delim;
|
||||
fs[14] = Vector4::Delim;
|
||||
}
|
||||
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y, &vec.z, &vec.w);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Base(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -1232,17 +966,7 @@ void Register_Base(HSQUIRRELVM vm)
|
||||
.Func(_SC("IsGraph"), &isgraph)
|
||||
.Func(_SC("IsBlank"), &isblank)
|
||||
.Func(_SC("SToB"), &SToB)
|
||||
.Func(_SC("GetColor"), &GetColor)
|
||||
.Func(_SC("GetCircle"), &GetCircle)
|
||||
.Func(_SC("GetAABB"), &GetAABB)
|
||||
.Func(_SC("GetColor3"), &GetColor3)
|
||||
.Func(_SC("GetColor4"), &GetColor4)
|
||||
.Func(_SC("GetQuaternion"), &GetQuaternion)
|
||||
.Func(_SC("GetSphere"), &GetSphere)
|
||||
.Func(_SC("GetVector2"), &GetVector2)
|
||||
.Func(_SC("GetVector2i"), &GetVector2i)
|
||||
.Func(_SC("GetVector3"), &GetVector3)
|
||||
.Func(_SC("GetVector4"), &GetVector4);
|
||||
.Func(_SC("GetColor"), &GetColor);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
@ -263,9 +263,13 @@ Object BufferToStrObj(const Buffer & b, Uint32 size);
|
||||
*/
|
||||
template < typename T > Object MakeObject(const T & v)
|
||||
{
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(DefaultVM::Get(), v);
|
||||
// Get the object from the stack to obtain a strong reference to it
|
||||
Var< Object > var(DefaultVM::Get(), -1);
|
||||
// Now it's safe to pop the object from the stack
|
||||
sq_pop(DefaultVM::Get(), 1);
|
||||
// Return the resulted script object
|
||||
return var.value;
|
||||
}
|
||||
|
||||
@ -274,9 +278,13 @@ template < typename T > Object MakeObject(const T & v)
|
||||
*/
|
||||
template < typename T > Object MakeObject(HSQUIRRELVM vm, const T & v)
|
||||
{
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(vm, v);
|
||||
// Get the object from the stack to obtain a strong reference to it
|
||||
Var< Object > var(vm, -1);
|
||||
// Now it's safe to pop the object from the stack
|
||||
sq_pop(vm, 1);
|
||||
// Return the resulted script object
|
||||
return var.value;
|
||||
}
|
||||
|
||||
@ -310,61 +318,10 @@ const Color3 & GetRandomColor();
|
||||
*/
|
||||
Color3 GetColor(CSStr name);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the AABB type from a string.
|
||||
*/
|
||||
const AABB & GetAABB(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Circle type from a string.
|
||||
*/
|
||||
const Circle & GetCircle(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color3 type from a string.
|
||||
*/
|
||||
const Color3 & GetColor3(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Color4 type from a string.
|
||||
*/
|
||||
const Color4 & GetColor4(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Quaternion type from a string.
|
||||
*/
|
||||
const Quaternion & GetQuaternion(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Sphere type from a string.
|
||||
*/
|
||||
const Sphere & GetSphere(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2 type from a string.
|
||||
*/
|
||||
const Vector2 & GetVector2(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2i type from a string.
|
||||
*/
|
||||
const Vector2i & GetVector2i(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector3 type from a string.
|
||||
*/
|
||||
const Vector3 & GetVector3(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector4 type from a string.
|
||||
*/
|
||||
const Vector4 & GetVector4(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Forward declarations of the logging functions to avoid including the logger everywhere.
|
||||
* Primary logging functions.
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void LogDbg(CCStr fmt, ...);
|
||||
void LogUsr(CCStr fmt, ...);
|
||||
void LogScs(CCStr fmt, ...);
|
||||
@ -373,7 +330,10 @@ void LogWrn(CCStr fmt, ...);
|
||||
void LogErr(CCStr fmt, ...);
|
||||
void LogFtl(CCStr fmt, ...);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Forward declarations of the logging functions to avoid including the logger everywhere.
|
||||
* Secondary logging functions.
|
||||
*/
|
||||
void LogSDbg(CCStr fmt, ...);
|
||||
void LogSUsr(CCStr fmt, ...);
|
||||
void LogSScs(CCStr fmt, ...);
|
||||
@ -382,7 +342,10 @@ void LogSWrn(CCStr fmt, ...);
|
||||
void LogSErr(CCStr fmt, ...);
|
||||
void LogSFtl(CCStr fmt, ...);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Forward declarations of the logging functions to avoid including the logger everywhere.
|
||||
* Primary conditional logging functions.
|
||||
*/
|
||||
bool cLogDbg(bool cond, CCStr fmt, ...);
|
||||
bool cLogUsr(bool cond, CCStr fmt, ...);
|
||||
bool cLogScs(bool cond, CCStr fmt, ...);
|
||||
@ -391,7 +354,10 @@ bool cLogWrn(bool cond, CCStr fmt, ...);
|
||||
bool cLogErr(bool cond, CCStr fmt, ...);
|
||||
bool cLogFtl(bool cond, CCStr fmt, ...);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Forward declarations of the logging functions to avoid including the logger everywhere.
|
||||
* Secondary conditional logging functions.
|
||||
*/
|
||||
bool cLogSDbg(bool cond, CCStr fmt, ...);
|
||||
bool cLogSUsr(bool cond, CCStr fmt, ...);
|
||||
bool cLogSScs(bool cond, CCStr fmt, ...);
|
||||
|
@ -382,7 +382,7 @@ void Sphere::Generate()
|
||||
void Sphere::Generate(Value min, Value max, bool r)
|
||||
{
|
||||
if (EpsLt(max, min))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
else if (r)
|
||||
rad = GetRandomFloat32(min, max);
|
||||
else
|
||||
@ -392,7 +392,7 @@ void Sphere::Generate(Value min, Value max, bool r)
|
||||
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
|
||||
}
|
||||
@ -400,7 +400,7 @@ void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin
|
||||
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(rmax, rmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
|
||||
rad = GetRandomFloat32(rmin, rmax);
|
||||
@ -412,6 +412,35 @@ Sphere Sphere::Abs() const
|
||||
return Sphere(pos.Abs(), fabs(rad));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere & GetSphere(CSStr str)
|
||||
{
|
||||
return GetSphere(str, Sphere::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere & GetSphere(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Sphere sphere;
|
||||
// Clear previous values, if any
|
||||
sphere.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return sphere; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, fs, &sphere.pos.x, &sphere.pos.y, &sphere.pos.z, &sphere.rad);
|
||||
// Return the resulted value
|
||||
return sphere;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Sphere(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -502,6 +531,9 @@ void Register_Sphere(HSQUIRRELVM vm)
|
||||
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opGreaterThan"), &Sphere::operator >)
|
||||
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opLessEqual"), &Sphere::operator <=)
|
||||
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opGreaterEqual"), &Sphere::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Sphere & (*)(CSStr) >(_SC("FromStr"), &GetSphere)
|
||||
.StaticOverload< const Sphere & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetSphere)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Sphere type from a string.
|
||||
*/
|
||||
const Sphere & GetSphere(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Sphere type from a string.
|
||||
*/
|
||||
const Sphere & GetSphere(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a three-dimensional sphere.
|
||||
*/
|
||||
|
@ -322,7 +322,7 @@ void Vector2::Generate()
|
||||
void Vector2::Generate(Value min, Value max)
|
||||
{
|
||||
if (EpsLt(max, min))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(min, max);
|
||||
y = GetRandomFloat32(min, max);
|
||||
@ -331,7 +331,7 @@ void Vector2::Generate(Value min, Value max)
|
||||
void Vector2::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(ymin, ymax);
|
||||
y = GetRandomFloat32(xmin, xmax);
|
||||
@ -343,6 +343,33 @@ Vector2 Vector2::Abs() const
|
||||
return Vector2(fabs(x), fabs(y));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2 & GetVector2(CSStr str)
|
||||
{
|
||||
return GetVector2(str, Vector2::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2 & GetVector2(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f ");
|
||||
static Vector2 vec;
|
||||
// Clear previous values, if any
|
||||
vec.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '0')
|
||||
{
|
||||
return vec; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, fs, &vec.x, &vec.y);
|
||||
// Return the resulted value
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Vector2(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -422,6 +449,9 @@ void Register_Vector2(HSQUIRRELVM vm)
|
||||
.Func<bool (Vector2::*)(const Vector2 &) const>(_SC("opGreaterThan"), &Vector2::operator >)
|
||||
.Func<bool (Vector2::*)(const Vector2 &) const>(_SC("opLessEqual"), &Vector2::operator <=)
|
||||
.Func<bool (Vector2::*)(const Vector2 &) const>(_SC("opGreaterEqual"), &Vector2::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Vector2 & (*)(CSStr) >(_SC("FromStr"), &GetVector2)
|
||||
.StaticOverload< const Vector2 & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetVector2)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2 type from a string.
|
||||
*/
|
||||
const Vector2 & GetVector2(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2 type from a string.
|
||||
*/
|
||||
const Vector2 & GetVector2(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a two-dimensional vector.
|
||||
*/
|
||||
|
@ -448,7 +448,7 @@ void Vector2i::Generate()
|
||||
void Vector2i::Generate(Value min, Value max)
|
||||
{
|
||||
if (max < min)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomInt32(min, max);
|
||||
y = GetRandomInt32(min, max);
|
||||
@ -457,7 +457,7 @@ void Vector2i::Generate(Value min, Value max)
|
||||
void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
||||
{
|
||||
if (xmax < xmin || ymax < ymin)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomInt32(ymin, ymax);
|
||||
y = GetRandomInt32(xmin, xmax);
|
||||
@ -469,6 +469,33 @@ Vector2i Vector2i::Abs() const
|
||||
return Vector2i(abs(x), abs(y));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2i & GetVector2i(CSStr str)
|
||||
{
|
||||
return GetVector2i(str, Vector2i::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2i & GetVector2i(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %d , %d ");
|
||||
static Vector2i vec;
|
||||
// Clear previous values, if any
|
||||
vec.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return vec; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y);
|
||||
// Return the resulted value
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Vector2i(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -569,6 +596,9 @@ void Register_Vector2i(HSQUIRRELVM vm)
|
||||
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterThan"), &Vector2i::operator >)
|
||||
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opLessEqual"), &Vector2i::operator <=)
|
||||
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterEqual"), &Vector2i::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Vector2i & (*)(CSStr) >(_SC("FromStr"), &GetVector2i)
|
||||
.StaticOverload< const Vector2i & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetVector2i)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2i type from a string.
|
||||
*/
|
||||
const Vector2i & GetVector2i(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector2i type from a string.
|
||||
*/
|
||||
const Vector2i & GetVector2i(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a two-dimensional vector using integral values.
|
||||
*/
|
||||
|
@ -353,7 +353,7 @@ void Vector3::Generate()
|
||||
void Vector3::Generate(Value min, Value max)
|
||||
{
|
||||
if (EpsLt(max, min))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(min, max);
|
||||
y = GetRandomFloat32(min, max);
|
||||
@ -363,7 +363,7 @@ void Vector3::Generate(Value min, Value max)
|
||||
void Vector3::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(xmin, xmax);
|
||||
y = GetRandomFloat32(ymin, ymax);
|
||||
@ -376,6 +376,34 @@ Vector3 Vector3::Abs() const
|
||||
return Vector3(fabs(x), fabs(y), fabs(z));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector3 & GetVector3(CSStr str)
|
||||
{
|
||||
return GetVector3(str, Vector3::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector3 & GetVector3(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f ");
|
||||
static Vector3 vec;
|
||||
// Clear previous values, if any
|
||||
vec.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return vec; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y, &vec.z);
|
||||
// Return the resulted value
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Vector3(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -457,6 +485,9 @@ void Register_Vector3(HSQUIRRELVM vm)
|
||||
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opGreaterThan"), &Vector3::operator >)
|
||||
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opLessEqual"), &Vector3::operator <=)
|
||||
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opGreaterEqual"), &Vector3::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Vector3 & (*)(CSStr) >(_SC("FromStr"), &GetVector3)
|
||||
.StaticOverload< const Vector3 & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetVector3)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector3 type from a string.
|
||||
*/
|
||||
const Vector3 & GetVector3(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector3 type from a string.
|
||||
*/
|
||||
const Vector3 & GetVector3(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a three-dimensional vector.
|
||||
*/
|
||||
|
@ -390,7 +390,7 @@ void Vector4::Generate()
|
||||
void Vector4::Generate(Value min, Value max)
|
||||
{
|
||||
if (max < min)
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(min, max);
|
||||
y = GetRandomFloat32(min, max);
|
||||
@ -401,7 +401,7 @@ void Vector4::Generate(Value min, Value max)
|
||||
void Vector4::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax)
|
||||
{
|
||||
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin))
|
||||
SqThrowF("max value is lower than min value");
|
||||
STHROWF("max value is lower than min value");
|
||||
|
||||
x = GetRandomFloat32(xmin, xmax);
|
||||
y = GetRandomFloat32(ymin, ymax);
|
||||
@ -415,6 +415,35 @@ Vector4 Vector4::Abs() const
|
||||
return Vector4(fabs(x), fabs(y), fabs(z), fabs(w));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector4 & GetVector4(CSStr str)
|
||||
{
|
||||
return GetVector4(str, Vector4::Delim);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector4 & GetVector4(CSStr str, SQChar delim)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
static Vector4 vec;
|
||||
// Clear previous values, if any
|
||||
vec.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
{
|
||||
return vec; // Return the value as is!
|
||||
}
|
||||
// Assign the specified delimiter
|
||||
fs[4] = delim;
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
sscanf(str, &fs[0], &vec.x, &vec.y, &vec.z, &vec.w);
|
||||
// Return the resulted value
|
||||
return vec;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Vector4(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -499,6 +528,9 @@ void Register_Vector4(HSQUIRRELVM vm)
|
||||
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opGreaterThan"), &Vector4::operator >)
|
||||
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opLessEqual"), &Vector4::operator <=)
|
||||
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opGreaterEqual"), &Vector4::operator >=)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Vector4 & (*)(CSStr) >(_SC("FromStr"), &GetVector4)
|
||||
.StaticOverload< const Vector4 & (*)(CSStr, SQChar) >(_SC("FromStr"), &GetVector4)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector4 type from a string.
|
||||
*/
|
||||
const Vector4 & GetVector4(CSStr str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Vector4 type from a string.
|
||||
*/
|
||||
const Vector4 & GetVector4(CSStr str, SQChar delim);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Class used to represent a four-dimensional vector.
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ static void ValidateName(CSStr name)
|
||||
// Is the name empty?
|
||||
if (!name || *name == '\0')
|
||||
{
|
||||
SqThrowF("Invalid or empty command name");
|
||||
STHROWF("Invalid or empty command name");
|
||||
}
|
||||
// Inspect name characters
|
||||
while (*name != '\0')
|
||||
@ -38,7 +38,7 @@ static void ValidateName(CSStr name)
|
||||
// Does it contain spaces?
|
||||
if (isspace(*name) != 0)
|
||||
{
|
||||
SqThrowF("Command names cannot contain spaces");
|
||||
STHROWF("Command names cannot contain spaces");
|
||||
}
|
||||
// Move to the next character
|
||||
++name;
|
||||
@ -112,7 +112,7 @@ Object & CmdManager::Attach(const String & name, CmdListener * ptr, bool autorel
|
||||
}
|
||||
// Now it's safe to throw the exception
|
||||
// (include information necessary to help identify hash collisions!)
|
||||
SqThrowF("Command (%s:%zu) already exists as (%s:%zu)",
|
||||
STHROWF("Command (%s:%zu) already exists as (%s:%zu)",
|
||||
name.c_str(), hash, cmd.mName.c_str(), cmd.mHash);
|
||||
}
|
||||
}
|
||||
@ -915,12 +915,12 @@ void CmdListener::Attach()
|
||||
// Is the associated name even valid?
|
||||
if (m_Name.empty())
|
||||
{
|
||||
SqThrowF("Invalid or empty command name");
|
||||
STHROWF("Invalid or empty command name");
|
||||
}
|
||||
// Are we already attached?
|
||||
else if (_Cmd->Attached(this))
|
||||
{
|
||||
SqThrowF("Command is already attached");
|
||||
STHROWF("Command is already attached");
|
||||
}
|
||||
// Attempt to attach this command
|
||||
_Cmd->Attach(m_Name, this, false);
|
||||
@ -1019,7 +1019,7 @@ void CmdListener::SetArgTags(Array & tags)
|
||||
}
|
||||
else
|
||||
{
|
||||
SqThrowF("Argument tag (%u) is out of range (%u)", max, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument tag (%u) is out of range (%u)", max, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1113,11 +1113,11 @@ void CmdListener::SetMinArgC(Uint8 val)
|
||||
// Perform a range check on the specified argument index
|
||||
if (val >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Argument (%u) is out of total range (%u)", val, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument (%u) is out of total range (%u)", val, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
else if (val > m_MaxArgc)
|
||||
{
|
||||
SqThrowF("Minimum argument (%u) exceeds maximum (%u)", val, m_MaxArgc);
|
||||
STHROWF("Minimum argument (%u) exceeds maximum (%u)", val, m_MaxArgc);
|
||||
}
|
||||
// Apply the specified value
|
||||
m_MinArgc = val;
|
||||
@ -1135,11 +1135,11 @@ void CmdListener::SetMaxArgC(Uint8 val)
|
||||
// Perform a range check on the specified argument index
|
||||
if (val >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Argument (%u) is out of total range (%u)", val, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument (%u) is out of total range (%u)", val, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
else if (val < m_MinArgc)
|
||||
{
|
||||
SqThrowF("Minimum argument (%u) exceeds maximum (%u)", m_MinArgc, val);
|
||||
STHROWF("Minimum argument (%u) exceeds maximum (%u)", m_MinArgc, val);
|
||||
}
|
||||
// Apply the specified value
|
||||
m_MaxArgc = val;
|
||||
@ -1157,7 +1157,7 @@ void CmdListener::SetOnExec(Object & env, Function & func)
|
||||
// Make sure that we are allowed to store script resources
|
||||
if (m_Name.empty())
|
||||
{
|
||||
SqThrowF("Invalid commands cannot store script resources");
|
||||
STHROWF("Invalid commands cannot store script resources");
|
||||
}
|
||||
// Apply the specified information
|
||||
m_OnExec = Function(env.GetVM(), env.GetObject(), func.GetFunc());
|
||||
@ -1175,7 +1175,7 @@ void CmdListener::SetOnAuth(Object & env, Function & func)
|
||||
// Make sure that we are allowed to store script resources
|
||||
if (m_Name.empty())
|
||||
{
|
||||
SqThrowF("Invalid commands cannot store script resources");
|
||||
STHROWF("Invalid commands cannot store script resources");
|
||||
}
|
||||
// Apply the specified information
|
||||
m_OnAuth = Function(env.GetVM(), env.GetObject(), func.GetFunc());
|
||||
@ -1193,7 +1193,7 @@ void CmdListener::SetOnPost(Object & env, Function & func)
|
||||
// Make sure that we are allowed to store script resources
|
||||
if (m_Name.empty())
|
||||
{
|
||||
SqThrowF("Invalid commands cannot store script resources");
|
||||
STHROWF("Invalid commands cannot store script resources");
|
||||
}
|
||||
// Apply the specified information
|
||||
m_OnPost = Function(env.GetVM(), env.GetObject(), func.GetFunc());
|
||||
@ -1211,7 +1211,7 @@ void CmdListener::SetOnFail(Object & env, Function & func)
|
||||
// Make sure that we are allowed to store script resources
|
||||
if (m_Name.empty())
|
||||
{
|
||||
SqThrowF("Invalid commands cannot store script resources");
|
||||
STHROWF("Invalid commands cannot store script resources");
|
||||
}
|
||||
// Apply the specified information
|
||||
m_OnFail = Function(env.GetVM(), env.GetObject(), func.GetFunc());
|
||||
@ -1223,7 +1223,7 @@ CSStr CmdListener::GetArgTag(Uint32 arg) const
|
||||
// Perform a range check on the specified argument index
|
||||
if (arg >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
// Return the requested information
|
||||
return m_ArgTags[arg].c_str();
|
||||
@ -1235,7 +1235,7 @@ void CmdListener::SetArgTag(Uint32 arg, CSStr name)
|
||||
// Perform a range check on the specified argument index
|
||||
if (arg >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
// The string type doesn't appreciate null values
|
||||
else if (name)
|
||||
@ -1368,7 +1368,7 @@ bool CmdListener::ArgCheck(Uint32 arg, Uint8 flag) const
|
||||
// Perform a range check on the specified argument index
|
||||
if (arg >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Argument (%u) is out of total range (%u)", arg, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
// Retrieve the argument flags
|
||||
const Uint8 f = m_ArgSpec[arg];
|
||||
@ -1460,7 +1460,7 @@ void CmdListener::ProcSpec(CSStr str)
|
||||
{
|
||||
if (idx >= SQMOD_MAX_CMD_ARGS)
|
||||
{
|
||||
SqThrowF("Extraneous type specifiers: %d >= %d", idx, SQMOD_MAX_CMD_ARGS);
|
||||
STHROWF("Extraneous type specifiers: %d >= %d", idx, SQMOD_MAX_CMD_ARGS);
|
||||
}
|
||||
// Move to the next character
|
||||
++str;
|
||||
@ -1549,7 +1549,7 @@ void CmdListener::ProcSpec(CSStr str)
|
||||
}
|
||||
} break;
|
||||
// Unknown type!
|
||||
default: SqThrowF("Unknown type specifier (%c) at argument: %u", *str, idx);
|
||||
default: STHROWF("Unknown type specifier (%c) at argument: %u", *str, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ static const Object & Blip_FindByID(Int32 id)
|
||||
{
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
|
||||
SqThrowF("The specified blip identifier is invalid: %d", id);
|
||||
STHROWF("The specified blip identifier is invalid: %d", id);
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
|
||||
Core::Blips::const_iterator end = _Core->GetBlips().cend();
|
||||
@ -302,7 +302,7 @@ static const Object & Blip_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified blip tag is invalid: null/empty");
|
||||
STHROWF("The specified blip tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
|
||||
@ -326,7 +326,7 @@ static const Object & Blip_FindBySprID(Int32 sprid)
|
||||
// Perform a range check on the specified identifier
|
||||
if (sprid < 0)
|
||||
{
|
||||
SqThrowF("The specified sprite identifier is invalid: %d", sprid);
|
||||
STHROWF("The specified sprite identifier is invalid: %d", sprid);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid blip reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid blip reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ bool CCheckpoint::IsStreamedFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -455,7 +455,7 @@ static const Object & Checkpoint_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
|
||||
{
|
||||
SqThrowF("The specified checkpoint identifier is invalid: %d", id);
|
||||
STHROWF("The specified checkpoint identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
|
||||
@ -478,7 +478,7 @@ static const Object & Checkpoint_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified checkpoint tag is invalid: null/empty");
|
||||
STHROWF("The specified checkpoint tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid checkpoint reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid checkpoint reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ bool CForcefield::IsStreamedFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -429,7 +429,7 @@ static const Object & Forcefield_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_FORCEFIELD_POOL))
|
||||
{
|
||||
SqThrowF("The specified forcefield identifier is invalid: %d", id);
|
||||
STHROWF("The specified forcefield identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
|
||||
@ -452,7 +452,7 @@ static const Object & Forcefield_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified forcefield tag is invalid: null/empty");
|
||||
STHROWF("The specified forcefield tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid forcefield reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid forcefield reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ static const Object & Keybind_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
|
||||
{
|
||||
SqThrowF("The specified keybind identifier is invalid: %d", id);
|
||||
STHROWF("The specified keybind identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
|
||||
@ -197,7 +197,7 @@ static const Object & Keybind_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified keybind tag is invalid: null/empty");
|
||||
STHROWF("The specified keybind tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid keybind reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid keybind reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ bool CObject::IsStreamedFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -576,7 +576,7 @@ static const Object & Object_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
|
||||
{
|
||||
SqThrowF("The specified object identifier is invalid: %d", id);
|
||||
STHROWF("The specified object identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
|
||||
@ -598,7 +598,7 @@ static const Object & Object_FindByTag(CSStr tag)
|
||||
{
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
SqThrowF("The specified object tag is invalid: null/empty");
|
||||
STHROWF("The specified object tag is invalid: null/empty");
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
|
||||
Core::Objects::const_iterator end = _Core->GetObjects().cend();
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid object reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid object reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ bool CPickup::IsStreamedFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -362,7 +362,7 @@ static const Object & Pickup_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
|
||||
{
|
||||
SqThrowF("The specified pickup identifier is invalid: %d", id);
|
||||
STHROWF("The specified pickup identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
|
||||
@ -385,7 +385,7 @@ static const Object & Pickup_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '0')
|
||||
{
|
||||
SqThrowF("The specified pickup tag is invalid: null/empty");
|
||||
STHROWF("The specified pickup tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid pickup reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid pickup reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ bool CPlayer::IsStreamedFor(CPlayer & player) const
|
||||
{
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Return the requested information
|
||||
@ -997,7 +997,7 @@ void CPlayer::SetSpectator(CPlayer & target) const
|
||||
// Is the specified player even valid?
|
||||
if (!target.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1082,7 +1082,7 @@ void CPlayer::Embark(CVehicle & vehicle) const
|
||||
// Is the specified vehicle even valid?
|
||||
if (!vehicle.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid vehicle argument: null");
|
||||
STHROWF("Invalid vehicle argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1096,7 +1096,7 @@ void CPlayer::Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) c
|
||||
// Is the specified vehicle even valid?
|
||||
if (!vehicle.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid vehicle argument: null");
|
||||
STHROWF("Invalid vehicle argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1146,7 +1146,7 @@ CSStr CPlayer::GetMessagePrefix(Uint32 index) const
|
||||
// Perform a range check on the specified prefix index
|
||||
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
||||
{
|
||||
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
|
||||
STHROWF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1160,7 +1160,7 @@ void CPlayer::SetMessagePrefix(Uint32 index, CSStr prefix) const
|
||||
// Perform a range check on the specified prefix index
|
||||
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
||||
{
|
||||
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
|
||||
STHROWF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1704,7 +1704,7 @@ static const Object & Player_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
||||
{
|
||||
SqThrowF("The specified player identifier is invalid: %d", id);
|
||||
STHROWF("The specified player identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
|
||||
@ -1727,7 +1727,7 @@ static const Object & Player_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified player tag is invalid: null/empty");
|
||||
STHROWF("The specified player tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid player reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid player reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ void CSprite::ShowFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -137,7 +137,7 @@ void CSprite::ShowRange(Int32 first, Int32 last) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -168,7 +168,7 @@ void CSprite::HideFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -182,7 +182,7 @@ void CSprite::HideRange(Int32 first, Int32 last) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -222,7 +222,7 @@ void CSprite::SetPositionFor(CPlayer & player, const Vector2i & pos) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -236,7 +236,7 @@ void CSprite::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -250,7 +250,7 @@ void CSprite::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) co
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -290,7 +290,7 @@ void CSprite::SetCenterFor(CPlayer & player, const Vector2i & pos) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -304,7 +304,7 @@ void CSprite::SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -318,7 +318,7 @@ void CSprite::SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) cons
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -349,7 +349,7 @@ void CSprite::SetRotationFor(CPlayer & player, Float32 rot) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -363,7 +363,7 @@ void CSprite::SetRotationRange(Int32 first, Int32 last, Float32 rot) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -394,7 +394,7 @@ void CSprite::SetAlphaFor(CPlayer & player, Uint8 alpha) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -408,7 +408,7 @@ void CSprite::SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -499,7 +499,7 @@ static const Object & Sprite_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_SPRITE_POOL))
|
||||
{
|
||||
SqThrowF("The specified sprite identifier is invalid: %d", id);
|
||||
STHROWF("The specified sprite identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
|
||||
@ -522,7 +522,7 @@ static const Object & Sprite_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified sprite tag is invalid: null/empty");
|
||||
STHROWF("The specified sprite tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid sprite reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid sprite reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ void CTextdraw::ShowFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -136,7 +136,7 @@ void CTextdraw::ShowRange(Int32 first, Int32 last) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -167,7 +167,7 @@ void CTextdraw::HideFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -181,7 +181,7 @@ void CTextdraw::HideRange(Int32 first, Int32 last) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -221,7 +221,7 @@ void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -235,7 +235,7 @@ void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -249,7 +249,7 @@ void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos)
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -289,7 +289,7 @@ void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -303,7 +303,7 @@ void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -317,7 +317,7 @@ void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
|
||||
// Validate the specified range
|
||||
if (first > last)
|
||||
{
|
||||
SqThrowF("Invalid player range: %d > %d", first, last);
|
||||
STHROWF("Invalid player range: %d > %d", first, last);
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -412,7 +412,7 @@ static const Object & Textdraw_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
|
||||
{
|
||||
SqThrowF("The specified textdraw identifier is invalid: %d", id);
|
||||
STHROWF("The specified textdraw identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
|
||||
@ -435,7 +435,7 @@ static const Object & Textdraw_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified textdraw tag is invalid: null/empty");
|
||||
STHROWF("The specified textdraw tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid textdraw reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid textdraw reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ bool CVehicle::IsStreamedFor(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -936,7 +936,7 @@ void CVehicle::Embark(CPlayer & player) const
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -950,7 +950,7 @@ void CVehicle::Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) co
|
||||
// Is the specified player even valid?
|
||||
if (!player.IsActive())
|
||||
{
|
||||
SqThrowF("Invalid player argument: null");
|
||||
STHROWF("Invalid player argument: null");
|
||||
}
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
@ -1235,7 +1235,7 @@ static const Object & Vehicle_FindByID(Int32 id)
|
||||
// Perform a range check on the specified identifier
|
||||
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
|
||||
{
|
||||
SqThrowF("The specified vehicle identifier is invalid: %d", id);
|
||||
STHROWF("The specified vehicle identifier is invalid: %d", id);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
|
||||
@ -1258,7 +1258,7 @@ static const Object & Vehicle_FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified vehicle tag is invalid: null/empty");
|
||||
STHROWF("The specified vehicle tag is invalid: null/empty");
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
{
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
{
|
||||
SqThrowF("Invalid vehicle reference [%s]", m_Tag.c_str());
|
||||
STHROWF("Invalid vehicle reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ void AES256::Init(CSStr key)
|
||||
const Uint32 size = (strlen(key) * sizeof(SQChar));
|
||||
// See if the key size is accepted
|
||||
if (size > sizeof(m_Buffer))
|
||||
SqThrowF("The specified key is out of bounds: %u > %u", size, sizeof(m_Buffer));
|
||||
STHROWF("The specified key is out of bounds: %u > %u", size, sizeof(m_Buffer));
|
||||
// Initialize the key buffer to 0
|
||||
memset(m_Buffer, 0, sizeof(m_Buffer));
|
||||
// Copy the key into the key buffer
|
||||
|
@ -25,7 +25,7 @@ CSStr LeftStr(CSStr t, SQChar f, Uint32 w)
|
||||
if (!w)
|
||||
return _SC("");
|
||||
// Allocate a buffer with the requested width
|
||||
Buffer b(w);
|
||||
Buffer b(w + 1); // + null terminator
|
||||
// Is the specified string valid?
|
||||
if (!t || *t == 0)
|
||||
// Insert only the fill character
|
||||
@ -52,9 +52,9 @@ CSStr LeftStr(CSStr t, SQChar f, Uint32 w, Uint32 o)
|
||||
return _SC("");
|
||||
// Is the specified offset within width range?
|
||||
else if (o > w)
|
||||
SqThrowF("Offset is out of bounds");
|
||||
STHROWF("Offset is out of bounds");
|
||||
// Allocate a buffer with the requested width
|
||||
Buffer b(w);
|
||||
Buffer b(w + 1); // + null terminator
|
||||
// Is the specified string valid?
|
||||
if (!t || *t == 0)
|
||||
// Insert only the fill character
|
||||
@ -81,7 +81,7 @@ CSStr RightStr(CSStr t, SQChar f, Uint32 w)
|
||||
if (!w)
|
||||
return _SC("");
|
||||
// Allocate a buffer with the requested width
|
||||
Buffer b(w);
|
||||
Buffer b(w + 1); // + null terminator
|
||||
// Is the specified string valid?
|
||||
if (!t || *t == 0)
|
||||
// Insert only the fill character
|
||||
@ -111,9 +111,9 @@ CSStr RightStr(CSStr t, SQChar f, Uint32 w, Uint32 o)
|
||||
return _SC("");
|
||||
// Is the specified offset within width range?
|
||||
else if (o > w)
|
||||
SqThrowF("Offset is out of bounds");
|
||||
STHROWF("Offset is out of bounds");
|
||||
// Allocate a buffer with the requested width
|
||||
Buffer b(w);
|
||||
Buffer b(w + 1); // + null terminator
|
||||
// Is the specified string valid?
|
||||
if (!t || *t == 0)
|
||||
// Insert only the fill character
|
||||
@ -143,7 +143,7 @@ CSStr CenterStr(CSStr t, SQChar f, Uint32 w)
|
||||
if (!w)
|
||||
return _SC("");
|
||||
// Allocate a buffer with the requested width
|
||||
Buffer b(w);
|
||||
Buffer b(w + 1); // + null terminator
|
||||
// Is the specified string valid?
|
||||
if (!t || *t == 0)
|
||||
// Insert only the fill character
|
||||
@ -172,13 +172,13 @@ CSStr StrJustAlphaNum(CSStr str)
|
||||
// Calculate the string length
|
||||
Uint32 size = strlen(str);
|
||||
// Obtain a temporary buffer
|
||||
Buffer b(size);
|
||||
Buffer b(size + 1); // + null terminator
|
||||
// Resulted string size
|
||||
Uint32 n = 0;
|
||||
// Currently processed character
|
||||
SQChar c = 0;
|
||||
// Process characters
|
||||
while ((c = *(str++)) != 0)
|
||||
while ((c = *(str++)) != '\0')
|
||||
{
|
||||
// Is this an alpha-numeric character?
|
||||
if (isalnum(c) != 0)
|
||||
@ -200,13 +200,13 @@ CSStr StrToLowercase(CSStr str)
|
||||
// Calculate the string length
|
||||
Uint32 size = strlen(str);
|
||||
// Obtain a temporary buffer
|
||||
Buffer b(size);
|
||||
Buffer b(size + 1); // + null terminator
|
||||
// Resulted string size
|
||||
Uint32 n = 0;
|
||||
// Currently processed character
|
||||
SQChar c = 0;
|
||||
// Process characters
|
||||
while ((c = *(str++)) != 0)
|
||||
while ((c = *(str++)) != '\0')
|
||||
// Convert it and move to the next one
|
||||
b.At(n++) = tolower(c);
|
||||
// End the resulted string
|
||||
@ -222,9 +222,9 @@ CSStr StrToUppercase(CSStr str)
|
||||
if(!str || *str == 0)
|
||||
return _SC("");
|
||||
// Calculate the string length
|
||||
Uint32 size = strlen(str);
|
||||
Uint32 size = strlen(str); // + null terminator
|
||||
// Obtain a temporary buffer
|
||||
Buffer b(size);
|
||||
Buffer b(size + 1); // + null terminator
|
||||
// Resulted string size
|
||||
Uint32 n = 0;
|
||||
// Currently processed character
|
||||
|
@ -360,7 +360,7 @@ SysPath & SysPath::Assign(CSStr path, Style style)
|
||||
ParseDynamic(path, path + strlen(path));
|
||||
break;
|
||||
default:
|
||||
SqThrowF("Unknown system path style");
|
||||
STHROWF("Unknown system path style");
|
||||
}
|
||||
}
|
||||
// Allow chaining
|
||||
@ -394,7 +394,7 @@ SysPath & SysPath::Assign(const Buffer & path, Int32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
SqThrowF("The specified path size is out of range: %u >= %u", size, path.Capacity());
|
||||
STHROWF("The specified path size is out of range: %u >= %u", size, path.Capacity());
|
||||
}
|
||||
// Allow chaining
|
||||
return *this;
|
||||
@ -434,7 +434,7 @@ SysPath & SysPath::Assign(const Buffer & path, Style style, Int32 size)
|
||||
ParseDynamic(path.Data(), &path.Cursor());
|
||||
break;
|
||||
default:
|
||||
SqThrowF("Unknown system path style");
|
||||
STHROWF("Unknown system path style");
|
||||
}
|
||||
}
|
||||
else if (static_cast< Uint32 >(size) < path.Capacity())
|
||||
@ -462,12 +462,12 @@ SysPath & SysPath::Assign(const Buffer & path, Style style, Int32 size)
|
||||
ParseDynamic(path.Data(), path.Data() + size);
|
||||
break;
|
||||
default:
|
||||
SqThrowF("Unknown system path style");
|
||||
STHROWF("Unknown system path style");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SqThrowF("The specified path size is out of range: %u >= %u", size, path.Capacity());
|
||||
STHROWF("The specified path size is out of range: %u >= %u", size, path.Capacity());
|
||||
}
|
||||
// Allow chaining
|
||||
return *this;
|
||||
@ -528,7 +528,7 @@ SysPath & SysPath::Assign(const String & path, Style style)
|
||||
ParseDynamic(path.data(), path.data() + path.size());
|
||||
break;
|
||||
default:
|
||||
SqThrowF("Unknown system path style");
|
||||
STHROWF("Unknown system path style");
|
||||
}
|
||||
}
|
||||
// Allow chaining
|
||||
|
@ -741,7 +741,7 @@ Object & FindPlayer(Object & by)
|
||||
_Core->GetPlayer(id).mObj;
|
||||
} break;
|
||||
default:
|
||||
SqThrowF("Unsupported search identifier");
|
||||
STHROWF("Unsupported search identifier");
|
||||
}
|
||||
return NullObject();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ Object Routine::Associate(Routine * routine)
|
||||
if (itr == s_Objects.end())
|
||||
{
|
||||
// NOTE: Routine instance is destroyed by the script object if necessary!
|
||||
SqThrowF("Unable to remember routine instance");
|
||||
STHROWF("Unable to remember routine instance");
|
||||
}
|
||||
}
|
||||
// Does this routine still keep a strong reference to it self?
|
||||
@ -438,7 +438,7 @@ void Routine::Terminate()
|
||||
// Was the routine already terminated?
|
||||
if (m_Terminated)
|
||||
{
|
||||
SqThrowF("Routine was already terminated");
|
||||
STHROWF("Routine was already terminated");
|
||||
}
|
||||
// Detach from the associated bucket
|
||||
Detach();
|
||||
@ -468,7 +468,7 @@ Routine & Routine::SetArg(Uint8 num, Object & val)
|
||||
case 12: m_Arg12 = val; break;
|
||||
case 13: m_Arg13 = val; break;
|
||||
case 14: m_Arg14 = val; break;
|
||||
default: SqThrowF("Argument is out of range: %d", num);
|
||||
default: STHROWF("Argument is out of range: %d", num);
|
||||
}
|
||||
// Allow chaining
|
||||
return *this;
|
||||
@ -496,7 +496,7 @@ Object & Routine::GetArg(Uint8 num)
|
||||
case 12: return m_Arg12;
|
||||
case 13: return m_Arg13;
|
||||
case 14: return m_Arg14;
|
||||
default: SqThrowF("Argument is out of range: %d", num);
|
||||
default: STHROWF("Argument is out of range: %d", num);
|
||||
}
|
||||
// Shouldn't really reach this point
|
||||
return NullObject();
|
||||
@ -516,7 +516,7 @@ void Routine::SetInterval(Interval interval)
|
||||
// Is the specified interval valid?
|
||||
if (!interval)
|
||||
{
|
||||
SqThrowF("Invalid routine interval");
|
||||
STHROWF("Invalid routine interval");
|
||||
}
|
||||
// Detach from the current bucket
|
||||
Detach();
|
||||
@ -554,7 +554,7 @@ void Routine::SetArguments(Uint8 num)
|
||||
// Is the specified argument count valid?
|
||||
if (num > 14)
|
||||
{
|
||||
SqThrowF("Argument is out of range: %d", num);
|
||||
STHROWF("Argument is out of range: %d", num);
|
||||
}
|
||||
// Perform the requested operation
|
||||
m_Arguments = num;
|
||||
@ -634,12 +634,12 @@ void Routine::Create()
|
||||
// Do we even have a valid interval?
|
||||
if (!m_Interval)
|
||||
{
|
||||
SqThrowF("Invalid routine interval");
|
||||
STHROWF("Invalid routine interval");
|
||||
}
|
||||
// Is the specified callback even valid?
|
||||
else if (m_Callback.IsNull())
|
||||
{
|
||||
SqThrowF("Invalid routine callback");
|
||||
STHROWF("Invalid routine callback");
|
||||
}
|
||||
// Always use the command queue to attach the routine when created
|
||||
s_Queue.emplace_back(this, m_Interval, CMD_ATTACH);
|
||||
@ -704,7 +704,7 @@ void Routine::Execute()
|
||||
// Make sure that we have a known number of arguments
|
||||
else if (m_Arguments > 14)
|
||||
{
|
||||
SqThrowF("Routine [%s] => Out of range argument count [%d]", m_Tag.c_str(), m_Arguments);
|
||||
STHROWF("Routine [%s] => Out of range argument count [%d]", m_Tag.c_str(), m_Arguments);
|
||||
}
|
||||
// Attempt to forward the call
|
||||
try
|
||||
@ -854,7 +854,7 @@ void Routine::Flush()
|
||||
// Make sure the buckets are not locked
|
||||
if (s_Lock)
|
||||
{
|
||||
SqThrowF("Buckets are under active lock");
|
||||
STHROWF("Buckets are under active lock");
|
||||
}
|
||||
// Process commands in queue
|
||||
ProcQueue();
|
||||
@ -928,7 +928,7 @@ Object Routine::FindByTag(CSStr tag)
|
||||
// Perform a validity check on the specified tag
|
||||
if (!tag || *tag == '\0')
|
||||
{
|
||||
SqThrowF("The specified routine tag is invalid: null/empty");
|
||||
STHROWF("The specified routine tag is invalid: null/empty");
|
||||
}
|
||||
// Process each routine in the pool
|
||||
for (const auto & elem : s_Objects)
|
||||
|
@ -231,7 +231,7 @@ protected:
|
||||
{
|
||||
if (m_Terminated)
|
||||
{
|
||||
SqThrowF("Routine was terminated [%s]", m_Tag.c_str());
|
||||
STHROWF("Routine was terminated [%s]", m_Tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,6 +502,31 @@ enum CmdError
|
||||
#define SQMOD_FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* LOGGING LOCATION
|
||||
*/
|
||||
|
||||
#define SQMOD_TRUESTRINGIZE(x) #x
|
||||
#define SQMOD_STRINGIZEWRAP(x) SQMOD_TRUESTRINGIZE(x)
|
||||
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
#define SQMOD_MSGLOC(m) (m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ")
|
||||
#else
|
||||
#define SQMOD_MSGLOC(m) (m)
|
||||
#endif // _DEBUG
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* EXCEPTION THROWING
|
||||
*/
|
||||
|
||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||
#define STHROWF(m, ...) SqThrowF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||
#else
|
||||
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
|
||||
#define STHROWF(m, ...) SqThrowF(m, ##__VA_ARGS__)
|
||||
#endif // _DEBUG
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* VARIOUS DEFINES
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user