1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

More code cleanup.

This commit is contained in:
Sandu Liviu Catalin 2020-03-22 09:16:40 +02:00
parent 615f3a4d46
commit 3080c20341
31 changed files with 701 additions and 1148 deletions

View File

@ -19,21 +19,21 @@ const AABB AABB::MAX = AABB(HUGE_VALF, -HUGE_VALF);
SQChar AABB::Delim = ','; SQChar AABB::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB::AABB() AABB::AABB() noexcept
: min(HUGE_VALF), max(-HUGE_VALF) : min(HUGE_VALF), max(-HUGE_VALF)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB::AABB(Value mins, Value maxs) AABB::AABB(Value mins, Value maxs) noexcept
: min(mins), max(maxs) : min(mins), max(maxs)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB::AABB(Value xv, Value yv, Value zv) AABB::AABB(Value xv, Value yv, Value zv) noexcept
: min(xv, yv, zv) : min(xv, yv, zv)
, max(xv, yv, zv) , max(xv, yv, zv)
{ {
@ -41,14 +41,14 @@ AABB::AABB(Value xv, Value yv, Value zv)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB::AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) AABB::AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept
: min(xmin, ymin, zmin), max(xmax, ymax, zmax) : min(xmin, ymin, zmin), max(xmax, ymax, zmax)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB::AABB(const Vector3 & vmin, const Vector3 & vmax) AABB::AABB(const Vector3 & vmin, const Vector3 & vmax) noexcept
: min(vmin), max(vmax) : min(vmin), max(vmax)
{ {
/* ... */ /* ... */
@ -158,7 +158,7 @@ AABB & AABB::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator ++ (int) AABB AABB::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
AABB state(*this); AABB state(*this);
++min; ++min;
@ -167,7 +167,7 @@ AABB AABB::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator -- (int) AABB AABB::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
AABB state(*this); AABB state(*this);
--min; --min;
@ -178,73 +178,73 @@ AABB AABB::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator + (const AABB & b) const AABB AABB::operator + (const AABB & b) const
{ {
return AABB(min + b.min, max + b.max); return {min + b.min, max + b.max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator - (const AABB & b) const AABB AABB::operator - (const AABB & b) const
{ {
return AABB(min - b.min, max - b.max); return AABB{min - b.min, max - b.max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator * (const AABB & b) const AABB AABB::operator * (const AABB & b) const
{ {
return AABB(min * b.min, max * b.max); return AABB{min * b.min, max * b.max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator / (const AABB & b) const AABB AABB::operator / (const AABB & b) const
{ {
return AABB(min / b.min, max / b.max); return AABB{min / b.min, max / b.max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator % (const AABB & b) const AABB AABB::operator % (const AABB & b) const
{ {
return AABB(min % b.min, max % b.max); return AABB{min % b.min, max % b.max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator + (Value s) const AABB AABB::operator + (Value s) const
{ {
return AABB(min + s, max + s); return AABB{min + s, max + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator - (Value s) const AABB AABB::operator - (Value s) const
{ {
return AABB(min - s, max - s); return AABB{min - s, max - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator * (Value s) const AABB AABB::operator * (Value s) const
{ {
return AABB(min * s, max * s); return AABB{min * s, max * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator / (Value s) const AABB AABB::operator / (Value s) const
{ {
return AABB(min / s, max / s); return AABB{min / s, max / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator % (Value s) const AABB AABB::operator % (Value s) const
{ {
return AABB(min % s, max % s); return AABB{min % s, max % s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator + () const AABB AABB::operator + () const
{ {
return AABB(min.Abs(), max.Abs()); return AABB{min.Abs(), max.Abs()};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AABB AABB::operator - () const AABB AABB::operator - () const
{ {
return AABB(-min, -max); return AABB{-min, -max};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -764,56 +764,11 @@ const AABB & AABB::GetEx(SQChar delim, StackStrF & str)
return box; return box;
} }
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB()
{
static AABB box;
box.Clear();
return box;
}
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB(Float32 mins, Float32 maxs)
{
static AABB box;
box.DefineScalar(mins, maxs);
return box;
}
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB(Float32 xv, Float32 yv, Float32 zv)
{
static AABB box;
box.DefineVector3Ex(xv, yv, zv);
return box;
}
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB(Float32 xmin, Float32 ymin, Float32 zmin, Float32 xmax, Float32 ymax, Float32 zmax)
{
static AABB box;
box.DefineAllVector3Ex(xmin, ymin, zmin, xmax, ymax, zmax);
return box;
}
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB(const Vector3 & vmin, const Vector3 & vmax)
{
static AABB box;
box.DefineAllVector3(vmin, vmax);
return box;
}
// ------------------------------------------------------------------------------------------------
const AABB & GetAABB(const AABB & o)
{
static AABB box;
box.DefineAABB(o);
return box;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_AABB(HSQUIRRELVM vm) void Register_AABB(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef AABB::Value Val; typedef AABB::Value Val;

View File

@ -36,40 +36,40 @@ struct AABB
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct with zero size. * Construct with zero size.
*/ */
AABB(); AABB() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a an equally sized and perfectly shaped box from scalar values. * Construct a an equally sized and perfectly shaped box from scalar values.
*/ */
explicit AABB(Value mins, Value maxs); explicit AABB(Value mins, Value maxs) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a an equally sized but imperfectly shaped box from individual components of a * Construct a an equally sized but imperfectly shaped box from individual components of a
* three-dimensional point. * three-dimensional point.
*/ */
AABB(Value xv, Value yv, Value zv); AABB(Value xv, Value yv, Value zv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a an unequally sized and imperfectly shaped box from individual components of two * Construct a an unequally sized and imperfectly shaped box from individual components of two
* three-dimensional points. * three-dimensional points.
*/ */
AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax); AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a an unequally sized and imperfectly shaped box from two three-dimensional * Construct a an unequally sized and imperfectly shaped box from two three-dimensional
* vectors representing two three-dimensional points. * vectors representing two three-dimensional points.
*/ */
AABB(const Vector3 & vmin, const Vector3 & vmax); AABB(const Vector3 & vmin, const Vector3 & vmax) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
AABB(const AABB & o) = default; AABB(const AABB & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
AABB(AABB && o) = default; AABB(AABB && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -154,12 +154,12 @@ struct AABB
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
AABB operator ++ (int); AABB operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
AABB operator -- (int); AABB operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.
@ -269,7 +269,7 @@ struct AABB
*/ */
Int32 Cmp(SQInteger s) const Int32 Cmp(SQInteger s) const
{ {
const Value v = static_cast< Value >(s); const auto v = static_cast< Value >(s);
return Cmp(AABB(v, v, v, v, v, v)); return Cmp(AABB(v, v, v, v, v, v));
} }
@ -278,7 +278,7 @@ struct AABB
*/ */
Int32 Cmp(bool s) const Int32 Cmp(bool s) const
{ {
const Value v = static_cast< Value >(s); const auto v = static_cast< Value >(s);
return Cmp(AABB(v, v, v, v, v, v)); return Cmp(AABB(v, v, v, v, v, v));
} }
@ -287,7 +287,7 @@ struct AABB
*/ */
Int32 Cmp(std::nullptr_t) const Int32 Cmp(std::nullptr_t) const
{ {
const Value v = static_cast< Value >(0); const auto v = static_cast< Value >(0);
return Cmp(AABB(v, v, v, v, v, v)); return Cmp(AABB(v, v, v, v, v, v));
} }

View File

@ -17,11 +17,11 @@ namespace SqMod {
inline unsigned int NextPow2(unsigned int num) inline unsigned int NextPow2(unsigned int num)
{ {
--num; --num;
num |= num >> 1; num |= num >> 1u;
num |= num >> 2; num |= num >> 2u;
num |= num >> 4; num |= num >> 4u;
num |= num >> 8; num |= num >> 8u;
num |= num >> 16; num |= num >> 16u;
return ++num; return ++num;
} }
@ -41,10 +41,10 @@ void ThrowMemExcept(const char * msg, ...)
// Check for formatting errors // Check for formatting errors
if (ret < 0) if (ret < 0)
{ {
throw Sqrat::Exception(_SC("Unknown memory error")); throw Sqrat::Exception(_SC("Unknown memory error")); // NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
} }
// Throw the actual exception // Throw the actual exception
throw Sqrat::Exception(buffer); throw Sqrat::Exception(buffer); // NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -53,7 +53,7 @@ void ThrowMemExcept(const char * msg, ...)
static Buffer::Pointer AllocMem(Buffer::SzType size) static Buffer::Pointer AllocMem(Buffer::SzType size)
{ {
// Attempt to allocate memory directly // Attempt to allocate memory directly
Buffer::Pointer ptr = reinterpret_cast< Buffer::Pointer >(std::malloc(size)); auto ptr = reinterpret_cast< Buffer::Pointer >(std::malloc(size));
// Validate the allocated memory // Validate the allocated memory
if (!ptr) if (!ptr)
{ {
@ -103,7 +103,7 @@ private:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Base constructor. * Base constructor.
*/ */
Node(Node * next) explicit Node(Node * next)
: mCap(0) : mCap(0)
, mPtr(nullptr) , mPtr(nullptr)
, mNext(next) , mNext(next)
@ -403,7 +403,7 @@ Buffer::~Buffer()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Buffer & Buffer::operator = (const Buffer & o) Buffer & Buffer::operator = (const Buffer & o) // NOLINT(cert-oop54-cpp)
{ {
if (m_Ptr != o.m_Ptr) if (m_Ptr != o.m_Ptr)
{ {

View File

@ -52,7 +52,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor (null). * Default constructor (null).
*/ */
MemRef() MemRef() noexcept
: m_Ptr(s_Mem.m_Ptr) : m_Ptr(s_Mem.m_Ptr)
, m_Ref(s_Mem.m_Ref) , m_Ref(s_Mem.m_Ref)
{ {
@ -62,7 +62,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
MemRef(const MemRef & o) MemRef(const MemRef & o) noexcept
: m_Ptr(o.m_Ptr) : m_Ptr(o.m_Ptr)
, m_Ref(o.m_Ref) , m_Ref(o.m_Ref)
@ -73,7 +73,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
MemRef(MemRef && o) MemRef(MemRef && o) noexcept
: m_Ptr(o.m_Ptr), m_Ref(o.m_Ref) : m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
{ {
@ -92,7 +92,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy assignment operator. * Copy assignment operator.
*/ */
MemRef & operator = (const MemRef & o) MemRef & operator = (const MemRef & o) noexcept // NOLINT(bugprone-unhandled-self-assignment,cert-oop54-cpp)
{ {
if (m_Ptr != o.m_Ptr) if (m_Ptr != o.m_Ptr)
{ {
@ -107,7 +107,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move assignment operator. * Move assignment operator.
*/ */
MemRef & operator = (MemRef && o) MemRef & operator = (MemRef && o) noexcept
{ {
if (m_Ptr != o.m_Ptr) if (m_Ptr != o.m_Ptr)
{ {
@ -203,11 +203,11 @@ private:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct and take ownership of the specified buffer. * Construct and take ownership of the specified buffer.
*/ */
Buffer(Pointer & ptr, SzType & cap, SzType & cur, const MemRef & mem) Buffer(Pointer & ptr, SzType & cap, SzType & cur, MemRef mem)
: m_Ptr(ptr) : m_Ptr(ptr)
, m_Cap(cap) , m_Cap(cap)
, m_Cur(cur) , m_Cur(cur)
, m_Mem(mem) , m_Mem(std::move(mem))
{ {
ptr = nullptr; ptr = nullptr;
cap = 0; cap = 0;
@ -239,7 +239,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Explicit size constructor. * Explicit size constructor.
*/ */
Buffer(SzType size) explicit Buffer(SzType size)
: m_Ptr(nullptr) : m_Ptr(nullptr)
, m_Cap(0) , m_Cap(0)
, m_Cur(0) , m_Cur(0)
@ -296,11 +296,11 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Buffer(Buffer && o) Buffer(Buffer && o) noexcept
: m_Ptr(o.m_Ptr) : m_Ptr(o.m_Ptr)
, m_Cap(o.m_Cap) , m_Cap(o.m_Cap)
, m_Cur(o.m_Cur) , m_Cur(o.m_Cur)
, m_Mem(o.m_Mem) , m_Mem(std::forward< MemRef >(o.m_Mem))
{ {
o.m_Ptr = nullptr; o.m_Ptr = nullptr;
} }
@ -318,7 +318,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy assignment operator. * Copy assignment operator.
*/ */
Buffer & operator = (Buffer && o) Buffer & operator = (Buffer && o) noexcept
{ {
if (m_Ptr != o.m_Ptr) if (m_Ptr != o.m_Ptr)
{ {
@ -386,7 +386,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. * Implicit conversion to boolean.
*/ */
operator bool () const explicit operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return (m_Ptr != nullptr); return (m_Ptr != nullptr);
} }

View File

@ -22,28 +22,28 @@ const Circle Circle::MAX = Circle(std::numeric_limits< Circle::Value >::max());
SQChar Circle::Delim = ','; SQChar Circle::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle::Circle() Circle::Circle() noexcept
: pos(0.0, 0.0), rad(0.0) : pos(0.0, 0.0), rad(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle::Circle(Value rv) Circle::Circle(Value rv) noexcept
: pos(0.0, 0.0), rad(rv) : pos(0.0, 0.0), rad(rv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle::Circle(const Vector2 & pv, Value rv) Circle::Circle(const Vector2 & pv, Value rv) noexcept
: pos(pv), rad(rv) : pos(pv), rad(rv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle::Circle(Value xv, Value yv, Value rv) Circle::Circle(Value xv, Value yv, Value rv) noexcept
: pos(xv, yv), rad(rv) : pos(xv, yv), rad(rv)
{ {
/* ... */ /* ... */
@ -191,7 +191,7 @@ Circle & Circle::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator ++ (int) Circle Circle::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Circle state(*this); Circle state(*this);
++pos; ++pos;
@ -200,7 +200,7 @@ Circle Circle::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator -- (int) Circle Circle::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Circle state(*this); Circle state(*this);
--pos; --pos;
@ -211,103 +211,103 @@ Circle Circle::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator + (const Circle & c) const Circle Circle::operator + (const Circle & c) const
{ {
return Circle(pos + c.pos, rad + c.rad); return {pos + c.pos, rad + c.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator - (const Circle & c) const Circle Circle::operator - (const Circle & c) const
{ {
return Circle(pos - c.pos, rad - c.rad); return {pos - c.pos, rad - c.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator * (const Circle & c) const Circle Circle::operator * (const Circle & c) const
{ {
return Circle(pos * c.pos, rad * c.rad); return {pos * c.pos, rad * c.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator / (const Circle & c) const Circle Circle::operator / (const Circle & c) const
{ {
return Circle(pos / c.pos, rad / c.rad); return {pos / c.pos, rad / c.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator % (const Circle & c) const Circle Circle::operator % (const Circle & c) const
{ {
return Circle(pos % c.pos, std::fmod(rad, c.rad)); return {pos % c.pos, std::fmod(rad, c.rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator + (Value r) const Circle Circle::operator + (Value r) const
{ {
return Circle(rad + r); return {rad + r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator - (Value r) const Circle Circle::operator - (Value r) const
{ {
return Circle(rad - r); return {rad - r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator * (Value r) const Circle Circle::operator * (Value r) const
{ {
return Circle(rad * r); return {rad * r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator / (Value r) const Circle Circle::operator / (Value r) const
{ {
return Circle(rad / r); return {rad / r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator % (Value r) const Circle Circle::operator % (Value r) const
{ {
return Circle(std::fmod(rad, r)); return {std::fmod(rad, r)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator + (const Vector2 & p) const Circle Circle::operator + (const Vector2 & p) const
{ {
return Circle(pos + p, rad); return {pos + p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator - (const Vector2 & p) const Circle Circle::operator - (const Vector2 & p) const
{ {
return Circle(pos - p, rad); return {pos - p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator * (const Vector2 & p) const Circle Circle::operator * (const Vector2 & p) const
{ {
return Circle(pos * p, rad); return {pos * p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator / (const Vector2 & p) const Circle Circle::operator / (const Vector2 & p) const
{ {
return Circle(pos / p, rad); return {pos / p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator % (const Vector2 & p) const Circle Circle::operator % (const Vector2 & p) const
{ {
return Circle(pos % p, rad); return {pos % p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator + () const Circle Circle::operator + () const
{ {
return Circle(pos.Abs(), std::fabs(rad)); return {pos.Abs(), std::fabs(rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::operator - () const Circle Circle::operator - () const
{ {
return Circle(-pos, -rad); return {-pos, -rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -464,7 +464,7 @@ void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Circle Circle::Abs() const Circle Circle::Abs() const
{ {
return Circle(pos.Abs(), std::fabs(rad)); return {pos.Abs(), std::fabs(rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -495,48 +495,11 @@ const Circle & Circle::GetEx(SQChar delim, StackStrF & str)
return circle; return circle;
} }
// ------------------------------------------------------------------------------------------------
const Circle & GetCircle()
{
static Circle circle;
circle.Clear();
return circle;
}
// ------------------------------------------------------------------------------------------------
const Circle & GetCircle(Float32 rv)
{
static Circle circle;
circle.SetRadius(rv);
return circle;
}
// ------------------------------------------------------------------------------------------------
const Circle & GetCircle(const Vector2 & pv, Float32 rv)
{
static Circle circle;
circle.SetValues(pv, rv);
return circle;
}
// ------------------------------------------------------------------------------------------------
const Circle & GetCircle(Float32 xv, Float32 yv, Float32 rv)
{
static Circle circle;
circle.SetCircleEx(xv, yv, rv);
return circle;
}
// ------------------------------------------------------------------------------------------------
const Circle & GetCircle(const Circle & o)
{
static Circle circle;
circle.SetCircle(o);
return circle;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Circle(HSQUIRRELVM vm) void Register_Circle(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Circle::Value Val; typedef Circle::Value Val;

View File

@ -38,32 +38,32 @@ struct Circle
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Circle(); Circle() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a circle at position 0,0 using the specified radius. * Construct a circle at position 0,0 using the specified radius.
*/ */
explicit Circle(Value rv); Circle(Value rv) noexcept; // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a circle at the specified position using the specified radius. * Construct a circle at the specified position using the specified radius.
*/ */
Circle(const Vector2 & pv, Value rv); Circle(const Vector2 & pv, Value rv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a circle at the specified position using the specified radius. * Construct a circle at the specified position using the specified radius.
*/ */
Circle(Value xv, Value yv, Value rv); Circle(Value xv, Value yv, Value rv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Circle(const Circle & o) = default; Circle(const Circle & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Circle(Circle && o) = default; Circle(Circle && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -178,12 +178,12 @@ struct Circle
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Circle operator ++ (int); Circle operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Circle operator -- (int); Circle operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -23,28 +23,28 @@ const Color3 Color3::MAX = Color3(std::numeric_limits< Color3::Value >::max());
SQChar Color3::Delim = ','; SQChar Color3::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3::Color3() Color3::Color3() noexcept
: r(0), g(0), b(0) : r(0), g(0), b(0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3::Color3(Value sv) Color3::Color3(Value sv) noexcept
: r(sv), g(sv), b(sv) : r(sv), g(sv), b(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3::Color3(Value rv, Value gv, Value bv) Color3::Color3(Value rv, Value gv, Value bv) noexcept
: r(rv), g(gv), b(bv) : r(rv), g(gv), b(bv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3::Color3(Value rv, Value gv, Value bv, Value /*av*/) Color3::Color3(Value rv, Value gv, Value bv, Value /*av*/) noexcept
: r(rv), g(gv), b(bv) : r(rv), g(gv), b(bv)
{ {
/* ... */ /* ... */
@ -267,7 +267,7 @@ Color3 & Color3::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator ++ (int) Color3 Color3::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Color3 state(*this); Color3 state(*this);
++r; ++r;
@ -277,7 +277,7 @@ Color3 Color3::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator -- (int) Color3 Color3::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Color3 state(*this); Color3 state(*this);
--r; --r;
@ -289,139 +289,139 @@ Color3 Color3::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator + (const Color3 & c) const Color3 Color3::operator + (const Color3 & c) const
{ {
return Color3(r + c.r, g + c.g, b + c.b); return {static_cast<Value>(r + c.r), static_cast<Value>(g + c.g), static_cast<Value>(b + c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator - (const Color3 & c) const Color3 Color3::operator - (const Color3 & c) const
{ {
return Color3(r - c.r, g - c.g, b - c.b); return {static_cast<Value>(r - c.r), static_cast<Value>(g - c.g), static_cast<Value>(b - c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator * (const Color3 & c) const Color3 Color3::operator * (const Color3 & c) const
{ {
return Color3(r * c.r, g * c.g, b * c.b); return {static_cast<Value>(r * c.r), static_cast<Value>(g * c.g), static_cast<Value>(b * c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator / (const Color3 & c) const Color3 Color3::operator / (const Color3 & c) const
{ {
return Color3(r / c.r, g / c.g, b / c.b); return {static_cast<Value>(r / c.r), static_cast<Value>(g / c.g), static_cast<Value>(b / c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator % (const Color3 & c) const Color3 Color3::operator % (const Color3 & c) const
{ {
return Color3(r % c.r, g % c.g, b % c.b); return {static_cast<Value>(r % c.r), static_cast<Value>(g % c.g), static_cast<Value>(b % c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator & (const Color3 & c) const Color3 Color3::operator & (const Color3 & c) const
{ {
return Color3(r & c.r, g & c.g, b & c.b); return {static_cast<Value>(r & c.r), static_cast<Value>(g & c.g), static_cast<Value>(b & c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator | (const Color3 & c) const Color3 Color3::operator | (const Color3 & c) const
{ {
return Color3(r | c.r, g | c.g, b | c.b); return {static_cast<Value>(r | c.r), static_cast<Value>(g | c.g), static_cast<Value>(b | c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator ^ (const Color3 & c) const Color3 Color3::operator ^ (const Color3 & c) const
{ {
return Color3(r ^ c.r, g ^ c.g, b ^ c.b); return {static_cast<Value>(r ^ c.r), static_cast<Value>(g ^ c.g), static_cast<Value>(b ^ c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator << (const Color3 & c) const Color3 Color3::operator << (const Color3 & c) const
{ {
return Color3(r << c.r, g << c.g, b << c.b); return {static_cast<Value>(r << c.r), static_cast<Value>(g << c.g), static_cast<Value>(b << c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator >> (const Color3 & c) const Color3 Color3::operator >> (const Color3 & c) const
{ {
return Color3(r >> c.r, g >> c.g, b >> c.b); return {static_cast<Value>(r >> c.r), static_cast<Value>(g >> c.g), static_cast<Value>(b >> c.b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator + (Value s) const Color3 Color3::operator + (Value s) const
{ {
return Color3(r + s, g + s, b + s); return {static_cast<Value>(r + s), static_cast<Value>(g + s), static_cast<Value>(b + s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator - (Value s) const Color3 Color3::operator - (Value s) const
{ {
return Color3(r - s, g - s, b - s); return {static_cast<Value>(r - s), static_cast<Value>(g - s), static_cast<Value>(b - s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator * (Value s) const Color3 Color3::operator * (Value s) const
{ {
return Color3(r * s, g * s, b * s); return {static_cast<Value>(r * s), static_cast<Value>(g * s), static_cast<Value>(b * s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator / (Value s) const Color3 Color3::operator / (Value s) const
{ {
return Color3(r / s, g / s, b / s); return {static_cast<Value>(r / s), static_cast<Value>(g / s), static_cast<Value>(b / s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator % (Value s) const Color3 Color3::operator % (Value s) const
{ {
return Color3(r % s, g % s, b % s); return {static_cast<Value>(r % s), static_cast<Value>(g % s), static_cast<Value>(b % s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator & (Value s) const Color3 Color3::operator & (Value s) const
{ {
return Color3(r & s, g & s, b & s); return {static_cast<Value>(r & s), static_cast<Value>(g & s), static_cast<Value>(b & s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator | (Value s) const Color3 Color3::operator | (Value s) const
{ {
return Color3(r | s, g | s, b | s); return {static_cast<Value>(r | s), static_cast<Value>(g | s), static_cast<Value>(b | s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator ^ (Value s) const Color3 Color3::operator ^ (Value s) const
{ {
return Color3(r ^ s, g ^ s, b ^ s); return {static_cast<Value>(r ^ s), static_cast<Value>(g ^ s), static_cast<Value>(b ^ s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator << (Value s) const Color3 Color3::operator << (Value s) const
{ {
return Color3(r << s, g << s, b << s); return {static_cast<Value>(r << s), static_cast<Value>(g << s), static_cast<Value>(b << s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator >> (Value s) const Color3 Color3::operator >> (Value s) const
{ {
return Color3(r >> s, g >> s, b >> s); return {static_cast<Value>(r >> s), static_cast<Value>(g >> s), static_cast<Value>(b >> s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator + () const Color3 Color3::operator + () const
{ {
return Color3(r, g, b); return {r, g, b};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator - () const Color3 Color3::operator - () const
{ {
return Color3(0, 0, 0); return {0, 0, 0};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3 Color3::operator ~ () const Color3 Color3::operator ~ () const
{ {
return Color3(~r, ~g, ~b); return {static_cast<Value>(~r), static_cast<Value>(~g), static_cast<Value>(~b)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -463,7 +463,7 @@ bool Color3::operator >= (const Color3 & c) const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color3::operator Color4 () const Color3::operator Color4 () const
{ {
return Color4(r, g, b); return {r, g, b};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -544,43 +544,43 @@ void Color3::SetName(StackStrF & name)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color3::GetRGB() const Uint32 Color3::GetRGB() const
{ {
return Uint32(r << 16 | g << 8 | b); return Uint32(r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::SetRGB(Uint32 p) void Color3::SetRGB(Uint32 p)
{ {
r = static_cast< Value >((p >> 16) & 0xFF); r = static_cast< Value >((p >> 16u) & 0xFFu);
g = static_cast< Value >((p >> 8) & 0xFF); g = static_cast< Value >((p >> 8u) & 0xFFu);
b = static_cast< Value >((p) & 0xFF); b = static_cast< Value >((p) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color3::GetRGBA() const Uint32 Color3::GetRGBA() const
{ {
return Uint32(r << 24 | g << 16 | b << 8 | 0x00); return Uint32(r << 24u | g << 16u | b << 8u | 0u); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::SetRGBA(Uint32 p) void Color3::SetRGBA(Uint32 p)
{ {
r = static_cast< Value >((p >> 24) & 0xFF); r = static_cast< Value >((p >> 24u) & 0xFFu);
g = static_cast< Value >((p >> 16) & 0xFF); g = static_cast< Value >((p >> 16u) & 0xFFu);
b = static_cast< Value >((p >> 8) & 0xFF); b = static_cast< Value >((p >> 8u) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color3::GetARGB() const Uint32 Color3::GetARGB() const
{ {
return Uint32(0x00 << 24 | r << 16 | g << 8 | b); return Uint32(0u << 24u | r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::SetARGB(Uint32 p) void Color3::SetARGB(Uint32 p)
{ {
r = static_cast< Value >((p >> 16) & 0xFF); r = static_cast< Value >((p >> 16u) & 0xFFu);
g = static_cast< Value >((p >> 8) & 0xFF); g = static_cast< Value >((p >> 8u) & 0xFFu);
b = static_cast< Value >((p) & 0xFF); b = static_cast< Value >((p) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -668,40 +668,11 @@ const Color3 & Color3::GetEx(SQChar delim, StackStrF & str)
return col; return col;
} }
// ------------------------------------------------------------------------------------------------
const Color3 & GetColor3()
{
static Color3 col;
col.Clear();
return col;
}
// ------------------------------------------------------------------------------------------------
const Color3 & GetColor3(Uint8 sv)
{
static Color3 col;
col.SetScalar(sv);
return col;
}
// ------------------------------------------------------------------------------------------------
const Color3 & GetColor3(Uint8 rv, Uint8 gv, Uint8 bv)
{
static Color3 col;
col.SetColor3Ex(rv, gv, bv);
return col;
}
// ------------------------------------------------------------------------------------------------
const Color3 & GetColor3(const Color3 & o)
{
static Color3 col;
col.SetColor3(o);
return col;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Color3(HSQUIRRELVM vm) void Register_Color3(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Color3::Value Val; typedef Color3::Value Val;

View File

@ -36,32 +36,32 @@ struct Color3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Color3(); Color3() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a color with all components with the same specified color. * Construct a color with all components with the same specified color.
*/ */
explicit Color3(Value sv); explicit Color3(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct with individually specified red, green and blue colors. * Construct with individually specified red, green and blue colors.
*/ */
Color3(Value rv, Value gv, Value bv); Color3(Value rv, Value gv, Value bv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct with individually specified red, green, blue and alpha colors. * Construct with individually specified red, green, blue and alpha colors.
*/ */
Color3(Value rv, Value gv, Value bv, Value av); Color3(Value rv, Value gv, Value bv, Value av) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Color3(const Color3 & o) = default; Color3(const Color3 & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Color3(Color3 && o) = default; Color3(Color3 && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -201,12 +201,12 @@ struct Color3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Color3 operator ++ (int); Color3 operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Color3 operator -- (int); Color3 operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.
@ -356,7 +356,7 @@ struct Color3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to transparent color. * Implicit conversion to transparent color.
*/ */
operator Color4 () const; operator Color4 () const; // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type. * Used by the script engine to compare two instances of this type.

View File

@ -23,28 +23,28 @@ const Color4 Color4::MAX = Color4(std::numeric_limits< Color4::Value >::max());
SQChar Color4::Delim = ','; SQChar Color4::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4::Color4() Color4::Color4() noexcept
: r(0), g(0), b(0), a(0) : r(0), g(0), b(0), a(0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4::Color4(Value sv) Color4::Color4(Value sv) noexcept
: r(sv), g(sv), b(sv), a(0) : r(sv), g(sv), b(sv), a(0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4::Color4(Value rv, Value gv, Value bv) Color4::Color4(Value rv, Value gv, Value bv) noexcept
: r(rv), g(gv), b(bv), a(0) : r(rv), g(gv), b(bv), a(0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4::Color4(Value rv, Value gv, Value bv, Value av) Color4::Color4(Value rv, Value gv, Value bv, Value av) noexcept
: r(rv), g(gv), b(bv), a(av) : r(rv), g(gv), b(bv), a(av)
{ {
/* ... */ /* ... */
@ -290,7 +290,7 @@ Color4 & Color4::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator ++ (int) Color4 Color4::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Color4 state(*this); Color4 state(*this);
++r; ++r;
@ -301,7 +301,7 @@ Color4 Color4::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator -- (int) Color4 Color4::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Color4 state(*this); Color4 state(*this);
--r; --r;
@ -314,139 +314,139 @@ Color4 Color4::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator + (const Color4 & c) const Color4 Color4::operator + (const Color4 & c) const
{ {
return Color4(r + c.r, g + c.g, b + c.b, a + c.a); return {static_cast<Value>(r + c.r), static_cast<Value>(g + c.g), static_cast<Value>(b + c.b), static_cast<Value>(a + c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator - (const Color4 & c) const Color4 Color4::operator - (const Color4 & c) const
{ {
return Color4(r - c.r, g - c.g, b - c.b, a - c.a); return {static_cast<Value>(r - c.r), static_cast<Value>(g - c.g), static_cast<Value>(b - c.b), static_cast<Value>(a - c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator * (const Color4 & c) const Color4 Color4::operator * (const Color4 & c) const
{ {
return Color4(r * c.r, g * c.g, b * c.b, a * c.a); return {static_cast<Value>(r * c.r), static_cast<Value>(g * c.g), static_cast<Value>(b * c.b), static_cast<Value>(a * c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator / (const Color4 & c) const Color4 Color4::operator / (const Color4 & c) const
{ {
return Color4(r / c.r, g / c.g, b / c.b, a / c.a); return {static_cast<Value>(r / c.r), static_cast<Value>(g / c.g), static_cast<Value>(b / c.b), static_cast<Value>(a / c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator % (const Color4 & c) const Color4 Color4::operator % (const Color4 & c) const
{ {
return Color4(r % c.r, g % c.g, b % c.b, a % c.a); return {static_cast<Value>(r % c.r), static_cast<Value>(g % c.g), static_cast<Value>(b % c.b), static_cast<Value>(a % c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator & (const Color4 & c) const Color4 Color4::operator & (const Color4 & c) const
{ {
return Color4(r & c.r, g & c.g, b & c.b, a & c.a); return {static_cast<Value>(r & c.r), static_cast<Value>(g & c.g), static_cast<Value>(b & c.b), static_cast<Value>(a & c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator | (const Color4 & c) const Color4 Color4::operator | (const Color4 & c) const
{ {
return Color4(r | c.r, g | c.g, b | c.b, a | c.a); return {static_cast<Value>(r | c.r), static_cast<Value>(g | c.g), static_cast<Value>(b | c.b), static_cast<Value>(a | c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator ^ (const Color4 & c) const Color4 Color4::operator ^ (const Color4 & c) const
{ {
return Color4(r ^ c.r, g ^ c.g, b ^ c.b, a ^ c.a); return {static_cast<Value>(r ^ c.r), static_cast<Value>(g ^ c.g), static_cast<Value>(b ^ c.b), static_cast<Value>(a ^ c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator << (const Color4 & c) const Color4 Color4::operator << (const Color4 & c) const
{ {
return Color4(r << c.r, g << c.g, b << c.b, a << c.a); return {static_cast<Value>(r << c.r), static_cast<Value>(g << c.g), static_cast<Value>(b << c.b), static_cast<Value>(a << c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator >> (const Color4 & c) const Color4 Color4::operator >> (const Color4 & c) const
{ {
return Color4(r >> c.r, g >> c.g, b >> c.b, a >> c.a); return {static_cast<Value>(r >> c.r), static_cast<Value>(g >> c.g), static_cast<Value>(b >> c.b), static_cast<Value>(a >> c.a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator + (Value s) const Color4 Color4::operator + (Value s) const
{ {
return Color4(r + s, g + s, b + s, a + s); return {static_cast<Value>(r + s), static_cast<Value>(g + s), static_cast<Value>(b + s), static_cast<Value>(a + s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator - (Value s) const Color4 Color4::operator - (Value s) const
{ {
return Color4(r - s, g - s, b - s, a - s); return {static_cast<Value>(r - s), static_cast<Value>(g - s), static_cast<Value>(b - s), static_cast<Value>(a - s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator * (Value s) const Color4 Color4::operator * (Value s) const
{ {
return Color4(r * s, g * s, b * s, a * s); return {static_cast<Value>(r * s), static_cast<Value>(g * s), static_cast<Value>(b * s), static_cast<Value>(a * s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator / (Value s) const Color4 Color4::operator / (Value s) const
{ {
return Color4(r / s, g / s, b / s, a / s); return {static_cast<Value>(r / s), static_cast<Value>(g / s), static_cast<Value>(b / s), static_cast<Value>(a / s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator % (Value s) const Color4 Color4::operator % (Value s) const
{ {
return Color4(r % s, g % s, b % s, a % s); return {static_cast<Value>(r % s), static_cast<Value>(g % s), static_cast<Value>(b % s), static_cast<Value>(a % s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator & (Value s) const Color4 Color4::operator & (Value s) const
{ {
return Color4(r & s, g & s, b & s, a & s); return {static_cast<Value>(r & s), static_cast<Value>(g & s), static_cast<Value>(b & s), static_cast<Value>(a & s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator | (Value s) const Color4 Color4::operator | (Value s) const
{ {
return Color4(r | s, g | s, b | s, a | s); return {static_cast<Value>(r | s), static_cast<Value>(g | s), static_cast<Value>(b | s), static_cast<Value>(a | s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator ^ (Value s) const Color4 Color4::operator ^ (Value s) const
{ {
return Color4(r ^ s, g ^ s, b ^ s, a ^ s); return {static_cast<Value>(r ^ s), static_cast<Value>(g ^ s), static_cast<Value>(b ^ s), static_cast<Value>(a ^ s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator << (Value s) const Color4 Color4::operator << (Value s) const
{ {
return Color4(r << s, g << s, b << s, a << s); return {static_cast<Value>(r << s), static_cast<Value>(g << s), static_cast<Value>(b << s), static_cast<Value>(a << s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator >> (Value s) const Color4 Color4::operator >> (Value s) const
{ {
return Color4(r >> s, g >> s, b >> s, a >> s); return {static_cast<Value>(r >> s), static_cast<Value>(g >> s), static_cast<Value>(b >> s), static_cast<Value>(a >> s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator + () const Color4 Color4::operator + () const
{ {
return Color4(r, g, b, a); return {r, g, b, a};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator - () const Color4 Color4::operator - () const
{ {
return Color4(0, 0, 0, 0); return {0, 0, 0, 0};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4 Color4::operator ~ () const Color4 Color4::operator ~ () const
{ {
return Color4(~r, ~g, ~b, ~a); return {static_cast<Value>(~r), static_cast<Value>(~g), static_cast<Value>(~b), static_cast<Value>(~a)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -488,7 +488,7 @@ bool Color4::operator >= (const Color4 & c) const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Color4::operator Color3 () const Color4::operator Color3 () const
{ {
return Color3(r, g, b); return {r, g, b};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -573,45 +573,45 @@ void Color4::SetName(StackStrF & name)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color4::GetRGB() const Uint32 Color4::GetRGB() const
{ {
return Uint32(r << 16 | g << 8 | b); return Uint32(r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::SetRGB(Uint32 p) void Color4::SetRGB(Uint32 p)
{ {
r = static_cast< Value >((p >> 16) & 0xFF); r = static_cast< Value >((p >> 16u) & 0xFFu);
g = static_cast< Value >((p >> 8) & 0xFF); g = static_cast< Value >((p >> 8u) & 0xFFu);
b = static_cast< Value >((p) & 0xFF); b = static_cast< Value >((p) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color4::GetRGBA() const Uint32 Color4::GetRGBA() const
{ {
return Uint32(r << 24 | g << 16 | b << 8 | a); return Uint32(r << 24u | g << 16u | b << 8u | a); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::SetRGBA(Uint32 p) void Color4::SetRGBA(Uint32 p)
{ {
r = static_cast< Value >((p >> 24) & 0xFF); r = static_cast< Value >((p >> 24u) & 0xFFu);
g = static_cast< Value >((p >> 16) & 0xFF); g = static_cast< Value >((p >> 16u) & 0xFFu);
b = static_cast< Value >((p >> 8) & 0xFF); b = static_cast< Value >((p >> 8u) & 0xFFu);
a = static_cast< Value >((p) & 0xFF); a = static_cast< Value >((p) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Uint32 Color4::GetARGB() const Uint32 Color4::GetARGB() const
{ {
return Uint32(a << 24 | r << 16 | g << 8 | b); return Uint32(a << 24u | r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::SetARGB(Uint32 p) void Color4::SetARGB(Uint32 p)
{ {
a = static_cast< Value >((p >> 24) & 0xFF); a = static_cast< Value >((p >> 24u) & 0xFFu);
r = static_cast< Value >((p >> 16) & 0xFF); r = static_cast< Value >((p >> 16u) & 0xFFu);
g = static_cast< Value >((p >> 8) & 0xFF); g = static_cast< Value >((p >> 8u) & 0xFFu);
b = static_cast< Value >((p) & 0xFF); b = static_cast< Value >((p) & 0xFFu);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -705,48 +705,11 @@ const Color4 & Color4::GetEx(SQChar delim, StackStrF & str)
return col; return col;
} }
// ------------------------------------------------------------------------------------------------
const Color4 & GetColor4()
{
static Color4 col;
col.Clear();
return col;
}
// ------------------------------------------------------------------------------------------------
const Color4 & GetColor4(Uint8 sv)
{
static Color4 col;
col.SetScalar(sv);
return col;
}
// ------------------------------------------------------------------------------------------------
const Color4 & GetColor4(Uint8 rv, Uint8 gv, Uint8 bv)
{
static Color4 col;
col.SetColor3Ex(rv, gv, bv);
return col;
}
// ------------------------------------------------------------------------------------------------
const Color4 & GetColor4(Uint8 rv, Uint8 gv, Uint8 bv, Uint8 av)
{
static Color4 col;
col.SetColor4Ex(rv, gv, bv, av);
return col;
}
// ------------------------------------------------------------------------------------------------
const Color4 & GetColor4(const Color4 & o)
{
static Color4 col;
col.SetColor4(o);
return col;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Color4(HSQUIRRELVM vm) void Register_Color4(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Color4::Value Val; typedef Color4::Value Val;

View File

@ -36,32 +36,32 @@ struct Color4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Color4(); Color4() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a color with all components with the same specified color. * Construct a color with all components with the same specified color.
*/ */
explicit Color4(Value sv); explicit Color4(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct with individually specified red, green and blue colors. * Construct with individually specified red, green and blue colors.
*/ */
Color4(Value rv, Value gv, Value bv); Color4(Value rv, Value gv, Value bv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct with individually specified red, green, blue and alpha colors. * Construct with individually specified red, green, blue and alpha colors.
*/ */
Color4(Value rv, Value gv, Value bv, Value av); Color4(Value rv, Value gv, Value bv, Value av) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Color4(const Color4 & o) = default; Color4(const Color4 & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Color4(Color4 && o) = default; Color4(Color4 && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -201,12 +201,12 @@ struct Color4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Color4 operator ++ (int); Color4 operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Color4 operator -- (int); Color4 operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.
@ -356,7 +356,7 @@ struct Color4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to opaque color. * Implicit conversion to opaque color.
*/ */
operator Color3 () const; operator Color3 () const; // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type. * Used by the script engine to compare two instances of this type.

View File

@ -398,7 +398,10 @@ template < typename F, typename U, typename... Ts > SQInteger SqDynArgFwd(HSQUIR
return sq_throwerror(vm, "Unknown error occurred during comparison"); return sq_throwerror(vm, "Unknown error occurred during comparison");
} }
// We shouldn't really reach this point but something must be returned // We shouldn't really reach this point but something must be returned
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCDFAInspection"
return sq_throwerror(vm, "Operation encountered unknown behavior"); return sq_throwerror(vm, "Operation encountered unknown behavior");
#pragma clang diagnostic pop
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -413,7 +416,7 @@ template < typename T > struct SqDynArgCmpFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgCmpFn(HSQUIRRELVM vm) explicit SqDynArgCmpFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -422,7 +425,7 @@ template < typename T > struct SqDynArgCmpFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(hicpp-explicit-conversions,google-explicit-constructor)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }
@ -480,7 +483,7 @@ template < typename T > struct SqDynArgAddFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgAddFn(HSQUIRRELVM vm) explicit SqDynArgAddFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -489,7 +492,7 @@ template < typename T > struct SqDynArgAddFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(hicpp-explicit-conversions,google-explicit-constructor)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }
@ -547,7 +550,7 @@ template < typename T > struct SqDynArgSubFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgSubFn(HSQUIRRELVM vm) explicit SqDynArgSubFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -556,7 +559,7 @@ template < typename T > struct SqDynArgSubFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }
@ -614,7 +617,7 @@ template < typename T > struct SqDynArgMulFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgMulFn(HSQUIRRELVM vm) explicit SqDynArgMulFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -623,7 +626,7 @@ template < typename T > struct SqDynArgMulFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }
@ -681,7 +684,7 @@ template < typename T > struct SqDynArgDivFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgDivFn(HSQUIRRELVM vm) explicit SqDynArgDivFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -690,7 +693,7 @@ template < typename T > struct SqDynArgDivFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }
@ -748,7 +751,7 @@ template < typename T > struct SqDynArgModFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Base constructor. (required) * Base constructor. (required)
*/ */
SqDynArgModFn(HSQUIRRELVM vm) explicit SqDynArgModFn(HSQUIRRELVM vm)
: mVM(vm), mVar(vm, 1) : mVM(vm), mVar(vm, 1)
{ {
/* ... */ /* ... */
@ -757,7 +760,7 @@ template < typename T > struct SqDynArgModFn
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean. (required) * Implicit conversion to boolean. (required)
*/ */
operator bool () const operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return (mVar.value != nullptr); return (mVar.value != nullptr);
} }

View File

@ -28,28 +28,28 @@ const Quaternion Quaternion::IDENTITY(1.0, 0.0, 0.0, 0.0);
SQChar Quaternion::Delim = ','; SQChar Quaternion::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion::Quaternion() Quaternion::Quaternion() noexcept
: x(0.0), y(0.0), z(0.0), w(0.0) : x(0.0), y(0.0), z(0.0), w(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(Value sv) Quaternion::Quaternion(Value sv) noexcept
: x(sv), y(sv), z(sv), w(sv) : x(sv), y(sv), z(sv), w(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(Value xv, Value yv, Value zv) Quaternion::Quaternion(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv), w(0.0) : x(xv), y(yv), z(zv), w(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(Value xv, Value yv, Value zv, Value wv) Quaternion::Quaternion(Value xv, Value yv, Value zv, Value wv) noexcept
: x(xv), y(yv), z(zv), w(wv) : x(xv), y(yv), z(zv), w(wv)
{ {
/* ... */ /* ... */
@ -206,7 +206,7 @@ Quaternion & Quaternion::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator ++ (int) Quaternion Quaternion::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Quaternion state(*this); Quaternion state(*this);
++x; ++x;
@ -217,7 +217,7 @@ Quaternion Quaternion::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator -- (int) Quaternion Quaternion::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Quaternion state(*this); Quaternion state(*this);
--x; --x;
@ -230,73 +230,73 @@ Quaternion Quaternion::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator + (const Quaternion & q) const Quaternion Quaternion::operator + (const Quaternion & q) const
{ {
return Quaternion(x + q.x, y + q.y, z + q.z, w + q.w); return {x + q.x, y + q.y, z + q.z, w + q.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator + (Value s) const Quaternion Quaternion::operator + (Value s) const
{ {
return Quaternion(x + s, y + s, z + s, w + s); return {x + s, y + s, z + s, w + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator - (const Quaternion & q) const Quaternion Quaternion::operator - (const Quaternion & q) const
{ {
return Quaternion(x - q.x, y - q.y, z - q.z, w - q.w); return {x - q.x, y - q.y, z - q.z, w - q.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator - (Value s) const Quaternion Quaternion::operator - (Value s) const
{ {
return Quaternion(x - s, y - s, z - s, w - s); return {x - s, y - s, z - s, w - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator * (const Quaternion & q) const Quaternion Quaternion::operator * (const Quaternion & q) const
{ {
return Quaternion(x * q.x, y * q.y, z * q.z, w * q.w); return {x * q.x, y * q.y, z * q.z, w * q.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator * (Value s) const Quaternion Quaternion::operator * (Value s) const
{ {
return Quaternion(x * s, y * s, z * s, w * s); return {x * s, y * s, z * s, w * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator / (const Quaternion & q) const Quaternion Quaternion::operator / (const Quaternion & q) const
{ {
return Quaternion(x / q.x, y / q.y, z / q.z, w / q.w); return {x / q.x, y / q.y, z / q.z, w / q.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator / (Value s) const Quaternion Quaternion::operator / (Value s) const
{ {
return Quaternion(x / s, y / s, z / s, w / s); return {x / s, y / s, z / s, w / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator % (const Quaternion & q) const Quaternion Quaternion::operator % (const Quaternion & q) const
{ {
return Quaternion(std::fmod(x, q.x), std::fmod(y, q.y), std::fmod(z, q.z), std::fmod(w, q.w)); return {std::fmod(x, q.x), std::fmod(y, q.y), std::fmod(z, q.z), std::fmod(w, q.w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator % (Value s) const Quaternion Quaternion::operator % (Value s) const
{ {
return Quaternion(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s)); return {std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator + () const Quaternion Quaternion::operator + () const
{ {
return Quaternion(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)); return {std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator - () const Quaternion Quaternion::operator - () const
{ {
return Quaternion(-x, -y, -z, -w); return {-x, -y, -z, -w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -476,7 +476,7 @@ void Quaternion::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::Abs() const Quaternion Quaternion::Abs() const
{ {
return Quaternion(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)); return {std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -500,7 +500,7 @@ Quaternion::Value Quaternion::DotProduct(const Quaternion & quat) const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Quaternion Quaternion::Conjugate() const Quaternion Quaternion::Conjugate() const
{ {
return Quaternion(-x, -y, -z, w);; return {-x, -y, -z, w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -610,35 +610,35 @@ Vector3 Quaternion::ToEuler() const
if (EpsEq(test, 1.0)) if (EpsEq(test, 1.0))
{ {
return Vector3( return {
// bank = rotation about x-axis // bank = rotation about x-axis
STOVAL(0.0), STOVAL(0.0),
// attitude = rotation about y-axis // attitude = rotation about y-axis
STOVAL(SQMOD_PI64 / 2.0), STOVAL(SQMOD_PI64 / 2.0),
// heading = rotation about z-axis // heading = rotation about z-axis
STOVAL(-2.0 * std::atan2(x, w)) STOVAL(-2.0 * std::atan2(x, w))
); };
} }
else if (EpsEq(test, -1.0)) else if (EpsEq(test, -1.0))
{ {
return Vector3( return {
// bank = rotation about x-axis // bank = rotation about x-axis
STOVAL(0.0), STOVAL(0.0),
// attitude = rotation about y-axis // attitude = rotation about y-axis
STOVAL(SQMOD_PI64 / -2.0), STOVAL(SQMOD_PI64 / -2.0),
// heading = rotation about z-axis // heading = rotation about z-axis
STOVAL(2.0 * std::atan2(x, w)) STOVAL(2.0 * std::atan2(x, w))
); };
} }
return Vector3( return {
// bank = rotation about x-axis // bank = rotation about x-axis
STOVAL(std::atan2(2.0 * ((y * z) + (x * w)), (-sqx - sqy + sqz + sqw))), STOVAL(std::atan2(2.0 * ((y * z) + (x * w)), (-sqx - sqy + sqz + sqw))),
// attitude = rotation about y-axis // attitude = rotation about y-axis
STOVAL(std::asin(Clamp(test, -1.0, 1.0))), STOVAL(std::asin(Clamp(test, -1.0, 1.0))),
// heading = rotation about z-axis // heading = rotation about z-axis
STOVAL(std::atan2(2.0 * ((x * y) + (z * w)), (sqx - sqy - sqz + sqw))) STOVAL(std::atan2(2.0 * ((x * y) + (z * w)), (sqx - sqy - sqz + sqw)))
); };
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -742,48 +742,11 @@ const Quaternion & Quaternion::GetEx(SQChar delim, StackStrF & str)
return quat; return quat;
} }
// ------------------------------------------------------------------------------------------------
const Quaternion & GetQuaternion()
{
static Quaternion quat;
quat.Clear();
return quat;
}
// ------------------------------------------------------------------------------------------------
const Quaternion & GetQuaternion(Float32 sv)
{
static Quaternion quat;
quat.SetScalar(sv);
return quat;
}
// ------------------------------------------------------------------------------------------------
const Quaternion & GetQuaternion(Float32 xv, Float32 yv, Float32 zv)
{
static Quaternion quat;
quat.SetVector3Ex(xv, yv, zv);
return quat;
}
// ------------------------------------------------------------------------------------------------
const Quaternion & GetQuaternion(Float32 xv, Float32 yv, Float32 zv, Float32 wv)
{
static Quaternion quat;
quat.SetQuaternionEx(xv, yv, zv, wv);
return quat;
}
// ------------------------------------------------------------------------------------------------
const Quaternion & GetQuaternion(const Quaternion & o)
{
static Quaternion quat;
quat.SetQuaternion(o);
return quat;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Quaternion(HSQUIRRELVM vm) void Register_Quaternion(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Quaternion::Value Val; typedef Quaternion::Value Val;

View File

@ -37,32 +37,32 @@ struct Quaternion
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Quaternion(); Quaternion() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct from scalar value. * Construct from scalar value.
*/ */
explicit Quaternion(Value sv); explicit Quaternion(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct from Euler angles (in degrees.) * Construct from Euler angles (in degrees.)
*/ */
Quaternion(Value xv, Value yv, Value zv); Quaternion(Value xv, Value yv, Value zv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct from individual values. * Construct from individual values.
*/ */
Quaternion(Value xv, Value yv, Value zv, Value wv); Quaternion(Value xv, Value yv, Value zv, Value wv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Quaternion(const Quaternion & o) = default; Quaternion(const Quaternion & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Quaternion(Quaternion && o) = default; Quaternion(Quaternion && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -157,12 +157,12 @@ struct Quaternion
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Quaternion operator ++ (int); Quaternion operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Quaternion operator -- (int); Quaternion operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -22,7 +22,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
FileHandle(CSStr path) explicit FileHandle(CSStr path)
: mFile(std::fopen(path, "rb")) : mFile(std::fopen(path, "rb"))
{ {
if (!mFile) if (!mFile)
@ -65,7 +65,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed file handle. * Implicit conversion to the managed file handle.
*/ */
operator std::FILE * () operator std::FILE * () // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return mFile; return mFile;
} }
@ -73,7 +73,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed file handle. * Implicit conversion to the managed file handle.
*/ */
operator std::FILE * () const operator std::FILE * () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
{ {
return mFile; return mFile;
} }
@ -99,11 +99,11 @@ void ScriptSrc::Process()
return; // Probably an empty file or compiled script return; // Probably an empty file or compiled script
} }
// Allocate enough space to hold the file data // Allocate enough space to hold the file data
mData.resize(length, 0); mData.resize(static_cast< size_t >(length), 0);
// Go back to the beginning // Go back to the beginning
std::fseek(fp, 0, SEEK_SET); std::fseek(fp, 0, SEEK_SET);
// Read the file contents into allocated data // Read the file contents into allocated data
std::fread(&mData[0], 1, length, fp); std::fread(&mData[0], 1, static_cast< size_t >(length), fp);
// Where the last line ended // Where the last line ended
size_t line_start = 0, line_end = 0; size_t line_start = 0, line_end = 0;
// Process the file data and locate new lines // Process the file data and locate new lines
@ -113,7 +113,7 @@ void ScriptSrc::Process()
if (*itr == '\n') if (*itr == '\n')
{ {
// Extract the line length // Extract the line length
line_end = std::distance(mData.cbegin(), itr); line_end = static_cast< size_t >(std::distance(mData.cbegin(), itr));
// Store the beginning of the line // Store the beginning of the line
mLine.emplace_back(line_start, line_end); mLine.emplace_back(line_start, line_end);
// Advance to the next line // Advance to the next line
@ -127,7 +127,7 @@ void ScriptSrc::Process()
if (*(++itr) == '\n') if (*(++itr) == '\n')
{ {
// Extract the line length // Extract the line length
line_end = std::distance(mData.cbegin(), itr)-1; line_end = static_cast< size_t >(std::distance(mData.cbegin(), itr) - 1);
// Store the beginning of the line // Store the beginning of the line
mLine.emplace_back(line_start, line_end); mLine.emplace_back(line_start, line_end);
// Advance to the next line // Advance to the next line

View File

@ -3,15 +3,12 @@
#include "Base/Buffer.hpp" #include "Base/Buffer.hpp"
#include "Base/Color3.hpp" #include "Base/Color3.hpp"
#include "Library/Numeric/Random.hpp" #include "Library/Numeric/Random.hpp"
#include "Library/Numeric/LongInt.hpp"
#include "Library/String.hpp" #include "Library/String.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <cerrno> #include <cerrno>
#include <cstdio>
#include <cstring> #include <cstring>
#include <cstdarg> #include <cstdarg>
#include <algorithm>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#ifdef SQMOD_OS_WINDOWS #ifdef SQMOD_OS_WINDOWS
@ -166,49 +163,6 @@ static const Color3 SQ_Color_List[] =
Color3(154, 205, 50) Color3(154, 205, 50)
}; };
// ------------------------------------------------------------------------------------------------
const SLongInt & GetSLongInt()
{
static SLongInt l;
l.SetNum(0);
return l;
}
const SLongInt & GetSLongInt(Int64 n)
{
static SLongInt l;
l.SetNum(n);
return l;
}
const SLongInt & GetSLongInt(CSStr s)
{
static SLongInt l;
l = s;
return l;
}
const ULongInt & GetULongInt()
{
static ULongInt l;
l.SetNum(0);
return l;
}
const ULongInt & GetULongInt(Uint64 n)
{
static ULongInt l;
l.SetNum(n);
return l;
}
const ULongInt & GetULongInt(CSStr s)
{
static ULongInt l;
l = s;
return l;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool NameFilterCheck(CSStr filter, CSStr name) bool NameFilterCheck(CSStr filter, CSStr name)
{ {
@ -371,22 +325,22 @@ Color3 GetColorStr(CSStr name)
switch (b) switch (b)
{ {
// [Al]iceBlue // [Al]iceBlue
case 'l': return Color3(240, 248, 255); case 'l': return {240, 248, 255};
// [Aq]ua[m]arine // [Aq]ua[m]arine
case 'm': return Color3(127, 255, 212); case 'm': return {127, 255, 212};
// [An]tiqueWhite // [An]tiqueWhite
case 'n': return Color3(250, 235, 215); case 'n': return {250, 235, 215};
// [Aq]ua // [Aq]ua
// [Aq]uamarine // [Aq]uamarine
case 'q': case 'q':
// [Aq]u[a] // [Aq]u[a]
if (d == 'a') return Color3(0, 255, 255); if (d == 'a') return {0, 255, 255};
// [Aq]ua[m]arin[e] // [Aq]ua[m]arin[e]
else if (d == 'e' || (len > 4 && str[4] == 'm')) return Color3(127, 255, 212); else if (d == 'e' || (len > 4 && str[4] == 'm')) return {127, 255, 212};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [Az]ure // [Az]ure
case 'z': return Color3(240, 255, 255); case 'z': return {240, 255, 255};
// Default to blank // Default to blank
default: return Color3::NIL; default: return Color3::NIL;
} }
@ -402,32 +356,32 @@ Color3 GetColorStr(CSStr name)
switch (b) switch (b)
{ {
// [B]lanched[A]lmond // [B]lanched[A]lmond
case 'a': return Color3(255, 235, 205); case 'a': return {255, 235, 205};
// [Be]ige // [Be]ige
case 'e': return Color3(245, 245, 220); case 'e': return {245, 245, 220};
// [Bi]sque // [Bi]sque
case 'i': return Color3(255, 228, 196); case 'i': return {255, 228, 196};
// [Bl]ack // [Bl]ack
// [Bl]anchedAlmond // [Bl]anchedAlmond
// [Bl]ue // [Bl]ue
// [Bl]ueViolet // [Bl]ueViolet
case 'l': case 'l':
// [Bl]a[ck] // [Bl]a[ck]
if (d == 'k' || d == 'c') return Color3(0, 0, 0); if (d == 'k' || d == 'c') return {0, 0, 0};
// [Bl]anched[A]lmon[d] // [Bl]anched[A]lmon[d]
else if (d == 'd' || (len > 8 && str[8] == 'a')) return Color3(255, 235, 205); else if (d == 'd' || (len > 8 && str[8] == 'a')) return {255, 235, 205};
// [Bl]u[e] // [Bl]u[e]
else if (d == 'e') return Color3(0, 0, 255); else if (d == 'e') return {0, 0, 255};
// [Bl]ue[V]iole[t] // [Bl]ue[V]iole[t]
else if (d == 't' || (len > 4 && str[4] == 'v')) return Color3(138, 43, 226); else if (d == 't' || (len > 4 && str[4] == 'v')) return {138, 43, 226};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [Br]own // [Br]own
case 'r': return Color3(165, 42, 42); case 'r': return {165, 42, 42};
// [Bu]rlyWood // [Bu]rlyWood
case 'u': return Color3(222, 184, 135); case 'u': return {222, 184, 135};
// [B]lue[V]iolet // [B]lue[V]iolet
case 'v': return Color3(138, 43, 226); case 'v': return {138, 43, 226};
// Default to blank // Default to blank
default: return Color3::NIL; default: return Color3::NIL;
} }
@ -443,14 +397,14 @@ Color3 GetColorStr(CSStr name)
switch (b) switch (b)
{ {
// [Ca]detBlue // [Ca]detBlue
case 'a': return Color3(95, 158, 160); case 'a': return {95, 158, 160};
// [Ch]artreuse // [Ch]artreuse
// [Ch]ocolate // [Ch]ocolate
case 'h': case 'h':
// [Ch]artreuse // [Ch]artreuse
if (c == 'a') return Color3(127, 255, 0); if (c == 'a') return {127, 255, 0};
// [Ch]ocolate // [Ch]ocolate
else if (c == 'o') return Color3(210, 105, 30); else if (c == 'o') return {210, 105, 30};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [Co]ral // [Co]ral
@ -458,17 +412,17 @@ Color3 GetColorStr(CSStr name)
// [Co]rnsilk // [Co]rnsilk
case 'o': case 'o':
// [Co]ra[l] // [Co]ra[l]
if (d == 'l') return Color3(255, 127, 80); if (d == 'l') return {255, 127, 80};
// [Co]rnflower[B]lu[e] // [Co]rnflower[B]lu[e]
else if (d == 'e' || (len > 10 && str[10] == 'b')) return Color3(100, 149, 237); else if (d == 'e' || (len > 10 && str[10] == 'b')) return {100, 149, 237};
// [Co]rnsil[k] // [Co]rnsil[k]
else if (d == 'k') return Color3(255, 248, 220); else if (d == 'k') return {255, 248, 220};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [Cr]imson // [Cr]imson
case 'r': return Color3(220, 20, 60); case 'r': return {220, 20, 60};
// [Cy]an // [Cy]an
case 'y': return Color3(0, 255, 255); case 'y': return {0, 255, 255};
// Default to blank // Default to blank
default: return Color3::NIL; default: return Color3::NIL;
} }
@ -495,13 +449,13 @@ Color3 GetColorStr(CSStr name)
// [D]odgerBlue // [D]odgerBlue
case 'd': case 'd':
// [Di]mGray // [Di]mGray
if (b == 'i' || b == 'g') return Color3(105, 105, 105); if (b == 'i' || b == 'g') return {105, 105, 105};
// [Do]dgerBlue // [Do]dgerBlue
else if (b == 'o' || b == 'b') return Color3(30, 144, 255); else if (b == 'o' || b == 'b') return {30, 144, 255};
// [De]ep[P]in[k] // [De]ep[P]in[k]
else if (b == 'e' && (d == 'k' || (len > 4 && str[4] == 'p'))) return Color3(255, 20, 147); else if (b == 'e' && (d == 'k' || (len > 4 && str[4] == 'p'))) return {255, 20, 147};
// [De]ep[S]kyBlu[e] // [De]ep[S]kyBlu[e]
else if (b == 'e' && (d == 'e' || (len > 4 && str[4] == 's'))) return Color3(0, 191, 255); else if (b == 'e' && (d == 'e' || (len > 4 && str[4] == 's'))) return {0, 191, 255};
// [Da]rkBlue // [Da]rkBlue
// [Da]rkCyan // [Da]rkCyan
// [Da]rkGoldenRod // [Da]rkGoldenRod
@ -521,39 +475,39 @@ Color3 GetColorStr(CSStr name)
// [Da]rkViolet // [Da]rkViolet
else if (b == 'a') { else if (b == 'a') {
// [Da]rk[B]lue // [Da]rk[B]lue
if (c == 'b' || (len > 4 && str[4] == 'b')) return Color3(0, 0, 139); if (c == 'b' || (len > 4 && str[4] == 'b')) return {0, 0, 139};
// [Da]rk[C]yan // [Da]rk[C]yan
else if (c == 'c' || (len > 4 && str[4] == 'c')) return Color3(0, 139, 139); else if (c == 'c' || (len > 4 && str[4] == 'c')) return {0, 139, 139};
// [Da]rk[Go]ldenRo[d] // [Da]rk[Go]ldenRo[d]
else if ((len > 4 && str[4] == 'g') && (d == 'd' || d == 'o')) return Color3(184, 134, 11); else if ((len > 4 && str[4] == 'g') && (d == 'd' || d == 'o')) return {184, 134, 11};
// [Da]rk[G]r[ay] // [Da]rk[G]r[ay]
else if ((len > 4 && str[4] == 'g') && (d == 'y' || d == 'a')) return Color3(169, 169, 169); else if ((len > 4 && str[4] == 'g') && (d == 'y' || d == 'a')) return {169, 169, 169};
// [Da]rk[G]r[een] // [Da]rk[G]r[een]
else if ((len > 4 && str[4] == 'g') && (d == 'n' || d == 'e')) return Color3(0, 100, 0); else if ((len > 4 && str[4] == 'g') && (d == 'n' || d == 'e')) return {0, 100, 0};
// [Da]rk[K]hak[i] // [Da]rk[K]hak[i]
else if (d == 'i' || c == 'k' || (len > 4 && str[4] == 'k')) return Color3(189, 183, 107); else if (d == 'i' || c == 'k' || (len > 4 && str[4] == 'k')) return {189, 183, 107};
// [Da]rk[M]agent[a] // [Da]rk[M]agent[a]
else if (d == 'a' || c == 'm' || (len > 4 && str[4] == 'm')) return Color3(139, 0, 139); else if (d == 'a' || c == 'm' || (len > 4 && str[4] == 'm')) return {139, 0, 139};
// [Da]rk[O]liveGr[een] // [Da]rk[O]liveGr[een]
else if ((len > 4 && str[4] == 'o') && (d == 'n' || d == 'e')) return Color3(85, 107, 47); else if ((len > 4 && str[4] == 'o') && (d == 'n' || d == 'e')) return {85, 107, 47};
// [Da]rk[O]r[a]ng[e] // [Da]rk[O]r[a]ng[e]
else if ((len > 4 && str[4] == 'o') && (d == 'e' || d == 'a')) return Color3(255, 140, 0); else if ((len > 4 && str[4] == 'o') && (d == 'e' || d == 'a')) return {255, 140, 0};
// [Da]rk[O]r[c]hi[d] // [Da]rk[O]r[c]hi[d]
else if ((len > 4 && str[4] == 'o') && (d == 'd' || d == 'c')) return Color3(153, 50, 204); else if ((len > 4 && str[4] == 'o') && (d == 'd' || d == 'c')) return {153, 50, 204};
// [Da]rk[R]ed // [Da]rk[R]ed
else if (len > 4 && str[4] == 'r') return Color3(139, 0, 0); else if (len > 4 && str[4] == 'r') return {139, 0, 0};
// [Da]rk[Sa]lmon // [Da]rk[Sa]lmon
else if (len > 5 && str[4] == 's' && str[5] == 'a') return Color3(233, 150, 122); else if (len > 5 && str[4] == 's' && str[5] == 'a') return {233, 150, 122};
// [Da]rk[Se]aGreen // [Da]rk[Se]aGreen
else if (len > 5 && str[4] == 's' && str[5] == 'e') return Color3(143, 188, 143); else if (len > 5 && str[4] == 's' && str[5] == 'e') return {143, 188, 143};
// [Da]rk[S]lateBlu[e] // [Da]rk[S]lateBlu[e]
else if ((len > 4 && str[4] == 's') && (d == 'e' || d == 'b')) return Color3(72, 61, 139); else if ((len > 4 && str[4] == 's') && (d == 'e' || d == 'b')) return {72, 61, 139};
// [Da]rk[S]lateGra[y] // [Da]rk[S]lateGra[y]
else if ((len > 4 && str[4] == 's') && (d == 'y' || d == 'g')) return Color3(47, 79, 79); else if ((len > 4 && str[4] == 's') && (d == 'y' || d == 'g')) return {47, 79, 79};
// [Da]rk[T]urquoise // [Da]rk[T]urquoise
else if (c == 't' || (len > 4 && str[4] == 't')) return Color3(0, 206, 209); else if (c == 't' || (len > 4 && str[4] == 't')) return {0, 206, 209};
// [Da]rk[V]iolet // [Da]rk[V]iolet
else if (c == 'v' || (len > 4 && str[4] == 'v')) return Color3(148, 0, 211); else if (c == 'v' || (len > 4 && str[4] == 'v')) return {148, 0, 211};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// Default to blank // Default to blank
@ -567,15 +521,15 @@ Color3 GetColorStr(CSStr name)
{ {
// [Fi]re[B]rick // [Fi]re[B]rick
case 'i': case 'i':
case 'b': return Color3(178, 34, 34); case 'b': return {178, 34, 34};
// [Fl]oral[W]hite // [Fl]oral[W]hite
case 'l': case 'l':
case 'w': return Color3(255, 250, 240); case 'w': return {255, 250, 240};
// [Fo]rest[G]reen // [Fo]rest[G]reen
case 'o': case 'o':
case 'g': return Color3(34, 139, 34); case 'g': return {34, 139, 34};
// [Fu]chsia // [Fu]chsia
case 'u': return Color3(255, 0, 255); case 'u': return {255, 0, 255};
// Default to blank // Default to blank
default: return Color3::NIL; default: return Color3::NIL;
} }
@ -588,28 +542,28 @@ Color3 GetColorStr(CSStr name)
// [G]reenYellow // [G]reenYellow
case 'g': case 'g':
// [Ga]insboro // [Ga]insboro
if (b == 'a') return Color3(220, 220, 220); if (b == 'a') return {220, 220, 220};
// [Gh]ost[W]hite // [Gh]ost[W]hite
else if (b == 'h' || b == 'w') return Color3(248, 248, 255); else if (b == 'h' || b == 'w') return {248, 248, 255};
// [Go]ld[e]n[R]od // [Go]ld[e]n[R]od
else if (len > 4 && (str[4] == 'e' || str[4] == 'r')) return Color3(218, 165, 32); else if (len > 4 && (str[4] == 'e' || str[4] == 'r')) return {218, 165, 32};
// [Go]l[d] // [Go]l[d]
else if (b == 'o' && d == 'd') return Color3(255, 215, 0); else if (b == 'o' && d == 'd') return {255, 215, 0};
// [Gray] // [Gray]
else if (b == 'r' && (d == 'y' || d == 'a')) return Color3(128, 128, 128); else if (b == 'r' && (d == 'y' || d == 'a')) return {128, 128, 128};
// [Gr]een // [Gr]een
else if (b == 'r' && d == 'n') return Color3(0, 128, 0); else if (b == 'r' && d == 'n') return {0, 128, 0};
// [Gr]eenYellow // [Gr]eenYellow
else if (b == 'r' && (d == 'w' || (len > 5 && str[5] == 'y'))) return Color3(173, 255, 47); else if (b == 'r' && (d == 'w' || (len > 5 && str[5] == 'y'))) return {173, 255, 47};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [H]oneyDew // [H]oneyDew
// [H]otPink // [H]otPink
case 'h': case 'h':
// [H]o[n]ey[D]e[w] // [H]o[n]ey[D]e[w]
if (d == 'w' || c == 'n' || (len > 5 && str[5] == 'd')) return Color3(240, 255, 240); if (d == 'w' || c == 'n' || (len > 5 && str[5] == 'd')) return {240, 255, 240};
// [H]o[tP]in[k] // [H]o[tP]in[k]
else if (d == 'k' || c == 't' || (len > 3 && str[3] == 'p')) return Color3(255, 105, 180); else if (d == 'k' || c == 't' || (len > 3 && str[3] == 'p')) return {255, 105, 180};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [I]ndianRed // [I]ndianRed
@ -617,15 +571,15 @@ Color3 GetColorStr(CSStr name)
// [I]vory // [I]vory
case 'i': case 'i':
// [In]dian[R]e[d] // [In]dian[R]e[d]
if (b == 'n' && (d == 'd' || d == 'r')) return Color3(205, 92, 92); if (b == 'n' && (d == 'd' || d == 'r')) return {205, 92, 92};
// [In]di[go] // [In]di[go]
else if (b == 'n' && (d == 'o' || d == 'g')) return Color3(75, 0, 130); else if (b == 'n' && (d == 'o' || d == 'g')) return {75, 0, 130};
// [I]vory // [I]vory
else if (b == 'v') return Color3(255, 255, 240); else if (b == 'v') return {255, 255, 240};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [K]haki // [K]haki
case 'k': return Color3(240, 230, 140); case 'k': return {240, 230, 140};
// [L]avender // [L]avender
// [L]avenderBlush // [L]avenderBlush
// [L]awnGreen // [L]awnGreen
@ -648,19 +602,19 @@ Color3 GetColorStr(CSStr name)
// [L]inen // [L]inen
case 'l': case 'l':
// [La]vende[r] // [La]vende[r]
if (b == 'a' && d == 'r') return Color3(230, 230, 250); if (b == 'a' && d == 'r') return {230, 230, 250};
// [La]vender[B]lus[h] // [La]vender[B]lus[h]
else if (b == 'a' && (d == 'h' || d == 'b')) return Color3(255, 240, 245); else if (b == 'a' && (d == 'h' || d == 'b')) return {255, 240, 245};
// [Law]n[G]ree[n] // [Law]n[G]ree[n]
else if (b == 'g' || (b == 'a' && (c == 'w' || d == 'n'))) return Color3(124, 252, 0); else if (b == 'g' || (b == 'a' && (c == 'w' || d == 'n'))) return {124, 252, 0};
// [Le]mon[C]hiffon // [Le]mon[C]hiffon
else if (b == 'e' || b == 'c') return Color3(255, 250, 205); else if (b == 'e' || b == 'c') return {255, 250, 205};
// [Li]me[G]reen // [Li]me[G]reen
else if (b == 'g' || (b == 'i' && (len > 4 && str[4] == 'g'))) return Color3(50, 205, 50); else if (b == 'g' || (b == 'i' && (len > 4 && str[4] == 'g'))) return {50, 205, 50};
// [Lime] // [Lime]
else if (b == 'i' && c == 'm' && d == 'e') return Color3(0, 255, 0); else if (b == 'i' && c == 'm' && d == 'e') return {0, 255, 0};
// [Lin]e[n] // [Lin]e[n]
else if (b == 'i' && (c == 'n' || d == 'n')) return Color3(250, 240, 230); else if (b == 'i' && (c == 'n' || d == 'n')) return {250, 240, 230};
// [Li]ghtBlue // [Li]ghtBlue
// [Li]ghtCoral // [Li]ghtCoral
// [Li]ghtCyan // [Li]ghtCyan
@ -676,31 +630,31 @@ Color3 GetColorStr(CSStr name)
// [Li]ghtYellow // [Li]ghtYellow
else if (b == 'i') { else if (b == 'i') {
// [Li]ght[B]lue // [Li]ght[B]lue
if (len > 5 && str[5] == 'b') return Color3(173, 216, 230); if (len > 5 && str[5] == 'b') return {173, 216, 230};
// [Li]ght[Co]ra[l] // [Li]ght[Co]ra[l]
else if ((len > 5 && str[5] == 'c') && (d == 'l' || d == 'o')) return Color3(240, 128, 128); else if ((len > 5 && str[5] == 'c') && (d == 'l' || d == 'o')) return {240, 128, 128};
// [Li]ght[Cy]a[n] // [Li]ght[Cy]a[n]
else if ((len > 5 && str[5] == 'c') && (d == 'n' || d == 'y')) return Color3(224, 255, 255); else if ((len > 5 && str[5] == 'c') && (d == 'n' || d == 'y')) return {224, 255, 255};
// [Li]ght[Go]ldenRodYello[w] // [Li]ght[Go]ldenRodYello[w]
else if ((len > 5 && str[5] == 'g') && (d == 'w' || d == 'o')) return Color3(250, 250, 210); else if ((len > 5 && str[5] == 'g') && (d == 'w' || d == 'o')) return {250, 250, 210};
// [Li]ght[G]r[ay] // [Li]ght[G]r[ay]
else if ((len > 5 && str[5] == 'g') && (d == 'y' || d == 'a')) return Color3(211, 211, 211); else if ((len > 5 && str[5] == 'g') && (d == 'y' || d == 'a')) return {211, 211, 211};
// [Li]ght[G]r[een] // [Li]ght[G]r[een]
else if ((len > 5 && str[5] == 'g') && (d == 'n' || d == 'e')) return Color3(144, 238, 144); else if ((len > 5 && str[5] == 'g') && (d == 'n' || d == 'e')) return {144, 238, 144};
// [Li]ght[P]ink // [Li]ght[P]ink
else if (len > 5 && str[5] == 'p') return Color3(255, 182, 193); else if (len > 5 && str[5] == 'p') return {255, 182, 193};
// [Li]ght[Sa]lmon // [Li]ght[Sa]lmon
else if (len > 6 && str[5] == 's' && str[5] == 'a') return Color3(255, 160, 122); else if (len > 6 && str[5] == 's' && str[5] == 'a') return {255, 160, 122};
// [Li]ght[Se]aGreen // [Li]ght[Se]aGreen
else if (len > 6 && str[5] == 's' && str[5] == 'e') return Color3(32, 178, 170); else if (len > 6 && str[5] == 's' && str[5] == 'e') return {32, 178, 170};
// [Li]ght[Sk]yBlue // [Li]ght[Sk]yBlue
else if (len > 6 && str[5] == 's' && str[5] == 'k') return Color3(135, 206, 250); else if (len > 6 && str[5] == 's' && str[5] == 'k') return {135, 206, 250};
// [Li]ght[Sl]ateGray // [Li]ght[Sl]ateGray
else if (len > 6 && str[5] == 's' && str[5] == 'l') return Color3(119, 136, 153); else if (len > 6 && str[5] == 's' && str[5] == 'l') return {119, 136, 153};
// [Li]ght[St]eelBlue // [Li]ght[St]eelBlue
else if (len > 6 && str[5] == 's' && str[5] == 't') return Color3(176, 196, 222); else if (len > 6 && str[5] == 's' && str[5] == 't') return {176, 196, 222};
// [Li]ght[Y]ellow // [Li]ght[Y]ellow
else if (len > 5 && str[5] == 'y') return Color3(255, 255, 224); else if (len > 5 && str[5] == 'y') return {255, 255, 224};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// Default to blank // Default to blank
@ -722,9 +676,9 @@ Color3 GetColorStr(CSStr name)
// [M]occasin // [M]occasin
case 'm': case 'm':
// [Ma]genta // [Ma]genta
if (b == 'a' && (c == 'a' || d == 'a')) return Color3(255, 0, 255); if (b == 'a' && (c == 'a' || d == 'a')) return {255, 0, 255};
// [Ma]roon // [Ma]roon
else if (b == 'a' && (c == 'r' || d == 'n' || d == 'o')) return Color3(128, 0, 0); else if (b == 'a' && (c == 'r' || d == 'n' || d == 'o')) return {128, 0, 0};
// [Me]diumAquaMarine // [Me]diumAquaMarine
// [Me]diumBlue // [Me]diumBlue
// [Me]diumOrchid // [Me]diumOrchid
@ -736,43 +690,43 @@ Color3 GetColorStr(CSStr name)
// [Me]diumVioletRed // [Me]diumVioletRed
else if (b == 'e') { else if (b == 'e') {
// [Me]dium[A]quaMarine // [Me]dium[A]quaMarine
if (c == 'a' || (len > 6 && str[6] == 'a')) return Color3(102, 205, 170); if (c == 'a' || (len > 6 && str[6] == 'a')) return {102, 205, 170};
// [Me]dium[B]lue // [Me]dium[B]lue
else if (c == 'b' || (len > 6 && str[6] == 'b')) return Color3(0, 0, 205); else if (c == 'b' || (len > 6 && str[6] == 'b')) return {0, 0, 205};
// [Me]dium[O]rchid // [Me]dium[O]rchid
else if (c == 'o' || (len > 6 && str[6] == 'o')) return Color3(186, 85, 211); else if (c == 'o' || (len > 6 && str[6] == 'o')) return {186, 85, 211};
// [Me]dium[P]urple // [Me]dium[P]urple
else if (c == 'p' || (len > 6 && str[6] == 'p')) return Color3(147, 112, 219); else if (c == 'p' || (len > 6 && str[6] == 'p')) return {147, 112, 219};
// [Me]dium[T]urquoise // [Me]dium[T]urquoise
else if (c == 't' || (len > 6 && str[6] == 't')) return Color3(72, 209, 204); else if (c == 't' || (len > 6 && str[6] == 't')) return {72, 209, 204};
// [Me]dium[V]ioletRed // [Me]dium[V]ioletRed
else if (c == 'v' || (len > 6 && str[6] == 'v')) return Color3(199, 21, 133); else if (c == 'v' || (len > 6 && str[6] == 'v')) return {199, 21, 133};
// [Me]dium[Se]aGreen // [Me]dium[Se]aGreen
else if (len > 7 && str[6] == 's' && str[7] == 'e') return Color3(60, 179, 113); else if (len > 7 && str[6] == 's' && str[7] == 'e') return {60, 179, 113};
// [Me]dium[Sl]ateBlue // [Me]dium[Sl]ateBlue
else if (len > 7 && str[6] == 's' && str[7] == 'l') return Color3(123, 104, 238); else if (len > 7 && str[6] == 's' && str[7] == 'l') return {123, 104, 238};
// [Me]dium[Sp]ringGreen // [Me]dium[Sp]ringGreen
else if (len > 7 && str[6] == 's' && str[7] == 'p') return Color3(0, 250, 154); else if (len > 7 && str[6] == 's' && str[7] == 'p') return {0, 250, 154};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
} }
// [Mi]dnightBlue // [Mi]dnightBlue
else if (b == 'i' && c == 'd') return Color3(25, 25, 112); else if (b == 'i' && c == 'd') return {25, 25, 112};
// [Mi]ntCream // [Mi]ntCream
else if (b == 'i' && c == 'n') return Color3(245, 255, 250); else if (b == 'i' && c == 'n') return {245, 255, 250};
// [Mi]styRose // [Mi]styRose
else if (b == 'i' && c == 's') return Color3(255, 228, 225); else if (b == 'i' && c == 's') return {255, 228, 225};
// [Mo]ccasin // [Mo]ccasin
else if (b == 'o') return Color3(255, 228, 181); else if (b == 'o') return {255, 228, 181};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [N]avajoWhite // [N]avajoWhite
// [N]avy // [N]avy
case 'n': case 'n':
// [Na]vajo[W]hite // [Na]vajo[W]hite
if (c == 'v' || c == 'w') return Color3(255, 222, 173); if (c == 'v' || c == 'w') return {255, 222, 173};
// [Na]v[y] // [Na]v[y]
else if (c == 'a' || d == 'y') return Color3(0, 0, 128); else if (c == 'a' || d == 'y') return {0, 0, 128};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [O]ldLace // [O]ldLace
@ -783,17 +737,17 @@ Color3 GetColorStr(CSStr name)
// [O]rchid // [O]rchid
case 'o': case 'o':
// [Old]Lace // [Old]Lace
if (b == 'l' && c == 'd') return Color3(253, 245, 230); if (b == 'l' && c == 'd') return {253, 245, 230};
// [Ol]ive[D]ra[b] // [Ol]ive[D]ra[b]
else if (b == 'l' && (d == 'b' || d == 'd')) return Color3(107, 142, 35); else if (b == 'l' && (d == 'b' || d == 'd')) return {107, 142, 35};
// [Ol]iv[e] // [Ol]iv[e]
else if (b == 'l' && d == 'e') return Color3(128, 128, 0); else if (b == 'l' && d == 'e') return {128, 128, 0};
// [Or]ange[R]e[d] // [Or]ange[R]e[d]
else if (b == 'r' && (d == 'd' || d == 'r')) return Color3(255, 69, 0); else if (b == 'r' && (d == 'd' || d == 'r')) return {255, 69, 0};
// [Or]ang[e] // [Or]ang[e]
else if (b == 'r' && d == 'e') return Color3(255, 165, 0); else if (b == 'r' && d == 'e') return {255, 165, 0};
// [Orc]hid // [Orc]hid
else if (d == 'c') return Color3(218, 112, 214); else if (d == 'c') return {218, 112, 214};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [P]aleGoldenRod // [P]aleGoldenRod
@ -809,27 +763,27 @@ Color3 GetColorStr(CSStr name)
// [P]urple // [P]urple
case 'p': case 'p':
// [Pu]rple // [Pu]rple
if (b == 'u') return Color3(128, 0, 128); if (b == 'u') return {128, 0, 128};
// [Po]wderBlue // [Po]wderBlue
else if (b == 'o') return Color3(176, 224, 230); else if (b == 'o') return {176, 224, 230};
// [Pi]nk // [Pi]nk
else if (b == 'i') return Color3(255, 192, 203); else if (b == 'i') return {255, 192, 203};
// [Pl]um // [Pl]um
else if (b == 'l') return Color3(221, 160, 221); else if (b == 'l') return {221, 160, 221};
// [Pea]chPuff // [Pea]chPuff
else if (b == 'e' && c == 'a') return Color3(255, 218, 185); else if (b == 'e' && c == 'a') return {255, 218, 185};
// [Per]u // [Per]u
else if (b == 'e' && c == 'r') return Color3(205, 133, 63); else if (b == 'e' && c == 'r') return {205, 133, 63};
// [Pa]payaWhip // [Pa]payaWhip
else if (b == 'a' && c == 'p') return Color3(255, 239, 213); else if (b == 'a' && c == 'p') return {255, 239, 213};
// [Pa]le[Go]ldenRod // [Pa]le[Go]ldenRod
else if (b == 'a' && (len > 5 && str[4] == 'g' && str[5] == 'o')) return Color3(238, 232, 170); else if (b == 'a' && (len > 5 && str[4] == 'g' && str[5] == 'o')) return {238, 232, 170};
// [Pa]le[Gr]een // [Pa]le[Gr]een
else if (b == 'a' && (len > 5 && str[4] == 'g' && str[5] == 'r')) return Color3(152, 251, 152); else if (b == 'a' && (len > 5 && str[4] == 'g' && str[5] == 'r')) return {152, 251, 152};
// [Pa]le[T]urquoise // [Pa]le[T]urquoise
else if (b == 'a' && (len > 4 && str[4] == 't')) return Color3(175, 238, 238); else if (b == 'a' && (len > 4 && str[4] == 't')) return {175, 238, 238};
// [Pa]le[V]ioletRed // [Pa]le[V]ioletRed
else if (b == 'a' && (len > 4 && str[4] == 'v')) return Color3(219, 112, 147); else if (b == 'a' && (len > 4 && str[4] == 'v')) return {219, 112, 147};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [R]ed // [R]ed
@ -837,11 +791,11 @@ Color3 GetColorStr(CSStr name)
// [R]oyalBlue // [R]oyalBlue
case 'r': case 'r':
// [Re]d // [Re]d
if (b == 'e') return Color3(255, 0, 0); if (b == 'e') return {255, 0, 0};
// [Ros]yBrown // [Ros]yBrown
else if (b == 'o' && c == 's') return Color3(188, 143, 143); else if (b == 'o' && c == 's') return {188, 143, 143};
// [Roy]alBlue // [Roy]alBlue
else if (b == 'o' && c == 'y') return Color3(65, 105, 225); else if (b == 'o' && c == 'y') return {65, 105, 225};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [S]addleBrown // [S]addleBrown
@ -859,31 +813,31 @@ Color3 GetColorStr(CSStr name)
// [S]teelBlue // [S]teelBlue
case 's': case 's':
// [Sad]dleBrown // [Sad]dleBrown
if (b == 'a' && c == 'd') return Color3(139, 69, 19); if (b == 'a' && c == 'd') return {139, 69, 19};
// [Sal]mon // [Sal]mon
else if (b == 'a' && c == 'l') return Color3(250, 128, 114); else if (b == 'a' && c == 'l') return {250, 128, 114};
// [San]dyBrown // [San]dyBrown
else if (b == 'a' && c == 'n') return Color3(244, 164, 96); else if (b == 'a' && c == 'n') return {244, 164, 96};
// [Se]a[G]reen // [Se]a[G]reen
else if (b == 'e' && d == 'g') return Color3(46, 139, 87); else if (b == 'e' && d == 'g') return {46, 139, 87};
// [Se]a[S]hell // [Se]a[S]hell
else if (b == 'e' && d == 's') return Color3(255, 245, 238); else if (b == 'e' && d == 's') return {255, 245, 238};
// [Sie]nna // [Sie]nna
else if (b == 'i' && c == 'e') return Color3(160, 82, 45); else if (b == 'i' && c == 'e') return {160, 82, 45};
// [Sil]ver // [Sil]ver
else if (b == 'i' && c == 'l') return Color3(192, 192, 192); else if (b == 'i' && c == 'l') return {192, 192, 192};
// [Sk]yBlue // [Sk]yBlue
else if (b == 'k') return Color3(135, 206, 235); else if (b == 'k') return {135, 206, 235};
// [Sl]ateBlue // [Sl]ateBlue
else if (b == 'l' && (d == 'e' || (len > 5 && str[5] == 'b'))) return Color3(106, 90, 205); else if (b == 'l' && (d == 'e' || (len > 5 && str[5] == 'b'))) return {106, 90, 205};
// [Sl]ateGray // [Sl]ateGray
else if (b == 'l' && (d == 'y' || (len > 5 && str[5] == 'g'))) return Color3(112, 128, 144); else if (b == 'l' && (d == 'y' || (len > 5 && str[5] == 'g'))) return {112, 128, 144};
// [Sn]ow // [Sn]ow
else if (b == 'n') return Color3(255, 250, 250); else if (b == 'n') return {255, 250, 250};
// [Sp]ringGreen // [Sp]ringGreen
else if (b == 'p') return Color3(0, 255, 127); else if (b == 'p') return {0, 255, 127};
// [St]eelBlue // [St]eelBlue
else if (b == 't') return Color3(70, 130, 180); else if (b == 't') return {70, 130, 180};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [T]an // [T]an
@ -895,39 +849,39 @@ Color3 GetColorStr(CSStr name)
switch(b) switch(b)
{ {
// [Ta]n // [Ta]n
case 'a': return Color3(210, 180, 140); case 'a': return {210, 180, 140};
// [Te]al // [Te]al
case 'e': return Color3(0, 128, 128); case 'e': return {0, 128, 128};
// [Th]istle // [Th]istle
case 'h': return Color3(216, 191, 216); case 'h': return {216, 191, 216};
// [To]mato // [To]mato
case 'o': return Color3(255, 99, 71); case 'o': return {255, 99, 71};
// [Tu]rquoise // [Tu]rquoise
case 'u': return Color3(64, 224, 208); case 'u': return {64, 224, 208};
// Default to blank // Default to blank
default: return Color3::NIL; default: return Color3::NIL;
} }
// [V]iolet // [V]iolet
case 'v': return Color3(238, 130, 238); case 'v': return {238, 130, 238};
// [W]heat // [W]heat
// [W]hite // [W]hite
// [W]hiteSmoke // [W]hiteSmoke
case 'w': case 'w':
// [Wh]eat // [Wh]eat
if (b == 'h' && c == 'e') return Color3(245, 222, 179); if (b == 'h' && c == 'e') return {245, 222, 179};
// [Wh]ite[S]moke // [Wh]ite[S]moke
else if (b == 'h' && (len > 5 && str[5] == 's')) return Color3(245, 245, 245); else if (b == 'h' && (len > 5 && str[5] == 's')) return {245, 245, 245};
// [Whi]te // [Whi]te
else if (b == 'h' && c == 'i') return Color3(255, 255, 255); else if (b == 'h' && c == 'i') return {255, 255, 255};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// [Y]ellow // [Y]ellow
// [Y]ellowGreen // [Y]ellowGreen
case 'y': case 'y':
// [Ye]llow[G]reen // [Ye]llow[G]reen
if (b == 'e' && (len > 6 && str[6] == 'g')) return Color3(154, 205, 50); if (b == 'e' && (len > 6 && str[6] == 'g')) return {154, 205, 50};
// [Yel]low // [Yel]low
else if (b == 'e' && c == 'l') return Color3(255, 255, 0); else if (b == 'e' && c == 'l') return {255, 255, 0};
// Default to blank // Default to blank
else return Color3::NIL; else return Color3::NIL;
// Default to blank // Default to blank
@ -963,8 +917,8 @@ void SqThrowLastF(CSStr msg, ...)
LPSTR msg_buff = nullptr; LPSTR msg_buff = nullptr;
// Attempt to obtain the error message // Attempt to obtain the error message
const std::size_t size = FormatMessageA( const std::size_t size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, // NOLINT(hicpp-signed-bitwise)
nullptr, error_num, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), nullptr, error_num, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // NOLINT(hicpp-signed-bitwise)
reinterpret_cast< LPSTR >(&msg_buff), 0, nullptr); reinterpret_cast< LPSTR >(&msg_buff), 0, nullptr);
// Copy the message buffer before freeing it // Copy the message buffer before freeing it
std::string message(msg_buff, size); std::string message(msg_buff, size);
@ -981,7 +935,7 @@ void SqThrowLastF(CSStr msg, ...)
static SQInteger SqPackRGB(SQInteger r, SQInteger g, SQInteger b) static SQInteger SqPackRGB(SQInteger r, SQInteger g, SQInteger b)
{ {
return static_cast< Int32 >(SQMOD_PACK_RGB( return static_cast< Int32 >(SQMOD_PACK_RGB(
ConvTo< Uint8 >::From(r), ConvTo< Uint8 >::From(r), // NOLINT(hicpp-signed-bitwise)
ConvTo< Uint8 >::From(g), ConvTo< Uint8 >::From(g),
ConvTo< Uint8 >::From(b) ConvTo< Uint8 >::From(b)
)); ));
@ -991,7 +945,7 @@ static SQInteger SqPackRGB(SQInteger r, SQInteger g, SQInteger b)
static SQInteger SqPackRGBA(SQInteger r, SQInteger g, SQInteger b, SQInteger a) static SQInteger SqPackRGBA(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
{ {
return static_cast< Int32 >(SQMOD_PACK_RGBA( return static_cast< Int32 >(SQMOD_PACK_RGBA(
ConvTo< Uint8 >::From(r), ConvTo< Uint8 >::From(r), // NOLINT(hicpp-signed-bitwise)
ConvTo< Uint8 >::From(g), ConvTo< Uint8 >::From(g),
ConvTo< Uint8 >::From(b), ConvTo< Uint8 >::From(b),
ConvTo< Uint8 >::From(a) ConvTo< Uint8 >::From(a)
@ -1002,7 +956,7 @@ static SQInteger SqPackRGBA(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
static SQInteger SqPackARGB(SQInteger r, SQInteger g, SQInteger b, SQInteger a) static SQInteger SqPackARGB(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
{ {
return static_cast< Int32 >(SQMOD_PACK_ARGB( return static_cast< Int32 >(SQMOD_PACK_ARGB(
ConvTo< Uint8 >::From(a), ConvTo< Uint8 >::From(a), // NOLINT(hicpp-signed-bitwise)
ConvTo< Uint8 >::From(r), ConvTo< Uint8 >::From(r),
ConvTo< Uint8 >::From(g), ConvTo< Uint8 >::From(g),
ConvTo< Uint8 >::From(b) ConvTo< Uint8 >::From(b)
@ -1038,7 +992,7 @@ static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
return name.mRes; // Propagate the error! return name.mRes; // Propagate the error!
} }
// Make the comparison and push the result on the stack // Make the comparison and push the result on the stack
sq_pushbool(vm, NameFilterCheck(filter.mPtr, name.mPtr)); sq_pushbool(vm, static_cast< SQBool >(NameFilterCheck(filter.mPtr, name.mPtr)));
// Specify that we have a return value on the stack // Specify that we have a return value on the stack
return 1; return 1;
} }
@ -1072,7 +1026,7 @@ static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
return name.mRes; // Propagate the error! return name.mRes; // Propagate the error!
} }
// Make the comparison and push the result on the stack // Make the comparison and push the result on the stack
sq_pushbool(vm, NameFilterCheckInsensitive(filter.mPtr, name.mPtr)); sq_pushbool(vm, static_cast< SQBool >(NameFilterCheckInsensitive(filter.mPtr, name.mPtr)));
// Specify that we have a return value on the stack // Specify that we have a return value on the stack
return 1; return 1;
} }

View File

@ -90,113 +90,6 @@ extern bool cLogSWrn(bool exp, CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 2, 3);
extern bool cLogSErr(bool exp, CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 2, 3); extern bool cLogSErr(bool exp, CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 2, 3);
extern bool cLogSFtl(bool exp, CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 2, 3); extern bool cLogSFtl(bool exp, CCStr fmt, ...) SQMOD_FORMAT_ATTR(printf, 2, 3);
/* ------------------------------------------------------------------------------------------------
* Get a persistent AABB instance with the given values.
*/
extern const AABB & GetAABB();
extern const AABB & GetAABB(Float32 mins, Float32 maxs);
extern const AABB & GetAABB(Float32 xv, Float32 yv, Float32 zv);
extern const AABB & GetAABB(Float32 xmin, Float32 ymin, Float32 zmin, Float32 xmax, Float32 ymax, Float32 zmax);
extern const AABB & GetAABB(const Vector3 & vmin, const Vector3 & vmax);
extern const AABB & GetAABB(const AABB & o);
extern const AABB & GetAABB(AABB && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Circle instance with the given values.
*/
extern const Circle & GetCircle();
extern const Circle & GetCircle(Float32 rv);
extern const Circle & GetCircle(const Vector2 & pv, Float32 rv);
extern const Circle & GetCircle(Float32 xv, Float32 yv, Float32 rv);
extern const Circle & GetCircle(const Circle & o);
extern const Circle & GetCircle(Circle && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Color3 instance with the given values.
*/
extern const Color3 & GetColor3();
extern const Color3 & GetColor3(Uint8 sv);
extern const Color3 & GetColor3(Uint8 rv, Uint8 gv, Uint8 bv);
extern const Color3 & GetColor3(const Color3 & o);
extern const Color3 & GetColor3(Color3 && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Color4 instance with the given values.
*/
extern const Color4 & GetColor4();
extern const Color4 & GetColor4(Uint8 sv);
extern const Color4 & GetColor4(Uint8 rv, Uint8 gv, Uint8 bv);
extern const Color4 & GetColor4(Uint8 rv, Uint8 gv, Uint8 bv, Uint8 av);
extern const Color4 & GetColor4(const Color4 & o);
extern const Color4 & GetColor4(Color4 && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Quaternion instance with the given values.
*/
extern const Quaternion & GetQuaternion();
extern const Quaternion & GetQuaternion(Float32 sv);
extern const Quaternion & GetQuaternion(Float32 xv, Float32 yv, Float32 zv);
extern const Quaternion & GetQuaternion(Float32 xv, Float32 yv, Float32 zv, Float32 wv);
extern const Quaternion & GetQuaternion(const Quaternion & o);
extern const Quaternion & GetQuaternion(Quaternion && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Sphere instance with the given values.
*/
extern const Sphere & GetSphere();
extern const Sphere & GetSphere(Float32 rv);
extern const Sphere & GetSphere(const Vector3 & pv, Float32 rv);
extern const Sphere & GetSphere(Float32 xv, Float32 yv, Float32 zv, Float32 rv);
extern const Sphere & GetSphere(const Sphere & o);
extern const Sphere & GetSphere(Sphere && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Vector2 instance with the given values.
*/
extern const Vector2 & GetVector2();
extern const Vector2 & GetVector2(Float32 sv);
extern const Vector2 & GetVector2(Float32 xv, Float32 yv);
extern const Vector2 & GetVector2(const Vector2 & o);
extern const Vector2 & GetVector2(Vector2 && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Vector2i instance with the given values.
*/
extern const Vector2i & GetVector2i();
extern const Vector2i & GetVector2i(Int32 sv);
extern const Vector2i & GetVector2i(Int32 xv, Int32 yv);
extern const Vector2i & GetVector2i(const Vector2i & o);
extern const Vector2i & GetVector2i(Vector2i && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Vector3 instance with the given values.
*/
extern const Vector3 & GetVector3();
extern const Vector3 & GetVector3(Float32 sv);
extern const Vector3 & GetVector3(Float32 xv, Float32 yv, Float32 zv);
extern const Vector3 & GetVector3(const Vector3 & o);
extern const Vector3 & GetVector3(Vector3 && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent Vector4 instance with the given values.
*/
extern const Vector4 & GetVector4();
extern const Vector4 & GetVector4(Float32 sv);
extern const Vector4 & GetVector4(Float32 xv, Float32 yv, Float32 zv);
extern const Vector4 & GetVector4(Float32 xv, Float32 yv, Float32 zv, Float32 wv);
extern const Vector4 & GetVector4(const Vector4 & o);
extern const Vector4 & GetVector4(Vector4 && o);
/* ------------------------------------------------------------------------------------------------
* Get a persistent LongInt instance with the given values.
*/
const SLongInt & GetSLongInt();
const SLongInt & GetSLongInt(Int64 n);
const SLongInt & GetSLongInt(CSStr s);
const ULongInt & GetULongInt();
const ULongInt & GetULongInt(Uint64 n);
const ULongInt & GetULongInt(CSStr s);
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Initialize a signal instance into the specified pair. * Initialize a signal instance into the specified pair.
*/ */

View File

@ -22,28 +22,28 @@ const Sphere Sphere::MAX = Sphere(std::numeric_limits< Sphere::Value >::max());
SQChar Sphere::Delim = ','; SQChar Sphere::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere::Sphere() Sphere::Sphere() noexcept
: pos(0.0), rad(0.0) : pos(0.0), rad(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere::Sphere(Value rv) Sphere::Sphere(Value rv) noexcept
: pos(0.0), rad(rv) : pos(0.0), rad(rv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere::Sphere(const Vector3 & pv, Value rv) Sphere::Sphere(const Vector3 & pv, Value rv) noexcept
: pos(pv), rad(rv) : pos(pv), rad(rv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere::Sphere(Value xv, Value yv, Value zv, Value rv) Sphere::Sphere(Value xv, Value yv, Value zv, Value rv) noexcept
: pos(xv, yv, zv), rad(rv) : pos(xv, yv, zv), rad(rv)
{ {
/* ... */ /* ... */
@ -191,7 +191,7 @@ Sphere & Sphere::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator ++ (int) Sphere Sphere::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Sphere state(*this); Sphere state(*this);
++pos; ++pos;
@ -200,7 +200,7 @@ Sphere Sphere::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator -- (int) Sphere Sphere::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Sphere state(*this); Sphere state(*this);
--pos; --pos;
@ -211,103 +211,103 @@ Sphere Sphere::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (const Sphere & s) const Sphere Sphere::operator + (const Sphere & s) const
{ {
return Sphere(pos + s.pos, rad + s.rad); return {pos + s.pos, rad + s.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator - (const Sphere & s) const Sphere Sphere::operator - (const Sphere & s) const
{ {
return Sphere(pos - s.pos, rad - s.rad); return {pos - s.pos, rad - s.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator * (const Sphere & s) const Sphere Sphere::operator * (const Sphere & s) const
{ {
return Sphere(pos * s.pos, rad * s.rad); return {pos * s.pos, rad * s.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator / (const Sphere & s) const Sphere Sphere::operator / (const Sphere & s) const
{ {
return Sphere(pos / s.pos, rad / s.rad); return {pos / s.pos, rad / s.rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator % (const Sphere & s) const Sphere Sphere::operator % (const Sphere & s) const
{ {
return Sphere(pos % s.pos, std::fmod(rad, s.rad)); return {pos % s.pos, std::fmod(rad, s.rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (Value r) const Sphere Sphere::operator + (Value r) const
{ {
return Sphere(rad + r); return {rad + r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator - (Value r) const Sphere Sphere::operator - (Value r) const
{ {
return Sphere(rad - r); return {rad - r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator * (Value r) const Sphere Sphere::operator * (Value r) const
{ {
return Sphere(rad * r); return {rad * r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator / (Value r) const Sphere Sphere::operator / (Value r) const
{ {
return Sphere(rad / r); return {rad / r};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator % (Value r) const Sphere Sphere::operator % (Value r) const
{ {
return Sphere(std::fmod(rad, r)); return {std::fmod(rad, r)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (const Vector3 & p) const Sphere Sphere::operator + (const Vector3 & p) const
{ {
return Sphere(pos + p, rad); return {pos + p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator - (const Vector3 & p) const Sphere Sphere::operator - (const Vector3 & p) const
{ {
return Sphere(pos - p, rad); return {pos - p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator * (const Vector3 & p) const Sphere Sphere::operator * (const Vector3 & p) const
{ {
return Sphere(pos * p, rad); return {pos * p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator / (const Vector3 & p) const Sphere Sphere::operator / (const Vector3 & p) const
{ {
return Sphere(pos / p, rad); return {pos / p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator % (const Vector3 & p) const Sphere Sphere::operator % (const Vector3 & p) const
{ {
return Sphere(pos % p, rad); return {pos % p, rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + () const Sphere Sphere::operator + () const
{ {
return Sphere(pos.Abs(), std::fabs(rad)); return {pos.Abs(), std::fabs(rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::operator - () const Sphere Sphere::operator - () const
{ {
return Sphere(-pos, -rad); return {-pos, -rad};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -464,7 +464,7 @@ void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Sphere Sphere::Abs() const Sphere Sphere::Abs() const
{ {
return Sphere(pos.Abs(), std::fabs(rad)); return {pos.Abs(), std::fabs(rad)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -496,48 +496,11 @@ const Sphere & Sphere::GetEx(SQChar delim, StackStrF & str)
return sphere; return sphere;
} }
// ------------------------------------------------------------------------------------------------
const Sphere & GetSphere()
{
static Sphere sphere;
sphere.Clear();
return sphere;
}
// ------------------------------------------------------------------------------------------------
const Sphere & GetSphere(Float32 rv)
{
static Sphere sphere;
sphere.SetRadius(rv);
return sphere;
}
// ------------------------------------------------------------------------------------------------
const Sphere & GetSphere(const Vector3 & pv, Float32 rv)
{
static Sphere sphere;
sphere.SetValues(pv, rv);
return sphere;
}
// ------------------------------------------------------------------------------------------------
const Sphere & GetSphere(Float32 xv, Float32 yv, Float32 zv, Float32 rv)
{
static Sphere sphere;
sphere.SetSphereEx(xv, yv, zv, rv);
return sphere;
}
// ------------------------------------------------------------------------------------------------
const Sphere & GetSphere(const Sphere & o)
{
static Sphere sphere;
sphere.SetSphere(o);
return sphere;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Sphere(HSQUIRRELVM vm) void Register_Sphere(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Sphere::Value Val; typedef Sphere::Value Val;

View File

@ -38,32 +38,32 @@ struct Sphere
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Sphere(); Sphere() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a sphere at position 0,0,0 using the specified radius. * Construct a sphere at position 0,0,0 using the specified radius.
*/ */
explicit Sphere(Value rv); Sphere(Value rv) noexcept; // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a sphere at the specified position using the specified radius. * Construct a sphere at the specified position using the specified radius.
*/ */
Sphere(const Vector3 & pv, Value rv); Sphere(const Vector3 & pv, Value rv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a sphere at the specified position using the specified radius. * Construct a sphere at the specified position using the specified radius.
*/ */
Sphere(Value xv, Value yv, Value zv, Value rv); Sphere(Value xv, Value yv, Value zv, Value rv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Sphere(const Sphere & o) = default; Sphere(const Sphere & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Sphere(Sphere && o) = default; Sphere(Sphere && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -178,12 +178,12 @@ struct Sphere
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Sphere operator ++ (int); Sphere operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Sphere operator -- (int); Sphere operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -58,7 +58,7 @@ static inline void OutputMessageImpl(CCStr msg, va_list args)
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN); SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
std::printf("[SQMOD] "); std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::vprintf(msg, args); std::vprintf(msg, args);
std::puts(""); std::puts("");
@ -80,10 +80,10 @@ static inline void OutputErrorImpl(CCStr msg, va_list args)
CONSOLE_SCREEN_BUFFER_INFO csb_before; CONSOLE_SCREEN_BUFFER_INFO csb_before;
GetConsoleScreenBufferInfo( hstdout, &csb_before); GetConsoleScreenBufferInfo( hstdout, &csb_before);
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY); SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::printf("[SQMOD] "); std::printf("[SQMOD] ");
SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY); // NOLINT(hicpp-signed-bitwise)
std::vprintf(msg, args); std::vprintf(msg, args);
std::puts(""); std::puts("");
@ -150,7 +150,7 @@ void SqThrowF(CSStr str, ...)
// Finalize the argument list // Finalize the argument list
va_end(args); va_end(args);
// Throw the exception with the resulted message // Throw the exception with the resulted message
throw Sqrat::Exception(g_Buffer); throw Sqrat::Exception(g_Buffer); // NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -237,9 +237,9 @@ bool SToB(CSStr str)
} }
// Add the null terminator // Add the null terminator
buffer[i] = '\0'; buffer[i] = '\0';
// Compare the lowercase string and return the result // Compare the lowercase string and return the result
return (std::strcmp(buffer, "true") == 0 || std::strcmp(buffer, "yes") == 0 || return std::strcmp(buffer, "true") == 0 || std::strcmp(buffer, "yes") == 0 ||
std::strcmp(buffer, "on") == 0 || std::strcmp(buffer, "1") == 0) ? true : false; std::strcmp(buffer, "on") == 0 || std::strcmp(buffer, "1") == 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -587,12 +587,12 @@ CSStr ConvNum< bool >::ToStr(bool v)
bool ConvNum< bool >::FromStr(CSStr s) bool ConvNum< bool >::FromStr(CSStr s)
{ {
return (std::strcmp(s, "true") == 0) ? true : false; return std::strcmp(s, "true") == 0;
} }
bool ConvNum< bool >::FromStr(CSStr s, Int32 /*base*/) bool ConvNum< bool >::FromStr(CSStr s, Int32 /*base*/)
{ {
return (std::strcmp(s, "true") == 0) ? true : false; return std::strcmp(s, "true") == 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -640,7 +640,7 @@ String SqTypeName(HSQUIRRELVM vm, SQInteger idx)
return _SC("unknown"); return _SC("unknown");
} }
// Return the obtained string value // Return the obtained string value
return String(val.mPtr, val.mLen); return String(val.mPtr, static_cast< size_t >(val.mLen));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -681,19 +681,19 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
SQInteger val; SQInteger val;
sq_getinteger(vm, idx, &val); sq_getinteger(vm, idx, &val);
return val; return val;
} break; }
case OT_FLOAT: case OT_FLOAT:
{ {
SQFloat val; SQFloat val;
sq_getfloat(vm, idx, &val); sq_getfloat(vm, idx, &val);
return ConvTo< SQInteger >::From(val); return ConvTo< SQInteger >::From(val);
} break; }
case OT_BOOL: case OT_BOOL:
{ {
SQBool val; SQBool val;
sq_getbool(vm, idx, &val); sq_getbool(vm, idx, &val);
return static_cast< SQInteger >(val); return static_cast< SQInteger >(val);
} break; }
case OT_STRING: case OT_STRING:
{ {
CSStr val = nullptr; CSStr val = nullptr;
@ -701,15 +701,15 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0') if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
{ {
return ConvTo< SQInteger >::From(std::strtoll(val, nullptr, 10)); return ConvTo< SQInteger >::From(std::strtoll(val, nullptr, 10));
} } else break;
} break; }
case OT_ARRAY: case OT_ARRAY:
case OT_TABLE: case OT_TABLE:
case OT_CLASS: case OT_CLASS:
case OT_USERDATA: case OT_USERDATA:
{ {
return sq_getsize(vm, idx); return sq_getsize(vm, idx);
} break; }
case OT_INSTANCE: case OT_INSTANCE:
{ {
// Attempt to treat the value as a signed long instance // Attempt to treat the value as a signed long instance
@ -732,7 +732,7 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
} }
// Attempt to get the size of the instance as a fall back // Attempt to get the size of the instance as a fall back
return sq_getsize(vm, idx); return sq_getsize(vm, idx);
} break; }
default: break; default: break;
} }
// Default to 0 // Default to 0
@ -750,19 +750,19 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
SQFloat val; SQFloat val;
sq_getfloat(vm, idx, &val); sq_getfloat(vm, idx, &val);
return val; return val;
} break; }
case OT_INTEGER: case OT_INTEGER:
{ {
SQInteger val; SQInteger val;
sq_getinteger(vm, idx, &val); sq_getinteger(vm, idx, &val);
return ConvTo< SQFloat >::From(val); return ConvTo< SQFloat >::From(val);
} break; }
case OT_BOOL: case OT_BOOL:
{ {
SQBool val; SQBool val;
sq_getbool(vm, idx, &val); sq_getbool(vm, idx, &val);
return ConvTo< SQFloat >::From(val); return ConvTo< SQFloat >::From(val);
} break; }
case OT_STRING: case OT_STRING:
{ {
CSStr val = nullptr; CSStr val = nullptr;
@ -774,15 +774,15 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
#else #else
return std::strtof(val, nullptr); return std::strtof(val, nullptr);
#endif // SQUSEDOUBLE #endif // SQUSEDOUBLE
} } else break;
} break; }
case OT_ARRAY: case OT_ARRAY:
case OT_TABLE: case OT_TABLE:
case OT_CLASS: case OT_CLASS:
case OT_USERDATA: case OT_USERDATA:
{ {
return ConvTo< SQFloat >::From(sq_getsize(vm, idx)); return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
} break; }
case OT_INSTANCE: case OT_INSTANCE:
{ {
// Attempt to treat the value as a signed long instance // Attempt to treat the value as a signed long instance
@ -805,7 +805,7 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
} }
// Attempt to get the size of the instance as a fall back // Attempt to get the size of the instance as a fall back
return ConvTo< SQFloat >::From(sq_getsize(vm, idx)); return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
} break; }
default: break; default: break;
} }
// Default to 0 // Default to 0

View File

@ -143,11 +143,11 @@ String & NullString();
inline Uint32 NextPow2(Uint32 num) inline Uint32 NextPow2(Uint32 num)
{ {
--num; --num;
num |= num >> 1; num |= num >> 1u;
num |= num >> 2; num |= num >> 2u;
num |= num >> 4; num |= num >> 4u;
num |= num >> 8; num |= num >> 8u;
num |= num >> 16; num |= num >> 16u;
return ++num; return ++num;
} }
@ -194,33 +194,33 @@ template < > struct EpsCmp< float, float > {
* Perform an equality comparison between two real values taking into account floating point issues. * Perform an equality comparison between two real values taking into account floating point issues.
*/ */
template < > struct EpsCmp< double, double > { template < > struct EpsCmp< double, double > {
static inline bool EQ(const double & a, const double & b) { return fabs(a - b) <= 0.000000001d; } static inline bool EQ(const double & a, const double & b) { return fabs(a - b) <= 0.000000001; }
static inline bool LT(const double & a, const double & b) { return !EQ(a, b) && (a - b) < 0.000000001d; } static inline bool LT(const double & a, const double & b) { return !EQ(a, b) && (a - b) < 0.000000001; }
static inline bool GT(const double & a, const double & b) { return !EQ(a, b) && (a - b) > 0.000000001d; } static inline bool GT(const double & a, const double & b) { return !EQ(a, b) && (a - b) > 0.000000001; }
static inline bool LE(const double & a, const double & b) { return EQ(a, b) || (a - b) < 0.000000001d; } static inline bool LE(const double & a, const double & b) { return EQ(a, b) || (a - b) < 0.000000001; }
static inline bool GE(const double & a, const double & b) { return EQ(a, b) || (a - b) > 0.000000001d; } static inline bool GE(const double & a, const double & b) { return EQ(a, b) || (a - b) > 0.000000001; }
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Perform an equality comparison between two real values taking into account floating point issues. * Perform an equality comparison between two real values taking into account floating point issues.
*/ */
template < > struct EpsCmp< float, double > { template < > struct EpsCmp< float, double > {
static inline bool EQ(const float & a, const double & b) { return fabs(static_cast< double >(a) - b) <= 0.000001d; } static inline bool EQ(const float & a, const double & b) { return fabs(static_cast< double >(a) - b) <= 0.000001; }
static inline bool LT(const float & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) < 0.000001d; } static inline bool LT(const float & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) < 0.000001; }
static inline bool GT(const float & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) > 0.000001d; } static inline bool GT(const float & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) > 0.000001; }
static inline bool LE(const float & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) < 0.000001d; } static inline bool LE(const float & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) < 0.000001; }
static inline bool GE(const float & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) > 0.000001d; } static inline bool GE(const float & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) > 0.000001; }
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Perform an equality comparison between two real values taking into account floating point issues. * Perform an equality comparison between two real values taking into account floating point issues.
*/ */
template < > struct EpsCmp< double, float > { template < > struct EpsCmp< double, float > {
static inline bool EQ(const double & a, const float & b) { return fabs(a - static_cast< double >(b)) <= 0.000001d; } static inline bool EQ(const double & a, const float & b) { return fabs(a - static_cast< double >(b)) <= 0.000001; }
static inline bool LT(const double & a, const float & b) { return !EQ(a, b) && (a - static_cast< double >(b)) < 0.000001d; } static inline bool LT(const double & a, const float & b) { return !EQ(a, b) && (a - static_cast< double >(b)) < 0.000001; }
static inline bool GT(const double & a, const float & b) { return !EQ(a, b) && (a - static_cast< double >(b)) > 0.000001d; } static inline bool GT(const double & a, const float & b) { return !EQ(a, b) && (a - static_cast< double >(b)) > 0.000001; }
static inline bool LE(const double & a, const float & b) { return EQ(a, b) || (a - static_cast< double >(b)) < 0.000001d; } static inline bool LE(const double & a, const float & b) { return EQ(a, b) || (a - static_cast< double >(b)) < 0.000001; }
static inline bool GE(const double & a, const float & b) { return EQ(a, b) || (a - static_cast< double >(b)) > 0.000001d; } static inline bool GE(const double & a, const float & b) { return EQ(a, b) || (a - static_cast< double >(b)) > 0.000001; }
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -249,22 +249,22 @@ template < typename T > struct EpsCmp< T, float > {
* Perform an equality comparison between two real values taking into account floating point issues. * Perform an equality comparison between two real values taking into account floating point issues.
*/ */
template < typename T > struct EpsCmp< double, T > { template < typename T > struct EpsCmp< double, T > {
static inline bool EQ(const double & a, const T & b) { return fabs(a - static_cast< double >(b)) <= 0.000000001d; } static inline bool EQ(const double & a, const T & b) { return fabs(a - static_cast< double >(b)) <= 0.000000001; }
static inline bool LT(const double & a, const T & b) { return !EQ(a, b) && (a - static_cast< double >(b)) < 0.000000001d; } static inline bool LT(const double & a, const T & b) { return !EQ(a, b) && (a - static_cast< double >(b)) < 0.000000001; }
static inline bool GT(const double & a, const T & b) { return !EQ(a, b) && (a - static_cast< double >(b)) > 0.000000001d; } static inline bool GT(const double & a, const T & b) { return !EQ(a, b) && (a - static_cast< double >(b)) > 0.000000001; }
static inline bool LE(const double & a, const T & b) { return EQ(a, b) || (a - static_cast< double >(b)) < 0.000000001d; } static inline bool LE(const double & a, const T & b) { return EQ(a, b) || (a - static_cast< double >(b)) < 0.000000001; }
static inline bool GE(const double & a, const T & b) { return EQ(a, b) || (a - static_cast< double >(b)) > 0.000000001d; } static inline bool GE(const double & a, const T & b) { return EQ(a, b) || (a - static_cast< double >(b)) > 0.000000001; }
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Perform an equality comparison between two real values taking into account floating point issues. * Perform an equality comparison between two real values taking into account floating point issues.
*/ */
template < typename T > struct EpsCmp< T, double > { template < typename T > struct EpsCmp< T, double > {
static inline bool EQ(const T & a, const double & b) { return fabs(static_cast< double >(a) - b) <= 0.000000001d; } static inline bool EQ(const T & a, const double & b) { return fabs(static_cast< double >(a) - b) <= 0.000000001; }
static inline bool LT(const T & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) < 0.000000001d; } static inline bool LT(const T & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) < 0.000000001; }
static inline bool GT(const T & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) > 0.000000001d; } static inline bool GT(const T & a, const double & b) { return !EQ(a, b) && (static_cast< double >(a) - b) > 0.000000001; }
static inline bool LE(const T & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) < 0.000000001d; } static inline bool LE(const T & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) < 0.000000001; }
static inline bool GE(const T & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) > 0.000000001d; } static inline bool GE(const T & a, const double & b) { return EQ(a, b) || (static_cast< double >(a) - b) > 0.000000001; }
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -1281,7 +1281,7 @@ public:
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Base constructor. * Base constructor.
*/ */
IsCType(CTypeFn fn) explicit IsCType(CTypeFn fn)
: m_Fn(fn) : m_Fn(fn)
{ {
/* ... */ /* ... */
@ -1314,7 +1314,7 @@ public:
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Base constructor. * Base constructor.
*/ */
IsNotCType(CTypeFn fn) explicit IsNotCType(CTypeFn fn)
: m_Fn(fn) : m_Fn(fn)
{ {
/* ... */ /* ... */

View File

@ -23,21 +23,21 @@ const Vector2 Vector2::MAX = Vector2(std::numeric_limits< Vector2::Value >::max(
SQChar Vector2::Delim = ','; SQChar Vector2::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2::Vector2() Vector2::Vector2() noexcept
: x(0.0), y(0.0) : x(0.0), y(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2::Vector2(Value sv) Vector2::Vector2(Value sv) noexcept
: x(sv), y(sv) : x(sv), y(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2::Vector2(Value xv, Value yv) Vector2::Vector2(Value xv, Value yv) noexcept
: x(xv), y(yv) : x(xv), y(yv)
{ {
/* ... */ /* ... */
@ -156,7 +156,7 @@ Vector2 & Vector2::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator ++ (int) Vector2 Vector2::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector2 state(*this); Vector2 state(*this);
++x; ++x;
@ -165,7 +165,7 @@ Vector2 Vector2::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator -- (int) Vector2 Vector2::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector2 state(*this); Vector2 state(*this);
--x; --x;
@ -176,73 +176,73 @@ Vector2 Vector2::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator + (const Vector2 & v) const Vector2 Vector2::operator + (const Vector2 & v) const
{ {
return Vector2(x + v.x, y + v.y); return {x + v.x, y + v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator - (const Vector2 & v) const Vector2 Vector2::operator - (const Vector2 & v) const
{ {
return Vector2(x - v.x, y - v.y); return {x - v.x, y - v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator * (const Vector2 & v) const Vector2 Vector2::operator * (const Vector2 & v) const
{ {
return Vector2(x * v.x, y * v.y); return {x * v.x, y * v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator / (const Vector2 & v) const Vector2 Vector2::operator / (const Vector2 & v) const
{ {
return Vector2(x / v.x, y / v.y); return {x / v.x, y / v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator % (const Vector2 & v) const Vector2 Vector2::operator % (const Vector2 & v) const
{ {
return Vector2(std::fmod(x, v.x), std::fmod(y, v.y)); return {std::fmod(x, v.x), std::fmod(y, v.y)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator + (Value s) const Vector2 Vector2::operator + (Value s) const
{ {
return Vector2(x + s, y + s); return {x + s, y + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator - (Value s) const Vector2 Vector2::operator - (Value s) const
{ {
return Vector2(x - s, y - s); return {x - s, y - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator * (Value s) const Vector2 Vector2::operator * (Value s) const
{ {
return Vector2(x * s, y * s); return {x * s, y * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator / (Value s) const Vector2 Vector2::operator / (Value s) const
{ {
return Vector2(x / s, y / s); return {x / s, y / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator % (Value s) const Vector2 Vector2::operator % (Value s) const
{ {
return Vector2(std::fmod(x, s), std::fmod(y, s)); return {std::fmod(x, s), std::fmod(y, s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator + () const Vector2 Vector2::operator + () const
{ {
return Vector2(std::fabs(x), std::fabs(y)); return {std::fabs(x), std::fabs(y)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::operator - () const Vector2 Vector2::operator - () const
{ {
return Vector2(-x, -y); return {-x, -y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -372,7 +372,7 @@ void Vector2::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2 Vector2::Abs() const Vector2 Vector2::Abs() const
{ {
return Vector2(std::fabs(x), std::fabs(y)); return {std::fabs(x), std::fabs(y)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -402,40 +402,11 @@ const Vector2 & Vector2::GetEx(SQChar delim, StackStrF & str)
return vec; return vec;
} }
// ------------------------------------------------------------------------------------------------
const Vector2 & GetVector2()
{
static Vector2 vec;
vec.Clear();
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2 & GetVector2(Float32 sv)
{
static Vector2 vec;
vec.SetScalar(sv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2 & GetVector2(Float32 xv, Float32 yv)
{
static Vector2 vec;
vec.SetVector2Ex(xv, yv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2 & GetVector2(const Vector2 & o)
{
static Vector2 vec;
vec.SetVector2(o);
return vec;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Vector2(HSQUIRRELVM vm) void Register_Vector2(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Vector2::Value Val; typedef Vector2::Value Val;

View File

@ -36,27 +36,27 @@ struct Vector2
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Vector2(); Vector2() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the same scalar value for all components. * Construct a vector with the same scalar value for all components.
*/ */
explicit Vector2(Value sv); explicit Vector2(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the specified component values. * Construct a vector with the specified component values.
*/ */
Vector2(Value xv, Value yv); Vector2(Value xv, Value yv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector2(const Vector2 & o) = default; Vector2(const Vector2 & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Vector2(Vector2 && o) = default; Vector2(Vector2 && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -78,11 +78,6 @@ struct Vector2
*/ */
Vector2 & operator = (Value s); Vector2 & operator = (Value s);
/* --------------------------------------------------------------------------------------------
* String assignment operator.
*/
Vector2 & operator = (CSStr values);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Integral two-dimensional vector assignment. * Integral two-dimensional vector assignment.
*/ */
@ -151,12 +146,12 @@ struct Vector2
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Vector2 operator ++ (int); Vector2 operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Vector2 operator -- (int); Vector2 operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -23,21 +23,21 @@ const Vector2i Vector2i::MAX = Vector2i(std::numeric_limits< Vector2i::Value >::
SQChar Vector2i::Delim = ','; SQChar Vector2i::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i::Vector2i() Vector2i::Vector2i() noexcept
: x(0), y(0) : x(0), y(0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i::Vector2i(Value sv) Vector2i::Vector2i(Value sv) noexcept
: x(sv), y(sv) : x(sv), y(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i::Vector2i(Value xv, Value yv) Vector2i::Vector2i(Value xv, Value yv) noexcept
: x(xv), y(yv) : x(xv), y(yv)
{ {
/* ... */ /* ... */
@ -102,40 +102,40 @@ Vector2i & Vector2i::operator %= (const Vector2i & v)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator &= (const Vector2i & v) Vector2i & Vector2i::operator &= (const Vector2i & v)
{ {
x &= v.x; x &= v.x; // NOLINT(hicpp-signed-bitwise)
y &= v.y; y &= v.y; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator |= (const Vector2i & v) Vector2i & Vector2i::operator |= (const Vector2i & v)
{ {
x |= v.x; x |= v.x; // NOLINT(hicpp-signed-bitwise)
y |= v.y; y |= v.y; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator ^= (const Vector2i & v) Vector2i & Vector2i::operator ^= (const Vector2i & v)
{ {
x ^= v.x; x ^= v.x; // NOLINT(hicpp-signed-bitwise)
y ^= v.y; y ^= v.y; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator <<= (const Vector2i & v) Vector2i & Vector2i::operator <<= (const Vector2i & v)
{ {
x <<= v.x; x <<= v.x; // NOLINT(hicpp-signed-bitwise)
y <<= v.y; y <<= v.y; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator >>= (const Vector2i & v) Vector2i & Vector2i::operator >>= (const Vector2i & v)
{ {
x >>= v.x; x >>= v.x; // NOLINT(hicpp-signed-bitwise)
y >>= v.y; y >>= v.y; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
@ -182,16 +182,16 @@ Vector2i & Vector2i::operator %= (Value s)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator &= (Value s) Vector2i & Vector2i::operator &= (Value s)
{ {
x &= s; x &= s; // NOLINT(hicpp-signed-bitwise)
y &= s; y &= s; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator |= (Value s) Vector2i & Vector2i::operator |= (Value s)
{ {
x |= s; x |= s; // NOLINT(hicpp-signed-bitwise)
y |= s; y |= s; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
@ -206,16 +206,16 @@ Vector2i & Vector2i::operator ^= (Value s)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator <<= (Value s) Vector2i & Vector2i::operator <<= (Value s)
{ {
x <<= s; x <<= s; // NOLINT(hicpp-signed-bitwise)
y <<= s; y <<= s; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator >>= (Value s) Vector2i & Vector2i::operator >>= (Value s)
{ {
x >>= s; x >>= s; // NOLINT(hicpp-signed-bitwise)
y >>= s; y >>= s; // NOLINT(hicpp-signed-bitwise)
return *this; return *this;
} }
@ -236,7 +236,7 @@ Vector2i & Vector2i::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ++ (int) Vector2i Vector2i::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector2i state(*this); Vector2i state(*this);
++x; ++x;
@ -245,7 +245,7 @@ Vector2i Vector2i::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator -- (int) Vector2i Vector2i::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector2i state(*this); Vector2i state(*this);
--x; --x;
@ -256,139 +256,139 @@ Vector2i Vector2i::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + (const Vector2i & v) const Vector2i Vector2i::operator + (const Vector2i & v) const
{ {
return Vector2i(x + v.x, y + v.y); return {x + v.x, y + v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator - (const Vector2i & v) const Vector2i Vector2i::operator - (const Vector2i & v) const
{ {
return Vector2i(x - v.x, y - v.y); return {x - v.x, y - v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator * (const Vector2i & v) const Vector2i Vector2i::operator * (const Vector2i & v) const
{ {
return Vector2i(x * v.x, y * v.y); return {x * v.x, y * v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator / (const Vector2i & v) const Vector2i Vector2i::operator / (const Vector2i & v) const
{ {
return Vector2i(x / v.x, y / v.y); return {x / v.x, y / v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator % (const Vector2i & v) const Vector2i Vector2i::operator % (const Vector2i & v) const
{ {
return Vector2i(x % v.x, y % v.y); return {x % v.x, y % v.y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator & (const Vector2i & v) const Vector2i Vector2i::operator & (const Vector2i & v) const
{ {
return Vector2i(x & v.x, y & v.y); return {x & v.x, y & v.y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator | (const Vector2i & v) const Vector2i Vector2i::operator | (const Vector2i & v) const
{ {
return Vector2i(x | v.x, y | v.y); return {x | v.x, y | v.y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ^ (const Vector2i & v) const Vector2i Vector2i::operator ^ (const Vector2i & v) const
{ {
return Vector2i(x ^ v.x, y ^ v.y); return {x ^ v.x, y ^ v.y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator << (const Vector2i & v) const Vector2i Vector2i::operator << (const Vector2i & v) const
{ {
return Vector2i(x << v.x, y << v.y); return {x << v.x, y << v.y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator >> (const Vector2i & v) const Vector2i Vector2i::operator >> (const Vector2i & v) const
{ {
return Vector2i(x >> v.x, y >> v.y); return {x >> v.x, y >> v.y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + (Value s) const Vector2i Vector2i::operator + (Value s) const
{ {
return Vector2i(x + s, y + s); return {x + s, y + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator - (Value s) const Vector2i Vector2i::operator - (Value s) const
{ {
return Vector2i(x - s, y - s); return {x - s, y - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator * (Value s) const Vector2i Vector2i::operator * (Value s) const
{ {
return Vector2i(x * s, y * s); return {x * s, y * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator / (Value s) const Vector2i Vector2i::operator / (Value s) const
{ {
return Vector2i(x / s, y / s); return {x / s, y / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator % (Value s) const Vector2i Vector2i::operator % (Value s) const
{ {
return Vector2i(x % s, y % s); return {x % s, y % s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator & (Value s) const Vector2i Vector2i::operator & (Value s) const
{ {
return Vector2i(x & s, y & s); return {x & s, y & s}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator | (Value s) const Vector2i Vector2i::operator | (Value s) const
{ {
return Vector2i(x | s, y | s); return {x | s, y | s}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ^ (Value s) const Vector2i Vector2i::operator ^ (Value s) const
{ {
return Vector2i(x ^ s, y ^ s); return {x ^ s, y ^ s}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator << (Value s) const Vector2i Vector2i::operator << (Value s) const
{ {
return Vector2i(x < s, y < s); return {x << s, y << s}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator >> (Value s) const Vector2i Vector2i::operator >> (Value s) const
{ {
return Vector2i(x >> s, y >> s); return {x >> s, y >> s}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + () const Vector2i Vector2i::operator + () const
{ {
return Vector2i(std::abs(x), std::abs(y)); return {std::abs(x), std::abs(y)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator - () const Vector2i Vector2i::operator - () const
{ {
return Vector2i(-x, -y); return {-x, -y};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ~ () const Vector2i Vector2i::operator ~ () const
{ {
return Vector2i(~x, ~y); return {~x, ~y}; // NOLINT(hicpp-signed-bitwise)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -518,7 +518,7 @@ void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i Vector2i::Abs() const Vector2i Vector2i::Abs() const
{ {
return Vector2i(std::abs(x), std::abs(y)); return {std::abs(x), std::abs(y)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -548,40 +548,11 @@ const Vector2i & Vector2i::GetEx(SQChar delim, StackStrF & str)
return vec; return vec;
} }
// ------------------------------------------------------------------------------------------------
const Vector2i & GetVector2i()
{
static Vector2i vec;
vec.Clear();
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2i & GetVector2i(Int32 sv)
{
static Vector2i vec;
vec.SetScalar(sv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2i & GetVector2i(Int32 xv, Int32 yv)
{
static Vector2i vec;
vec.SetVector2iEx(xv, yv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector2i & GetVector2i(const Vector2i & o)
{
static Vector2i vec;
vec.SetVector2i(o);
return vec;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Vector2i(HSQUIRRELVM vm) void Register_Vector2i(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Vector2i::Value Val; typedef Vector2i::Value Val;

View File

@ -36,27 +36,27 @@ struct Vector2i
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Vector2i(); Vector2i() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the same scalar value for all components. * Construct a vector with the same scalar value for all components.
*/ */
explicit Vector2i(Value sv); explicit Vector2i(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the specified component values. * Construct a vector with the specified component values.
*/ */
Vector2i(Value xv, Value yv); Vector2i(Value xv, Value yv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector2i(const Vector2i & o) = default; Vector2i(const Vector2i & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector2i(Vector2i && o) = default; Vector2i(Vector2i && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -196,12 +196,12 @@ struct Vector2i
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Vector2i operator ++ (int); Vector2i operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Vector2i operator -- (int); Vector2i operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -34,21 +34,21 @@ const Vector3 Vector3::ONE(STOVAL(1.0), STOVAL(1.0), STOVAL(1.0));
SQChar Vector3::Delim = ','; SQChar Vector3::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3::Vector3() Vector3::Vector3() noexcept
: x(0.0), y(0.0), z(0.0) : x(0.0), y(0.0), z(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3::Vector3(Value sv) Vector3::Vector3(Value sv) noexcept
: x(sv), y(sv), z(sv) : x(sv), y(sv), z(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3::Vector3(Value xv, Value yv, Value zv) Vector3::Vector3(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv) : x(xv), y(yv), z(zv)
{ {
/* ... */ /* ... */
@ -190,7 +190,7 @@ Vector3 & Vector3::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator ++ (int) Vector3 Vector3::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector3 state(*this); Vector3 state(*this);
++x; ++x;
@ -200,7 +200,7 @@ Vector3 Vector3::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator -- (int) Vector3 Vector3::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector3 state(*this); Vector3 state(*this);
--x; --x;
@ -212,73 +212,73 @@ Vector3 Vector3::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + (const Vector3 & v) const Vector3 Vector3::operator + (const Vector3 & v) const
{ {
return Vector3(x + v.x, y + v.y, z + v.z); return {x + v.x, y + v.y, z + v.z};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator - (const Vector3 & v) const Vector3 Vector3::operator - (const Vector3 & v) const
{ {
return Vector3(x - v.x, y - v.y, z - v.z); return {x - v.x, y - v.y, z - v.z};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator * (const Vector3 & v) const Vector3 Vector3::operator * (const Vector3 & v) const
{ {
return Vector3(x * v.x, y * v.y, z * v.z); return {x * v.x, y * v.y, z * v.z};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator / (const Vector3 & v) const Vector3 Vector3::operator / (const Vector3 & v) const
{ {
return Vector3(x / v.x, y / v.y, z / v.z); return {x / v.x, y / v.y, z / v.z};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator % (const Vector3 & v) const Vector3 Vector3::operator % (const Vector3 & v) const
{ {
return Vector3(std::fmod(x, v.x), std::fmod(y, v.y), std::fmod(z, v.z)); return {std::fmod(x, v.x), std::fmod(y, v.y), std::fmod(z, v.z)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + (Value s) const Vector3 Vector3::operator + (Value s) const
{ {
return Vector3(x + s, y + s, z + s); return {x + s, y + s, z + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator - (Value s) const Vector3 Vector3::operator - (Value s) const
{ {
return Vector3(x - s, y - s, z - s); return {x - s, y - s, z - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator * (Value s) const Vector3 Vector3::operator * (Value s) const
{ {
return Vector3(x * s, y * s, z * s); return {x * s, y * s, z * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator / (Value s) const Vector3 Vector3::operator / (Value s) const
{ {
return Vector3(x / s, y / s, z / s); return {x / s, y / s, z / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator % (Value s) const Vector3 Vector3::operator % (Value s) const
{ {
return Vector3(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s)); return {std::fmod(x, s), std::fmod(y, s), std::fmod(z, s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + () const Vector3 Vector3::operator + () const
{ {
return Vector3(std::fabs(x), std::fabs(y), std::fabs(z)); return {std::fabs(x), std::fabs(y), std::fabs(z)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator - () const Vector3 Vector3::operator - () const
{ {
return Vector3(-x, -y, -z); return {-x, -y, -z};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -457,7 +457,7 @@ void Vector3::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmi
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::Abs() const Vector3 Vector3::Abs() const
{ {
return Vector3(std::fabs(x), std::fabs(y), std::fabs(z)); return {std::fabs(x), std::fabs(y), std::fabs(z)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -538,7 +538,7 @@ Vector3::Value Vector3::AbsDotProduct(const Vector3 & vec) const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector3 Vector3::CrossProduct(const Vector3 & vec) const Vector3 Vector3::CrossProduct(const Vector3 & vec) const
{ {
return Vector3((y * vec.z) - (z * vec.y), (z * vec.x) - (x * vec.z), (x * vec.y) - (y * vec.x)); return {(y * vec.z) - (z * vec.y), (z * vec.x) - (x * vec.z), (x * vec.y) - (y * vec.x)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -578,11 +578,11 @@ void Vector3::Interpolate(const Vector3 & a, const Vector3 & b, Value d)
Vector3 Vector3::Interpolated(const Vector3 & vec, Value d) const Vector3 Vector3::Interpolated(const Vector3 & vec, Value d) const
{ {
const Float64 inv = 1.0 - d; const Float64 inv = 1.0 - d;
return Vector3( return {
STOVAL((vec.x * inv) + (x * d)), STOVAL((vec.x * inv) + (x * d)),
STOVAL((vec.y * inv) + (y * d)), STOVAL((vec.y * inv) + (y * d)),
STOVAL((vec.z * inv) + (z * d)) STOVAL((vec.z * inv) + (z * d))
); };
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -656,40 +656,11 @@ const Vector3 & Vector3::GetEx(SQChar delim, StackStrF & str)
return vec; return vec;
} }
// ------------------------------------------------------------------------------------------------
const Vector3 & GetVector3()
{
static Vector3 vec;
vec.Clear();
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector3 & GetVector3(Float32 sv)
{
static Vector3 vec;
vec.SetScalar(sv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector3 & GetVector3(Float32 xv, Float32 yv, Float32 zv)
{
static Vector3 vec;
vec.SetVector3Ex(xv, yv, zv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector3 & GetVector3(const Vector3 & o)
{
static Vector3 vec;
vec.SetVector3(o);
return vec;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Vector3(HSQUIRRELVM vm) void Register_Vector3(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Vector3::Value Val; typedef Vector3::Value Val;

View File

@ -43,27 +43,27 @@ struct Vector3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Vector3(); Vector3() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the same scalar value for all components. * Construct a vector with the same scalar value for all components.
*/ */
explicit Vector3(Value sv); explicit Vector3(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the specified component values. * Construct a vector with the specified component values.
*/ */
Vector3(Value xv, Value yv, Value zv); Vector3(Value xv, Value yv, Value zv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector3(const Vector3 & o) = default; Vector3(const Vector3 & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector3(Vector3 && o) = default; Vector3(Vector3 && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -158,12 +158,12 @@ struct Vector3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Vector3 operator ++ (int); Vector3 operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Vector3 operator -- (int); Vector3 operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -24,28 +24,28 @@ const Vector4 Vector4::MAX = Vector4(std::numeric_limits< Vector4::Value >::max(
SQChar Vector4::Delim = ','; SQChar Vector4::Delim = ',';
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4::Vector4() Vector4::Vector4() noexcept
: x(0.0), y(0.0), z(0.0), w(0.0) : x(0.0), y(0.0), z(0.0), w(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4::Vector4(Value sv) Vector4::Vector4(Value sv) noexcept
: x(sv), y(sv), z(sv), w(sv) : x(sv), y(sv), z(sv), w(sv)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4::Vector4(Value xv, Value yv, Value zv) Vector4::Vector4(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv), w(0.0) : x(xv), y(yv), z(zv), w(0.0)
{ {
/* ... */ /* ... */
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4::Vector4(Value xv, Value yv, Value zv, Value wv) Vector4::Vector4(Value xv, Value yv, Value zv, Value wv) noexcept
: x(xv), y(yv), z(zv), w(wv) : x(xv), y(yv), z(zv), w(wv)
{ {
/* ... */ /* ... */
@ -201,7 +201,7 @@ Vector4 & Vector4::operator -- ()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator ++ (int) Vector4 Vector4::operator ++ (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector4 state(*this); Vector4 state(*this);
++x; ++x;
@ -212,7 +212,7 @@ Vector4 Vector4::operator ++ (int)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator -- (int) Vector4 Vector4::operator -- (int) // NOLINT(cert-dcl21-cpp)
{ {
Vector4 state(*this); Vector4 state(*this);
--x; --x;
@ -225,73 +225,73 @@ Vector4 Vector4::operator -- (int)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator + (const Vector4 & v) const Vector4 Vector4::operator + (const Vector4 & v) const
{ {
return Vector4(x + v.x, y + v.y, z + v.z, w + v.w); return {x + v.x, y + v.y, z + v.z, w + v.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator - (const Vector4 & v) const Vector4 Vector4::operator - (const Vector4 & v) const
{ {
return Vector4(x - v.x, y - v.y, z - v.z, w - v.w); return {x - v.x, y - v.y, z - v.z, w - v.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator * (const Vector4 & v) const Vector4 Vector4::operator * (const Vector4 & v) const
{ {
return Vector4(x * v.x, y * v.y, z * v.z, w * v.w); return {x * v.x, y * v.y, z * v.z, w * v.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator / (const Vector4 & v) const Vector4 Vector4::operator / (const Vector4 & v) const
{ {
return Vector4(x / v.x, y / v.y, z / v.z, w / v.w); return {x / v.x, y / v.y, z / v.z, w / v.w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator % (const Vector4 & v) const Vector4 Vector4::operator % (const Vector4 & v) const
{ {
return Vector4(std::fmod(x, v.x), std::fmod(y, v.y), std::fmod(z, v.z), std::fmod(w, v.w)); return {std::fmod(x, v.x), std::fmod(y, v.y), std::fmod(z, v.z), std::fmod(w, v.w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator + (Value s) const Vector4 Vector4::operator + (Value s) const
{ {
return Vector4(x + s, y + s, z + s, w + s); return {x + s, y + s, z + s, w + s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator - (Value s) const Vector4 Vector4::operator - (Value s) const
{ {
return Vector4(x - s, y - s, z - s, w - s); return {x - s, y - s, z - s, w - s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator * (Value s) const Vector4 Vector4::operator * (Value s) const
{ {
return Vector4(x * s, y * s, z * s, w * s); return {x * s, y * s, z * s, w * s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator / (Value s) const Vector4 Vector4::operator / (Value s) const
{ {
return Vector4(x / s, y / s, z / s, w / s); return {x / s, y / s, z / s, w / s};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator % (Value s) const Vector4 Vector4::operator % (Value s) const
{ {
return Vector4(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s)); return {std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator + () const Vector4 Vector4::operator + () const
{ {
return Vector4(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)); return {std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator - () const Vector4 Vector4::operator - () const
{ {
return Vector4(-x, -y, -z, -w); return {-x, -y, -z, -w};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -461,7 +461,7 @@ void Vector4::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmi
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector4 Vector4::Abs() const Vector4 Vector4::Abs() const
{ {
return Vector4(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)); return {std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w)};
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -493,48 +493,11 @@ const Vector4 & Vector4::GetEx(SQChar delim, StackStrF & str)
return vec; return vec;
} }
// ------------------------------------------------------------------------------------------------
const Vector4 & GetVector4()
{
static Vector4 vec;
vec.Clear();
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector4 & GetVector4(Float32 sv)
{
static Vector4 vec;
vec.SetScalar(sv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector4 & GetVector4(Float32 xv, Float32 yv, Float32 zv)
{
static Vector4 vec;
vec.SetVector3Ex(xv, yv, zv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector4 & GetVector4(Float32 xv, Float32 yv, Float32 zv, Float32 wv)
{
static Vector4 vec;
vec.SetVector4Ex(xv, yv, zv, wv);
return vec;
}
// ------------------------------------------------------------------------------------------------
const Vector4 & GetVector4(const Vector4 & o)
{
static Vector4 vec;
vec.SetVector4(o);
return vec;
}
// ================================================================================================ // ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_Vector4(HSQUIRRELVM vm) void Register_Vector4(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{ {
typedef Vector4::Value Val; typedef Vector4::Value Val;

View File

@ -36,32 +36,32 @@ struct Vector4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Vector4(); Vector4() noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the same scalar value for all components. * Construct a vector with the same scalar value for all components.
*/ */
explicit Vector4(Value sv); explicit Vector4(Value sv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the specified component values. * Construct a vector with the specified component values.
*/ */
Vector4(Value xv, Value yv, Value zv); Vector4(Value xv, Value yv, Value zv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Construct a vector with the specified component values. * Construct a vector with the specified component values.
*/ */
Vector4(Value xv, Value yv, Value zv, Value wv); Vector4(Value xv, Value yv, Value zv, Value wv) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Copy constructor. * Copy constructor.
*/ */
Vector4(const Vector4 & o) = default; Vector4(const Vector4 & o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Move constructor. * Move constructor.
*/ */
Vector4(Vector4 && o) = default; Vector4(Vector4 && o) noexcept = default;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -156,12 +156,12 @@ struct Vector4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-increment operator. * Post-increment operator.
*/ */
Vector4 operator ++ (int); Vector4 operator ++ (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Post-decrement operator. * Post-decrement operator.
*/ */
Vector4 operator -- (int); Vector4 operator -- (int); // NOLINT(cert-dcl21-cpp)
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Addition operator. * Addition operator.

View File

@ -254,6 +254,49 @@ Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx)
return 0; return 0;
} }
// ------------------------------------------------------------------------------------------------
const SLongInt & GetSLongInt()
{
static SLongInt l;
l.SetNum(0);
return l;
}
const SLongInt & GetSLongInt(Int64 n)
{
static SLongInt l;
l.SetNum(n);
return l;
}
const SLongInt & GetSLongInt(CSStr s)
{
static SLongInt l;
l = s;
return l;
}
const ULongInt & GetULongInt()
{
static ULongInt l;
l.SetNum(0);
return l;
}
const ULongInt & GetULongInt(Uint64 n)
{
static ULongInt l;
l.SetNum(n);
return l;
}
const ULongInt & GetULongInt(CSStr s)
{
static ULongInt l;
l = s;
return l;
}
// ================================================================================================ // ================================================================================================
void Register_LongInt(HSQUIRRELVM vm) void Register_LongInt(HSQUIRRELVM vm)
{ {

View File

@ -1284,4 +1284,14 @@ Int64 PopStackSLong(HSQUIRRELVM vm, SQInteger idx);
*/ */
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx); Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx);
/* ------------------------------------------------------------------------------------------------
* Get a persistent LongInt instance with the given values.
*/
const SLongInt & GetSLongInt();
const SLongInt & GetSLongInt(Int64 n);
const SLongInt & GetSLongInt(CSStr s);
const ULongInt & GetULongInt();
const ULongInt & GetULongInt(Uint64 n);
const ULongInt & GetULongInt(CSStr s);
} // Namespace:: SqMod } // Namespace:: SqMod

View File

@ -6,6 +6,7 @@
#include "Base/Vector3.hpp" #include "Base/Vector3.hpp"
#include "Entity/Player.hpp" #include "Entity/Player.hpp"
#include "Core.hpp" #include "Core.hpp"
#include "Library/Numeric/LongInt.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {