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

Initial commit.

This commit is contained in:
Sandu Liviu Catalin 2015-09-30 03:56:11 +03:00
parent 4bd8e68a7b
commit 6ed02d0fd4
118 changed files with 23795 additions and 0 deletions

492
source/Base/AABB.cpp Normal file
View File

@ -0,0 +1,492 @@
#include "Base/AABB.hpp"
#include "Base/Vector4.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const AABB AABB::NIL = AABB(0);
const AABB AABB::MIN = AABB(-1, -1, -1, 1, 1, 1);
const AABB AABB::MAX = AABB(Vector3::MIN, Vector3::MAX);
// ------------------------------------------------------------------------------------------------
SQChar AABB::Delim = ',';
// ------------------------------------------------------------------------------------------------
AABB::AABB() noexcept
: min(-1), max(1)
{
}
AABB::AABB(Value s) noexcept
: min(-s), max(std::fabs(s))
{
}
AABB::AABB(Value xv, Value yv, Value zv) noexcept
: min(-xv, -yv, -zv), max(std::fabs(xv), std::fabs(yv), std::fabs(zv))
{
}
AABB::AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept
: min(xmin, ymin, zmin), max(xmax, ymax, zmax)
{
}
// ------------------------------------------------------------------------------------------------
AABB::AABB(const Vector3 & v) noexcept
: min(-v), max(v.Abs())
{
}
AABB::AABB(const Vector3 & vmin, const Vector3 & vmax) noexcept
: min(vmin), max(vmax)
{
}
// ------------------------------------------------------------------------------------------------
AABB::AABB(const Vector4 & v) noexcept
: min(-v), max(v.Abs())
{
}
AABB::AABB(const Vector4 & vmin, const Vector4 & vmax) noexcept
: min(vmin), max(vmax)
{
}
// ------------------------------------------------------------------------------------------------
AABB::AABB(const SQChar * values, SQChar delim) noexcept
: AABB(GetAABB(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
AABB::AABB(const AABB & b) noexcept
: min(b.min), max(b.max)
{
}
AABB::AABB(AABB && b) noexcept
: min(b.min), max(b.max)
{
}
// ------------------------------------------------------------------------------------------------
AABB::~AABB()
{
}
// ------------------------------------------------------------------------------------------------
AABB & AABB::operator = (const AABB & b) noexcept
{
min = b.min;
max = b.max;
return *this;
}
AABB & AABB::operator = (AABB && b) noexcept
{
min = b.min;
max = b.max;
return *this;
}
// ------------------------------------------------------------------------------------------------
AABB & AABB::operator = (Value s) noexcept
{
min.Set(-s);
max.Set(std::fabs(s));
return *this;
}
AABB & AABB::operator = (const Vector3 & v) noexcept
{
min.Set(-v);
max.Set(v.Abs());
return *this;
}
AABB & AABB::operator = (const Vector4 & v) noexcept
{
min.Set(-v);
max.Set(v.Abs());
return *this;
}
// ------------------------------------------------------------------------------------------------
AABB & AABB::operator += (const AABB & b) noexcept
{
min += b.min;
max += b.max;
return *this;
}
AABB & AABB::operator -= (const AABB & b) noexcept
{
min -= b.min;
max -= b.max;
return *this;
}
AABB & AABB::operator *= (const AABB & b) noexcept
{
min *= b.min;
max *= b.max;
return *this;
}
AABB & AABB::operator /= (const AABB & b) noexcept
{
min /= b.min;
max /= b.max;
return *this;
}
AABB & AABB::operator %= (const AABB & b) noexcept
{
min %= b.min;
max %= b.max;
return *this;
}
// ------------------------------------------------------------------------------------------------
AABB & AABB::operator += (Value s) noexcept
{
min += s;
max += s;
return *this;
}
AABB & AABB::operator -= (Value s) noexcept
{
min -= s;
max -= s;
return *this;
}
AABB & AABB::operator *= (Value s) noexcept
{
min *= s;
max *= s;
return *this;
}
AABB & AABB::operator /= (Value s) noexcept
{
min /= s;
max /= s;
return *this;
}
AABB & AABB::operator %= (Value s) noexcept
{
min %= s;
max %= s;
return *this;
}
// ------------------------------------------------------------------------------------------------
AABB & AABB::operator ++ () noexcept
{
++min;
++max;
return *this;
}
AABB & AABB::operator -- () noexcept
{
--min;
--max;
return *this;
}
// ------------------------------------------------------------------------------------------------
AABB AABB::operator ++ (int) noexcept
{
AABB state(*this);
++min;
++max;
return state;
}
AABB AABB::operator -- (int) noexcept
{
AABB state(*this);
--min;
--max;
return state;
}
// ------------------------------------------------------------------------------------------------
AABB AABB::operator + (const AABB & b) const noexcept
{
return AABB(min + b.min, max + b.max);
}
AABB AABB::operator - (const AABB & b) const noexcept
{
return AABB(min - b.min, max - b.max);
}
AABB AABB::operator * (const AABB & b) const noexcept
{
return AABB(min * b.min, max * b.max);
}
AABB AABB::operator / (const AABB & b) const noexcept
{
return AABB(min / b.min, max / b.max);
}
AABB AABB::operator % (const AABB & b) const noexcept
{
return AABB(min % b.min, max % b.max);
}
// ------------------------------------------------------------------------------------------------
AABB AABB::operator + (Value s) const noexcept
{
return AABB(min + s, max + s);
}
AABB AABB::operator - (Value s) const noexcept
{
return AABB(min - s, max - s);
}
AABB AABB::operator * (Value s) const noexcept
{
return AABB(min * s, max * s);
}
AABB AABB::operator / (Value s) const noexcept
{
return AABB(min / s, max / s);
}
AABB AABB::operator % (Value s) const noexcept
{
return AABB(min % s, max % s);
}
// ------------------------------------------------------------------------------------------------
AABB AABB::operator + () const noexcept
{
return AABB(min.Abs(), max.Abs());
}
AABB AABB::operator - () const noexcept
{
return AABB(-min, -max);
}
// ------------------------------------------------------------------------------------------------
bool AABB::operator == (const AABB & b) const noexcept
{
return (min == b.min) && (max == b.max);
}
bool AABB::operator != (const AABB & b) const noexcept
{
return (min != b.min) && (max != b.max);
}
bool AABB::operator < (const AABB & b) const noexcept
{
return (min < b.min) && (max < b.max);
}
bool AABB::operator > (const AABB & b) const noexcept
{
return (min > b.min) && (max > b.max);
}
bool AABB::operator <= (const AABB & b) const noexcept
{
return (min <= b.min) && (max <= b.max);
}
bool AABB::operator >= (const AABB & b) const noexcept
{
return (min >= b.min) && (max >= b.max);
}
// ------------------------------------------------------------------------------------------------
SQInteger AABB::Cmp(const AABB & b) const noexcept
{
return *this == b ? 0 : (*this > b ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * AABB::ToString() const noexcept
{
return ToStringF("%f,%f,%f,%f,%f,%f", min.x, min.y, min.z, max.x, max.y, max.z);
}
// ------------------------------------------------------------------------------------------------
void AABB::Set(Value ns) noexcept
{
min = -ns;
max = std::fabs(ns);
}
void AABB::Set(Value nx, Value ny, Value nz) noexcept
{
min.Set(-nx, -ny, -nz);
max.Set(std::fabs(nx), std::fabs(ny), std::fabs(nz));
}
void AABB::Set(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept
{
min.Set(xmin, ymin, zmin);
max.Set(xmax, ymax, zmax);
}
// ------------------------------------------------------------------------------------------------
void AABB::Set(const AABB & b) noexcept
{
min = b.min;
max = b.max;
}
// ------------------------------------------------------------------------------------------------
void AABB::Set(const Vector3 & v) noexcept
{
min = -v;
max = v.Abs();
}
void AABB::Set(const Vector3 & nmin, const Vector3 & nmax) noexcept
{
min = nmin;
max = nmax;
}
// ------------------------------------------------------------------------------------------------
void AABB::Set(const Vector4 & v) noexcept
{
min = -v;
max = v.Abs();
}
void AABB::Set(const Vector4 & nmin, const Vector4 & nmax) noexcept
{
min = nmin;
max = nmax;
}
// ------------------------------------------------------------------------------------------------
void AABB::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetAABB(values, delim));
}
// ------------------------------------------------------------------------------------------------
AABB AABB::Abs() const noexcept
{
return AABB(min.Abs(), max.Abs());
}
// ================================================================================================
bool Register_AABB(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <AABB> type");
typedef AABB::Value Val;
Sqrat::RootTable(vm).Bind(_SC("AABB"), Sqrat::Class<AABB>(vm, _SC("AABB"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<Val, Val, Val, Val, Val, Val>()
.Ctor<const Vector3 &, const Vector3 &>()
.SetStaticValue(_SC("delim"), &AABB::Delim)
.Var(_SC("min"), &AABB::min)
.Var(_SC("max"), &AABB::max)
.Prop(_SC("abs"), &AABB::Abs)
.Func(_SC("_tostring"), &AABB::ToString)
.Func(_SC("_cmp"), &AABB::Cmp)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("_add"), &AABB::operator +)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("_sub"), &AABB::operator -)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("_mul"), &AABB::operator *)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("_div"), &AABB::operator /)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("_modulo"), &AABB::operator %)
.Func<AABB (AABB::*)(void) const>(_SC("_unm"), &AABB::operator -)
.Overload<void (AABB::*)(Val)>(_SC("set"), &AABB::Set)
.Overload<void (AABB::*)(Val, Val, Val)>(_SC("set"), &AABB::Set)
.Overload<void (AABB::*)(Val, Val, Val, Val, Val, Val)>(_SC("set"), &AABB::Set)
.Overload<void (AABB::*)(const AABB &)>(_SC("set_box"), &AABB::Set)
.Overload<void (AABB::*)(const Vector3 &)>(_SC("set_vec3"), &AABB::Set)
.Overload<void (AABB::*)(const Vector3 &, const Vector3 &)>(_SC("set_vec3"), &AABB::Set)
.Overload<void (AABB::*)(const Vector4 &)>(_SC("set_vec4"), &AABB::Set)
.Overload<void (AABB::*)(const Vector4 &, const Vector4 &)>(_SC("set_vec4"), &AABB::Set)
.Overload<void (AABB::*)(const SQChar *, SQChar)>(_SC("set_str"), &AABB::Set)
.Func(_SC("clear"), &AABB::Clear)
.Func<AABB & (AABB::*)(const AABB &)>(_SC("opAddAssign"), &AABB::operator +=)
.Func<AABB & (AABB::*)(const AABB &)>(_SC("opSubAssign"), &AABB::operator -=)
.Func<AABB & (AABB::*)(const AABB &)>(_SC("opMulAssign"), &AABB::operator *=)
.Func<AABB & (AABB::*)(const AABB &)>(_SC("opDivAssign"), &AABB::operator /=)
.Func<AABB & (AABB::*)(const AABB &)>(_SC("opModAssign"), &AABB::operator %=)
.Func<AABB & (AABB::*)(AABB::Value)>(_SC("opAddAssignS"), &AABB::operator +=)
.Func<AABB & (AABB::*)(AABB::Value)>(_SC("opSubAssignS"), &AABB::operator -=)
.Func<AABB & (AABB::*)(AABB::Value)>(_SC("opMulAssignS"), &AABB::operator *=)
.Func<AABB & (AABB::*)(AABB::Value)>(_SC("opDivAssignS"), &AABB::operator /=)
.Func<AABB & (AABB::*)(AABB::Value)>(_SC("opModAssignS"), &AABB::operator %=)
.Func<AABB & (AABB::*)(void)>(_SC("opPreInc"), &AABB::operator ++)
.Func<AABB & (AABB::*)(void)>(_SC("opPreDec"), &AABB::operator --)
.Func<AABB (AABB::*)(int)>(_SC("opPostInc"), &AABB::operator ++)
.Func<AABB (AABB::*)(int)>(_SC("opPostDec"), &AABB::operator --)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("opAdd"), &AABB::operator +)
.Func<AABB (AABB::*)(AABB::Value) const>(_SC("opAddS"), &AABB::operator +)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("opSub"), &AABB::operator -)
.Func<AABB (AABB::*)(AABB::Value) const>(_SC("opSubS"), &AABB::operator -)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("opMul"), &AABB::operator *)
.Func<AABB (AABB::*)(AABB::Value) const>(_SC("opMulS"), &AABB::operator *)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("opDiv"), &AABB::operator /)
.Func<AABB (AABB::*)(AABB::Value) const>(_SC("opDivS"), &AABB::operator /)
.Func<AABB (AABB::*)(const AABB &) const>(_SC("opMod"), &AABB::operator %)
.Func<AABB (AABB::*)(AABB::Value) const>(_SC("opModS"), &AABB::operator %)
.Func<AABB (AABB::*)(void) const>(_SC("opUnPlus"), &AABB::operator +)
.Func<AABB (AABB::*)(void) const>(_SC("opUnMinus"), &AABB::operator -)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opEqual"), &AABB::operator ==)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opNotEqual"), &AABB::operator !=)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opLessThan"), &AABB::operator <)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opGreaterThan"), &AABB::operator >)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opLessEqual"), &AABB::operator <=)
.Func<bool (AABB::*)(const AABB &) const>(_SC("opGreaterEqual"), &AABB::operator >=)
);
LogDbg("Registration of <AABB> type was successful");
return true;
}
} // Namespace:: SqMod

117
source/Base/AABB.hpp Normal file
View File

@ -0,0 +1,117 @@
#ifndef _BASE_AABB_HPP_
#define _BASE_AABB_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
#include "Base/Vector3.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct AABB
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const AABB NIL;
static const AABB MIN;
static const AABB MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Vector3 min, max;
// --------------------------------------------------------------------------------------------
AABB() noexcept;
AABB(Value s) noexcept;
AABB(Value x, Value y, Value z) noexcept;
AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept;
// --------------------------------------------------------------------------------------------
AABB(const Vector3 & b) noexcept;
AABB(const Vector3 & vmin, const Vector3 & vmax) noexcept;
// --------------------------------------------------------------------------------------------
AABB(const Vector4 & b) noexcept;
AABB(const Vector4 & vmin, const Vector4 & vmax) noexcept;
// --------------------------------------------------------------------------------------------
AABB(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
AABB(const AABB & b) noexcept;
AABB(AABB && b) noexcept;
// --------------------------------------------------------------------------------------------
~AABB();
// --------------------------------------------------------------------------------------------
AABB & operator = (const AABB & b) noexcept;
AABB & operator = (AABB && b) noexcept;
// --------------------------------------------------------------------------------------------
AABB & operator = (Value s) noexcept;
AABB & operator = (const Vector3 & v) noexcept;
AABB & operator = (const Vector4 & v) noexcept;
// --------------------------------------------------------------------------------------------
AABB & operator += (const AABB & b) noexcept;
AABB & operator -= (const AABB & b) noexcept;
AABB & operator *= (const AABB & b) noexcept;
AABB & operator /= (const AABB & b) noexcept;
AABB & operator %= (const AABB & b) noexcept;
// --------------------------------------------------------------------------------------------
AABB & operator += (Value s) noexcept;
AABB & operator -= (Value s) noexcept;
AABB & operator *= (Value s) noexcept;
AABB & operator /= (Value s) noexcept;
AABB & operator %= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
AABB & operator ++ () noexcept;
AABB & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
AABB operator ++ (int) noexcept;
AABB operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
AABB operator + (const AABB & b) const noexcept;
AABB operator - (const AABB & b) const noexcept;
AABB operator * (const AABB & b) const noexcept;
AABB operator / (const AABB & b) const noexcept;
AABB operator % (const AABB & b) const noexcept;
// --------------------------------------------------------------------------------------------
AABB operator + (Value s) const noexcept;
AABB operator - (Value s) const noexcept;
AABB operator * (Value s) const noexcept;
AABB operator / (Value s) const noexcept;
AABB operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
AABB operator + () const noexcept;
AABB operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const AABB & b) const noexcept;
bool operator != (const AABB & b) const noexcept;
bool operator < (const AABB & b) const noexcept;
bool operator > (const AABB & b) const noexcept;
bool operator <= (const AABB & b) const noexcept;
bool operator >= (const AABB & b) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const AABB & b) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny, Value nz) noexcept;
void Set(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const AABB & b) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector3 & v) noexcept;
void Set(const Vector3 & nmin, const Vector3 & nmax) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector4 & v) noexcept;
void Set(const Vector4 & nmin, const Vector4 & nmax) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { min.Clear(); max.Clear(); }
// --------------------------------------------------------------------------------------------
AABB Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_AABB_HPP_

542
source/Base/Circle.cpp Normal file
View File

@ -0,0 +1,542 @@
#include "Base/Circle.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Circle Circle::NIL = Circle();
const Circle Circle::MIN = Circle(0.0);
const Circle Circle::MAX = Circle(std::numeric_limits<Circle::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Circle::Delim = ',';
// ------------------------------------------------------------------------------------------------
Circle::Circle() noexcept
: pos(0.0, 0.0), rad(0.0)
{
}
Circle::Circle(Value r) noexcept
: pos(0.0, 0.0), rad(r)
{
}
Circle::Circle(const Vector2f & p) noexcept
: pos(p), rad(0.0)
{
}
Circle::Circle(const Vector2f & p, Value r) noexcept
: pos(p), rad(r)
{
}
Circle::Circle(Value x, Value y, Value r) noexcept
: pos(x, y), rad(r)
{
}
// ------------------------------------------------------------------------------------------------
Circle::Circle(const Circle & c) noexcept
: pos(c.pos), rad(c.rad)
{
}
Circle::Circle(Circle && c) noexcept
: pos(c.pos), rad(c.rad)
{
}
// ------------------------------------------------------------------------------------------------
Circle::~Circle()
{
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator = (const Circle & c) noexcept
{
pos = c.pos;
rad = c.rad;
return *this;
}
Circle & Circle::operator = (Circle && c) noexcept
{
pos = c.pos;
rad = c.rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator = (Value r) noexcept
{
rad = r;
return *this;
}
Circle & Circle::operator = (const Vector2f & p) noexcept
{
pos = p;
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator += (const Circle & c) noexcept
{
pos += c.pos;
rad += c.rad;
return *this;
}
Circle & Circle::operator -= (const Circle & c) noexcept
{
pos -= c.pos;
rad -= c.rad;
return *this;
}
Circle & Circle::operator *= (const Circle & c) noexcept
{
pos *= c.pos;
rad *= c.rad;
return *this;
}
Circle & Circle::operator /= (const Circle & c) noexcept
{
pos /= c.pos;
rad /= c.rad;
return *this;
}
Circle & Circle::operator %= (const Circle & c) noexcept
{
pos %= c.pos;
rad = std::fmod(rad, c.rad);
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator += (Value r) noexcept
{
rad += r;
return *this;
}
Circle & Circle::operator -= (Value r) noexcept
{
rad -= r;
return *this;
}
Circle & Circle::operator *= (Value r) noexcept
{
rad *= r;
return *this;
}
Circle & Circle::operator /= (Value r) noexcept
{
rad /= r;
return *this;
}
Circle & Circle::operator %= (Value r) noexcept
{
rad = std::fmod(rad, r);
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator += (const Vector2f & p) noexcept
{
pos += p;
return *this;
}
Circle & Circle::operator -= (const Vector2f & p) noexcept
{
pos -= p;
return *this;
}
Circle & Circle::operator *= (const Vector2f & p) noexcept
{
pos *= p;
return *this;
}
Circle & Circle::operator /= (const Vector2f & p) noexcept
{
pos /= p;
return *this;
}
Circle & Circle::operator %= (const Vector2f & p) noexcept
{
pos %= p;
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator ++ () noexcept
{
++pos;
++rad;
return *this;
}
Circle & Circle::operator -- () noexcept
{
--pos;
--rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle Circle::operator ++ (int) noexcept
{
Circle state(*this);
++pos;
++rad;
return state;
}
Circle Circle::operator -- (int) noexcept
{
Circle state(*this);
--pos;
--rad;
return state;
}
// ------------------------------------------------------------------------------------------------
Circle Circle::operator + (const Circle & c) const noexcept
{
return Circle(pos + c.pos, rad + c.rad);
}
Circle Circle::operator - (const Circle & c) const noexcept
{
return Circle(pos - c.pos, rad - c.rad);
}
Circle Circle::operator * (const Circle & c) const noexcept
{
return Circle(pos * c.pos, rad * c.rad);
}
Circle Circle::operator / (const Circle & c) const noexcept
{
return Circle(pos / c.pos, rad / c.rad);
}
Circle Circle::operator % (const Circle & c) const noexcept
{
return Circle(pos % c.pos, std::fmod(rad, c.rad));
}
// ------------------------------------------------------------------------------------------------
Circle Circle::operator + (Value r) const noexcept
{
return Circle(rad + r);
}
Circle Circle::operator - (Value r) const noexcept
{
return Circle(rad - r);
}
Circle Circle::operator * (Value r) const noexcept
{
return Circle(rad * r);
}
Circle Circle::operator / (Value r) const noexcept
{
return Circle(rad / r);
}
Circle Circle::operator % (Value r) const noexcept
{
return Circle(std::fmod(rad, r));
}
// ------------------------------------------------------------------------------------------------
Circle Circle::operator + (const Vector2f & p) const noexcept
{
return Circle(pos + p);
}
Circle Circle::operator - (const Vector2f & p) const noexcept
{
return Circle(pos - p);
}
Circle Circle::operator * (const Vector2f & p) const noexcept
{
return Circle(pos * p);
}
Circle Circle::operator / (const Vector2f & p) const noexcept
{
return Circle(pos / p);
}
Circle Circle::operator % (const Vector2f & p) const noexcept
{
return Circle(pos % p);
}
// ------------------------------------------------------------------------------------------------
Circle Circle::operator + () const noexcept
{
return Circle(pos.Abs(), std::fabs(rad));
}
Circle Circle::operator - () const noexcept
{
return Circle(-pos, -rad);
}
// ------------------------------------------------------------------------------------------------
bool Circle::operator == (const Circle & c) const noexcept
{
return (rad == c.rad) && (pos == c.pos);
}
bool Circle::operator != (const Circle & c) const noexcept
{
return (rad != c.rad) && (pos != c.pos);
}
bool Circle::operator < (const Circle & c) const noexcept
{
return (rad < c.rad) && (pos < c.pos);
}
bool Circle::operator > (const Circle & c) const noexcept
{
return (rad > c.rad) && (pos > c.pos);
}
bool Circle::operator <= (const Circle & c) const noexcept
{
return (rad <= c.rad) && (pos <= c.pos);
}
bool Circle::operator >= (const Circle & c) const noexcept
{
return (rad >= c.rad) && (pos >= c.pos);
}
// ------------------------------------------------------------------------------------------------
SQInteger Circle::Cmp(const Circle & c) const noexcept
{
return *this == c ? 0 : (*this > c ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Circle::ToString() const noexcept
{
return ToStringF("%f,%f,%f", pos.x, pos.y, rad);
}
// ------------------------------------------------------------------------------------------------
void Circle::Set(Value nr) noexcept
{
rad = nr;
}
void Circle::Set(const Circle & nc) noexcept
{
pos = nc.pos;
rad = nc.rad;
}
void Circle::Set(const Vector2f & np) noexcept
{
pos = np;
}
void Circle::Set(const Vector2f & np, Value nr) noexcept
{
pos = np;
rad = nr;
}
// ------------------------------------------------------------------------------------------------
void Circle::Set(Value nx, Value ny) noexcept
{
pos.Set(nx, ny);
}
void Circle::Set(Value nx, Value ny, Value nr) noexcept
{
pos.Set(nx, ny);
rad = nr;
}
// ------------------------------------------------------------------------------------------------
void Circle::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetCircle(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Circle::Generate() noexcept
{
pos.Generate();
rad = RandomVal<Value>::Get();
}
void Circle::Generate(Value min, Value max, bool r) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else if (r)
{
rad = RandomVal<Value>::Get(min, max);
}
else
{
pos.Generate(min, max);
}
}
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept
{
pos.Generate(xmin, xmax, ymin, ymax);
}
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax) noexcept
{
if (std::isless(rmax, rmin))
{
LogErr("max value is lower than min value");
}
else
{
pos.Generate(xmin, xmax, ymin, ymax);
rad = RandomVal<Value>::Get(rmin, rmax);
}
}
// ------------------------------------------------------------------------------------------------
Circle Circle::Abs() const noexcept
{
return Circle(pos.Abs(), std::fabs(rad));
}
// ------------------------------------------------------------------------------------------------
bool Register_Circle(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Circle> type");
typedef Circle::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Circle"), Sqrat::Class<Circle>(vm, _SC("Circle"))
.Ctor()
.Ctor<Val>()
.Ctor<const Vector2f &, Val>()
.Ctor<Val, Val, Val>()
.SetStaticValue(_SC("delim"), &Circle::Delim)
.Var(_SC("pos"), &Circle::pos)
.Var(_SC("rad"), &Circle::rad)
.Prop(_SC("abs"), &Circle::Abs)
.Func(_SC("_tostring"), &Circle::ToString)
.Func(_SC("_cmp"), &Circle::Cmp)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_add"), &Circle::operator +)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_sub"), &Circle::operator -)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_mul"), &Circle::operator *)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_div"), &Circle::operator /)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_modulo"), &Circle::operator %)
.Func<Circle (Circle::*)(void) const>(_SC("_unm"), &Circle::operator -)
.Overload<void (Circle::*)(const Circle &)>(_SC("set"), &Circle::Set)
.Overload<void (Circle::*)(const Vector2f &, Val)>(_SC("set"), &Circle::Set)
.Overload<void (Circle::*)(Val, Val, Val)>(_SC("set"), &Circle::Set)
.Overload<void (Circle::*)(Val)>(_SC("set_rad"), &Circle::Set)
.Overload<void (Circle::*)(const Vector2f &)>(_SC("set_vec2"), &Circle::Set)
.Overload<void (Circle::*)(Val, Val)>(_SC("set_vec2"), &Circle::Set)
.Overload<void (Circle::*)(const SQChar *, SQChar)>(_SC("set_str"), &Circle::Set)
.Func(_SC("clear"), &Circle::Clear)
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opAddAssign"), &Circle::operator +=)
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opSubAssign"), &Circle::operator -=)
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opMulAssign"), &Circle::operator *=)
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opDivAssign"), &Circle::operator /=)
.Func<Circle & (Circle::*)(const Circle &)>(_SC("opModAssign"), &Circle::operator %=)
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opAddAssignR"), &Circle::operator +=)
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opSubAssignR"), &Circle::operator -=)
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opMulAssignR"), &Circle::operator *=)
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opDivAssignR"), &Circle::operator /=)
.Func<Circle & (Circle::*)(Circle::Value)>(_SC("opModAssignR"), &Circle::operator %=)
.Func<Circle & (Circle::*)(const Vector2f &)>(_SC("opAddAssignP"), &Circle::operator +=)
.Func<Circle & (Circle::*)(const Vector2f &)>(_SC("opSubAssignP"), &Circle::operator -=)
.Func<Circle & (Circle::*)(const Vector2f &)>(_SC("opMulAssignP"), &Circle::operator *=)
.Func<Circle & (Circle::*)(const Vector2f &)>(_SC("opDivAssignP"), &Circle::operator /=)
.Func<Circle & (Circle::*)(const Vector2f &)>(_SC("opModAssignP"), &Circle::operator %=)
.Func<Circle & (Circle::*)(void)>(_SC("opPreInc"), &Circle::operator ++)
.Func<Circle & (Circle::*)(void)>(_SC("opPreDec"), &Circle::operator --)
.Func<Circle (Circle::*)(int)>(_SC("opPostInc"), &Circle::operator ++)
.Func<Circle (Circle::*)(int)>(_SC("opPostDec"), &Circle::operator --)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opAdd"), &Circle::operator +)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opSub"), &Circle::operator -)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opMul"), &Circle::operator *)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opDiv"), &Circle::operator /)
.Func<Circle (Circle::*)(const Circle &) const>(_SC("opMod"), &Circle::operator %)
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opAddR"), &Circle::operator +)
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opSubR"), &Circle::operator -)
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opMulR"), &Circle::operator *)
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opDivR"), &Circle::operator /)
.Func<Circle (Circle::*)(Circle::Value) const>(_SC("opModR"), &Circle::operator %)
.Func<Circle (Circle::*)(const Vector2f &) const>(_SC("opAddP"), &Circle::operator +)
.Func<Circle (Circle::*)(const Vector2f &) const>(_SC("opSubP"), &Circle::operator -)
.Func<Circle (Circle::*)(const Vector2f &) const>(_SC("opMulP"), &Circle::operator *)
.Func<Circle (Circle::*)(const Vector2f &) const>(_SC("opDivP"), &Circle::operator /)
.Func<Circle (Circle::*)(const Vector2f &) const>(_SC("opModP"), &Circle::operator %)
.Func<Circle (Circle::*)(void) const>(_SC("opUnPlus"), &Circle::operator +)
.Func<Circle (Circle::*)(void) const>(_SC("opUnMinus"), &Circle::operator -)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opEqual"), &Circle::operator ==)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opNotEqual"), &Circle::operator !=)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opLessThan"), &Circle::operator <)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterThan"), &Circle::operator >)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opLessEqual"), &Circle::operator <=)
.Func<bool (Circle::*)(const Circle &) const>(_SC("opGreaterEqual"), &Circle::operator >=)
);
LogDbg("Registration of <Circle> type was successful");
return true;
}
} // Namespace:: SqMod

123
source/Base/Circle.hpp Normal file
View File

@ -0,0 +1,123 @@
#ifndef _BASE_CIRCLE_HPP_
#define _BASE_CIRCLE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
#include "Base/Vector2f.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Circle
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Circle NIL;
static const Circle MIN;
static const Circle MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Vector2f pos;
Value rad;
// --------------------------------------------------------------------------------------------
Circle() noexcept;
Circle(Value r) noexcept;
Circle(const Vector2f & p) noexcept;
Circle(const Vector2f & p, Value r) noexcept;
Circle(Value x, Value y, Value r) noexcept;
// --------------------------------------------------------------------------------------------
Circle(const Circle & c) noexcept;
Circle(Circle && c) noexcept;
// --------------------------------------------------------------------------------------------
~Circle();
// --------------------------------------------------------------------------------------------
Circle & operator = (const Circle & c) noexcept;
Circle & operator = (Circle && c) noexcept;
// --------------------------------------------------------------------------------------------
Circle & operator = (Value r) noexcept;
Circle & operator = (const Vector2f & p) noexcept;
// --------------------------------------------------------------------------------------------
Circle & operator += (const Circle & c) noexcept;
Circle & operator -= (const Circle & c) noexcept;
Circle & operator *= (const Circle & c) noexcept;
Circle & operator /= (const Circle & c) noexcept;
Circle & operator %= (const Circle & c) noexcept;
// --------------------------------------------------------------------------------------------
Circle & operator += (Value r) noexcept;
Circle & operator -= (Value r) noexcept;
Circle & operator *= (Value r) noexcept;
Circle & operator /= (Value r) noexcept;
Circle & operator %= (Value r) noexcept;
// --------------------------------------------------------------------------------------------
Circle & operator += (const Vector2f & p) noexcept;
Circle & operator -= (const Vector2f & p) noexcept;
Circle & operator *= (const Vector2f & p) noexcept;
Circle & operator /= (const Vector2f & p) noexcept;
Circle & operator %= (const Vector2f & p) noexcept;
// --------------------------------------------------------------------------------------------
Circle & operator ++ () noexcept;
Circle & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Circle operator ++ (int) noexcept;
Circle operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Circle operator + (const Circle & c) const noexcept;
Circle operator - (const Circle & c) const noexcept;
Circle operator * (const Circle & c) const noexcept;
Circle operator / (const Circle & c) const noexcept;
Circle operator % (const Circle & c) const noexcept;
// --------------------------------------------------------------------------------------------
Circle operator + (Value r) const noexcept;
Circle operator - (Value r) const noexcept;
Circle operator * (Value r) const noexcept;
Circle operator / (Value r) const noexcept;
Circle operator % (Value r) const noexcept;
// --------------------------------------------------------------------------------------------
Circle operator + (const Vector2f & p) const noexcept;
Circle operator - (const Vector2f & p) const noexcept;
Circle operator * (const Vector2f & p) const noexcept;
Circle operator / (const Vector2f & p) const noexcept;
Circle operator % (const Vector2f & p) const noexcept;
// --------------------------------------------------------------------------------------------
Circle operator + () const noexcept;
Circle operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Circle & c) const noexcept;
bool operator != (const Circle & c) const noexcept;
bool operator < (const Circle & c) const noexcept;
bool operator > (const Circle & c) const noexcept;
bool operator <= (const Circle & c) const noexcept;
bool operator >= (const Circle & c) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Circle & c) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value nr) noexcept;
void Set(const Circle & nc) noexcept;
void Set(const Vector2f & np) noexcept;
void Set(const Vector2f & np, Value nr) noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value nx, Value ny) noexcept;
void Set(Value nx, Value ny, Value nr) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max, bool r) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { pos.Clear(); rad = 0.0; }
// --------------------------------------------------------------------------------------------
Circle Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_CIRCLE_HPP_

720
source/Base/Color3.cpp Normal file
View File

@ -0,0 +1,720 @@
#include "Base/Color3.hpp"
#include "Base/Color4.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Color3 Color3::NIL = Color3();
const Color3 Color3::MIN = Color3(std::numeric_limits<Color3::Value>::min());
const Color3 Color3::MAX = Color3(std::numeric_limits<Color3::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Color3::Delim = ',';
// ------------------------------------------------------------------------------------------------
Color3::Color3() noexcept
: r(0), g(0), b(0)
{
}
Color3::Color3(Value s) noexcept
: r(s), g(s), b(s)
{
}
Color3::Color3(Value rv, Value gv, Value bv) noexcept
: r(rv), g(gv), b(bv)
{
}
// ------------------------------------------------------------------------------------------------
Color3::Color3(const Color4 & c) noexcept
: r(c.r), g(c.g), b(c.b)
{
}
// ------------------------------------------------------------------------------------------------
Color3::Color3(const SQChar * name) noexcept
: Color3(GetColor(name))
{
}
Color3::Color3(const SQChar * str, SQChar delim) noexcept
: Color3(GetColor3(str, delim))
{
}
// ------------------------------------------------------------------------------------------------
Color3::Color3(const Color3 & c) noexcept
: r(c.r), g(c.g), b(c.b)
{
}
Color3::Color3(Color3 && c) noexcept
: r(c.r), g(c.g), b(c.b)
{
}
// ------------------------------------------------------------------------------------------------
Color3::~Color3()
{
}
// ------------------------------------------------------------------------------------------------
Color3 & Color3::operator = (const Color3 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
return *this;
}
Color3 & Color3::operator = (Color3 && c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color3 & Color3::operator = (Value s) noexcept
{
r = s;
g = s;
b = s;
return *this;
}
Color3 & Color3::operator = (const SQChar * name) noexcept
{
Set(GetColor(name));
return *this;
}
Color3 & Color3::operator = (const Color4 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color3 & Color3::operator += (const Color3 & c) noexcept
{
r += c.r;
g += c.g;
b += c.b;
return *this;
}
Color3 & Color3::operator -= (const Color3 & c) noexcept
{
r -= c.r;
g -= c.g;
b -= c.b;
return *this;
}
Color3 & Color3::operator *= (const Color3 & c) noexcept
{
r *= c.r;
g *= c.g;
b *= c.b;
return *this;
}
Color3 & Color3::operator /= (const Color3 & c) noexcept
{
r /= c.r;
g /= c.g;
b /= c.b;
return *this;
}
Color3 & Color3::operator %= (const Color3 & c) noexcept
{
r %= c.r;
g %= c.g;
b %= c.b;
return *this;
}
Color3 & Color3::operator &= (const Color3 & c) noexcept
{
r &= c.r;
g &= c.g;
b &= c.b;
return *this;
}
Color3 & Color3::operator |= (const Color3 & c) noexcept
{
r |= c.r;
g |= c.g;
b |= c.b;
return *this;
}
Color3 & Color3::operator ^= (const Color3 & c) noexcept
{
r ^= c.r;
g ^= c.g;
b ^= c.b;
return *this;
}
Color3 & Color3::operator <<= (const Color3 & c) noexcept
{
r <<= c.r;
g <<= c.g;
b <<= c.b;
return *this;
}
Color3 & Color3::operator >>= (const Color3 & c) noexcept
{
r >>= c.r;
g >>= c.g;
b >>= c.b;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color3 & Color3::operator += (Value s) noexcept
{
r += s;
g += s;
b += s;
return *this;
}
Color3 & Color3::operator -= (Value s) noexcept
{
r -= s;
g -= s;
b -= s;
return *this;
}
Color3 & Color3::operator *= (Value s) noexcept
{
r *= s;
g *= s;
b *= s;
return *this;
}
Color3 & Color3::operator /= (Value s) noexcept
{
r /= s;
g /= s;
b /= s;
return *this;
}
Color3 & Color3::operator %= (Value s) noexcept
{
r %= s;
g %= s;
b %= s;
return *this;
}
Color3 & Color3::operator &= (Value s) noexcept
{
r &= s;
g &= s;
b &= s;
return *this;
}
Color3 & Color3::operator |= (Value s) noexcept
{
r |= s;
g |= s;
b |= s;
return *this;
}
Color3 & Color3::operator ^= (Value s) noexcept
{
r ^= s;
g ^= s;
b ^= s;
return *this;
}
Color3 & Color3::operator <<= (Value s) noexcept
{
r <<= s;
g <<= s;
b <<= s;
return *this;
}
Color3 & Color3::operator >>= (Value s) noexcept
{
r >>= s;
g >>= s;
b >>= s;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color3 & Color3::operator ++ () noexcept
{
++r;
++g;
++b;
return *this;
}
Color3 & Color3::operator -- () noexcept
{
--r;
--g;
--b;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color3 Color3::operator ++ (int) noexcept
{
Color3 state(*this);
++r;
++g;
++b;
return state;
}
Color3 Color3::operator -- (int) noexcept
{
Color3 state(*this);
--r;
--g;
--b;
return state;
}
// ------------------------------------------------------------------------------------------------
Color3 Color3::operator + (const Color3 & c) const noexcept
{
return Color3(r + c.r, g + c.g, b + c.b);
}
Color3 Color3::operator - (const Color3 & c) const noexcept
{
return Color3(r - c.r, g - c.g, b - c.b);
}
Color3 Color3::operator * (const Color3 & c) const noexcept
{
return Color3(r * c.r, g * c.g, b * c.b);
}
Color3 Color3::operator / (const Color3 & c) const noexcept
{
return Color3(r / c.r, g / c.g, b / c.b);
}
Color3 Color3::operator % (const Color3 & c) const noexcept
{
return Color3(r % c.r, g % c.g, b % c.b);
}
Color3 Color3::operator & (const Color3 & c) const noexcept
{
return Color3(r & c.r, g & c.g, b & c.b);
}
Color3 Color3::operator | (const Color3 & c) const noexcept
{
return Color3(r | c.r, g | c.g, b | c.b);
}
Color3 Color3::operator ^ (const Color3 & c) const noexcept
{
return Color3(r ^ c.r, g ^ c.g, b ^ c.b);
}
Color3 Color3::operator << (const Color3 & c) const noexcept
{
return Color3(r << c.r, g << c.g, b << c.b);
}
Color3 Color3::operator >> (const Color3 & c) const noexcept
{
return Color3(r >> c.r, g >> c.g, b >> c.b);
}
// ------------------------------------------------------------------------------------------------
Color3 Color3::operator + (Value s) const noexcept
{
return Color3(r + s, g + s, b + s);
}
Color3 Color3::operator - (Value s) const noexcept
{
return Color3(r - s, g - s, b - s);
}
Color3 Color3::operator * (Value s) const noexcept
{
return Color3(r * s, g * s, b * s);
}
Color3 Color3::operator / (Value s) const noexcept
{
return Color3(r / s, g / s, b / s);
}
Color3 Color3::operator % (Value s) const noexcept
{
return Color3(r % s, g % s, b % s);
}
Color3 Color3::operator & (Value s) const noexcept
{
return Color3(r & s, g & s, b & s);
}
Color3 Color3::operator | (Value s) const noexcept
{
return Color3(r | s, g | s, b | s);
}
Color3 Color3::operator ^ (Value s) const noexcept
{
return Color3(r ^ s, g ^ s, b ^ s);
}
Color3 Color3::operator << (Value s) const noexcept
{
return Color3(r << s, g << s, b << s);
}
Color3 Color3::operator >> (Value s) const noexcept
{
return Color3(r >> s, g >> s, b >> s);
}
// ------------------------------------------------------------------------------------------------
Color3 Color3::operator + () const noexcept
{
return Color3(r, g, b);
}
Color3 Color3::operator - () const noexcept
{
return Color3(0, 0, 0);
}
// ------------------------------------------------------------------------------------------------
Color3 Color3::operator ~ () const noexcept
{
return Color3(~r, ~g, ~b);
}
// ------------------------------------------------------------------------------------------------
bool Color3::operator == (const Color3 & c) const noexcept
{
return (r == c.r) && (g == c.g) && (b == c.b);
}
bool Color3::operator != (const Color3 & c) const noexcept
{
return (r != c.r) && (g != c.g) && (b != c.b);
}
bool Color3::operator < (const Color3 & c) const noexcept
{
return (r < c.r) && (g < c.g) && (b < c.b);
}
bool Color3::operator > (const Color3 & c) const noexcept
{
return (r > c.r) && (g > c.g) && (b > c.b);
}
bool Color3::operator <= (const Color3 & c) const noexcept
{
return (r <= c.r) && (g <= c.g) && (b <= c.b);
}
bool Color3::operator >= (const Color3 & c) const noexcept
{
return (r >= c.r) && (g >= c.g) && (b >= c.b);
}
// ------------------------------------------------------------------------------------------------
SQInteger Color3::Cmp(const Color3 & c) const noexcept
{
return *this == c ? 0 : (*this > c ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Color3::ToString() const noexcept
{
return ToStringF("%u,%u,%u", r, g, b);
}
// ------------------------------------------------------------------------------------------------
void Color3::Set(Value ns) noexcept
{
r = ns;
g = ns;
b = ns;
}
void Color3::Set(Value nr, Value ng, Value nb) noexcept
{
r = nr;
g = ng;
b = nb;
}
// ------------------------------------------------------------------------------------------------
void Color3::Set(const Color3 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
}
void Color3::Set(const Color4 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
}
// ------------------------------------------------------------------------------------------------
void Color3::Set(const SQChar * str, SQChar delim) noexcept
{
Set(GetColor3(str, delim));
}
// ------------------------------------------------------------------------------------------------
void Color3::SetCol(const SQChar * name) noexcept
{
Set(GetColor(name));
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color3::GetRGB() const noexcept
{
return static_cast<SQUint32>(r << 16 | g << 8 | b);
}
void Color3::SetRGB(SQUint32 p) noexcept
{
r = static_cast<Value>((p >> 16) & 0xFF);
g = static_cast<Value>((p >> 8) & 0xFF);
b = static_cast<Value>((p) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color3::GetRGBA() const noexcept
{
return static_cast<SQUint32>(r << 24 | g << 16 | b << 8 | 0x00);
}
void Color3::SetRGBA(SQUint32 p) noexcept
{
r = static_cast<Value>((p >> 24) & 0xFF);
g = static_cast<Value>((p >> 16) & 0xFF);
b = static_cast<Value>((p >> 8) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color3::GetARGB() const noexcept
{
return static_cast<SQUint32>(0x00 << 24 | r << 16 | g << 8 | b);
}
void Color3::SetARGB(SQUint32 p) noexcept
{
r = static_cast<Value>((p >> 16) & 0xFF);
g = static_cast<Value>((p >> 8) & 0xFF);
b = static_cast<Value>((p) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
void Color3::Generate() noexcept
{
r = RandomVal<Value>::Get();
g = RandomVal<Value>::Get();
b = RandomVal<Value>::Get();
}
void Color3::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
r = RandomVal<Value>::Get(min, max);
g = RandomVal<Value>::Get(min, max);
b = RandomVal<Value>::Get(min, max);
}
}
void Color3::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax) noexcept
{
if (rmax < rmin || gmax < gmin || bmax < bmin)
{
LogErr("max value is lower than min value");
}
else
{
r = RandomVal<Value>::Get(rmin, rmax);
g = RandomVal<Value>::Get(gmin, gmax);
b = RandomVal<Value>::Get(bmin, bmax);
}
}
// ------------------------------------------------------------------------------------------------
void Color3::Random() noexcept
{
Set(GetRandomColor());
}
// ------------------------------------------------------------------------------------------------
void Color3::Inverse() noexcept
{
r = static_cast<Value>(~r);
g = static_cast<Value>(~g);
b = static_cast<Value>(~b);
}
// ================================================================================================
bool Register_Color3(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Color3> type");
typedef Color3::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Color3"), Sqrat::Class<Color3>(vm, _SC("Color3"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<const SQChar *, SQChar>()
.SetStaticValue(_SC("delim"), &Color3::Delim)
.Var(_SC("r"), &Color3::r)
.Var(_SC("g"), &Color3::g)
.Var(_SC("b"), &Color3::b)
.Prop(_SC("rgb"), &Color3::GetRGB, &Color3::SetRGB)
.Prop(_SC("rgba"), &Color3::GetRGBA, &Color3::SetRGBA)
.Prop(_SC("argb"), &Color3::GetARGB, &Color3::SetARGB)
.Prop(_SC("str"), &Color3::SetCol)
.Func(_SC("_tostring"), &Color3::ToString)
.Func(_SC("_cmp"), &Color3::Cmp)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("_add"), &Color3::operator +)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("_sub"), &Color3::operator -)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("_mul"), &Color3::operator *)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("_div"), &Color3::operator /)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("_modulo"), &Color3::operator %)
.Func<Color3 (Color3::*)(void) const>(_SC("_unm"), &Color3::operator -)
.Overload<void (Color3::*)(Val)>(_SC("set"), &Color3::Set)
.Overload<void (Color3::*)(Val, Val, Val)>(_SC("set"), &Color3::Set)
.Overload<void (Color3::*)(const Color3 &)>(_SC("set_col3"), &Color3::Set)
.Overload<void (Color3::*)(const Color4 &)>(_SC("set_col4"), &Color3::Set)
.Overload<void (Color3::*)(const SQChar *, SQChar)>(_SC("set_str"), &Color3::Set)
.Overload<void (Color3::*)(void)>(_SC("generate"), &Color3::Generate)
.Overload<void (Color3::*)(Val, Val)>(_SC("generate"), &Color3::Generate)
.Overload<void (Color3::*)(Val, Val, Val, Val, Val, Val)>(_SC("generate"), &Color3::Generate)
.Func(_SC("clear"), &Color3::Clear)
.Func(_SC("random"), &Color3::Random)
.Func(_SC("inverse"), &Color3::Inverse)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opAddAssign"), &Color3::operator +=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opSubAssign"), &Color3::operator -=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opMulAssign"), &Color3::operator *=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opDivAssign"), &Color3::operator /=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opModAssign"), &Color3::operator %=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opAndAssign"), &Color3::operator &=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opOrAssign"), &Color3::operator |=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opXorAssign"), &Color3::operator ^=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opShlAssign"), &Color3::operator <<=)
.Func<Color3 & (Color3::*)(const Color3 &)>(_SC("opShrAssign"), &Color3::operator >>=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opAddAssignS"), &Color3::operator +=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opSubAssignS"), &Color3::operator -=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opMulAssignS"), &Color3::operator *=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opDivAssignS"), &Color3::operator /=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opModAssignS"), &Color3::operator %=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opAndAssignS"), &Color3::operator &=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opOrAssignS"), &Color3::operator |=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opXorAssignS"), &Color3::operator ^=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opShlAssignS"), &Color3::operator <<=)
.Func<Color3 & (Color3::*)(Color3::Value)>(_SC("opShrAssignS"), &Color3::operator >>=)
.Func<Color3 & (Color3::*)(void)>(_SC("opPreInc"), &Color3::operator ++)
.Func<Color3 & (Color3::*)(void)>(_SC("opPreDec"), &Color3::operator --)
.Func<Color3 (Color3::*)(int)>(_SC("opPostInc"), &Color3::operator ++)
.Func<Color3 (Color3::*)(int)>(_SC("opPostDec"), &Color3::operator --)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opAdd"), &Color3::operator +)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opSub"), &Color3::operator -)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opMul"), &Color3::operator *)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opDiv"), &Color3::operator /)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opMod"), &Color3::operator %)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opAnd"), &Color3::operator &)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opOr"), &Color3::operator |)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opShl"), &Color3::operator ^)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opShl"), &Color3::operator <<)
.Func<Color3 (Color3::*)(const Color3 &) const>(_SC("opShr"), &Color3::operator >>)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opAddS"), &Color3::operator +)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opSubS"), &Color3::operator -)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opMulS"), &Color3::operator *)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opDivS"), &Color3::operator /)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opModS"), &Color3::operator %)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opAndS"), &Color3::operator &)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opOrS"), &Color3::operator |)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opShlS"), &Color3::operator ^)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opShlS"), &Color3::operator <<)
.Func<Color3 (Color3::*)(Color3::Value) const>(_SC("opShrS"), &Color3::operator >>)
.Func<Color3 (Color3::*)(void) const>(_SC("opUnPlus"), &Color3::operator +)
.Func<Color3 (Color3::*)(void) const>(_SC("opUnMinus"), &Color3::operator -)
.Func<Color3 (Color3::*)(void) const>(_SC("opCom"), &Color3::operator ~)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opEqual"), &Color3::operator ==)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opNotEqual"), &Color3::operator !=)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opLessThan"), &Color3::operator <)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opGreaterThan"), &Color3::operator >)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opLessEqual"), &Color3::operator <=)
.Func<bool (Color3::*)(const Color3 &) const>(_SC("opGreaterEqual"), &Color3::operator >=)
);
LogDbg("Registration of <Color3> type was successful");
return true;
}
} // Namespace:: SqMod

145
source/Base/Color3.hpp Normal file
View File

@ -0,0 +1,145 @@
#ifndef _BASE_COLOR3_HPP_
#define _BASE_COLOR3_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Color3
{
// --------------------------------------------------------------------------------------------
typedef Uint8 Value;
// --------------------------------------------------------------------------------------------
static const Color3 NIL;
static const Color3 MIN;
static const Color3 MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value r, g, b;
// --------------------------------------------------------------------------------------------
Color3() noexcept;
Color3(Value s) noexcept;
Color3(Value r, Value g, Value b) noexcept;
// --------------------------------------------------------------------------------------------
Color3(const Color4 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color3(const SQChar * name) noexcept;
Color3(const SQChar * str, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Color3(const Color3 & c) noexcept;
Color3(Color3 && c) noexcept;
// --------------------------------------------------------------------------------------------
~Color3();
// --------------------------------------------------------------------------------------------
Color3 & operator = (const Color3 & c) noexcept;
Color3 & operator = (Color3 && c) noexcept;
// --------------------------------------------------------------------------------------------
Color3 & operator = (Value s) noexcept;
Color3 & operator = (const SQChar * name) noexcept;
Color3 & operator = (const Color4 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color3 & operator += (const Color3 & c) noexcept;
Color3 & operator -= (const Color3 & c) noexcept;
Color3 & operator *= (const Color3 & c) noexcept;
Color3 & operator /= (const Color3 & c) noexcept;
Color3 & operator %= (const Color3 & c) noexcept;
Color3 & operator &= (const Color3 & c) noexcept;
Color3 & operator |= (const Color3 & c) noexcept;
Color3 & operator ^= (const Color3 & c) noexcept;
Color3 & operator <<= (const Color3 & c) noexcept;
Color3 & operator >>= (const Color3 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color3 & operator += (Value s) noexcept;
Color3 & operator -= (Value s) noexcept;
Color3 & operator *= (Value s) noexcept;
Color3 & operator /= (Value s) noexcept;
Color3 & operator %= (Value s) noexcept;
Color3 & operator &= (Value s) noexcept;
Color3 & operator |= (Value s) noexcept;
Color3 & operator ^= (Value s) noexcept;
Color3 & operator <<= (Value s) noexcept;
Color3 & operator >>= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Color3 & operator ++ () noexcept;
Color3 & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Color3 operator ++ (int) noexcept;
Color3 operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Color3 operator + (const Color3 & c) const noexcept;
Color3 operator - (const Color3 & c) const noexcept;
Color3 operator * (const Color3 & c) const noexcept;
Color3 operator / (const Color3 & c) const noexcept;
Color3 operator % (const Color3 & c) const noexcept;
Color3 operator & (const Color3 & c) const noexcept;
Color3 operator | (const Color3 & c) const noexcept;
Color3 operator ^ (const Color3 & c) const noexcept;
Color3 operator << (const Color3 & c) const noexcept;
Color3 operator >> (const Color3 & c) const noexcept;
// --------------------------------------------------------------------------------------------
Color3 operator + (Value s) const noexcept;
Color3 operator - (Value s) const noexcept;
Color3 operator * (Value s) const noexcept;
Color3 operator / (Value s) const noexcept;
Color3 operator % (Value s) const noexcept;
Color3 operator & (Value s) const noexcept;
Color3 operator | (Value s) const noexcept;
Color3 operator ^ (Value s) const noexcept;
Color3 operator << (Value s) const noexcept;
Color3 operator >> (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Color3 operator + () const noexcept;
Color3 operator - () const noexcept;
// --------------------------------------------------------------------------------------------
Color3 operator ~ () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Color3 & c) const noexcept;
bool operator != (const Color3 & c) const noexcept;
bool operator < (const Color3 & c) const noexcept;
bool operator > (const Color3 & c) const noexcept;
bool operator <= (const Color3 & c) const noexcept;
bool operator >= (const Color3 & c) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Color3 & c) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nr, Value ng, Value nb) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Color3 & c) noexcept;
void Set(const Color4 & c) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * str, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void SetCol(const SQChar * name) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetRGB() const noexcept;
void SetRGB(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetRGBA() const noexcept;
void SetRGBA(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetARGB() const noexcept;
void SetARGB(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { r = 0, g = 0, b = 0; }
// --------------------------------------------------------------------------------------------
void Random() noexcept;
// --------------------------------------------------------------------------------------------
void Inverse() noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_COLOR3_HPP_

773
source/Base/Color4.cpp Normal file
View File

@ -0,0 +1,773 @@
#include "Base/Color4.hpp"
#include "Base/Color3.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Color4 Color4::NIL = Color4();
const Color4 Color4::MIN = Color4(std::numeric_limits<Color4::Value>::min());
const Color4 Color4::MAX = Color4(std::numeric_limits<Color4::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Color4::Delim = ',';
// ------------------------------------------------------------------------------------------------
Color4::Color4() noexcept
: r(0), g(0), b(0), a(0)
{
}
Color4::Color4(Value s) noexcept
: r(s), g(s), b(s), a(s)
{
}
Color4::Color4(Value rv, Value gv, Value bv) noexcept
: r(rv), g(gv), b(bv), a(0)
{
}
Color4::Color4(Value rv, Value gv, Value bv, Value av) noexcept
: r(rv), g(gv), b(bv), a(av)
{
}
// ------------------------------------------------------------------------------------------------
Color4::Color4(const Color3 & c) noexcept
: r(c.r), g(c.g), b(c.b), a(0)
{
}
// ------------------------------------------------------------------------------------------------
Color4::Color4(const SQChar * name) noexcept
: Color4(GetColor(name))
{
}
Color4::Color4(const SQChar * str, SQChar delim) noexcept
: Color4(GetColor4(str, delim))
{
}
// ------------------------------------------------------------------------------------------------
Color4::Color4(const Color4 & c) noexcept
: r(c.r), g(c.g), b(c.b), a(c.a)
{
}
Color4::Color4(Color4 && c) noexcept
: r(c.r), g(c.g), b(c.b), a(c.a)
{
}
// ------------------------------------------------------------------------------------------------
Color4::~Color4()
{
}
// ------------------------------------------------------------------------------------------------
Color4 & Color4::operator = (const Color4 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
a = c.a;
return *this;
}
Color4 & Color4::operator = (Color4 && c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
a = c.a;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color4 & Color4::operator = (Value s) noexcept
{
r = s;
g = s;
b = s;
a = s;
return *this;
}
Color4 & Color4::operator = (const SQChar * name) noexcept
{
Set(GetColor(name));
return *this;
}
Color4 & Color4::operator = (const Color3 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color4 & Color4::operator += (const Color4 & c) noexcept
{
r += c.r;
g += c.g;
b += c.b;
a += c.a;
return *this;
}
Color4 & Color4::operator -= (const Color4 & c) noexcept
{
r -= c.r;
g -= c.g;
b -= c.b;
a -= c.a;
return *this;
}
Color4 & Color4::operator *= (const Color4 & c) noexcept
{
r *= c.r;
g *= c.g;
b *= c.b;
a *= c.a;
return *this;
}
Color4 & Color4::operator /= (const Color4 & c) noexcept
{
r /= c.r;
g /= c.g;
b /= c.b;
a /= c.a;
return *this;
}
Color4 & Color4::operator %= (const Color4 & c) noexcept
{
r %= c.r;
g %= c.g;
b %= c.b;
a %= c.a;
return *this;
}
Color4 & Color4::operator &= (const Color4 & c) noexcept
{
r &= c.r;
g &= c.g;
b &= c.b;
a &= c.a;
return *this;
}
Color4 & Color4::operator |= (const Color4 & c) noexcept
{
r |= c.r;
g |= c.g;
b |= c.b;
a |= c.a;
return *this;
}
Color4 & Color4::operator ^= (const Color4 & c) noexcept
{
r ^= c.r;
g ^= c.g;
b ^= c.b;
a ^= c.a;
return *this;
}
Color4 & Color4::operator <<= (const Color4 & c) noexcept
{
r <<= c.r;
g <<= c.g;
b <<= c.b;
a <<= c.a;
return *this;
}
Color4 & Color4::operator >>= (const Color4 & c) noexcept
{
r >>= c.r;
g >>= c.g;
b >>= c.b;
a >>= c.a;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color4 & Color4::operator += (Value s) noexcept
{
r += s;
g += s;
b += s;
a += s;
return *this;
}
Color4 & Color4::operator -= (Value s) noexcept
{
r -= s;
g -= s;
b -= s;
a -= s;
return *this;
}
Color4 & Color4::operator *= (Value s) noexcept
{
r *= s;
g *= s;
b *= s;
a *= s;
return *this;
}
Color4 & Color4::operator /= (Value s) noexcept
{
r /= s;
g /= s;
b /= s;
a /= s;
return *this;
}
Color4 & Color4::operator %= (Value s) noexcept
{
r %= s;
g %= s;
b %= s;
a %= s;
return *this;
}
Color4 & Color4::operator &= (Value s) noexcept
{
r &= s;
g &= s;
b &= s;
a &= s;
return *this;
}
Color4 & Color4::operator |= (Value s) noexcept
{
r |= s;
g |= s;
b |= s;
a |= s;
return *this;
}
Color4 & Color4::operator ^= (Value s) noexcept
{
r ^= s;
g ^= s;
b ^= s;
a ^= s;
return *this;
}
Color4 & Color4::operator <<= (Value s) noexcept
{
r <<= s;
g <<= s;
b <<= s;
a <<= s;
return *this;
}
Color4 & Color4::operator >>= (Value s) noexcept
{
r >>= s;
g >>= s;
b >>= s;
a >>= s;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color4 & Color4::operator ++ () noexcept
{
++r;
++g;
++b;
++a;
return *this;
}
Color4 & Color4::operator -- () noexcept
{
--r;
--g;
--b;
--a;
return *this;
}
// ------------------------------------------------------------------------------------------------
Color4 Color4::operator ++ (int) noexcept
{
Color4 state(*this);
++r;
++g;
++b;
++a;
return state;
}
Color4 Color4::operator -- (int) noexcept
{
Color4 state(*this);
--r;
--g;
--b;
--a;
return state;
}
// ------------------------------------------------------------------------------------------------
Color4 Color4::operator + (const Color4 & c) const noexcept
{
return Color4(r + c.r, g + c.g, b + c.b, a + c.a);
}
Color4 Color4::operator - (const Color4 & c) const noexcept
{
return Color4(r - c.r, g - c.g, b - c.b, a - c.a);
}
Color4 Color4::operator * (const Color4 & c) const noexcept
{
return Color4(r * c.r, g * c.g, b * c.b, a * c.a);
}
Color4 Color4::operator / (const Color4 & c) const noexcept
{
return Color4(r / c.r, g / c.g, b / c.b, a / c.a);
}
Color4 Color4::operator % (const Color4 & c) const noexcept
{
return Color4(r % c.r, g % c.g, b % c.b, a % c.a);
}
Color4 Color4::operator & (const Color4 & c) const noexcept
{
return Color4(r & c.r, g & c.g, b & c.b, a & c.a);
}
Color4 Color4::operator | (const Color4 & c) const noexcept
{
return Color4(r | c.r, g | c.g, b | c.b, a | c.a);
}
Color4 Color4::operator ^ (const Color4 & c) const noexcept
{
return Color4(r ^ c.r, g ^ c.g, b ^ c.b, a ^ c.a);
}
Color4 Color4::operator << (const Color4 & c) const noexcept
{
return Color4(r << c.r, g << c.g, b << c.b, a << c.a);
}
Color4 Color4::operator >> (const Color4 & c) const noexcept
{
return Color4(r >> c.r, g >> c.g, b >> c.b, a >> c.a);
}
// ------------------------------------------------------------------------------------------------
Color4 Color4::operator + (Value s) const noexcept
{
return Color4(r + s, g + s, b + s, a + s);
}
Color4 Color4::operator - (Value s) const noexcept
{
return Color4(r - s, g - s, b - s, a - s);
}
Color4 Color4::operator * (Value s) const noexcept
{
return Color4(r * s, g * s, b * s, a * s);
}
Color4 Color4::operator / (Value s) const noexcept
{
return Color4(r / s, g / s, b / s, a / s);
}
Color4 Color4::operator % (Value s) const noexcept
{
return Color4(r % s, g % s, b % s, a % s);
}
Color4 Color4::operator & (Value s) const noexcept
{
return Color4(r & s, g & s, b & s, a & s);
}
Color4 Color4::operator | (Value s) const noexcept
{
return Color4(r | s, g | s, b | s, a | s);
}
Color4 Color4::operator ^ (Value s) const noexcept
{
return Color4(r ^ s, g ^ s, b ^ s, a ^ s);
}
Color4 Color4::operator << (Value s) const noexcept
{
return Color4(r << s, g << s, b << s, a << s);
}
Color4 Color4::operator >> (Value s) const noexcept
{
return Color4(r >> s, g >> s, b >> s, a >> s);
}
// ------------------------------------------------------------------------------------------------
Color4 Color4::operator + () const noexcept
{
return Color4(r, g, b, a);
}
Color4 Color4::operator - () const noexcept
{
return Color4(0, 0, 0, 0);
}
// ------------------------------------------------------------------------------------------------
Color4 Color4::operator ~ () const noexcept
{
return Color4(~r, ~g, ~b, ~a);
}
// ------------------------------------------------------------------------------------------------
bool Color4::operator == (const Color4 & c) const noexcept
{
return (r == c.r) && (g == c.g) && (b == c.b) && (a == c.a);
}
bool Color4::operator != (const Color4 & c) const noexcept
{
return (r != c.r) && (g != c.g) && (b != c.b) && (a != c.a);
}
bool Color4::operator < (const Color4 & c) const noexcept
{
return (r < c.r) && (g < c.g) && (b < c.b) && (a < c.a);
}
bool Color4::operator > (const Color4 & c) const noexcept
{
return (r > c.r) && (g > c.g) && (b > c.b) && (a > c.a);
}
bool Color4::operator <= (const Color4 & c) const noexcept
{
return (r <= c.r) && (g <= c.g) && (b <= c.b) && (a <= c.a);
}
bool Color4::operator >= (const Color4 & c) const noexcept
{
return (r >= c.r) && (g >= c.g) && (b >= c.b) && (a >= c.a);
}
// ------------------------------------------------------------------------------------------------
SQInteger Color4::Cmp(const Color4 & c) const noexcept
{
return *this == c ? 0 : (*this > c ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Color4::ToString() const noexcept
{
return ToStringF("%u,%u,%u,%u", r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
void Color4::Set(Value ns) noexcept
{
r = ns;
g = ns;
b = ns;
a = ns;
}
void Color4::Set(Value nr, Value ng, Value nb) noexcept
{
r = nr;
g = ng;
b = nb;
}
void Color4::Set(Value nr, Value ng, Value nb, Value na) noexcept
{
r = nr;
g = ng;
b = nb;
a = na;
}
// ------------------------------------------------------------------------------------------------
void Color4::Set(const Color4 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
a = c.a;
}
void Color4::Set(const Color3 & c) noexcept
{
r = c.r;
g = c.g;
b = c.b;
a = 0;
}
// ------------------------------------------------------------------------------------------------
void Color4::Set(const SQChar * str, SQChar delim) noexcept
{
Set(GetColor4(str, delim));
}
// ------------------------------------------------------------------------------------------------
void Color4::SetCol(const SQChar * name) noexcept
{
Set(GetColor(name));
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color4::GetRGB() const noexcept
{
return static_cast<SQUint32>(r << 16 | g << 8 | b);
}
void Color4::SetRGB(SQUint32 p) noexcept
{
r = static_cast<Value>((p >> 16) & 0xFF);
g = static_cast<Value>((p >> 8) & 0xFF);
b = static_cast<Value>((p) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color4::GetRGBA() const noexcept
{
return static_cast<SQUint32>(r << 24 | g << 16 | b << 8 | a);
}
void Color4::SetRGBA(SQUint32 p) noexcept
{
r = static_cast<Value>((p >> 24) & 0xFF);
g = static_cast<Value>((p >> 16) & 0xFF);
b = static_cast<Value>((p >> 8) & 0xFF);
a = static_cast<Value>((p) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
SQUint32 Color4::GetARGB() const noexcept
{
return static_cast<SQUint32>(a << 24 | r << 16 | g << 8 | b);
}
void Color4::SetARGB(SQUint32 p) noexcept
{
a = static_cast<Value>((p >> 24) & 0xFF);
r = static_cast<Value>((p >> 16) & 0xFF);
g = static_cast<Value>((p >> 8) & 0xFF);
b = static_cast<Value>((p) & 0xFF);
}
// ------------------------------------------------------------------------------------------------
void Color4::Generate() noexcept
{
r = RandomVal<Value>::Get();
g = RandomVal<Value>::Get();
b = RandomVal<Value>::Get();
a = RandomVal<Value>::Get();
}
void Color4::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
r = RandomVal<Value>::Get(min, max);
g = RandomVal<Value>::Get(min, max);
b = RandomVal<Value>::Get(min, max);
a = RandomVal<Value>::Get(min, max);
}
}
void Color4::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax) noexcept
{
if (rmax < rmin || gmax < gmin || bmax < bmin || amax < amin)
{
LogErr("max value is lower than min value");
}
else
{
r = RandomVal<Value>::Get(rmin, rmax);
g = RandomVal<Value>::Get(gmin, gmax);
b = RandomVal<Value>::Get(bmin, bmax);
a = RandomVal<Value>::Get(bmin, bmax);
}
}
// ------------------------------------------------------------------------------------------------
void Color4::Random() noexcept
{
Set(GetRandomColor());
}
// ------------------------------------------------------------------------------------------------
void Color4::Inverse() noexcept
{
r = static_cast<Value>(~r);
g = static_cast<Value>(~g);
b = static_cast<Value>(~b);
a = static_cast<Value>(~a);
}
// ================================================================================================
bool Register_Color4(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Color4> type");
typedef Color4::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Color4"), Sqrat::Class<Color4>(vm, _SC("Color4"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<Val, Val, Val, Val>()
.Ctor<const SQChar *, SQChar>()
.SetStaticValue(_SC("delim"), &Color4::Delim)
.Var(_SC("r"), &Color4::r)
.Var(_SC("g"), &Color4::g)
.Var(_SC("b"), &Color4::b)
.Var(_SC("a"), &Color4::a)
.Prop(_SC("rgb"), &Color4::GetRGB, &Color4::SetRGB)
.Prop(_SC("rgba"), &Color4::GetRGBA, &Color4::SetRGBA)
.Prop(_SC("argb"), &Color4::GetARGB, &Color4::SetARGB)
.Prop(_SC("str"), &Color4::SetCol)
.Func(_SC("_tostring"), &Color4::ToString)
.Func(_SC("_cmp"), &Color4::Cmp)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("_add"), &Color4::operator +)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("_sub"), &Color4::operator -)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("_mul"), &Color4::operator *)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("_div"), &Color4::operator /)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("_modulo"), &Color4::operator %)
.Func<Color4 (Color4::*)(void) const>(_SC("_unm"), &Color4::operator -)
.Overload<void (Color4::*)(Val)>(_SC("set"), &Color4::Set)
.Overload<void (Color4::*)(Val, Val, Val)>(_SC("set"), &Color4::Set)
.Overload<void (Color4::*)(Val, Val, Val, Val)>(_SC("set"), &Color4::Set)
.Overload<void (Color4::*)(const Color4 &)>(_SC("set_col4"), &Color4::Set)
.Overload<void (Color4::*)(const Color3 &)>(_SC("set_col3"), &Color4::Set)
.Overload<void (Color4::*)(const SQChar *, SQChar)>(_SC("set_str"), &Color4::Set)
.Overload<void (Color4::*)(void)>(_SC("generate"), &Color4::Generate)
.Overload<void (Color4::*)(Val, Val)>(_SC("generate"), &Color4::Generate)
.Overload<void (Color4::*)(Val, Val, Val, Val, Val, Val, Val, Val)>(_SC("generate"), &Color4::Generate)
.Func(_SC("clear"), &Color4::Clear)
.Func(_SC("random"), &Color4::Random)
.Func(_SC("inverse"), &Color4::Inverse)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opAddAssign"), &Color4::operator +=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opSubAssign"), &Color4::operator -=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opMulAssign"), &Color4::operator *=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opDivAssign"), &Color4::operator /=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opModAssign"), &Color4::operator %=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opAndAssign"), &Color4::operator &=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opOrAssign"), &Color4::operator |=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opXorAssign"), &Color4::operator ^=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opShlAssign"), &Color4::operator <<=)
.Func<Color4 & (Color4::*)(const Color4 &)>(_SC("opShrAssign"), &Color4::operator >>=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opAddAssignS"), &Color4::operator +=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opSubAssignS"), &Color4::operator -=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opMulAssignS"), &Color4::operator *=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opDivAssignS"), &Color4::operator /=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opModAssignS"), &Color4::operator %=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opAndAssignS"), &Color4::operator &=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opOrAssignS"), &Color4::operator |=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opXorAssignS"), &Color4::operator ^=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opShlAssignS"), &Color4::operator <<=)
.Func<Color4 & (Color4::*)(Color4::Value)>(_SC("opShrAssignS"), &Color4::operator >>=)
.Func<Color4 & (Color4::*)(void)>(_SC("opPreInc"), &Color4::operator ++)
.Func<Color4 & (Color4::*)(void)>(_SC("opPreDec"), &Color4::operator --)
.Func<Color4 (Color4::*)(int)>(_SC("opPostInc"), &Color4::operator ++)
.Func<Color4 (Color4::*)(int)>(_SC("opPostDec"), &Color4::operator --)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opAdd"), &Color4::operator +)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opSub"), &Color4::operator -)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opMul"), &Color4::operator *)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opDiv"), &Color4::operator /)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opMod"), &Color4::operator %)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opAnd"), &Color4::operator &)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opOr"), &Color4::operator |)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opShl"), &Color4::operator ^)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opShl"), &Color4::operator <<)
.Func<Color4 (Color4::*)(const Color4 &) const>(_SC("opShr"), &Color4::operator >>)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opAddS"), &Color4::operator +)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opSubS"), &Color4::operator -)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opMulS"), &Color4::operator *)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opDivS"), &Color4::operator /)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opModS"), &Color4::operator %)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opAndS"), &Color4::operator &)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opOrS"), &Color4::operator |)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opShlS"), &Color4::operator ^)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opShlS"), &Color4::operator <<)
.Func<Color4 (Color4::*)(Color4::Value) const>(_SC("opShrS"), &Color4::operator >>)
.Func<Color4 (Color4::*)(void) const>(_SC("opUnPlus"), &Color4::operator +)
.Func<Color4 (Color4::*)(void) const>(_SC("opUnMinus"), &Color4::operator -)
.Func<Color4 (Color4::*)(void) const>(_SC("opCom"), &Color4::operator ~)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opEqual"), &Color4::operator ==)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opNotEqual"), &Color4::operator !=)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opLessThan"), &Color4::operator <)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opGreaterThan"), &Color4::operator >)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opLessEqual"), &Color4::operator <=)
.Func<bool (Color4::*)(const Color4 &) const>(_SC("opGreaterEqual"), &Color4::operator >=)
);
LogDbg("Registration of <Color4> type was successful");
return true;
}
} // Namespace:: SqMod

147
source/Base/Color4.hpp Normal file
View File

@ -0,0 +1,147 @@
#ifndef _BASE_COLOR4_HPP_
#define _BASE_COLOR4_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Color4
{
// --------------------------------------------------------------------------------------------
typedef Uint8 Value;
// --------------------------------------------------------------------------------------------
static const Color4 NIL;
static const Color4 MIN;
static const Color4 MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value r, g, b, a;
// --------------------------------------------------------------------------------------------
Color4() noexcept;
Color4(Value s) noexcept;
Color4(Value r, Value g, Value b) noexcept;
Color4(Value r, Value g, Value b, Value a) noexcept;
// --------------------------------------------------------------------------------------------
Color4(const Color3 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color4(const SQChar * name) noexcept;
Color4(const SQChar * str, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Color4(const Color4 & c) noexcept;
Color4(Color4 && c) noexcept;
// --------------------------------------------------------------------------------------------
~Color4();
// --------------------------------------------------------------------------------------------
Color4 & operator = (const Color4 & c) noexcept;
Color4 & operator = (Color4 && c) noexcept;
// --------------------------------------------------------------------------------------------
Color4 & operator = (Value s) noexcept;
Color4 & operator = (const SQChar * name) noexcept;
Color4 & operator = (const Color3 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color4 & operator += (const Color4 & c) noexcept;
Color4 & operator -= (const Color4 & c) noexcept;
Color4 & operator *= (const Color4 & c) noexcept;
Color4 & operator /= (const Color4 & c) noexcept;
Color4 & operator %= (const Color4 & c) noexcept;
Color4 & operator &= (const Color4 & c) noexcept;
Color4 & operator |= (const Color4 & c) noexcept;
Color4 & operator ^= (const Color4 & c) noexcept;
Color4 & operator <<= (const Color4 & c) noexcept;
Color4 & operator >>= (const Color4 & c) noexcept;
// --------------------------------------------------------------------------------------------
Color4 & operator += (Value s) noexcept;
Color4 & operator -= (Value s) noexcept;
Color4 & operator *= (Value s) noexcept;
Color4 & operator /= (Value s) noexcept;
Color4 & operator %= (Value s) noexcept;
Color4 & operator &= (Value s) noexcept;
Color4 & operator |= (Value s) noexcept;
Color4 & operator ^= (Value s) noexcept;
Color4 & operator <<= (Value s) noexcept;
Color4 & operator >>= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Color4 & operator ++ () noexcept;
Color4 & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Color4 operator ++ (int) noexcept;
Color4 operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Color4 operator + (const Color4 & c) const noexcept;
Color4 operator - (const Color4 & c) const noexcept;
Color4 operator * (const Color4 & c) const noexcept;
Color4 operator / (const Color4 & c) const noexcept;
Color4 operator % (const Color4 & c) const noexcept;
Color4 operator & (const Color4 & c) const noexcept;
Color4 operator | (const Color4 & c) const noexcept;
Color4 operator ^ (const Color4 & c) const noexcept;
Color4 operator << (const Color4 & c) const noexcept;
Color4 operator >> (const Color4 & c) const noexcept;
// --------------------------------------------------------------------------------------------
Color4 operator + (Value s) const noexcept;
Color4 operator - (Value s) const noexcept;
Color4 operator * (Value s) const noexcept;
Color4 operator / (Value s) const noexcept;
Color4 operator % (Value s) const noexcept;
Color4 operator & (Value s) const noexcept;
Color4 operator | (Value s) const noexcept;
Color4 operator ^ (Value s) const noexcept;
Color4 operator << (Value s) const noexcept;
Color4 operator >> (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Color4 operator + () const noexcept;
Color4 operator - () const noexcept;
// --------------------------------------------------------------------------------------------
Color4 operator ~ () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Color4 & c) const noexcept;
bool operator != (const Color4 & c) const noexcept;
bool operator < (const Color4 & c) const noexcept;
bool operator > (const Color4 & c) const noexcept;
bool operator <= (const Color4 & c) const noexcept;
bool operator >= (const Color4 & c) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Color4 & c) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nr, Value ng, Value nb) noexcept;
void Set(Value nr, Value ng, Value nb, Value na) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Color4 & c) noexcept;
void Set(const Color3 & c) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * name, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void SetCol(const SQChar * name) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetRGB() const noexcept;
void SetRGB(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetRGBA() const noexcept;
void SetRGBA(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
SQUint32 GetARGB() const noexcept;
void SetARGB(SQUint32 p) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { r = 0, g = 0, b = 0, a = 0; }
// --------------------------------------------------------------------------------------------
void Random() noexcept;
// --------------------------------------------------------------------------------------------
void Inverse() noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_COLOR4_HPP_

562
source/Base/Quaternion.cpp Normal file
View File

@ -0,0 +1,562 @@
#include "Base/Quaternion.hpp"
#include "Base/Vector3.hpp"
#include "Base/Vector4.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Quaternion Quaternion::NIL = Quaternion(0);
const Quaternion Quaternion::MIN = Quaternion(std::numeric_limits<Quaternion::Value>::min());
const Quaternion Quaternion::MAX = Quaternion(std::numeric_limits<Quaternion::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Quaternion::Delim = ',';
// ------------------------------------------------------------------------------------------------
Quaternion::Quaternion() noexcept
: x(0.0), y(0.0), z(0.0), w(0.0)
{
}
Quaternion::Quaternion(Value s) noexcept
: x(s), y(s), z(s), w(s)
{
}
Quaternion::Quaternion(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv), w(0.0)
{
}
Quaternion::Quaternion(Value xv, Value yv, Value zv, Value wv) noexcept
: x(xv), y(yv), z(zv), w(wv)
{
}
// ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(const Vector3 & v) noexcept
: x(v.x), y(v.y), z(v.z), w(0.0)
{
}
Quaternion::Quaternion(const Vector4 & v) noexcept
: x(v.x), y(v.y), z(v.z), w(v.w)
{
}
// ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(const SQChar * values, SQChar delim) noexcept
: Quaternion(GetQuaternion(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Quaternion::Quaternion(const Quaternion & q) noexcept
: x(q.x), y(q.y), z(q.z), w(q.w)
{
}
Quaternion::Quaternion(Quaternion && q) noexcept
: x(q.x), y(q.y), z(q.z), w(q.w)
{
}
// ------------------------------------------------------------------------------------------------
Quaternion::~Quaternion()
{
}
// ------------------------------------------------------------------------------------------------
Quaternion & Quaternion::operator = (const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
return *this;
}
Quaternion & Quaternion::operator = (Quaternion && q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Quaternion & Quaternion::operator = (Value s) noexcept
{
x = s;
y = s;
z = s;
w = s;
return *this;
}
Quaternion & Quaternion::operator = (const Vector3 & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = 0.0;
return *this;
}
Quaternion & Quaternion::operator = (const Vector4 & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Quaternion & Quaternion::operator += (const Quaternion & q) noexcept
{
x += q.x;
y += q.y;
z += q.z;
w += q.w;
return *this;
}
Quaternion & Quaternion::operator -= (const Quaternion & q) noexcept
{
x -= q.x;
y -= q.y;
z -= q.z;
w -= q.w;
return *this;
}
Quaternion & Quaternion::operator *= (const Quaternion & q) noexcept
{
x *= q.x;
y *= q.y;
z *= q.z;
w *= q.w;
return *this;
}
Quaternion & Quaternion::operator /= (const Quaternion & q) noexcept
{
x /= q.x;
y /= q.y;
z /= q.z;
w /= q.w;
return *this;
}
Quaternion & Quaternion::operator %= (const Quaternion & q) noexcept
{
x = std::fmod(x, q.x);
y = std::fmod(y, q.y);
z = std::fmod(z, q.z);
w = std::fmod(w, q.w);
return *this;
}
// ------------------------------------------------------------------------------------------------
Quaternion & Quaternion::operator += (Value s) noexcept
{
x += s;
y += s;
z += s;
w += s;
return *this;
}
Quaternion & Quaternion::operator -= (Value s) noexcept
{
x -= s;
y -= s;
z -= s;
w -= s;
return *this;
}
Quaternion & Quaternion::operator *= (Value s) noexcept
{
x *= s;
y *= s;
z *= s;
w *= s;
return *this;
}
Quaternion & Quaternion::operator /= (Value s) noexcept
{
x /= s;
y /= s;
z /= s;
w /= s;
return *this;
}
Quaternion & Quaternion::operator %= (Value s) noexcept
{
x = std::fmod(x, s);
y = std::fmod(y, s);
z = std::fmod(z, s);
w = std::fmod(w, s);
return *this;
}
// ------------------------------------------------------------------------------------------------
Quaternion & Quaternion::operator ++ () noexcept
{
++x;
++y;
++z;
++w;
return *this;
}
Quaternion & Quaternion::operator -- () noexcept
{
--x;
--y;
--z;
--w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator ++ (int) noexcept
{
Quaternion state(*this);
++x;
++y;
++z;
++w;
return state;
}
Quaternion Quaternion::operator -- (int) noexcept
{
Quaternion state(*this);
--x;
--y;
--z;
--w;
return state;
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator + (const Quaternion & q) const noexcept
{
return Quaternion(x + q.x, y + q.y, z + q.z, w + q.w);
}
Quaternion Quaternion::operator + (Value s) const noexcept
{
return Quaternion(x + s, y + s, z + s, w + s);
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator - (const Quaternion & q) const noexcept
{
return Quaternion(x - q.x, y - q.y, z - q.z, w - q.w);
}
Quaternion Quaternion::operator - (Value s) const noexcept
{
return Quaternion(x - s, y - s, z - s, w - s);
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator * (const Quaternion & q) const noexcept
{
return Quaternion(x * q.x, y * q.y, z * q.z, w * q.w);
}
Quaternion Quaternion::operator * (Value s) const noexcept
{
return Quaternion(x * s, y * s, z * s, w * s);
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator / (const Quaternion & q) const noexcept
{
return Quaternion(x / q.x, y / q.y, z / q.z, w / q.w);
}
Quaternion Quaternion::operator / (Value s) const noexcept
{
return Quaternion(x / s, y / s, z / s, w / s);
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator % (const Quaternion & q) const noexcept
{
return Quaternion(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 noexcept
{
return Quaternion(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s));
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::operator + () const noexcept
{
return Quaternion(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w));
}
Quaternion Quaternion::operator - () const noexcept
{
return Quaternion(-x, -y, -z, -w);
}
// ------------------------------------------------------------------------------------------------
bool Quaternion::operator == (const Quaternion & q) const noexcept
{
return EpsEq(x, q.x) && EpsEq(y, q.y) && EpsEq(z, q.z) && EpsEq(w, q.w);
}
bool Quaternion::operator != (const Quaternion & q) const noexcept
{
return !EpsEq(x, q.x) && !EpsEq(y, q.y) && !EpsEq(z, q.z) && !EpsEq(w, q.w);
}
bool Quaternion::operator < (const Quaternion & q) const noexcept
{
return std::isless(x, q.x) && std::isless(y, q.y) && std::isless(z, q.z) && std::isless(w, q.w);
}
bool Quaternion::operator > (const Quaternion & q) const noexcept
{
return std::isgreater(x, q.x) && std::isgreater(y, q.y) && std::isgreater(z, q.z) && std::isgreater(w, q.w);
}
bool Quaternion::operator <= (const Quaternion & q) const noexcept
{
return std::islessequal(x, q.x) && std::islessequal(y, q.y) && std::islessequal(z, q.z) && std::islessequal(w, q.w);
}
bool Quaternion::operator >= (const Quaternion & q) const noexcept
{
return std::isgreaterequal(x, q.x) && std::isgreaterequal(y, q.y) && std::isgreaterequal(z, q.z) && std::isgreaterequal(w, q.w);
}
// ------------------------------------------------------------------------------------------------
SQInteger Quaternion::Cmp(const Quaternion & q) const noexcept
{
return *this == q ? 0 : (*this > q ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Quaternion::ToString() const noexcept
{
return ToStringF("%f,%f,%f,%f", x, y, z, w);
}
// ------------------------------------------------------------------------------------------------
void Quaternion::Set(Value ns) noexcept
{
x = ns;
y = ns;
z = ns;
w = ns;
}
void Quaternion::Set(Value nx, Value ny, Value nz) noexcept
{
x = nx;
y = ny;
z = nz;
}
void Quaternion::Set(Value nx, Value ny, Value nz, Value nw) noexcept
{
x = nx;
y = ny;
z = nz;
w = nw;
}
// ------------------------------------------------------------------------------------------------
void Quaternion::Set(const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
}
void Quaternion::Set(const Vector3 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = 0.0;
}
void Quaternion::Set(const Vector4 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = v.w;
}
// ------------------------------------------------------------------------------------------------
void Quaternion::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetQuaternion(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Quaternion::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
z = RandomVal<Value>::Get();
w = RandomVal<Value>::Get();
}
void Quaternion::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
z = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
}
}
void Quaternion::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) noexcept
{
if (std::isless(xmax, xmin) || std::isless(ymax, ymin) || std::isless(zmax, zmin) || std::isless(wmax, wmin))
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(xmin, xmax);
y = RandomVal<Value>::Get(ymin, ymax);
z = RandomVal<Value>::Get(zmin, zmax);
y = RandomVal<Value>::Get(ymin, ymax);
}
}
// ------------------------------------------------------------------------------------------------
Quaternion Quaternion::Abs() const noexcept
{
return Quaternion(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w));
}
// ================================================================================================
bool Register_Quaternion(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Quaternion> type");
typedef Quaternion::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Quaternion"), Sqrat::Class<Quaternion>(vm, _SC("Quaternion"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<Val, Val, Val, Val>()
.Ctor<const SQChar *, SQChar>()
.SetStaticValue(_SC("delim"), &Quaternion::Delim)
.Var(_SC("x"), &Quaternion::x)
.Var(_SC("y"), &Quaternion::y)
.Var(_SC("z"), &Quaternion::z)
.Var(_SC("w"), &Quaternion::w)
.Prop(_SC("abs"), &Quaternion::Abs)
.Func(_SC("_tostring"), &Quaternion::ToString)
.Func(_SC("_cmp"), &Quaternion::Cmp)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("_add"), &Quaternion::operator +)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("_sub"), &Quaternion::operator -)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("_mul"), &Quaternion::operator *)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("_div"), &Quaternion::operator /)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("_modulo"), &Quaternion::operator %)
.Func<Quaternion (Quaternion::*)(void) const>(_SC("_unm"), &Quaternion::operator -)
.Overload<void (Quaternion::*)(Val)>(_SC("set"), &Quaternion::Set)
.Overload<void (Quaternion::*)(Val, Val, Val)>(_SC("set"), &Quaternion::Set)
.Overload<void (Quaternion::*)(Val, Val, Val, Val)>(_SC("set"), &Quaternion::Set)
.Overload<void (Quaternion::*)(const Quaternion &)>(_SC("set_quat"), &Quaternion::Set)
.Overload<void (Quaternion::*)(const Vector3 &)>(_SC("set_vec3"), &Quaternion::Set)
.Overload<void (Quaternion::*)(const Vector4 &)>(_SC("set_vec4"), &Quaternion::Set)
.Overload<void (Quaternion::*)(const SQChar *, SQChar)>(_SC("set_str"), &Quaternion::Set)
.Overload<void (Quaternion::*)(void)>(_SC("generate"), &Quaternion::Generate)
.Overload<void (Quaternion::*)(Val, Val)>(_SC("generate"), &Quaternion::Generate)
.Overload<void (Quaternion::*)(Val, Val, Val, Val, Val, Val, Val, Val)>(_SC("generate"), &Quaternion::Generate)
.Func(_SC("clear"), &Quaternion::Clear)
.Func<Quaternion & (Quaternion::*)(const Quaternion &)>(_SC("opAddAssign"), &Quaternion::operator +=)
.Func<Quaternion & (Quaternion::*)(const Quaternion &)>(_SC("opSubAssign"), &Quaternion::operator -=)
.Func<Quaternion & (Quaternion::*)(const Quaternion &)>(_SC("opMulAssign"), &Quaternion::operator *=)
.Func<Quaternion & (Quaternion::*)(const Quaternion &)>(_SC("opDivAssign"), &Quaternion::operator /=)
.Func<Quaternion & (Quaternion::*)(const Quaternion &)>(_SC("opModAssign"), &Quaternion::operator %=)
.Func<Quaternion & (Quaternion::*)(Quaternion::Value)>(_SC("opAddAssignS"), &Quaternion::operator +=)
.Func<Quaternion & (Quaternion::*)(Quaternion::Value)>(_SC("opSubAssignS"), &Quaternion::operator -=)
.Func<Quaternion & (Quaternion::*)(Quaternion::Value)>(_SC("opMulAssignS"), &Quaternion::operator *=)
.Func<Quaternion & (Quaternion::*)(Quaternion::Value)>(_SC("opDivAssignS"), &Quaternion::operator /=)
.Func<Quaternion & (Quaternion::*)(Quaternion::Value)>(_SC("opModAssignS"), &Quaternion::operator %=)
.Func<Quaternion & (Quaternion::*)(void)>(_SC("opPreInc"), &Quaternion::operator ++)
.Func<Quaternion & (Quaternion::*)(void)>(_SC("opPreDec"), &Quaternion::operator --)
.Func<Quaternion (Quaternion::*)(int)>(_SC("opPostInc"), &Quaternion::operator ++)
.Func<Quaternion (Quaternion::*)(int)>(_SC("opPostDec"), &Quaternion::operator --)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("opAdd"), &Quaternion::operator +)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("opSub"), &Quaternion::operator -)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("opMul"), &Quaternion::operator *)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("opDiv"), &Quaternion::operator /)
.Func<Quaternion (Quaternion::*)(const Quaternion &) const>(_SC("opMod"), &Quaternion::operator %)
.Func<Quaternion (Quaternion::*)(Quaternion::Value) const>(_SC("opAddS"), &Quaternion::operator +)
.Func<Quaternion (Quaternion::*)(Quaternion::Value) const>(_SC("opSubS"), &Quaternion::operator -)
.Func<Quaternion (Quaternion::*)(Quaternion::Value) const>(_SC("opMulS"), &Quaternion::operator *)
.Func<Quaternion (Quaternion::*)(Quaternion::Value) const>(_SC("opDivS"), &Quaternion::operator /)
.Func<Quaternion (Quaternion::*)(Quaternion::Value) const>(_SC("opModS"), &Quaternion::operator %)
.Func<Quaternion (Quaternion::*)(void) const>(_SC("opUnPlus"), &Quaternion::operator +)
.Func<Quaternion (Quaternion::*)(void) const>(_SC("opUnMinus"), &Quaternion::operator -)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opEqual"), &Quaternion::operator ==)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opNotEqual"), &Quaternion::operator !=)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opLessThan"), &Quaternion::operator <)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opGreaterThan"), &Quaternion::operator >)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opLessEqual"), &Quaternion::operator <=)
.Func<bool (Quaternion::*)(const Quaternion &) const>(_SC("opGreaterEqual"), &Quaternion::operator >=)
);
LogDbg("Registration of <Quaternion> type was successful");
return true;
}
} // Namespace:: SqMod

113
source/Base/Quaternion.hpp Normal file
View File

@ -0,0 +1,113 @@
#ifndef _BASE_QUATERNION_HPP_
#define _BASE_QUATERNION_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Quaternion
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Quaternion NIL;
static const Quaternion MIN;
static const Quaternion MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y, z, w;
// --------------------------------------------------------------------------------------------
Quaternion() noexcept;
Quaternion(Value s) noexcept;
Quaternion(Value xv, Value yv, Value zv) noexcept;
Quaternion(Value xv, Value yv, Value zv, Value wv) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion(const Vector3 & v) noexcept;
Quaternion(const Vector4 & v) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion(const Quaternion & q) noexcept;
Quaternion(Quaternion && q) noexcept;
// --------------------------------------------------------------------------------------------
~Quaternion();
// --------------------------------------------------------------------------------------------
Quaternion & operator = (const Quaternion & q) noexcept;
Quaternion & operator = (Quaternion && q) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion & operator = (Value s) noexcept;
Quaternion & operator = (const Vector3 & q) noexcept;
Quaternion & operator = (const Vector4 & q) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion & operator += (const Quaternion & q) noexcept;
Quaternion & operator -= (const Quaternion & q) noexcept;
Quaternion & operator *= (const Quaternion & q) noexcept;
Quaternion & operator /= (const Quaternion & q) noexcept;
Quaternion & operator %= (const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion & operator += (Value s) noexcept;
Quaternion & operator -= (Value s) noexcept;
Quaternion & operator *= (Value s) noexcept;
Quaternion & operator /= (Value s) noexcept;
Quaternion & operator %= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion & operator ++ () noexcept;
Quaternion & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Quaternion operator ++ (int) noexcept;
Quaternion operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Quaternion operator + (const Quaternion & q) const noexcept;
Quaternion operator - (const Quaternion & q) const noexcept;
Quaternion operator * (const Quaternion & q) const noexcept;
Quaternion operator / (const Quaternion & q) const noexcept;
Quaternion operator % (const Quaternion & q) const noexcept;
// --------------------------------------------------------------------------------------------
Quaternion operator + (Value s) const noexcept;
Quaternion operator - (Value s) const noexcept;
Quaternion operator * (Value s) const noexcept;
Quaternion operator / (Value s) const noexcept;
Quaternion operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Quaternion operator + () const noexcept;
Quaternion operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Quaternion & q) const noexcept;
bool operator != (const Quaternion & q) const noexcept;
bool operator < (const Quaternion & q) const noexcept;
bool operator > (const Quaternion & q) const noexcept;
bool operator <= (const Quaternion & q) const noexcept;
bool operator >= (const Quaternion & q) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Quaternion & q) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny, Value nz) noexcept;
void Set(Value nx, Value ny, Value nz, Value nw) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Quaternion & q) noexcept;
void Set(const Vector3 & v) noexcept;
void Set(const Vector4 & v) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0.0, y = 0.0, z = 0.0, w = 0.0; }
// --------------------------------------------------------------------------------------------
Quaternion Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_QUATERNION_HPP_

1848
source/Base/Shared.cpp Normal file

File diff suppressed because it is too large Load Diff

400
source/Base/Shared.hpp Normal file
View File

@ -0,0 +1,400 @@
#ifndef _BASE_SHARED_HPP_
#define _BASE_SHARED_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
#include <cmath>
#include <limits>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <type_traits>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
#ifdef PI
#undef PI
#endif
// ------------------------------------------------------------------------------------------------
const Float32 PI = 3.14159265359f;
const Float32 RECIPROCAL_PI = 1.0f/PI;
const Float32 HALF_PI = PI/2.0f;
// ------------------------------------------------------------------------------------------------
#ifdef PI64
#undef PI64
#endif
// ------------------------------------------------------------------------------------------------
const Float64 PI64 = 3.1415926535897932384626433832795028841971693993751;
const Float64 RECIPROCAL_PI64 = 1.0/PI64;
// ------------------------------------------------------------------------------------------------
const Float32 DEGTORAD = PI / 180.0f;
const Float32 RADTODEG = 180.0f / PI;
const Float64 DEGTORAD64 = PI64 / 180.0;
const Float64 RADTODEG64 = 180.0 / PI64;
/* ------------------------------------------------------------------------------------------------
* ...
*/
template< typename T > inline bool EpsEq(const T a, const T b) noexcept
{
return abs(a - b) <= std::numeric_limits<T>::epsilon();
}
template <> inline bool EpsEq(const Float32 a, const Float32 b) noexcept
{
return fabs(a - b) <= 0.000001f;
}
template <> inline bool EpsEq(const Float64 a, const Float64 b) noexcept
{
return fabs(a - b) <= 0.000000001d;
}
/* ------------------------------------------------------------------------------------------------
* ...
*/
template< typename T > inline T Clamp(T val, T min, T max) noexcept
{
return val < min ? min : (val > max ? max : val);
}
template<> inline Float32 Clamp(const Float32 val, const Float32 min, const Float32 max) noexcept
{
return std::isless(val, min) ? min : (std::isgreater(val, max) ? max : val);
}
template<> inline Float64 Clamp(const Float64 val, const Float64 min, const Float64 max) noexcept
{
return std::isless(val, min) ? min : (std::isgreater(val, max) ? max : val);
}
/* ------------------------------------------------------------------------------------------------
* Simple functions to quickly forward logging messages without including the logging system
*/
void LogDbg(const char * fmt, ...) noexcept;
void LogMsg(const char * fmt, ...) noexcept;
void LogScs(const char * fmt, ...) noexcept;
void LogInf(const char * fmt, ...) noexcept;
void LogWrn(const char * fmt, ...) noexcept;
void LogErr(const char * fmt, ...) noexcept;
void LogFtl(const char * fmt, ...) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
const SQChar * ToStringF(const char * fmt, ...) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
void InitMTRG64() noexcept;
void InitMTRG64() noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Int8 GetRandomInt8() noexcept;
Int8 GetRandomInt8(Int8 min, Int8 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Uint8 GetRandomUint8() noexcept;
Uint8 GetRandomUint8(Uint8 min, Uint8 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Int16 GetRandomInt16() noexcept;
Int16 GetRandomInt16(Int16 min, Int16 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Uint16 GetRandomUint16() noexcept;
Uint16 GetRandomUint16(Uint16 min, Uint16 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Int32 GetRandomInt32() noexcept;
Int32 GetRandomInt32(Int32 min, Int32 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Uint32 GetRandomUint32() noexcept;
Uint32 GetRandomUint32(Uint32 min, Uint32 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Int64 GetRandomInt64() noexcept;
Int64 GetRandomInt64(Int64 min, Int64 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Uint64 GetRandomUint64() noexcept;
Uint64 GetRandomUint64(Uint64 min, Uint64 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Float32 GetRandomFloat32() noexcept;
Float32 GetRandomFloat32(Float32 min, Float32 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Float64 GetRandomFloat64() noexcept;
Float64 GetRandomFloat64(Float64 min, Float64 max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
String GetRandomString(String::size_type len) noexcept;
String GetRandomString(String::size_type len, String::value_type min, String::value_type max) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
bool GetRandomBool() noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <typename T> struct RandomVal
{ /* ... */ };
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<Int8>
{
static inline Int8 Get() noexcept { return GetRandomInt8(); }
static inline Int8 Get(Int8 min, Int8 max) noexcept { return GetRandomInt8(min, max); }
};
template <> struct RandomVal<Uint8>
{
static inline Uint8 Get() noexcept { return GetRandomUint8(); }
static inline Uint8 Get(Uint8 min, Uint8 max) noexcept { return GetRandomUint8(min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<Int16>
{
static inline Int16 Get() noexcept { return GetRandomInt16(); }
static inline Int16 Get(Int16 min, Int16 max) noexcept { return GetRandomInt16(min, max); }
};
template <> struct RandomVal<Uint16>
{
static inline Uint16 Get() noexcept { return GetRandomUint16(); }
static inline Uint16 Get(Uint16 min, Uint16 max) noexcept { return GetRandomUint16(min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<Int32>
{
static inline Int32 Get() noexcept { return GetRandomInt32(); }
static inline Int32 Get(Int32 min, Int32 max) noexcept { return GetRandomInt32(min, max); }
};
template <> struct RandomVal<Uint32>
{
static inline Uint32 Get() noexcept { return GetRandomUint32(); }
static inline Uint32 Get(Uint32 min, Uint32 max) noexcept { return GetRandomUint32(min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<Int64>
{
static inline Int64 Get() noexcept { return GetRandomInt64(); }
static inline Int64 Get(Int64 min, Int64 max) noexcept { return GetRandomInt64(min, max); }
};
template <> struct RandomVal<Uint64>
{
static inline Uint64 Get() noexcept { return GetRandomUint64(); }
static inline Uint64 Get(Uint64 min, Uint64 max) noexcept { return GetRandomUint64(min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<Float32>
{
static inline Float32 Get() noexcept { return GetRandomFloat32(); }
static inline Float32 Get(Float32 min, Float32 max) noexcept { return GetRandomFloat32(min, max); }
};
template <> struct RandomVal<Float64>
{
static inline Float64 Get() noexcept { return GetRandomFloat64(); }
static inline Float64 Get(Float64 min, Float64 max) noexcept { return GetRandomFloat64(min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<String>
{
static inline String Get(String::size_type len) noexcept { return GetRandomString(len); }
static inline String Get(String::size_type len, String::value_type min, String::value_type max) noexcept
{ return GetRandomString(len, min, max); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
template <> struct RandomVal<bool>
{
static inline bool Get() noexcept { return GetRandomBool(); }
};
/* ------------------------------------------------------------------------------------------------
* ...
*/
const Color3 & GetRandomColor() noexcept;
/* ------------------------------------------------------------------------------------------------
* Simple function to check whether the specified string can be considered as a boolean value
*/
bool SToB(const SQChar * str) noexcept;
/* ------------------------------------------------------------------------------------------------
* Utility used to unify the string converstion functions under one name.
*/
template < typename T > struct SToI { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template < typename T > struct SToF { static constexpr auto Fn = static_cast< float(*)(const String &, std::size_t*) >(std::stof); };
// ------------------------------------------------------------------------------------------------
template <> struct SToI < char > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < signed char > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < unsigned char > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < short > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < unsigned short > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < int > { static constexpr auto Fn = static_cast< int(*)(const String &, std::size_t*, int) >(std::stoi); };
template <> struct SToI < unsigned int > { static constexpr auto Fn = static_cast< unsigned long(*)(const String &, std::size_t*, int) >(std::stoul); };
template <> struct SToI < long > { static constexpr auto Fn = static_cast< long(*)(const String &, std::size_t*, int) >(std::stol); };
template <> struct SToI < unsigned long > { static constexpr auto Fn = static_cast< unsigned long(*)(const String &, std::size_t*, int) >(std::stoul); };
template <> struct SToI < long long > { static constexpr auto Fn = static_cast< long long(*)(const String &, std::size_t*, int b) >(std::stoll); };
template <> struct SToI < unsigned long long > { static constexpr auto Fn = static_cast< unsigned long long(*)(const String &, std::size_t*, int) >(std::stoull); };
template <> struct SToF < float > { static constexpr auto Fn = static_cast< float(*)(const String &, std::size_t*) >(std::stof); };
template <> struct SToF < double > { static constexpr auto Fn = static_cast< double(*)(const String &, std::size_t*) >(std::stod); };
template <> struct SToF < long double > { static constexpr auto Fn = static_cast< long double(*)(const String &, std::size_t*) >(std::stold); };
// ------------------------------------------------------------------------------------------------
template < typename T > inline String NToS(T n) noexcept { return std::to_string(n); }
template < typename T > inline const SQChar * NToCS(T n) noexcept { return std::to_string(n).c_str(); }
/* ------------------------------------------------------------------------------------------------
* ...
*/
Color3 GetColor(const SQChar * name) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Circle GetCircle(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
AABB GetAABB(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Color3 GetColor3(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Color4 GetColor4(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Quaternion GetQuaternion(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Sphere GetSphere(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Vector2f GetVector2f(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Vector2i GetVector2i(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Vector2u GetVector2u(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Vector3 GetVector3(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* ...
*/
Vector4 GetVector4(const SQChar * str, SQChar delim) noexcept;
/* ------------------------------------------------------------------------------------------------
* Fake deleter meant for classes that should not be deleted by smart pointers
*/
template <typename T> struct FakeDeleter
{
void operator () (T * /* ptr */) const noexcept { /* Ignored... */ }
};
/* ------------------------------------------------------------------------------------------------
* Utility used to generate a string with an arbitrary text surrounded by a specific character
*/
const SQChar * LeftStr(const SQChar * t, SQChar f, SQUint32 w = 72) noexcept;
const SQChar * LeftStr(const SQChar * t, SQChar f, SQUint32 w = 72, SQUint32 o = 0) noexcept;
const SQChar * RightStr(const SQChar * t, SQChar f, SQUint32 w = 72) noexcept;
const SQChar * RightStr(const SQChar * t, SQChar f, SQUint32 w = 72, SQUint32 o = 0) noexcept;
const SQChar * CenterStr(const SQChar * t, SQChar f, SQUint32 w = 72) noexcept;
/* ------------------------------------------------------------------------------------------------
* Function used insert arbitrary text at certain positions within a string
*/
const SQChar * InsertStr(const SQChar * f, const std::vector< const SQChar * > & a) noexcept;
// Utility for the <InsertStr> function
const SQChar * InsStr(const SQChar * f) noexcept;
template < typename... Args > const SQChar * InsStr(const SQChar * f, Args... args) noexcept
{
return InsertStr(f, {{args...}});
}
} // Namespace:: SqMod
#endif // _BASE_SHARED_HPP_

542
source/Base/Sphere.cpp Normal file
View File

@ -0,0 +1,542 @@
#include "Base/Sphere.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Sphere Sphere::NIL = Sphere();
const Sphere Sphere::MIN = Sphere(0.0);
const Sphere Sphere::MAX = Sphere(std::numeric_limits<Sphere::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Sphere::Delim = ',';
// ------------------------------------------------------------------------------------------------
Sphere::Sphere() noexcept
: pos(0.0, 0.0, 0.0), rad(0.0)
{
}
Sphere::Sphere(Value r) noexcept
: pos(0.0, 0.0, 0.0), rad(r)
{
}
Sphere::Sphere(const Vector3 & p) noexcept
: pos(p), rad(0.0)
{
}
Sphere::Sphere(const Vector3 & p, Value r) noexcept
: pos(p), rad(r)
{
}
Sphere::Sphere(Value x, Value y, Value z, Value r) noexcept
: pos(x, y, z), rad(r)
{
}
// ------------------------------------------------------------------------------------------------
Sphere::Sphere(const Sphere & s) noexcept
: pos(s.pos), rad(s.rad)
{
}
Sphere::Sphere(Sphere && s) noexcept
: pos(s.pos), rad(s.rad)
{
}
// ------------------------------------------------------------------------------------------------
Sphere::~Sphere()
{
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator = (const Sphere & s) noexcept
{
pos = s.pos;
rad = s.rad;
return *this;
}
Sphere & Sphere::operator = (Sphere && s) noexcept
{
pos = s.pos;
rad = s.rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator = (Value r) noexcept
{
rad = r;
return *this;
}
Sphere & Sphere::operator = (const Vector3 & p) noexcept
{
pos = p;
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator += (const Sphere & s) noexcept
{
pos += s.pos;
rad += s.rad;
return *this;
}
Sphere & Sphere::operator -= (const Sphere & s) noexcept
{
pos -= s.pos;
rad -= s.rad;
return *this;
}
Sphere & Sphere::operator *= (const Sphere & s) noexcept
{
pos *= s.pos;
rad *= s.rad;
return *this;
}
Sphere & Sphere::operator /= (const Sphere & s) noexcept
{
pos /= s.pos;
rad /= s.rad;
return *this;
}
Sphere & Sphere::operator %= (const Sphere & s) noexcept
{
pos %= s.pos;
rad = std::fmod(rad, s.rad);
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator += (Value r) noexcept
{
rad += r;
return *this;
}
Sphere & Sphere::operator -= (Value r) noexcept
{
rad -= r;
return *this;
}
Sphere & Sphere::operator *= (Value r) noexcept
{
rad *= r;
return *this;
}
Sphere & Sphere::operator /= (Value r) noexcept
{
rad /= r;
return *this;
}
Sphere & Sphere::operator %= (Value r) noexcept
{
rad = std::fmod(rad, r);
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator += (const Vector3 & p) noexcept
{
pos += p;
return *this;
}
Sphere & Sphere::operator -= (const Vector3 & p) noexcept
{
pos -= p;
return *this;
}
Sphere & Sphere::operator *= (const Vector3 & p) noexcept
{
pos *= p;
return *this;
}
Sphere & Sphere::operator /= (const Vector3 & p) noexcept
{
pos /= p;
return *this;
}
Sphere & Sphere::operator %= (const Vector3 & p) noexcept
{
pos %= p;
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator ++ () noexcept
{
++pos;
++rad;
return *this;
}
Sphere & Sphere::operator -- () noexcept
{
--pos;
--rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::operator ++ (int) noexcept
{
Sphere state(*this);
++pos;
++rad;
return state;
}
Sphere Sphere::operator -- (int) noexcept
{
Sphere state(*this);
--pos;
--rad;
return state;
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (const Sphere & s) const noexcept
{
return Sphere(pos + s.pos, rad + s.rad);
}
Sphere Sphere::operator - (const Sphere & s) const noexcept
{
return Sphere(pos - s.pos, rad - s.rad);
}
Sphere Sphere::operator * (const Sphere & s) const noexcept
{
return Sphere(pos * s.pos, rad * s.rad);
}
Sphere Sphere::operator / (const Sphere & s) const noexcept
{
return Sphere(pos / s.pos, rad / s.rad);
}
Sphere Sphere::operator % (const Sphere & s) const noexcept
{
return Sphere(pos % s.pos, std::fmod(rad, s.rad));
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (Value r) const noexcept
{
return Sphere(rad + r);
}
Sphere Sphere::operator - (Value r) const noexcept
{
return Sphere(rad - r);
}
Sphere Sphere::operator * (Value r) const noexcept
{
return Sphere(rad * r);
}
Sphere Sphere::operator / (Value r) const noexcept
{
return Sphere(rad / r);
}
Sphere Sphere::operator % (Value r) const noexcept
{
return Sphere(std::fmod(rad, r));
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + (const Vector3 & p) const noexcept
{
return Sphere(pos + p);
}
Sphere Sphere::operator - (const Vector3 & p) const noexcept
{
return Sphere(pos - p);
}
Sphere Sphere::operator * (const Vector3 & p) const noexcept
{
return Sphere(pos * p);
}
Sphere Sphere::operator / (const Vector3 & p) const noexcept
{
return Sphere(pos / p);
}
Sphere Sphere::operator % (const Vector3 & p) const noexcept
{
return Sphere(pos % p);
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::operator + () const noexcept
{
return Sphere(pos.Abs(), std::fabs(rad));
}
Sphere Sphere::operator - () const noexcept
{
return Sphere(-pos, -rad);
}
// ------------------------------------------------------------------------------------------------
bool Sphere::operator == (const Sphere & s) const noexcept
{
return (rad == s.rad) && (pos == s.pos);
}
bool Sphere::operator != (const Sphere & s) const noexcept
{
return (rad != s.rad) && (pos != s.pos);
}
bool Sphere::operator < (const Sphere & s) const noexcept
{
return (rad < s.rad) && (pos < s.pos);
}
bool Sphere::operator > (const Sphere & s) const noexcept
{
return (rad > s.rad) && (pos > s.pos);
}
bool Sphere::operator <= (const Sphere & s) const noexcept
{
return (rad <= s.rad) && (pos <= s.pos);
}
bool Sphere::operator >= (const Sphere & s) const noexcept
{
return (rad >= s.rad) && (pos >= s.pos);
}
// ------------------------------------------------------------------------------------------------
SQInteger Sphere::Cmp(const Sphere & s) const noexcept
{
return *this == s ? 0 : (*this > s ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Sphere::ToString() const noexcept
{
return ToStringF("%f,%f,%f,%f", pos.x, pos.y, pos.z, rad);
}
// ------------------------------------------------------------------------------------------------
void Sphere::Set(Value nr) noexcept
{
rad = nr;
}
void Sphere::Set(const Sphere & ns) noexcept
{
pos = ns.pos;
rad = ns.rad;
}
void Sphere::Set(const Vector3 & np) noexcept
{
pos = np;
}
void Sphere::Set(const Vector3 & np, Value nr) noexcept
{
pos = np;
rad = nr;
}
// ------------------------------------------------------------------------------------------------
void Sphere::Set(Value nx, Value ny, Value nz) noexcept
{
pos.Set(nx, ny, nz);
}
void Sphere::Set(Value nx, Value ny, Value nz, Value nr) noexcept
{
pos.Set(nx, ny, nz);
rad = nr;
}
// ------------------------------------------------------------------------------------------------
void Sphere::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetSphere(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Sphere::Generate() noexcept
{
pos.Generate();
rad = RandomVal<Value>::Get();
}
void Sphere::Generate(Value min, Value max, bool r) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else if (r)
{
rad = RandomVal<Value>::Get(min, max);
}
else
{
pos.Generate(min, max);
}
}
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) noexcept
{
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
}
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax) noexcept
{
if (std::isless(rmax, rmin))
{
LogErr("max value is lower than min value");
}
else
{
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
rad = RandomVal<Value>::Get(rmin, rmax);
}
}
// ------------------------------------------------------------------------------------------------
Sphere Sphere::Abs() const noexcept
{
return Sphere(pos.Abs(), std::fabs(rad));
}
// ------------------------------------------------------------------------------------------------
bool Register_Sphere(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Sphere> type");
typedef Sphere::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Sphere"), Sqrat::Class<Sphere>(vm, _SC("Sphere"))
.Ctor()
.Ctor<Val>()
.Ctor<const Vector3 &, Val>()
.Ctor<Val, Val, Val, Val>()
.SetStaticValue(_SC("delim"), &Sphere::Delim)
.Var(_SC("pos"), &Sphere::pos)
.Var(_SC("rad"), &Sphere::rad)
.Prop(_SC("abs"), &Sphere::Abs)
.Func(_SC("_tostring"), &Sphere::ToString)
.Func(_SC("_cmp"), &Sphere::Cmp)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_add"), &Sphere::operator +)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_sub"), &Sphere::operator -)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_mul"), &Sphere::operator *)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_div"), &Sphere::operator /)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_modulo"), &Sphere::operator %)
.Func<Sphere (Sphere::*)(void) const>(_SC("_unm"), &Sphere::operator -)
.Overload<void (Sphere::*)(const Sphere &)>(_SC("set"), &Sphere::Set)
.Overload<void (Sphere::*)(const Vector3 &, Val)>(_SC("set"), &Sphere::Set)
.Overload<void (Sphere::*)(Val, Val, Val, Val)>(_SC("set"), &Sphere::Set)
.Overload<void (Sphere::*)(Val)>(_SC("set_rad"), &Sphere::Set)
.Overload<void (Sphere::*)(const Vector3 &)>(_SC("set_vec3"), &Sphere::Set)
.Overload<void (Sphere::*)(Val, Val, Val)>(_SC("set_vec3"), &Sphere::Set)
.Overload<void (Sphere::*)(const SQChar *, SQChar)>(_SC("set_str"), &Sphere::Set)
.Func(_SC("clear"), &Sphere::Clear)
.Func<Sphere & (Sphere::*)(const Sphere &)>(_SC("opAddAssign"), &Sphere::operator +=)
.Func<Sphere & (Sphere::*)(const Sphere &)>(_SC("opSubAssign"), &Sphere::operator -=)
.Func<Sphere & (Sphere::*)(const Sphere &)>(_SC("opMulAssign"), &Sphere::operator *=)
.Func<Sphere & (Sphere::*)(const Sphere &)>(_SC("opDivAssign"), &Sphere::operator /=)
.Func<Sphere & (Sphere::*)(const Sphere &)>(_SC("opModAssign"), &Sphere::operator %=)
.Func<Sphere & (Sphere::*)(Sphere::Value)>(_SC("opAddAssignR"), &Sphere::operator +=)
.Func<Sphere & (Sphere::*)(Sphere::Value)>(_SC("opSubAssignR"), &Sphere::operator -=)
.Func<Sphere & (Sphere::*)(Sphere::Value)>(_SC("opMulAssignR"), &Sphere::operator *=)
.Func<Sphere & (Sphere::*)(Sphere::Value)>(_SC("opDivAssignR"), &Sphere::operator /=)
.Func<Sphere & (Sphere::*)(Sphere::Value)>(_SC("opModAssignR"), &Sphere::operator %=)
.Func<Sphere & (Sphere::*)(const Vector3 &)>(_SC("opAddAssignP"), &Sphere::operator +=)
.Func<Sphere & (Sphere::*)(const Vector3 &)>(_SC("opSubAssignP"), &Sphere::operator -=)
.Func<Sphere & (Sphere::*)(const Vector3 &)>(_SC("opMulAssignP"), &Sphere::operator *=)
.Func<Sphere & (Sphere::*)(const Vector3 &)>(_SC("opDivAssignP"), &Sphere::operator /=)
.Func<Sphere & (Sphere::*)(const Vector3 &)>(_SC("opModAssignP"), &Sphere::operator %=)
.Func<Sphere & (Sphere::*)(void)>(_SC("opPreInc"), &Sphere::operator ++)
.Func<Sphere & (Sphere::*)(void)>(_SC("opPreDec"), &Sphere::operator --)
.Func<Sphere (Sphere::*)(int)>(_SC("opPostInc"), &Sphere::operator ++)
.Func<Sphere (Sphere::*)(int)>(_SC("opPostDec"), &Sphere::operator --)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("opAdd"), &Sphere::operator +)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("opSub"), &Sphere::operator -)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("opMul"), &Sphere::operator *)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("opDiv"), &Sphere::operator /)
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("opMod"), &Sphere::operator %)
.Func<Sphere (Sphere::*)(Sphere::Value) const>(_SC("opAddR"), &Sphere::operator +)
.Func<Sphere (Sphere::*)(Sphere::Value) const>(_SC("opSubR"), &Sphere::operator -)
.Func<Sphere (Sphere::*)(Sphere::Value) const>(_SC("opMulR"), &Sphere::operator *)
.Func<Sphere (Sphere::*)(Sphere::Value) const>(_SC("opDivR"), &Sphere::operator /)
.Func<Sphere (Sphere::*)(Sphere::Value) const>(_SC("opModR"), &Sphere::operator %)
.Func<Sphere (Sphere::*)(const Vector3 &) const>(_SC("opAddP"), &Sphere::operator +)
.Func<Sphere (Sphere::*)(const Vector3 &) const>(_SC("opSubP"), &Sphere::operator -)
.Func<Sphere (Sphere::*)(const Vector3 &) const>(_SC("opMulP"), &Sphere::operator *)
.Func<Sphere (Sphere::*)(const Vector3 &) const>(_SC("opDivP"), &Sphere::operator /)
.Func<Sphere (Sphere::*)(const Vector3 &) const>(_SC("opModP"), &Sphere::operator %)
.Func<Sphere (Sphere::*)(void) const>(_SC("opUnPlus"), &Sphere::operator +)
.Func<Sphere (Sphere::*)(void) const>(_SC("opUnMinus"), &Sphere::operator -)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opEqual"), &Sphere::operator ==)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opNotEqual"), &Sphere::operator !=)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opLessThan"), &Sphere::operator <)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opGreaterThan"), &Sphere::operator >)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opLessEqual"), &Sphere::operator <=)
.Func<bool (Sphere::*)(const Sphere &) const>(_SC("opGreaterEqual"), &Sphere::operator >=)
);
LogDbg("Registration of <Sphere> type was successful");
return true;
}
} // Namespace:: SqMod

123
source/Base/Sphere.hpp Normal file
View File

@ -0,0 +1,123 @@
#ifndef _BASE_SPHERE_HPP_
#define _BASE_SPHERE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
#include "Base/Vector3.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Sphere
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Sphere NIL;
static const Sphere MIN;
static const Sphere MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Vector3 pos;
Value rad;
// --------------------------------------------------------------------------------------------
Sphere() noexcept;
Sphere(Value r) noexcept;
Sphere(const Vector3 & p) noexcept;
Sphere(const Vector3 & p, Value r) noexcept;
Sphere(Value x, Value y, Value z, Value r) noexcept;
// --------------------------------------------------------------------------------------------
Sphere(const Sphere & s) noexcept;
Sphere(Sphere && s) noexcept;
// --------------------------------------------------------------------------------------------
~Sphere();
// --------------------------------------------------------------------------------------------
Sphere & operator = (const Sphere & s) noexcept;
Sphere & operator = (Sphere && s) noexcept;
// --------------------------------------------------------------------------------------------
Sphere & operator = (Value r) noexcept;
Sphere & operator = (const Vector3 & p) noexcept;
// --------------------------------------------------------------------------------------------
Sphere & operator += (const Sphere & s) noexcept;
Sphere & operator -= (const Sphere & s) noexcept;
Sphere & operator *= (const Sphere & s) noexcept;
Sphere & operator /= (const Sphere & s) noexcept;
Sphere & operator %= (const Sphere & s) noexcept;
// --------------------------------------------------------------------------------------------
Sphere & operator += (Value r) noexcept;
Sphere & operator -= (Value r) noexcept;
Sphere & operator *= (Value r) noexcept;
Sphere & operator /= (Value r) noexcept;
Sphere & operator %= (Value r) noexcept;
// --------------------------------------------------------------------------------------------
Sphere & operator += (const Vector3 & p) noexcept;
Sphere & operator -= (const Vector3 & p) noexcept;
Sphere & operator *= (const Vector3 & p) noexcept;
Sphere & operator /= (const Vector3 & p) noexcept;
Sphere & operator %= (const Vector3 & p) noexcept;
// --------------------------------------------------------------------------------------------
Sphere & operator ++ () noexcept;
Sphere & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Sphere operator ++ (int) noexcept;
Sphere operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Sphere operator + (const Sphere & s) const noexcept;
Sphere operator - (const Sphere & s) const noexcept;
Sphere operator * (const Sphere & s) const noexcept;
Sphere operator / (const Sphere & s) const noexcept;
Sphere operator % (const Sphere & s) const noexcept;
// --------------------------------------------------------------------------------------------
Sphere operator + (Value r) const noexcept;
Sphere operator - (Value r) const noexcept;
Sphere operator * (Value r) const noexcept;
Sphere operator / (Value r) const noexcept;
Sphere operator % (Value r) const noexcept;
// --------------------------------------------------------------------------------------------
Sphere operator + (const Vector3 & p) const noexcept;
Sphere operator - (const Vector3 & p) const noexcept;
Sphere operator * (const Vector3 & p) const noexcept;
Sphere operator / (const Vector3 & p) const noexcept;
Sphere operator % (const Vector3 & p) const noexcept;
// --------------------------------------------------------------------------------------------
Sphere operator + () const noexcept;
Sphere operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Sphere & s) const noexcept;
bool operator != (const Sphere & s) const noexcept;
bool operator < (const Sphere & s) const noexcept;
bool operator > (const Sphere & s) const noexcept;
bool operator <= (const Sphere & s) const noexcept;
bool operator >= (const Sphere & s) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Sphere & s) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value nr) noexcept;
void Set(const Sphere & ns) noexcept;
void Set(const Vector3 & np) noexcept;
void Set(const Vector3 & np, Value nr) noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value nx, Value ny, Value nz) noexcept;
void Set(Value nx, Value ny, Value nz, Value nr) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max, bool r) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { pos.Clear(); rad = 0.0; }
// --------------------------------------------------------------------------------------------
Sphere Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_SPHERE_HPP_

493
source/Base/Vector2f.cpp Normal file
View File

@ -0,0 +1,493 @@
#include "Base/Vector2f.hpp"
#include "Base/Vector2i.hpp"
#include "Base/Vector2u.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Vector2f Vector2f::NIL = Vector2f(0);
const Vector2f Vector2f::MIN = Vector2f(std::numeric_limits<Vector2f::Value>::min());
const Vector2f Vector2f::MAX = Vector2f(std::numeric_limits<Vector2f::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Vector2f::Delim = ',';
// ------------------------------------------------------------------------------------------------
Vector2f::Vector2f() noexcept
: x(0.0), y(0.0)
{
}
Vector2f::Vector2f(Value s) noexcept
: x(s), y(s)
{
}
Vector2f::Vector2f(Value xv, Value yv) noexcept
: x(xv), y(yv)
{
}
// ------------------------------------------------------------------------------------------------
Vector2f::Vector2f(const Vector2i & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
Vector2f::Vector2f(const Vector2u & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
// ------------------------------------------------------------------------------------------------
Vector2f::Vector2f(const SQChar * values, SQChar delim) noexcept
: Vector2f(GetVector2f(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Vector2f::Vector2f(const Vector2f & v) noexcept
: x(v.x), y(v.y)
{
}
Vector2f::Vector2f(Vector2f && v) noexcept
: x(v.x), y(v.y)
{
}
// ------------------------------------------------------------------------------------------------
Vector2f::~Vector2f()
{
}
// ------------------------------------------------------------------------------------------------
Vector2f & Vector2f::operator = (const Vector2f & v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
Vector2f & Vector2f::operator = (Vector2f && v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2f & Vector2f::operator = (Value s) noexcept
{
x = s;
y = s;
return *this;
}
Vector2f & Vector2f::operator = (const SQChar * values) noexcept
{
Set(GetVector2f(values, Delim));
return *this;
}
Vector2f & Vector2f::operator = (const Vector2i & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
Vector2f & Vector2f::operator = (const Vector2u & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2f & Vector2f::operator += (const Vector2f & v) noexcept
{
x += v.x;
y += v.y;
return *this;
}
Vector2f & Vector2f::operator -= (const Vector2f & v) noexcept
{
x -= v.x;
y -= v.y;
return *this;
}
Vector2f & Vector2f::operator *= (const Vector2f & v) noexcept
{
x *= v.x;
y *= v.y;
return *this;
}
Vector2f & Vector2f::operator /= (const Vector2f & v) noexcept
{
x /= v.x;
y /= v.y;
return *this;
}
Vector2f & Vector2f::operator %= (const Vector2f & v) noexcept
{
x = std::fmod(x, v.x);
y = std::fmod(y, v.y);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2f & Vector2f::operator += (Value s) noexcept
{
x += s;
y += s;
return *this;
}
Vector2f & Vector2f::operator -= (Value s) noexcept
{
x -= s;
y -= s;
return *this;
}
Vector2f & Vector2f::operator *= (Value s) noexcept
{
x *= s;
y *= s;
return *this;
}
Vector2f & Vector2f::operator /= (Value s) noexcept
{
x /= s;
y /= s;
return *this;
}
Vector2f & Vector2f::operator %= (Value s) noexcept
{
x = std::fmod(x, s);
y = std::fmod(y, s);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2f & Vector2f::operator ++ () noexcept
{
++x;
++y;
return *this;
}
Vector2f & Vector2f::operator -- () noexcept
{
--x;
--y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2f Vector2f::operator ++ (int) noexcept
{
Vector2f state(*this);
++x;
++y;
return state;
}
Vector2f Vector2f::operator -- (int) noexcept
{
Vector2f state(*this);
--x;
--y;
return state;
}
// ------------------------------------------------------------------------------------------------
Vector2f Vector2f::operator + (const Vector2f & v) const noexcept
{
return Vector2f(x + v.x, y + v.y);
}
Vector2f Vector2f::operator - (const Vector2f & v) const noexcept
{
return Vector2f(x - v.x, y - v.y);
}
Vector2f Vector2f::operator * (const Vector2f & v) const noexcept
{
return Vector2f(x * v.x, y * v.y);
}
Vector2f Vector2f::operator / (const Vector2f & v) const noexcept
{
return Vector2f(x / v.x, y / v.y);
}
Vector2f Vector2f::operator % (const Vector2f & v) const noexcept
{
return Vector2f(std::fmod(x, v.x), std::fmod(y, v.y));
}
// ------------------------------------------------------------------------------------------------
Vector2f Vector2f::operator + (Value s) const noexcept
{
return Vector2f(x + s, y + s);
}
Vector2f Vector2f::operator - (Value s) const noexcept
{
return Vector2f(x - s, y - s);
}
Vector2f Vector2f::operator * (Value s) const noexcept
{
return Vector2f(x * s, y * s);
}
Vector2f Vector2f::operator / (Value s) const noexcept
{
return Vector2f(x / s, y / s);
}
Vector2f Vector2f::operator % (Value s) const noexcept
{
return Vector2f(std::fmod(x, s), std::fmod(y, s));
}
// ------------------------------------------------------------------------------------------------
Vector2f Vector2f::operator + () const noexcept
{
return Vector2f(std::fabs(x), std::fabs(y));
}
Vector2f Vector2f::operator - () const noexcept
{
return Vector2f(-x, -y);
}
// ------------------------------------------------------------------------------------------------
bool Vector2f::operator == (const Vector2f & v) const noexcept
{
return EpsEq(x, v.x) && EpsEq(y, v.y);
}
bool Vector2f::operator != (const Vector2f & v) const noexcept
{
return !EpsEq(x, v.x) && !EpsEq(y, v.y);
}
bool Vector2f::operator < (const Vector2f & v) const noexcept
{
return std::isless(x, v.x) && std::isless(y, v.y);
}
bool Vector2f::operator > (const Vector2f & v) const noexcept
{
return std::isgreater(x, v.x) && std::isgreater(y, v.y);
}
bool Vector2f::operator <= (const Vector2f & v) const noexcept
{
return std::islessequal(x, v.x) && std::islessequal(y, v.y);
}
bool Vector2f::operator >= (const Vector2f & v) const noexcept
{
return std::isgreaterequal(x, v.x) && std::isgreaterequal(y, v.y);
}
// ------------------------------------------------------------------------------------------------
SQInteger Vector2f::Cmp(const Vector2f & v) const noexcept
{
return *this == v ? 0 : (*this > v ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Vector2f::ToString() const noexcept
{
return ToStringF("%f,%f", x, y);
}
// ------------------------------------------------------------------------------------------------
void Vector2f::Set(Value ns) noexcept
{
x = ns;
y = ns;
}
void Vector2f::Set(Value nx, Value ny) noexcept
{
x = nx;
y = ny;
}
// ------------------------------------------------------------------------------------------------
void Vector2f::Set(const Vector2f & v) noexcept
{
x = v.x;
y = v.y;
}
void Vector2f::Set(const Vector2i & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
}
void Vector2f::Set(const Vector2u & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
}
// ------------------------------------------------------------------------------------------------
void Vector2f::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetVector2f(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Vector2f::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
}
void Vector2f::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
}
}
void Vector2f::Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept
{
if (xmax < xmin || ymax < ymin)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(ymin, ymax);
y = RandomVal<Value>::Get(xmin, xmax);
}
}
// ------------------------------------------------------------------------------------------------
Vector2f Vector2f::Abs() const noexcept
{
return Vector2f(std::fabs(x), std::fabs(y));
}
// ================================================================================================
bool Register_Vector2f(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Vector2f> type");
typedef Vector2f::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Vector2f"), Sqrat::Class<Vector2f>(vm, _SC("Vector2f"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val>()
.SetStaticValue(_SC("delim"), &Vector2f::Delim)
.Var(_SC("x"), &Vector2f::x)
.Var(_SC("y"), &Vector2f::y)
.Prop(_SC("abs"), &Vector2f::Abs)
.Func(_SC("_tostring"), &Vector2f::ToString)
.Func(_SC("_cmp"), &Vector2f::Cmp)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("_add"), &Vector2f::operator +)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("_sub"), &Vector2f::operator -)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("_mul"), &Vector2f::operator *)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("_div"), &Vector2f::operator /)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("_modulo"), &Vector2f::operator %)
.Func<Vector2f (Vector2f::*)(void) const>(_SC("_unm"), &Vector2f::operator -)
.Overload<void (Vector2f::*)(Val)>(_SC("set"), &Vector2f::Set)
.Overload<void (Vector2f::*)(Val, Val)>(_SC("set"), &Vector2f::Set)
.Overload<void (Vector2f::*)(const Vector2f &)>(_SC("set_vec2f"), &Vector2f::Set)
.Overload<void (Vector2f::*)(const Vector2i &)>(_SC("set_vec2i"), &Vector2f::Set)
.Overload<void (Vector2f::*)(const Vector2u &)>(_SC("set_vec2u"), &Vector2f::Set)
.Overload<void (Vector2f::*)(const SQChar *, SQChar)>(_SC("set_str"), &Vector2f::Set)
.Overload<void (Vector2f::*)(void)>(_SC("generate"), &Vector2f::Generate)
.Overload<void (Vector2f::*)(Val, Val)>(_SC("generate"), &Vector2f::Generate)
.Overload<void (Vector2f::*)(Val, Val, Val, Val)>(_SC("generate"), &Vector2f::Generate)
.Func(_SC("clear"), &Vector2f::Clear)
.Func<Vector2f & (Vector2f::*)(const Vector2f &)>(_SC("opAddAssign"), &Vector2f::operator +=)
.Func<Vector2f & (Vector2f::*)(const Vector2f &)>(_SC("opSubAssign"), &Vector2f::operator -=)
.Func<Vector2f & (Vector2f::*)(const Vector2f &)>(_SC("opMulAssign"), &Vector2f::operator *=)
.Func<Vector2f & (Vector2f::*)(const Vector2f &)>(_SC("opDivAssign"), &Vector2f::operator /=)
.Func<Vector2f & (Vector2f::*)(const Vector2f &)>(_SC("opModAssign"), &Vector2f::operator %=)
.Func<Vector2f & (Vector2f::*)(Vector2f::Value)>(_SC("opAddAssignS"), &Vector2f::operator +=)
.Func<Vector2f & (Vector2f::*)(Vector2f::Value)>(_SC("opSubAssignS"), &Vector2f::operator -=)
.Func<Vector2f & (Vector2f::*)(Vector2f::Value)>(_SC("opMulAssignS"), &Vector2f::operator *=)
.Func<Vector2f & (Vector2f::*)(Vector2f::Value)>(_SC("opDivAssignS"), &Vector2f::operator /=)
.Func<Vector2f & (Vector2f::*)(Vector2f::Value)>(_SC("opModAssignS"), &Vector2f::operator %=)
.Func<Vector2f & (Vector2f::*)(void)>(_SC("opPreInc"), &Vector2f::operator ++)
.Func<Vector2f & (Vector2f::*)(void)>(_SC("opPreDec"), &Vector2f::operator --)
.Func<Vector2f (Vector2f::*)(int)>(_SC("opPostInc"), &Vector2f::operator ++)
.Func<Vector2f (Vector2f::*)(int)>(_SC("opPostDec"), &Vector2f::operator --)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("opAdd"), &Vector2f::operator +)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("opSub"), &Vector2f::operator -)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("opMul"), &Vector2f::operator *)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("opDiv"), &Vector2f::operator /)
.Func<Vector2f (Vector2f::*)(const Vector2f &) const>(_SC("opMod"), &Vector2f::operator %)
.Func<Vector2f (Vector2f::*)(Vector2f::Value) const>(_SC("opAddS"), &Vector2f::operator +)
.Func<Vector2f (Vector2f::*)(Vector2f::Value) const>(_SC("opSubS"), &Vector2f::operator -)
.Func<Vector2f (Vector2f::*)(Vector2f::Value) const>(_SC("opMulS"), &Vector2f::operator *)
.Func<Vector2f (Vector2f::*)(Vector2f::Value) const>(_SC("opDivS"), &Vector2f::operator /)
.Func<Vector2f (Vector2f::*)(Vector2f::Value) const>(_SC("opModS"), &Vector2f::operator %)
.Func<Vector2f (Vector2f::*)(void) const>(_SC("opUnPlus"), &Vector2f::operator +)
.Func<Vector2f (Vector2f::*)(void) const>(_SC("opUnMinus"), &Vector2f::operator -)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opEqual"), &Vector2f::operator ==)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opNotEqual"), &Vector2f::operator !=)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opLessThan"), &Vector2f::operator <)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opGreaterThan"), &Vector2f::operator >)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opLessEqual"), &Vector2f::operator <=)
.Func<bool (Vector2f::*)(const Vector2f &) const>(_SC("opGreaterEqual"), &Vector2f::operator >=)
);
LogDbg("Registration of <Vector2f> type was successful");
return true;
}
} // Namespace:: SqMod

112
source/Base/Vector2f.hpp Normal file
View File

@ -0,0 +1,112 @@
#ifndef _BASE_VECTOR2F_HPP_
#define _BASE_VECTOR2F_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Vector2f
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Vector2f NIL;
static const Vector2f MIN;
static const Vector2f MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y;
// --------------------------------------------------------------------------------------------
Vector2f() noexcept;
Vector2f(Value s) noexcept;
Vector2f(Value xv, Value yv) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f(const Vector2i & v) noexcept;
Vector2f(const Vector2u & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f(const Vector2f & v) noexcept;
Vector2f(Vector2f && v) noexcept;
// --------------------------------------------------------------------------------------------
~Vector2f();
// --------------------------------------------------------------------------------------------
Vector2f & operator = (const Vector2f & v) noexcept;
Vector2f & operator = (Vector2f && v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f & operator = (Value s) noexcept;
Vector2f & operator = (const SQChar * values) noexcept;
Vector2f & operator = (const Vector2i & v) noexcept;
Vector2f & operator = (const Vector2u & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f & operator += (const Vector2f & v) noexcept;
Vector2f & operator -= (const Vector2f & v) noexcept;
Vector2f & operator *= (const Vector2f & v) noexcept;
Vector2f & operator /= (const Vector2f & v) noexcept;
Vector2f & operator %= (const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f & operator += (Value s) noexcept;
Vector2f & operator -= (Value s) noexcept;
Vector2f & operator *= (Value s) noexcept;
Vector2f & operator /= (Value s) noexcept;
Vector2f & operator %= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f & operator ++ () noexcept;
Vector2f & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Vector2f operator ++ (int) noexcept;
Vector2f operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Vector2f operator + (const Vector2f & v) const noexcept;
Vector2f operator - (const Vector2f & v) const noexcept;
Vector2f operator * (const Vector2f & v) const noexcept;
Vector2f operator / (const Vector2f & v) const noexcept;
Vector2f operator % (const Vector2f & v) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2f operator + (Value s) const noexcept;
Vector2f operator - (Value s) const noexcept;
Vector2f operator * (Value s) const noexcept;
Vector2f operator / (Value s) const noexcept;
Vector2f operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2f operator + () const noexcept;
Vector2f operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Vector2f & v) const noexcept;
bool operator != (const Vector2f & v) const noexcept;
bool operator < (const Vector2f & v) const noexcept;
bool operator > (const Vector2f & v) const noexcept;
bool operator <= (const Vector2f & v) const noexcept;
bool operator >= (const Vector2f & v) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Vector2f & v) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector2f & v) noexcept;
void Set(const Vector2i & v) noexcept;
void Set(const Vector2u & v) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0.0, y = 0.0; }
// --------------------------------------------------------------------------------------------
Vector2f Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_VECTOR2F_HPP_

640
source/Base/Vector2i.cpp Normal file
View File

@ -0,0 +1,640 @@
#include "Base/Vector2i.hpp"
#include "Base/Vector2u.hpp"
#include "Base/Vector2f.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Vector2i Vector2i::NIL = Vector2i(0);
const Vector2i Vector2i::MIN = Vector2i(std::numeric_limits<Vector2i::Value>::min());
const Vector2i Vector2i::MAX = Vector2i(std::numeric_limits<Vector2i::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Vector2i::Delim = ',';
// ------------------------------------------------------------------------------------------------
Vector2i::Vector2i() noexcept
: x(0), y(0)
{
}
Vector2i::Vector2i(Value s) noexcept
: x(s), y(s)
{
}
Vector2i::Vector2i(Value xv, Value yv) noexcept
: x(xv), y(yv)
{
}
// ------------------------------------------------------------------------------------------------
Vector2i::Vector2i(const Vector2u & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
Vector2i::Vector2i(const Vector2f & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
// ------------------------------------------------------------------------------------------------
Vector2i::Vector2i(const SQChar * values, SQChar delim) noexcept
: Vector2i(GetVector2i(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Vector2i::Vector2i(const Vector2i & v) noexcept
: x(v.x), y(v.y)
{
}
Vector2i::Vector2i(Vector2i && v) noexcept
: x(v.x), y(v.y)
{
}
// ------------------------------------------------------------------------------------------------
Vector2i::~Vector2i()
{
}
// ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator = (const Vector2i & v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
Vector2i & Vector2i::operator = (Vector2i && v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator = (Value s) noexcept
{
x = s;
y = s;
return *this;
}
Vector2i & Vector2i::operator = (const SQChar * values) noexcept
{
Set(GetVector2i(values, Delim));
return *this;
}
Vector2i & Vector2i::operator = (const Vector2u & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
Vector2i & Vector2i::operator = (const Vector2f & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator += (const Vector2i & v) noexcept
{
x += v.x;
y += v.y;
return *this;
}
Vector2i & Vector2i::operator -= (const Vector2i & v) noexcept
{
x -= v.x;
y -= v.y;
return *this;
}
Vector2i & Vector2i::operator *= (const Vector2i & v) noexcept
{
x *= v.x;
y *= v.y;
return *this;
}
Vector2i & Vector2i::operator /= (const Vector2i & v) noexcept
{
x /= v.x;
y /= v.y;
return *this;
}
Vector2i & Vector2i::operator %= (const Vector2i & v) noexcept
{
x %= v.x;
y %= v.y;
return *this;
}
Vector2i & Vector2i::operator &= (const Vector2i & v) noexcept
{
x &= v.x;
y &= v.y;
return *this;
}
Vector2i & Vector2i::operator |= (const Vector2i & v) noexcept
{
x |= v.x;
y |= v.y;
return *this;
}
Vector2i & Vector2i::operator ^= (const Vector2i & v) noexcept
{
x ^= v.x;
y ^= v.y;
return *this;
}
Vector2i & Vector2i::operator <<= (const Vector2i & v) noexcept
{
x <<= v.x;
y <<= v.y;
return *this;
}
Vector2i & Vector2i::operator >>= (const Vector2i & v) noexcept
{
x >>= v.x;
y >>= v.y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator += (Value s) noexcept
{
x += s;
y += s;
return *this;
}
Vector2i & Vector2i::operator -= (Value s) noexcept
{
x -= s;
y -= s;
return *this;
}
Vector2i & Vector2i::operator *= (Value s) noexcept
{
x *= s;
y *= s;
return *this;
}
Vector2i & Vector2i::operator /= (Value s) noexcept
{
x /= s;
y /= s;
return *this;
}
Vector2i & Vector2i::operator %= (Value s) noexcept
{
x %= s;
y %= s;
return *this;
}
Vector2i & Vector2i::operator &= (Value s) noexcept
{
x &= s;
y &= s;
return *this;
}
Vector2i & Vector2i::operator |= (Value s) noexcept
{
x |= s;
y |= s;
return *this;
}
Vector2i & Vector2i::operator ^= (Value s) noexcept
{
x += s;
y += s;
return *this;
}
Vector2i & Vector2i::operator <<= (Value s) noexcept
{
x <<= s;
y <<= s;
return *this;
}
Vector2i & Vector2i::operator >>= (Value s) noexcept
{
x >>= s;
y >>= s;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2i & Vector2i::operator ++ () noexcept
{
++x;
++y;
return *this;
}
Vector2i & Vector2i::operator -- () noexcept
{
--x;
--y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ++ (int) noexcept
{
Vector2i state(*this);
++x;
++y;
return state;
}
Vector2i Vector2i::operator -- (int) noexcept
{
Vector2i state(*this);
--x;
--y;
return state;
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + (const Vector2i & v) const noexcept
{
return Vector2i(x + v.x, y + v.y);
}
Vector2i Vector2i::operator - (const Vector2i & v) const noexcept
{
return Vector2i(x - v.x, y - v.y);
}
Vector2i Vector2i::operator * (const Vector2i & v) const noexcept
{
return Vector2i(x * v.x, y * v.y);
}
Vector2i Vector2i::operator / (const Vector2i & v) const noexcept
{
return Vector2i(x / v.x, y / v.y);
}
Vector2i Vector2i::operator % (const Vector2i & v) const noexcept
{
return Vector2i(x % v.x, y % v.y);
}
Vector2i Vector2i::operator & (const Vector2i & v) const noexcept
{
return Vector2i(x & v.x, y & v.y);
}
Vector2i Vector2i::operator | (const Vector2i & v) const noexcept
{
return Vector2i(x | v.x, y | v.y);
}
Vector2i Vector2i::operator ^ (const Vector2i & v) const noexcept
{
return Vector2i(x ^ v.x, y ^ v.y);
}
Vector2i Vector2i::operator << (const Vector2i & v) const noexcept
{
return Vector2i(x << v.x, y << v.y);
}
Vector2i Vector2i::operator >> (const Vector2i & v) const noexcept
{
return Vector2i(x >> v.x, y >> v.y);
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + (Value s) const noexcept
{
return Vector2i(x + s, y + s);
}
Vector2i Vector2i::operator - (Value s) const noexcept
{
return Vector2i(x - s, y - s);
}
Vector2i Vector2i::operator * (Value s) const noexcept
{
return Vector2i(x * s, y * s);
}
Vector2i Vector2i::operator / (Value s) const noexcept
{
return Vector2i(x / s, y / s);
}
Vector2i Vector2i::operator % (Value s) const noexcept
{
return Vector2i(x % s, y % s);
}
Vector2i Vector2i::operator & (Value s) const noexcept
{
return Vector2i(x & s, y & s);
}
Vector2i Vector2i::operator | (Value s) const noexcept
{
return Vector2i(x | s, y | s);
}
Vector2i Vector2i::operator ^ (Value s) const noexcept
{
return Vector2i(x ^ s, y ^ s);
}
Vector2i Vector2i::operator << (Value s) const noexcept
{
return Vector2i(x < s, y < s);
}
Vector2i Vector2i::operator >> (Value s) const noexcept
{
return Vector2i(x >> s, y >> s);
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator + () const noexcept
{
return Vector2i(std::abs(x), std::abs(y));
}
Vector2i Vector2i::operator - () const noexcept
{
return Vector2i(-x, -y);
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::operator ~ () const noexcept
{
return Vector2i(~x, ~y);
}
// ------------------------------------------------------------------------------------------------
bool Vector2i::operator == (const Vector2i & v) const noexcept
{
return (x == v.x) && (y == v.y);
}
bool Vector2i::operator != (const Vector2i & v) const noexcept
{
return (x != v.x) && (y != v.y);
}
bool Vector2i::operator < (const Vector2i & v) const noexcept
{
return (x < v.x) && (y < v.y);
}
bool Vector2i::operator > (const Vector2i & v) const noexcept
{
return (x > v.x) && (y > v.y);
}
bool Vector2i::operator <= (const Vector2i & v) const noexcept
{
return (x <= v.x) && (y <= v.y);
}
bool Vector2i::operator >= (const Vector2i & v) const noexcept
{
return (x >= v.x) && (y >= v.y);
}
// ------------------------------------------------------------------------------------------------
SQInteger Vector2i::Cmp(const Vector2i & v) const noexcept
{
return *this == v ? 0 : (*this > v ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Vector2i::ToString() const noexcept
{
return ToStringF("%d,%d", x, y);
}
// ------------------------------------------------------------------------------------------------
void Vector2i::Set(Value ns) noexcept
{
x = ns;
y = ns;
}
void Vector2i::Set(Value nx, Value ny) noexcept
{
x = nx;
y = ny;
}
// ------------------------------------------------------------------------------------------------
void Vector2i::Set(const Vector2i & v) noexcept
{
x = v.x;
y = v.y;
}
void Vector2i::Set(const Vector2u & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
}
void Vector2i::Set(const Vector2f & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
}
// ------------------------------------------------------------------------------------------------
void Vector2i::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetVector2i(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Vector2i::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
}
void Vector2i::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
}
}
void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept
{
if (xmax < xmin || ymax < ymin)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(ymin, ymax);
y = RandomVal<Value>::Get(xmin, xmax);
}
}
// ------------------------------------------------------------------------------------------------
Vector2i Vector2i::Abs() const noexcept
{
return Vector2i(std::abs(x), std::abs(y));
}
// ================================================================================================
bool Register_Vector2i(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Vector2i> type");
typedef Vector2i::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Vector2i"), Sqrat::Class<Vector2i>(vm, _SC("Vector2i"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val>()
.SetStaticValue(_SC("delim"), &Vector2i::Delim)
.Var(_SC("x"), &Vector2i::x)
.Var(_SC("y"), &Vector2i::y)
.Prop(_SC("abs"), &Vector2i::Abs)
.Func(_SC("_tostring"), &Vector2i::ToString)
.Func(_SC("_cmp"), &Vector2i::Cmp)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_add"), &Vector2i::operator +)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_sub"), &Vector2i::operator -)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_mul"), &Vector2i::operator *)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_div"), &Vector2i::operator /)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_modulo"), &Vector2i::operator %)
.Func<Vector2i (Vector2i::*)(void) const>(_SC("_unm"), &Vector2i::operator -)
.Overload<void (Vector2i::*)(Val)>(_SC("set"), &Vector2i::Set)
.Overload<void (Vector2i::*)(Val, Val)>(_SC("set"), &Vector2i::Set)
.Overload<void (Vector2i::*)(const Vector2i &)>(_SC("set_vec2i"), &Vector2i::Set)
.Overload<void (Vector2i::*)(const Vector2u &)>(_SC("set_vec2u"), &Vector2i::Set)
.Overload<void (Vector2i::*)(const Vector2f &)>(_SC("set_vec2f"), &Vector2i::Set)
.Overload<void (Vector2i::*)(const SQChar *, SQChar)>(_SC("set_str"), &Vector2i::Set)
.Overload<void (Vector2i::*)(void)>(_SC("generate"), &Vector2i::Generate)
.Overload<void (Vector2i::*)(Val, Val)>(_SC("generate"), &Vector2i::Generate)
.Overload<void (Vector2i::*)(Val, Val, Val, Val)>(_SC("generate"), &Vector2i::Generate)
.Func(_SC("clear"), &Vector2i::Clear)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opAddAssign"), &Vector2i::operator +=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opSubAssign"), &Vector2i::operator -=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opMulAssign"), &Vector2i::operator *=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opDivAssign"), &Vector2i::operator /=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opModAssign"), &Vector2i::operator %=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opAndAssign"), &Vector2i::operator &=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opOrAssign"), &Vector2i::operator |=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opXorAssign"), &Vector2i::operator ^=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opShlAssign"), &Vector2i::operator <<=)
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opShrAssign"), &Vector2i::operator >>=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opAddAssignS"), &Vector2i::operator +=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opSubAssignS"), &Vector2i::operator -=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opMulAssignS"), &Vector2i::operator *=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opDivAssignS"), &Vector2i::operator /=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opModAssignS"), &Vector2i::operator %=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opAndAssignS"), &Vector2i::operator &=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opOrAssignS"), &Vector2i::operator |=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opXorAssignS"), &Vector2i::operator ^=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opShlAssignS"), &Vector2i::operator <<=)
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opShrAssignS"), &Vector2i::operator >>=)
.Func<Vector2i & (Vector2i::*)(void)>(_SC("opPreInc"), &Vector2i::operator ++)
.Func<Vector2i & (Vector2i::*)(void)>(_SC("opPreDec"), &Vector2i::operator --)
.Func<Vector2i (Vector2i::*)(int)>(_SC("opPostInc"), &Vector2i::operator ++)
.Func<Vector2i (Vector2i::*)(int)>(_SC("opPostDec"), &Vector2i::operator --)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opAdd"), &Vector2i::operator +)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opSub"), &Vector2i::operator -)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opMul"), &Vector2i::operator *)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opDiv"), &Vector2i::operator /)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opMod"), &Vector2i::operator %)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opAnd"), &Vector2i::operator &)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opOr"), &Vector2i::operator |)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShl"), &Vector2i::operator ^)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShl"), &Vector2i::operator <<)
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShr"), &Vector2i::operator >>)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opAddS"), &Vector2i::operator +)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opSubS"), &Vector2i::operator -)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opMulS"), &Vector2i::operator *)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opDivS"), &Vector2i::operator /)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opModS"), &Vector2i::operator %)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opAndS"), &Vector2i::operator &)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opOrS"), &Vector2i::operator |)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShlS"), &Vector2i::operator ^)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShlS"), &Vector2i::operator <<)
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShrS"), &Vector2i::operator >>)
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opUnPlus"), &Vector2i::operator +)
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opUnMinus"), &Vector2i::operator -)
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opCom"), &Vector2i::operator ~)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opEqual"), &Vector2i::operator ==)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opNotEqual"), &Vector2i::operator !=)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opLessThan"), &Vector2i::operator <)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterThan"), &Vector2i::operator >)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opLessEqual"), &Vector2i::operator <=)
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterEqual"), &Vector2i::operator >=)
);
LogDbg("Registration of <Vector2i> type was successful");
return true;
}
} // Namespace:: SqMod

134
source/Base/Vector2i.hpp Normal file
View File

@ -0,0 +1,134 @@
#ifndef _BASE_VECTOR2I_HPP_
#define _BASE_VECTOR2I_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Vector2i
{
// --------------------------------------------------------------------------------------------
typedef SQInt32 Value;
// --------------------------------------------------------------------------------------------
static const Vector2i NIL;
static const Vector2i MIN;
static const Vector2i MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y;
// --------------------------------------------------------------------------------------------
Vector2i() noexcept;
Vector2i(Value s) noexcept;
Vector2i(Value xv, Value yv) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i(const Vector2u & v) noexcept;
Vector2i(const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i(const Vector2i & v) noexcept;
Vector2i(Vector2i && v) noexcept;
// --------------------------------------------------------------------------------------------
~Vector2i();
// --------------------------------------------------------------------------------------------
Vector2i & operator = (const Vector2i & v) noexcept;
Vector2i & operator = (Vector2i && v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i & operator = (Value s) noexcept;
Vector2i & operator = (const SQChar * values) noexcept;
Vector2i & operator = (const Vector2u & v) noexcept;
Vector2i & operator = (const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i & operator += (const Vector2i & v) noexcept;
Vector2i & operator -= (const Vector2i & v) noexcept;
Vector2i & operator *= (const Vector2i & v) noexcept;
Vector2i & operator /= (const Vector2i & v) noexcept;
Vector2i & operator %= (const Vector2i & v) noexcept;
Vector2i & operator &= (const Vector2i & v) noexcept;
Vector2i & operator |= (const Vector2i & v) noexcept;
Vector2i & operator ^= (const Vector2i & v) noexcept;
Vector2i & operator <<= (const Vector2i & v) noexcept;
Vector2i & operator >>= (const Vector2i & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i & operator += (Value s) noexcept;
Vector2i & operator -= (Value s) noexcept;
Vector2i & operator *= (Value s) noexcept;
Vector2i & operator /= (Value s) noexcept;
Vector2i & operator %= (Value s) noexcept;
Vector2i & operator &= (Value s) noexcept;
Vector2i & operator |= (Value s) noexcept;
Vector2i & operator ^= (Value s) noexcept;
Vector2i & operator <<= (Value s) noexcept;
Vector2i & operator >>= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i & operator ++ () noexcept;
Vector2i & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Vector2i operator ++ (int) noexcept;
Vector2i operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Vector2i operator + (const Vector2i & v) const noexcept;
Vector2i operator - (const Vector2i & v) const noexcept;
Vector2i operator * (const Vector2i & v) const noexcept;
Vector2i operator / (const Vector2i & v) const noexcept;
Vector2i operator % (const Vector2i & v) const noexcept;
Vector2i operator & (const Vector2i & v) const noexcept;
Vector2i operator | (const Vector2i & v) const noexcept;
Vector2i operator ^ (const Vector2i & v) const noexcept;
Vector2i operator << (const Vector2i & v) const noexcept;
Vector2i operator >> (const Vector2i & v) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2i operator + (Value s) const noexcept;
Vector2i operator - (Value s) const noexcept;
Vector2i operator * (Value s) const noexcept;
Vector2i operator / (Value s) const noexcept;
Vector2i operator % (Value s) const noexcept;
Vector2i operator & (Value s) const noexcept;
Vector2i operator | (Value s) const noexcept;
Vector2i operator ^ (Value s) const noexcept;
Vector2i operator << (Value s) const noexcept;
Vector2i operator >> (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2i operator + () const noexcept;
Vector2i operator - () const noexcept;
// --------------------------------------------------------------------------------------------
Vector2i operator ~ () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Vector2i & v) const noexcept;
bool operator != (const Vector2i & v) const noexcept;
bool operator < (const Vector2i & v) const noexcept;
bool operator > (const Vector2i & v) const noexcept;
bool operator <= (const Vector2i & v) const noexcept;
bool operator >= (const Vector2i & v) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Vector2i & v) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector2i & v) noexcept;
void Set(const Vector2u & v) noexcept;
void Set(const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0, y = 0; }
// --------------------------------------------------------------------------------------------
Vector2i Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_VECTOR2I_HPP_

640
source/Base/Vector2u.cpp Normal file
View File

@ -0,0 +1,640 @@
#include "Base/Vector2u.hpp"
#include "Base/Vector2f.hpp"
#include "Base/Vector2i.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Vector2u Vector2u::NIL = Vector2u(0);
const Vector2u Vector2u::MIN = Vector2u(std::numeric_limits<Vector2u::Value>::min());
const Vector2u Vector2u::MAX = Vector2u(std::numeric_limits<Vector2u::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Vector2u::Delim = ',';
// ------------------------------------------------------------------------------------------------
Vector2u::Vector2u() noexcept
: x(0), y(0)
{
}
Vector2u::Vector2u(Value s) noexcept
: x(s), y(s)
{
}
Vector2u::Vector2u(Value xv, Value yv) noexcept
: x(xv), y(yv)
{
}
// ------------------------------------------------------------------------------------------------
Vector2u::Vector2u(const Vector2i & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
Vector2u::Vector2u(const Vector2f & v) noexcept
: x(static_cast<Value>(v.x)), y(static_cast<Value>(v.y))
{
}
// ------------------------------------------------------------------------------------------------
Vector2u::Vector2u(const SQChar * values, SQChar delim) noexcept
: Vector2u(GetVector2u(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Vector2u::Vector2u(const Vector2u & v) noexcept
: x(v.x), y(v.y)
{
}
Vector2u::Vector2u(Vector2u && v) noexcept
: x(v.x), y(v.y)
{
}
// ------------------------------------------------------------------------------------------------
Vector2u::~Vector2u()
{
}
// ------------------------------------------------------------------------------------------------
Vector2u & Vector2u::operator = (const Vector2u & v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
Vector2u & Vector2u::operator = (Vector2u && v) noexcept
{
x = v.x;
y = v.y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2u & Vector2u::operator = (Value s) noexcept
{
x = s;
y = s;
return *this;
}
Vector2u & Vector2u::operator = (const SQChar * values) noexcept
{
Set(GetVector2i(values, Delim));
return *this;
}
Vector2u & Vector2u::operator = (const Vector2i & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
Vector2u & Vector2u::operator = (const Vector2f & v) noexcept
{
x = static_cast<Value>(v.x);
y = static_cast<Value>(v.y);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2u & Vector2u::operator += (const Vector2u & v) noexcept
{
x += v.x;
y += v.y;
return *this;
}
Vector2u & Vector2u::operator -= (const Vector2u & v) noexcept
{
x -= v.x;
y -= v.y;
return *this;
}
Vector2u & Vector2u::operator *= (const Vector2u & v) noexcept
{
x *= v.x;
y *= v.y;
return *this;
}
Vector2u & Vector2u::operator /= (const Vector2u & v) noexcept
{
x /= v.x;
y /= v.y;
return *this;
}
Vector2u & Vector2u::operator %= (const Vector2u & v) noexcept
{
x %= v.x;
y %= v.y;
return *this;
}
Vector2u & Vector2u::operator &= (const Vector2u & v) noexcept
{
x &= v.x;
y &= v.y;
return *this;
}
Vector2u & Vector2u::operator |= (const Vector2u & v) noexcept
{
x |= v.x;
y |= v.y;
return *this;
}
Vector2u & Vector2u::operator ^= (const Vector2u & v) noexcept
{
x ^= v.x;
y ^= v.y;
return *this;
}
Vector2u & Vector2u::operator <<= (const Vector2u & v) noexcept
{
x <<= v.x;
y <<= v.y;
return *this;
}
Vector2u & Vector2u::operator >>= (const Vector2u & v) noexcept
{
x >>= v.x;
y >>= v.y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2u & Vector2u::operator += (Value s) noexcept
{
x += s;
y += s;
return *this;
}
Vector2u & Vector2u::operator -= (Value s) noexcept
{
x -= s;
y -= s;
return *this;
}
Vector2u & Vector2u::operator *= (Value s) noexcept
{
x *= s;
y *= s;
return *this;
}
Vector2u & Vector2u::operator /= (Value s) noexcept
{
x /= s;
y /= s;
return *this;
}
Vector2u & Vector2u::operator %= (Value s) noexcept
{
x %= s;
y %= s;
return *this;
}
Vector2u & Vector2u::operator &= (Value s) noexcept
{
x &= s;
y &= s;
return *this;
}
Vector2u & Vector2u::operator |= (Value s) noexcept
{
x |= s;
y |= s;
return *this;
}
Vector2u & Vector2u::operator ^= (Value s) noexcept
{
x ^= s;
y ^= s;
return *this;
}
Vector2u & Vector2u::operator <<= (Value s) noexcept
{
x <<= s;
y <<= s;
return *this;
}
Vector2u & Vector2u::operator >>= (Value s) noexcept
{
x >>= s;
y >>= s;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2u & Vector2u::operator ++ () noexcept
{
++x;
++y;
return *this;
}
Vector2u & Vector2u::operator -- () noexcept
{
--x;
--y;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::operator ++ (int) noexcept
{
Vector2i state(*this);
++x;
++y;
return state;
}
Vector2u Vector2u::operator -- (int) noexcept
{
Vector2i state(*this);
--x;
--y;
return state;
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::operator + (const Vector2u & v) const noexcept
{
return Vector2i(x + v.x, y + v.y);
}
Vector2u Vector2u::operator - (const Vector2u & v) const noexcept
{
return Vector2i(x - v.x, y - v.y);
}
Vector2u Vector2u::operator * (const Vector2u & v) const noexcept
{
return Vector2i(x * v.x, y * v.y);
}
Vector2u Vector2u::operator / (const Vector2u & v) const noexcept
{
return Vector2i(x / v.x, y / v.y);
}
Vector2u Vector2u::operator % (const Vector2u & v) const noexcept
{
return Vector2i(x % v.x, y % v.y);
}
Vector2u Vector2u::operator & (const Vector2u & v) const noexcept
{
return Vector2i(x & v.x, y & v.y);
}
Vector2u Vector2u::operator | (const Vector2u & v) const noexcept
{
return Vector2i(x | v.x, y | v.y);
}
Vector2u Vector2u::operator ^ (const Vector2u & v) const noexcept
{
return Vector2i(x ^ v.x, y ^ v.y);
}
Vector2u Vector2u::operator << (const Vector2u & v) const noexcept
{
return Vector2i(x << v.x, y << v.y);
}
Vector2u Vector2u::operator >> (const Vector2u & v) const noexcept
{
return Vector2i(x >> v.x, y >> v.y);
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::operator + (Value s) const noexcept
{
return Vector2i(x + s, y + s);
}
Vector2u Vector2u::operator - (Value s) const noexcept
{
return Vector2i(x - s, y - s);
}
Vector2u Vector2u::operator * (Value s) const noexcept
{
return Vector2i(x - s, y - s);
}
Vector2u Vector2u::operator / (Value s) const noexcept
{
return Vector2i(x / s, y / s);
}
Vector2u Vector2u::operator % (Value s) const noexcept
{
return Vector2i(x % s, y % s);
}
Vector2u Vector2u::operator & (Value s) const noexcept
{
return Vector2i(x & s, y & s);
}
Vector2u Vector2u::operator | (Value s) const noexcept
{
return Vector2i(x | s, y | s);
}
Vector2u Vector2u::operator ^ (Value s) const noexcept
{
return Vector2i(x ^ s, y ^ s);
}
Vector2u Vector2u::operator << (Value s) const noexcept
{
return Vector2i(x << s, y << s);
}
Vector2u Vector2u::operator >> (Value s) const noexcept
{
return Vector2i(x >> s, y >> s);
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::operator + () const noexcept
{
return Vector2i(x, y);
}
Vector2u Vector2u::operator - () const noexcept
{
return Vector2i(0, 0);
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::operator ~ () const noexcept
{
return Vector2i(~x, ~y);
}
// ------------------------------------------------------------------------------------------------
bool Vector2u::operator == (const Vector2u & v) const noexcept
{
return (x == v.x) && (y == v.y);
}
bool Vector2u::operator != (const Vector2u & v) const noexcept
{
return (x != v.x) && (y != v.y);
}
bool Vector2u::operator < (const Vector2u & v) const noexcept
{
return (x < v.x) && (y < v.y);
}
bool Vector2u::operator > (const Vector2u & v) const noexcept
{
return (x > v.x) && (y > v.y);
}
bool Vector2u::operator <= (const Vector2u & v) const noexcept
{
return (x <= v.x) && (y <= v.y);
}
bool Vector2u::operator >= (const Vector2u & v) const noexcept
{
return (x >= v.x) && (y >= v.y);
}
// ------------------------------------------------------------------------------------------------
SQInteger Vector2u::Cmp(const Vector2u & v) const noexcept
{
return *this == v ? 0 : (*this > v ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Vector2u::ToString() const noexcept
{
return ToStringF("%u,%u", x, y);
}
// ------------------------------------------------------------------------------------------------
void Vector2u::Set(Value ns) noexcept
{
x = ns;
y = ns;
}
void Vector2u::Set(Value nx, Value ny) noexcept
{
x = nx;
y = ny;
}
// ------------------------------------------------------------------------------------------------
void Vector2u::Set(const Vector2u & v) noexcept
{
x = v.x;
y = v.y;
}
void Vector2u::Set(const Vector2i & v) noexcept
{
x = static_cast<SQInt32>(v.x);
y = static_cast<SQInt32>(v.y);
}
void Vector2u::Set(const Vector2f & v) noexcept
{
x = static_cast<SQInt32>(v.x);
y = static_cast<SQInt32>(v.y);
}
// ------------------------------------------------------------------------------------------------
void Vector2u::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetVector2i(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Vector2u::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
}
void Vector2u::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
}
}
void Vector2u::Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept
{
if (xmax < xmin || ymax < ymin)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(ymin, ymax);
y = RandomVal<Value>::Get(xmin, xmax);
}
}
// ------------------------------------------------------------------------------------------------
Vector2u Vector2u::Abs() const noexcept
{
return Vector2i(x, y);
}
// ================================================================================================
bool Register_Vector2u(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Vector2u> type");
typedef Vector2u::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Vector2u"), Sqrat::Class<Vector2u>(vm, _SC("Vector2u"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val>()
.SetStaticValue(_SC("delim"), &Vector2u::Delim)
.Var(_SC("x"), &Vector2u::x)
.Var(_SC("y"), &Vector2u::y)
.Prop(_SC("abs"), &Vector2u::Abs)
.Func(_SC("_tostring"), &Vector2u::ToString)
.Func(_SC("_cmp"), &Vector2u::Cmp)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("_add"), &Vector2u::operator +)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("_sub"), &Vector2u::operator -)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("_mul"), &Vector2u::operator *)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("_div"), &Vector2u::operator /)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("_modulo"), &Vector2u::operator %)
.Func<Vector2u (Vector2u::*)(void) const>(_SC("_unm"), &Vector2u::operator -)
.Overload<void (Vector2u::*)(Val)>(_SC("set"), &Vector2u::Set)
.Overload<void (Vector2u::*)(Val, Val)>(_SC("set"), &Vector2u::Set)
.Overload<void (Vector2u::*)(const Vector2u &)>(_SC("set_vec2u"), &Vector2u::Set)
.Overload<void (Vector2u::*)(const Vector2i &)>(_SC("set_vec2i"), &Vector2u::Set)
.Overload<void (Vector2u::*)(const Vector2f &)>(_SC("set_vec2f"), &Vector2u::Set)
.Overload<void (Vector2u::*)(const SQChar *, SQChar)>(_SC("set_str"), &Vector2u::Set)
.Overload<void (Vector2u::*)(void)>(_SC("generate"), &Vector2u::Generate)
.Overload<void (Vector2u::*)(Val, Val)>(_SC("generate"), &Vector2u::Generate)
.Overload<void (Vector2u::*)(Val, Val, Val, Val)>(_SC("generate"), &Vector2u::Generate)
.Func(_SC("clear"), &Vector2u::Clear)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opAddAssign"), &Vector2u::operator +=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opSubAssign"), &Vector2u::operator -=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opMulAssign"), &Vector2u::operator *=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opDivAssign"), &Vector2u::operator /=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opModAssign"), &Vector2u::operator %=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opAndAssign"), &Vector2u::operator &=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opOrAssign"), &Vector2u::operator |=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opXorAssign"), &Vector2u::operator ^=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opShlAssign"), &Vector2u::operator <<=)
.Func<Vector2u & (Vector2u::*)(const Vector2u &)>(_SC("opShrAssign"), &Vector2u::operator >>=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opAddAssignS"), &Vector2u::operator +=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opSubAssignS"), &Vector2u::operator -=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opMulAssignS"), &Vector2u::operator *=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opDivAssignS"), &Vector2u::operator /=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opModAssignS"), &Vector2u::operator %=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opAndAssignS"), &Vector2u::operator &=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opOrAssignS"), &Vector2u::operator |=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opXorAssignS"), &Vector2u::operator ^=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opShlAssignS"), &Vector2u::operator <<=)
.Func<Vector2u & (Vector2u::*)(Vector2u::Value)>(_SC("opShrAssignS"), &Vector2u::operator >>=)
.Func<Vector2u & (Vector2u::*)(void)>(_SC("opPreInc"), &Vector2u::operator ++)
.Func<Vector2u & (Vector2u::*)(void)>(_SC("opPreDec"), &Vector2u::operator --)
.Func<Vector2u (Vector2u::*)(int)>(_SC("opPostInc"), &Vector2u::operator ++)
.Func<Vector2u (Vector2u::*)(int)>(_SC("opPostDec"), &Vector2u::operator --)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opAdd"), &Vector2u::operator +)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opSub"), &Vector2u::operator -)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opMul"), &Vector2u::operator *)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opDiv"), &Vector2u::operator /)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opMod"), &Vector2u::operator %)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opAnd"), &Vector2u::operator &)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opOr"), &Vector2u::operator |)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opShl"), &Vector2u::operator ^)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opShl"), &Vector2u::operator <<)
.Func<Vector2u (Vector2u::*)(const Vector2u &) const>(_SC("opShr"), &Vector2u::operator >>)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opAddS"), &Vector2u::operator +)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opSubS"), &Vector2u::operator -)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opMulS"), &Vector2u::operator *)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opDivS"), &Vector2u::operator /)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opModS"), &Vector2u::operator %)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opAndS"), &Vector2u::operator &)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opOrS"), &Vector2u::operator |)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opShlS"), &Vector2u::operator ^)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opShlS"), &Vector2u::operator <<)
.Func<Vector2u (Vector2u::*)(Vector2u::Value) const>(_SC("opShrS"), &Vector2u::operator >>)
.Func<Vector2u (Vector2u::*)(void) const>(_SC("opUnPlus"), &Vector2u::operator +)
.Func<Vector2u (Vector2u::*)(void) const>(_SC("opUnMinus"), &Vector2u::operator -)
.Func<Vector2u (Vector2u::*)(void) const>(_SC("opCom"), &Vector2u::operator ~)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opEqual"), &Vector2u::operator ==)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opNotEqual"), &Vector2u::operator !=)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opLessThan"), &Vector2u::operator <)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opGreaterThan"), &Vector2u::operator >)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opLessEqual"), &Vector2u::operator <=)
.Func<bool (Vector2u::*)(const Vector2u &) const>(_SC("opGreaterEqual"), &Vector2u::operator >=)
);
LogDbg("Registration of <Vector2u> type was successful");
return true;
}
} // Namespace:: SqMod

142
source/Base/Vector2u.hpp Normal file
View File

@ -0,0 +1,142 @@
#ifndef _BASE_VECTOR2U_HPP_
#define _BASE_VECTOR2U_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Vector2u
{
// --------------------------------------------------------------------------------------------
typedef SQUnsignedInteger32 Value;
// --------------------------------------------------------------------------------------------
static const Vector2u NIL;
static const Vector2u MIN;
static const Vector2u MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y;
// --------------------------------------------------------------------------------------------
Vector2u() noexcept;
Vector2u(Value s) noexcept;
Vector2u(Value xv, Value yv) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u(const Vector2i & v) noexcept;
Vector2u(const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u(const Vector2u & v) noexcept;
Vector2u(Vector2u && v) noexcept;
// --------------------------------------------------------------------------------------------
~Vector2u();
// --------------------------------------------------------------------------------------------
Vector2u & operator = (const Vector2u & v) noexcept;
Vector2u & operator = (Vector2u && v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u & operator = (Value s) noexcept;
Vector2u & operator = (const SQChar * values) noexcept;
Vector2u & operator = (const Vector2i & v) noexcept;
Vector2u & operator = (const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u & operator += (const Vector2u & v) noexcept;
Vector2u & operator -= (const Vector2u & v) noexcept;
Vector2u & operator *= (const Vector2u & v) noexcept;
Vector2u & operator /= (const Vector2u & v) noexcept;
Vector2u & operator %= (const Vector2u & v) noexcept;
Vector2u & operator &= (const Vector2u & v) noexcept;
Vector2u & operator |= (const Vector2u & v) noexcept;
Vector2u & operator ^= (const Vector2u & v) noexcept;
Vector2u & operator <<= (const Vector2u & v) noexcept;
Vector2u & operator >>= (const Vector2u & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u & operator += (Value s) noexcept;
Vector2u & operator -= (Value s) noexcept;
Vector2u & operator *= (Value s) noexcept;
Vector2u & operator /= (Value s) noexcept;
Vector2u & operator %= (Value s) noexcept;
Vector2u & operator &= (Value s) noexcept;
Vector2u & operator |= (Value s) noexcept;
Vector2u & operator ^= (Value s) noexcept;
Vector2u & operator <<= (Value s) noexcept;
Vector2u & operator >>= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u & operator ++ () noexcept;
Vector2u & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator ++ (int) noexcept;
Vector2u operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator + (const Vector2u & v) const noexcept;
Vector2u operator + (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator - (const Vector2u & v) const noexcept;
Vector2u operator - (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator * (const Vector2u & v) const noexcept;
Vector2u operator * (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator / (const Vector2u & v) const noexcept;
Vector2u operator / (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator % (const Vector2u & v) const noexcept;
Vector2u operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator & (const Vector2u & v) const noexcept;
Vector2u operator & (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator | (const Vector2u & v) const noexcept;
Vector2u operator | (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator ^ (const Vector2u & v) const noexcept;
Vector2u operator ^ (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator << (const Vector2u & v) const noexcept;
Vector2u operator << (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator >> (const Vector2u & v) const noexcept;
Vector2u operator >> (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator + () const noexcept;
Vector2u operator - () const noexcept;
// --------------------------------------------------------------------------------------------
Vector2u operator ~ () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Vector2u & v) const noexcept;
bool operator != (const Vector2u & v) const noexcept;
bool operator < (const Vector2u & v) const noexcept;
bool operator > (const Vector2u & v) const noexcept;
bool operator <= (const Vector2u & v) const noexcept;
bool operator >= (const Vector2u & v) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Vector2u & v) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector2u & v) noexcept;
void Set(const Vector2i & v) noexcept;
void Set(const Vector2f & v) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0, y = 0; }
// --------------------------------------------------------------------------------------------
Vector2u Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_VECTOR2U_HPP_

516
source/Base/Vector3.cpp Normal file
View File

@ -0,0 +1,516 @@
#include "Base/Vector3.hpp"
#include "Base/Vector4.hpp"
#include "Base/Quaternion.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Vector3 Vector3::NIL = Vector3(0);
const Vector3 Vector3::MIN = Vector3(std::numeric_limits<Vector3::Value>::min());
const Vector3 Vector3::MAX = Vector3(std::numeric_limits<Vector3::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Vector3::Delim = ',';
// ------------------------------------------------------------------------------------------------
Vector3::Vector3() noexcept
: x(0.0), y(0.0), z(0.0)
{
}
Vector3::Vector3(Value s) noexcept
: x(s), y(s), z(s)
{
}
Vector3::Vector3(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv)
{
}
// ------------------------------------------------------------------------------------------------
Vector3::Vector3(const Vector4 & v) noexcept
: x(v.x), y(v.y), z(v.z)
{
}
Vector3::Vector3(const Quaternion & q) noexcept
: x(q.x), y(q.y), z(q.z)
{
}
// ------------------------------------------------------------------------------------------------
Vector3::Vector3(const SQChar * values, char delim) noexcept
: Vector3(GetVector3(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Vector3::Vector3(const Vector3 & v) noexcept
: x(v.x), y(v.y), z(v.z)
{
}
Vector3::Vector3(Vector3 && v) noexcept
: x(v.x), y(v.y), z(v.z)
{
}
// ------------------------------------------------------------------------------------------------
Vector3::~Vector3()
{
}
// ------------------------------------------------------------------------------------------------
Vector3 & Vector3::operator = (const Vector3 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vector3 & Vector3::operator = (Vector3 && v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector3 & Vector3::operator = (Value s) noexcept
{
x = s;
y = s;
z = s;
return *this;
}
Vector3 & Vector3::operator = (const Vector4 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vector3 & Vector3::operator = (const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector3 & Vector3::operator += (const Vector3 & v) noexcept
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
Vector3 & Vector3::operator -= (const Vector3 & v) noexcept
{
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
}
Vector3 & Vector3::operator *= (const Vector3 & v) noexcept
{
x *= v.x;
y *= v.y;
z *= v.z;
return *this;
}
Vector3 & Vector3::operator /= (const Vector3 & v) noexcept
{
x /= v.x;
y /= v.y;
z /= v.z;
return *this;
}
Vector3 & Vector3::operator %= (const Vector3 & v) noexcept
{
x = std::fmod(x, v.x);
y = std::fmod(y, v.y);
z = std::fmod(z, v.z);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector3 & Vector3::operator += (Value s) noexcept
{
x += s;
y += s;
z += s;
return *this;
}
Vector3 & Vector3::operator -= (Value s) noexcept
{
x -= s;
y -= s;
z -= s;
return *this;
}
Vector3 & Vector3::operator *= (Value s) noexcept
{
x *= s;
y *= s;
z *= s;
return *this;
}
Vector3 & Vector3::operator /= (Value s) noexcept
{
x /= s;
y /= s;
z /= s;
return *this;
}
Vector3 & Vector3::operator %= (Value s) noexcept
{
x = std::fmod(x, s);
y = std::fmod(y, s);
z = std::fmod(z, s);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector3 & Vector3::operator ++ () noexcept
{
++x;
++y;
++z;
return *this;
}
Vector3 & Vector3::operator -- () noexcept
{
--x;
--y;
--z;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator ++ (int) noexcept
{
Vector3 state(*this);
++x;
++y;
++z;
return state;
}
Vector3 Vector3::operator -- (int) noexcept
{
Vector3 state(*this);
--x;
--y;
--z;
return state;
}
// ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + (const Vector3 & v) const noexcept
{
return Vector3(x + v.x, y + v.y, z + v.z);
}
Vector3 Vector3::operator - (const Vector3 & v) const noexcept
{
return Vector3(x - v.x, y - v.y, z - v.z);
}
Vector3 Vector3::operator * (const Vector3 & v) const noexcept
{
return Vector3(x * v.x, y * v.y, z * v.z);
}
Vector3 Vector3::operator / (const Vector3 & v) const noexcept
{
return Vector3(x / v.x, y / v.y, z / v.z);
}
Vector3 Vector3::operator % (const Vector3 & v) const noexcept
{
return Vector3(std::fmod(x, v.x), std::fmod(y, v.y), std::fmod(z, v.z));
}
// ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + (Value s) const noexcept
{
return Vector3(x + s, y + s, z + s);
}
Vector3 Vector3::operator - (Value s) const noexcept
{
return Vector3(x - s, y - s, z - s);
}
Vector3 Vector3::operator * (Value s) const noexcept
{
return Vector3(x * s, y * s, z * s);
}
Vector3 Vector3::operator / (Value s) const noexcept
{
return Vector3(x / s, y / s, z / s);
}
Vector3 Vector3::operator % (Value s) const noexcept
{
return Vector3(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s));
}
// ------------------------------------------------------------------------------------------------
Vector3 Vector3::operator + () const noexcept
{
return Vector3(std::fabs(x), std::fabs(y), std::fabs(z));
}
Vector3 Vector3::operator - () const noexcept
{
return Vector3(-x, -y, -z);
}
// ------------------------------------------------------------------------------------------------
bool Vector3::operator == (const Vector3 & v) const noexcept
{
return EpsEq(x, v.x) && EpsEq(y, v.y) && EpsEq(z, v.z);
}
bool Vector3::operator != (const Vector3 & v) const noexcept
{
return !EpsEq(x, v.x) && !EpsEq(y, v.y) && !EpsEq(z, v.z);
}
bool Vector3::operator < (const Vector3 & v) const noexcept
{
return std::isless(x, v.x) && std::isless(y, v.y) && std::isless(z, v.z);
}
bool Vector3::operator > (const Vector3 & v) const noexcept
{
return std::isgreater(x, v.x) && std::isgreater(y, v.y) && std::isgreater(z, v.z);
}
bool Vector3::operator <= (const Vector3 & v) const noexcept
{
return std::islessequal(x, v.x) && std::islessequal(y, v.y) && std::islessequal(z, v.z);
}
bool Vector3::operator >= (const Vector3 & v) const noexcept
{
return std::isgreaterequal(x, v.x) && std::isgreaterequal(y, v.y) && std::isgreaterequal(z, v.z);
}
// ------------------------------------------------------------------------------------------------
SQInteger Vector3::Cmp(const Vector3 & v) const noexcept
{
return *this == v ? 0 : (*this > v ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Vector3::ToString() const noexcept
{
return ToStringF("%f,%f,%f", x, y, z);
}
// ------------------------------------------------------------------------------------------------
void Vector3::Set(Value ns) noexcept
{
x = ns;
y = ns;
z = ns;
}
void Vector3::Set(Value nx, Value ny, Value nz) noexcept
{
x = nx;
y = ny;
z = nz;
}
// ------------------------------------------------------------------------------------------------
void Vector3::Set(const Vector3 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
}
void Vector3::Set(const Vector4 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
}
void Vector3::Set(const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
}
// ------------------------------------------------------------------------------------------------
void Vector3::Set(const SQChar * values, char delim) noexcept
{
Set(GetVector3(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Vector3::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
z = RandomVal<Value>::Get();
}
void Vector3::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
z = RandomVal<Value>::Get(min, max);
}
}
void Vector3::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) noexcept
{
if (std::isless(xmax, xmin) || std::isless(ymax, ymin) || std::isless(zmax, zmin))
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(xmin, xmax);
y = RandomVal<Value>::Get(ymin, ymax);
z = RandomVal<Value>::Get(zmin, zmax);
}
}
// ------------------------------------------------------------------------------------------------
Vector3 Vector3::Abs() const noexcept
{
return Vector3(std::fabs(x), std::fabs(y), std::fabs(z));
}
// ================================================================================================
bool Register_Vector3(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Vector3> type");
typedef Vector3::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Vector3"), Sqrat::Class<Vector3>(vm, _SC("Vector3"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<const SQChar *, SQChar>()
.SetStaticValue(_SC("delim"), &Vector3::Delim)
.Var(_SC("x"), &Vector3::x)
.Var(_SC("y"), &Vector3::y)
.Var(_SC("z"), &Vector3::z)
.Prop(_SC("abs"), &Vector3::Abs)
.Func(_SC("_tostring"), &Vector3::ToString)
.Func(_SC("_cmp"), &Vector3::Cmp)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("_add"), &Vector3::operator +)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("_sub"), &Vector3::operator -)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("_mul"), &Vector3::operator *)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("_div"), &Vector3::operator /)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("_modulo"), &Vector3::operator %)
.Func<Vector3 (Vector3::*)(void) const>(_SC("_unm"), &Vector3::operator -)
.Overload<void (Vector3::*)(Val)>(_SC("set"), &Vector3::Set)
.Overload<void (Vector3::*)(Val, Val, Val)>(_SC("set"), &Vector3::Set)
.Overload<void (Vector3::*)(const Vector3 &)>(_SC("set_vec3"), &Vector3::Set)
.Overload<void (Vector3::*)(const Vector4 &)>(_SC("set_vec4"), &Vector3::Set)
.Overload<void (Vector3::*)(const Quaternion &)>(_SC("set_quat"), &Vector3::Set)
.Overload<void (Vector3::*)(const SQChar *, SQChar)>(_SC("set_str"), &Vector3::Set)
.Overload<void (Vector3::*)(void)>(_SC("generate"), &Vector3::Generate)
.Overload<void (Vector3::*)(Val, Val)>(_SC("generate"), &Vector3::Generate)
.Overload<void (Vector3::*)(Val, Val, Val, Val, Val, Val)>(_SC("generate"), &Vector3::Generate)
.Func(_SC("clear"), &Vector3::Clear)
.Func<Vector3 & (Vector3::*)(const Vector3 &)>(_SC("opAddAssign"), &Vector3::operator +=)
.Func<Vector3 & (Vector3::*)(const Vector3 &)>(_SC("opSubAssign"), &Vector3::operator -=)
.Func<Vector3 & (Vector3::*)(const Vector3 &)>(_SC("opMulAssign"), &Vector3::operator *=)
.Func<Vector3 & (Vector3::*)(const Vector3 &)>(_SC("opDivAssign"), &Vector3::operator /=)
.Func<Vector3 & (Vector3::*)(const Vector3 &)>(_SC("opModAssign"), &Vector3::operator %=)
.Func<Vector3 & (Vector3::*)(Vector3::Value)>(_SC("opAddAssignS"), &Vector3::operator +=)
.Func<Vector3 & (Vector3::*)(Vector3::Value)>(_SC("opSubAssignS"), &Vector3::operator -=)
.Func<Vector3 & (Vector3::*)(Vector3::Value)>(_SC("opMulAssignS"), &Vector3::operator *=)
.Func<Vector3 & (Vector3::*)(Vector3::Value)>(_SC("opDivAssignS"), &Vector3::operator /=)
.Func<Vector3 & (Vector3::*)(Vector3::Value)>(_SC("opModAssignS"), &Vector3::operator %=)
.Func<Vector3 & (Vector3::*)(void)>(_SC("opPreInc"), &Vector3::operator ++)
.Func<Vector3 & (Vector3::*)(void)>(_SC("opPreDec"), &Vector3::operator --)
.Func<Vector3 (Vector3::*)(int)>(_SC("opPostInc"), &Vector3::operator ++)
.Func<Vector3 (Vector3::*)(int)>(_SC("opPostDec"), &Vector3::operator --)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("opAdd"), &Vector3::operator +)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("opSub"), &Vector3::operator -)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("opMul"), &Vector3::operator *)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("opDiv"), &Vector3::operator /)
.Func<Vector3 (Vector3::*)(const Vector3 &) const>(_SC("opMod"), &Vector3::operator %)
.Func<Vector3 (Vector3::*)(Vector3::Value) const>(_SC("opAddS"), &Vector3::operator +)
.Func<Vector3 (Vector3::*)(Vector3::Value) const>(_SC("opSubS"), &Vector3::operator -)
.Func<Vector3 (Vector3::*)(Vector3::Value) const>(_SC("opMulS"), &Vector3::operator *)
.Func<Vector3 (Vector3::*)(Vector3::Value) const>(_SC("opDivS"), &Vector3::operator /)
.Func<Vector3 (Vector3::*)(Vector3::Value) const>(_SC("opModS"), &Vector3::operator %)
.Func<Vector3 (Vector3::*)(void) const>(_SC("opUnPlus"), &Vector3::operator +)
.Func<Vector3 (Vector3::*)(void) const>(_SC("opUnMinus"), &Vector3::operator -)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opEqual"), &Vector3::operator ==)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opNotEqual"), &Vector3::operator !=)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opLessThan"), &Vector3::operator <)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opGreaterThan"), &Vector3::operator >)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opLessEqual"), &Vector3::operator <=)
.Func<bool (Vector3::*)(const Vector3 &) const>(_SC("opGreaterEqual"), &Vector3::operator >=)
);
LogDbg("Registration of <Vector3> type was successful");
return true;
}
} // Namespace:: SqMod

111
source/Base/Vector3.hpp Normal file
View File

@ -0,0 +1,111 @@
#ifndef _BASE_VECTOR3_HPP_
#define _BASE_VECTOR3_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Vector3
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Vector3 NIL;
static const Vector3 MIN;
static const Vector3 MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y, z;
// --------------------------------------------------------------------------------------------
Vector3() noexcept;
Vector3(Value s) noexcept;
Vector3(Value xv, Value yv, Value zv) noexcept;
// --------------------------------------------------------------------------------------------
Vector3(const Vector4 & v) noexcept;
Vector3(const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
Vector3(const SQChar * values, char delim) noexcept;
// --------------------------------------------------------------------------------------------
Vector3(const Vector3 & v) noexcept;
Vector3(Vector3 && v) noexcept;
// --------------------------------------------------------------------------------------------
~Vector3();
// --------------------------------------------------------------------------------------------
Vector3 & operator = (const Vector3 & v) noexcept;
Vector3 & operator = (Vector3 && v) noexcept;
// --------------------------------------------------------------------------------------------
Vector3 & operator = (Value s) noexcept;
Vector3 & operator = (const Vector4 & v) noexcept;
Vector3 & operator = (const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
Vector3 & operator += (const Vector3 & v) noexcept;
Vector3 & operator -= (const Vector3 & v) noexcept;
Vector3 & operator *= (const Vector3 & v) noexcept;
Vector3 & operator /= (const Vector3 & v) noexcept;
Vector3 & operator %= (const Vector3 & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector3 & operator += (Value s) noexcept;
Vector3 & operator -= (Value s) noexcept;
Vector3 & operator *= (Value s) noexcept;
Vector3 & operator /= (Value s) noexcept;
Vector3 & operator %= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Vector3 & operator ++ () noexcept;
Vector3 & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Vector3 operator ++ (int) noexcept;
Vector3 operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Vector3 operator + (const Vector3 & v) const noexcept;
Vector3 operator - (const Vector3 & v) const noexcept;
Vector3 operator * (const Vector3 & v) const noexcept;
Vector3 operator / (const Vector3 & v) const noexcept;
Vector3 operator % (const Vector3 & v) const noexcept;
// --------------------------------------------------------------------------------------------
Vector3 operator + (Value s) const noexcept;
Vector3 operator - (Value s) const noexcept;
Vector3 operator * (Value s) const noexcept;
Vector3 operator / (Value s) const noexcept;
Vector3 operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector3 operator + () const noexcept;
Vector3 operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Vector3 & v) const noexcept;
bool operator != (const Vector3 & v) const noexcept;
bool operator < (const Vector3 & v) const noexcept;
bool operator > (const Vector3 & v) const noexcept;
bool operator <= (const Vector3 & v) const noexcept;
bool operator >= (const Vector3 & v) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Vector3 & v) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny, Value nz) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector3 & v) noexcept;
void Set(const Vector4 & v) noexcept;
void Set(const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, char delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0.0, y = 0.0, z = 0.0; }
// --------------------------------------------------------------------------------------------
Vector3 Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_VECTOR3_HPP_

559
source/Base/Vector4.cpp Normal file
View File

@ -0,0 +1,559 @@
#include "Base/Vector4.hpp"
#include "Base/Vector3.hpp"
#include "Base/Quaternion.hpp"
#include "Base/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Vector4 Vector4::NIL = Vector4(0);
const Vector4 Vector4::MIN = Vector4(std::numeric_limits<Vector4::Value>::min());
const Vector4 Vector4::MAX = Vector4(std::numeric_limits<Vector4::Value>::max());
// ------------------------------------------------------------------------------------------------
SQChar Vector4::Delim = ',';
// ------------------------------------------------------------------------------------------------
Vector4::Vector4() noexcept
: x(0.0), y(0.0), z(0.0), w(0.0)
{
}
Vector4::Vector4(Value s) noexcept
: x(s), y(s), z(s), w(s)
{
}
Vector4::Vector4(Value xv, Value yv, Value zv) noexcept
: x(xv), y(yv), z(zv), w(0.0)
{
}
Vector4::Vector4(Value xv, Value yv, Value zv, Value wv) noexcept
: x(xv), y(yv), z(zv), w(wv)
{
}
// ------------------------------------------------------------------------------------------------
Vector4::Vector4(const Vector3 & v) noexcept
: x(v.x), y(v.y), z(v.z), w(0.0)
{
}
Vector4::Vector4(const Quaternion & q) noexcept
: x(q.x), y(q.y), z(q.z), w(q.w)
{
}
// ------------------------------------------------------------------------------------------------
Vector4::Vector4(const SQChar * values, SQChar delim) noexcept
: Vector4(GetVector4(values, delim))
{
}
// ------------------------------------------------------------------------------------------------
Vector4::Vector4(const Vector4 & v) noexcept
: x(v.x), y(v.y), z(v.z), w(v.w)
{
}
Vector4::Vector4(Vector4 && v) noexcept
: x(v.x), y(v.y), z(v.z), w(v.w)
{
}
// ------------------------------------------------------------------------------------------------
Vector4::~Vector4()
{
}
// ------------------------------------------------------------------------------------------------
Vector4 & Vector4::operator = (const Vector4 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = v.w;
return *this;
}
Vector4 & Vector4::operator = (Vector4 && v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = v.w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector4 & Vector4::operator = (Value s) noexcept
{
x = s;
y = s;
z = s;
w = s;
return *this;
}
Vector4 & Vector4::operator = (const Vector3 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = 0.0;
return *this;
}
Vector4 & Vector4::operator = (const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector4 & Vector4::operator += (const Vector4 & v) noexcept
{
x += v.x;
y += v.y;
z += v.z;
w += v.w;
return *this;
}
Vector4 & Vector4::operator -= (const Vector4 & v) noexcept
{
x -= v.x;
y -= v.y;
z -= v.z;
w -= v.w;
return *this;
}
Vector4 & Vector4::operator *= (const Vector4 & v) noexcept
{
x *= v.x;
y *= v.y;
z *= v.z;
w *= v.w;
return *this;
}
Vector4 & Vector4::operator /= (const Vector4 & v) noexcept
{
x /= v.x;
y /= v.y;
z /= v.z;
w /= v.w;
return *this;
}
Vector4 & Vector4::operator %= (const Vector4 & v) noexcept
{
x = std::fmod(x, v.x);
y = std::fmod(y, v.y);
z = std::fmod(z, v.z);
w = std::fmod(w, v.w);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector4 & Vector4::operator += (Value s) noexcept
{
x += s;
y += s;
z += s;
w += s;
return *this;
}
Vector4 & Vector4::operator -= (Value s) noexcept
{
x -= s;
y -= s;
z -= s;
w -= s;
return *this;
}
Vector4 & Vector4::operator *= (Value s) noexcept
{
x *= s;
y *= s;
z *= s;
w *= s;
return *this;
}
Vector4 & Vector4::operator /= (Value s) noexcept
{
x /= s;
y /= s;
z /= s;
w /= s;
return *this;
}
Vector4 & Vector4::operator %= (Value s) noexcept
{
x = std::fmod(x, s);
y = std::fmod(y, s);
z = std::fmod(z, s);
w = std::fmod(w, s);
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector4 & Vector4::operator ++ () noexcept
{
++x;
++y;
++z;
++w;
return *this;
}
Vector4 & Vector4::operator -- () noexcept
{
--x;
--y;
--z;
--w;
return *this;
}
// ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator ++ (int) noexcept
{
Vector4 state(*this);
++x;
++y;
++z;
++w;
return state;
}
Vector4 Vector4::operator -- (int) noexcept
{
Vector4 state(*this);
--x;
--y;
--z;
--w;
return state;
}
// ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator + (const Vector4 & v) const noexcept
{
return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
}
Vector4 Vector4::operator - (const Vector4 & v) const noexcept
{
return Vector4(x - v.x, y - v.y, z - v.z, w - v.w);
}
Vector4 Vector4::operator * (const Vector4 & v) const noexcept
{
return Vector4(x * v.x, y * v.y, z * v.z, w * v.w);
}
Vector4 Vector4::operator / (const Vector4 & v) const noexcept
{
return Vector4(x / v.x, y / v.y, z / v.z, w / v.w);
}
Vector4 Vector4::operator % (const Vector4 & v) const noexcept
{
return Vector4(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 noexcept
{
return Vector4(x + s, y + s, z + s, w + s);
}
Vector4 Vector4::operator - (Value s) const noexcept
{
return Vector4(x - s, y - s, z - s, w - s);
}
Vector4 Vector4::operator * (Value s) const noexcept
{
return Vector4(x * s, y * s, z * s, w * s);
}
Vector4 Vector4::operator / (Value s) const noexcept
{
return Vector4(x / s, y / s, z / s, w / s);
}
Vector4 Vector4::operator % (Value s) const noexcept
{
return Vector4(std::fmod(x, s), std::fmod(y, s), std::fmod(z, s), std::fmod(w, s));
}
// ------------------------------------------------------------------------------------------------
Vector4 Vector4::operator + () const noexcept
{
return Vector4(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w));
}
Vector4 Vector4::operator - () const noexcept
{
return Vector4(-x, -y, -z, -w);
}
// ------------------------------------------------------------------------------------------------
bool Vector4::operator == (const Vector4 & v) const noexcept
{
return EpsEq(x, v.x) && EpsEq(y, v.y) && EpsEq(z, v.z) && EpsEq(w, v.w);
}
bool Vector4::operator != (const Vector4 & v) const noexcept
{
return !EpsEq(x, v.x) && !EpsEq(y, v.y) && !EpsEq(z, v.z) && !EpsEq(w, v.w);
}
bool Vector4::operator < (const Vector4 & v) const noexcept
{
return std::isless(x, v.x) && std::isless(y, v.y) && std::isless(z, v.z) && std::isless(w, v.w);
}
bool Vector4::operator > (const Vector4 & v) const noexcept
{
return std::isgreater(x, v.x) && std::isgreater(y, v.y) && std::isgreater(z, v.z) && std::isgreater(w, v.w);
}
bool Vector4::operator <= (const Vector4 & v) const noexcept
{
return std::islessequal(x, v.x) && std::islessequal(y, v.y) && std::islessequal(z, v.z) && std::islessequal(w, v.w);
}
bool Vector4::operator >= (const Vector4 & v) const noexcept
{
return std::isgreaterequal(x, v.x) && std::isgreaterequal(y, v.y) && std::isgreaterequal(z, v.z) && std::isgreaterequal(w, v.w);
}
// ------------------------------------------------------------------------------------------------
SQInteger Vector4::Cmp(const Vector4 & v) const noexcept
{
return *this == v ? 0 : (*this > v ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * Vector4::ToString() const noexcept
{
return ToStringF("%f,%f,%f,%f", x, y, z, w);
}
// ------------------------------------------------------------------------------------------------
void Vector4::Set(Value ns) noexcept
{
x = ns;
y = ns;
z = ns;
w = ns;
}
void Vector4::Set(Value nx, Value ny, Value nz) noexcept
{
x = nx;
y = ny;
z = nz;
}
void Vector4::Set(Value nx, Value ny, Value nz, Value nw) noexcept
{
x = nx;
y = ny;
z = nz;
w = nw;
}
// ------------------------------------------------------------------------------------------------
void Vector4::Set(const Vector4 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = v.w;
}
void Vector4::Set(const Vector3 & v) noexcept
{
x = v.x;
y = v.y;
z = v.z;
w = 0.0;
}
void Vector4::Set(const Quaternion & q) noexcept
{
x = q.x;
y = q.y;
z = q.z;
w = q.w;
}
// ------------------------------------------------------------------------------------------------
void Vector4::Set(const SQChar * values, SQChar delim) noexcept
{
Set(GetVector4(values, delim));
}
// ------------------------------------------------------------------------------------------------
void Vector4::Generate() noexcept
{
x = RandomVal<Value>::Get();
y = RandomVal<Value>::Get();
z = RandomVal<Value>::Get();
w = RandomVal<Value>::Get();
}
void Vector4::Generate(Value min, Value max) noexcept
{
if (max < min)
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
z = RandomVal<Value>::Get(min, max);
y = RandomVal<Value>::Get(min, max);
}
}
void Vector4::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) noexcept
{
if (std::isless(xmax, xmin) || std::isless(ymax, ymin) || std::isless(zmax, zmin) || std::isless(wmax, wmin))
{
LogErr("max value is lower than min value");
}
else
{
x = RandomVal<Value>::Get(xmin, xmax);
y = RandomVal<Value>::Get(ymin, ymax);
z = RandomVal<Value>::Get(zmin, zmax);
y = RandomVal<Value>::Get(ymin, ymax);
}
}
// ------------------------------------------------------------------------------------------------
Vector4 Vector4::Abs() const noexcept
{
return Vector4(std::fabs(x), std::fabs(y), std::fabs(z), std::fabs(w));
}
// ================================================================================================
bool Register_Vector4(HSQUIRRELVM vm)
{
LogDbg("Beginning registration of <Vector4> type");
typedef Vector4::Value Val;
Sqrat::RootTable(vm).Bind(_SC("Vector4"), Sqrat::Class<Vector4>(vm, _SC("Vector4"))
.Ctor()
.Ctor<Val>()
.Ctor<Val, Val, Val>()
.Ctor<Val, Val, Val, Val>()
.Ctor<const SQChar *, SQChar>()
.SetStaticValue(_SC("delim"), &Vector4::Delim)
.Var(_SC("x"), &Vector4::x)
.Var(_SC("y"), &Vector4::y)
.Var(_SC("z"), &Vector4::z)
.Var(_SC("w"), &Vector4::w)
.Prop(_SC("abs"), &Vector4::Abs)
.Func(_SC("_tostring"), &Vector4::ToString)
.Func(_SC("_cmp"), &Vector4::Cmp)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("_add"), &Vector4::operator +)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("_sub"), &Vector4::operator -)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("_mul"), &Vector4::operator *)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("_div"), &Vector4::operator /)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("_modulo"), &Vector4::operator %)
.Func<Vector4 (Vector4::*)(void) const>(_SC("_unm"), &Vector4::operator -)
.Overload<void (Vector4::*)(Val)>(_SC("set"), &Vector4::Set)
.Overload<void (Vector4::*)(Val, Val, Val)>(_SC("set"), &Vector4::Set)
.Overload<void (Vector4::*)(Val, Val, Val, Val)>(_SC("set"), &Vector4::Set)
.Overload<void (Vector4::*)(const Vector4 &)>(_SC("set_vec4"), &Vector4::Set)
.Overload<void (Vector4::*)(const Vector3 &)>(_SC("set_vec3"), &Vector4::Set)
.Overload<void (Vector4::*)(const Quaternion &)>(_SC("set_quat"), &Vector4::Set)
.Overload<void (Vector4::*)(const SQChar *, SQChar)>(_SC("set_str"), &Vector4::Set)
.Overload<void (Vector4::*)(void)>(_SC("generate"), &Vector4::Generate)
.Overload<void (Vector4::*)(Val, Val)>(_SC("generate"), &Vector4::Generate)
.Overload<void (Vector4::*)(Val, Val, Val, Val, Val, Val, Val, Val)>(_SC("generate"), &Vector4::Generate)
.Func(_SC("clear"), &Vector4::Clear)
.Func<Vector4 & (Vector4::*)(const Vector4 &)>(_SC("opAddAssign"), &Vector4::operator +=)
.Func<Vector4 & (Vector4::*)(const Vector4 &)>(_SC("opSubAssign"), &Vector4::operator -=)
.Func<Vector4 & (Vector4::*)(const Vector4 &)>(_SC("opMulAssign"), &Vector4::operator *=)
.Func<Vector4 & (Vector4::*)(const Vector4 &)>(_SC("opDivAssign"), &Vector4::operator /=)
.Func<Vector4 & (Vector4::*)(const Vector4 &)>(_SC("opModAssign"), &Vector4::operator %=)
.Func<Vector4 & (Vector4::*)(Vector4::Value)>(_SC("opAddAssignS"), &Vector4::operator +=)
.Func<Vector4 & (Vector4::*)(Vector4::Value)>(_SC("opSubAssignS"), &Vector4::operator -=)
.Func<Vector4 & (Vector4::*)(Vector4::Value)>(_SC("opMulAssignS"), &Vector4::operator *=)
.Func<Vector4 & (Vector4::*)(Vector4::Value)>(_SC("opDivAssignS"), &Vector4::operator /=)
.Func<Vector4 & (Vector4::*)(Vector4::Value)>(_SC("opModAssignS"), &Vector4::operator %=)
.Func<Vector4 & (Vector4::*)(void)>(_SC("opPreInc"), &Vector4::operator ++)
.Func<Vector4 & (Vector4::*)(void)>(_SC("opPreDec"), &Vector4::operator --)
.Func<Vector4 (Vector4::*)(int)>(_SC("opPostInc"), &Vector4::operator ++)
.Func<Vector4 (Vector4::*)(int)>(_SC("opPostDec"), &Vector4::operator --)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("opAdd"), &Vector4::operator +)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("opSub"), &Vector4::operator -)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("opMul"), &Vector4::operator *)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("opDiv"), &Vector4::operator /)
.Func<Vector4 (Vector4::*)(const Vector4 &) const>(_SC("opMod"), &Vector4::operator %)
.Func<Vector4 (Vector4::*)(Vector4::Value) const>(_SC("opAddS"), &Vector4::operator +)
.Func<Vector4 (Vector4::*)(Vector4::Value) const>(_SC("opSubS"), &Vector4::operator -)
.Func<Vector4 (Vector4::*)(Vector4::Value) const>(_SC("opMulS"), &Vector4::operator *)
.Func<Vector4 (Vector4::*)(Vector4::Value) const>(_SC("opDivS"), &Vector4::operator /)
.Func<Vector4 (Vector4::*)(Vector4::Value) const>(_SC("opModS"), &Vector4::operator %)
.Func<Vector4 (Vector4::*)(void) const>(_SC("opUnPlus"), &Vector4::operator +)
.Func<Vector4 (Vector4::*)(void) const>(_SC("opUnMinus"), &Vector4::operator -)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opEqual"), &Vector4::operator ==)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opNotEqual"), &Vector4::operator !=)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opLessThan"), &Vector4::operator <)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opGreaterThan"), &Vector4::operator >)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opLessEqual"), &Vector4::operator <=)
.Func<bool (Vector4::*)(const Vector4 &) const>(_SC("opGreaterEqual"), &Vector4::operator >=)
);
LogDbg("Registration of <Vector4> type was successful");
return true;
}
} // Namespace:: SqMod

113
source/Base/Vector4.hpp Normal file
View File

@ -0,0 +1,113 @@
#ifndef _BASE_VECTOR4_HPP_
#define _BASE_VECTOR4_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
struct Vector4
{
// --------------------------------------------------------------------------------------------
typedef SQFloat Value;
// --------------------------------------------------------------------------------------------
static const Vector4 NIL;
static const Vector4 MIN;
static const Vector4 MAX;
// --------------------------------------------------------------------------------------------
static SQChar Delim;
// --------------------------------------------------------------------------------------------
Value x, y, z, w;
// --------------------------------------------------------------------------------------------
Vector4() noexcept;
Vector4(Value s) noexcept;
Vector4(Value xv, Value yv, Value zv) noexcept;
Vector4(Value xv, Value yv, Value zv, Value wv) noexcept;
// --------------------------------------------------------------------------------------------
Vector4(const Vector3 & v) noexcept;
Vector4(const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
Vector4(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
Vector4(const Vector4 & v) noexcept;
Vector4(Vector4 && v) noexcept;
// --------------------------------------------------------------------------------------------
~Vector4();
// --------------------------------------------------------------------------------------------
Vector4 & operator = (const Vector4 & v) noexcept;
Vector4 & operator = (Vector4 && v) noexcept;
// --------------------------------------------------------------------------------------------
Vector4 & operator = (Value s) noexcept;
Vector4 & operator = (const Vector3 & v) noexcept;
Vector4 & operator = (const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
Vector4 & operator += (const Vector4 & v) noexcept;
Vector4 & operator -= (const Vector4 & v) noexcept;
Vector4 & operator *= (const Vector4 & v) noexcept;
Vector4 & operator /= (const Vector4 & v) noexcept;
Vector4 & operator %= (const Vector4 & v) noexcept;
// --------------------------------------------------------------------------------------------
Vector4 & operator += (Value s) noexcept;
Vector4 & operator -= (Value s) noexcept;
Vector4 & operator *= (Value s) noexcept;
Vector4 & operator /= (Value s) noexcept;
Vector4 & operator %= (Value s) noexcept;
// --------------------------------------------------------------------------------------------
Vector4 & operator ++ () noexcept;
Vector4 & operator -- () noexcept;
// --------------------------------------------------------------------------------------------
Vector4 operator ++ (int) noexcept;
Vector4 operator -- (int) noexcept;
// --------------------------------------------------------------------------------------------
Vector4 operator + (const Vector4 & v) const noexcept;
Vector4 operator - (const Vector4 & v) const noexcept;
Vector4 operator * (const Vector4 & v) const noexcept;
Vector4 operator / (const Vector4 & v) const noexcept;
Vector4 operator % (const Vector4 & v) const noexcept;
// --------------------------------------------------------------------------------------------
Vector4 operator + (Value s) const noexcept;
Vector4 operator - (Value s) const noexcept;
Vector4 operator * (Value s) const noexcept;
Vector4 operator / (Value s) const noexcept;
Vector4 operator % (Value s) const noexcept;
// --------------------------------------------------------------------------------------------
Vector4 operator + () const noexcept;
Vector4 operator - () const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const Vector4 & v) const noexcept;
bool operator != (const Vector4 & v) const noexcept;
bool operator < (const Vector4 & v) const noexcept;
bool operator > (const Vector4 & v) const noexcept;
bool operator <= (const Vector4 & v) const noexcept;
bool operator >= (const Vector4 & v) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const Vector4 & v) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
void Set(Value ns) noexcept;
void Set(Value nx, Value ny, Value nz) noexcept;
void Set(Value nx, Value ny, Value nz, Value nw) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const Vector4 & v) noexcept;
void Set(const Vector3 & v) noexcept;
void Set(const Quaternion & q) noexcept;
// --------------------------------------------------------------------------------------------
void Set(const SQChar * values, SQChar delim) noexcept;
// --------------------------------------------------------------------------------------------
void Generate() noexcept;
void Generate(Value min, Value max) noexcept;
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) noexcept;
// --------------------------------------------------------------------------------------------
void Clear() noexcept { x = 0.0, y = 0.0, z = 0.0, w = 0.0; }
// --------------------------------------------------------------------------------------------
Vector4 Abs() const noexcept;
};
} // Namespace:: SqMod
#endif // _BASE_VECTOR4_HPP_

463
source/Common.cpp Normal file
View File

@ -0,0 +1,463 @@
#include "Common.hpp"
#include "Logger.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstdio>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// --------------------------------------------------------------------------------------------
PluginFuncs* _Func = 0;
PluginCallbacks* _Clbk = 0;
PluginInfo* _Info = 0;
// ------------------------------------------------------------------------------------------------
void BindCallbacks() noexcept;
// ------------------------------------------------------------------------------------------------
SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallbacks * calls, PluginInfo * info)
{
if (!_Log)
{
puts("[SQMOD] Unable to start because the logging class could not be instantiated");
return SQMOD_FAILURE;
}
else if (!_Core)
{
puts("[SQMOD] Unable to start because the central core class could not be instantiated");
return SQMOD_FAILURE;
}
else
{
_Func = funcs;
_Clbk = calls;
_Info = info;
_Info->uPluginVer = SQMOD_VERSION;
std::strcpy(_Info->szName, SQMOD_NAME);
}
_Log->Msg("%s", CenterStr("STARTUP", '*'));
_Log->Inf("%s", CenterStr(SQMOD_NAME, ' '));
_Log->Inf("%s", CenterStr(SQMOD_COPYRIGHT, ' '));
_Log->Inf("%s", CenterStr(SQMOD_VERSION_STR, ' '));
if (!_Core->Init())
{
_Log->Ftl("The plugin failed to initialize");
_Log->Msg("%s", CenterStr("ABORTING", '*'));
_Core->Deinit();
return SQMOD_FAILURE;
}
else if (_Clbk)
{
BindCallbacks();
}
else
{
_Log->Ftl("Unable to start because the server callbacks are missing");
return SQMOD_FAILURE;
}
return SQMOD_SUCCESS;
}
// --------------------------------------------------------------------------------------------
static int VC_InitServer(void) noexcept
{
if (_Core->Load())
{
_Core->OnServerStartup();
}
else
{
_Log->Ftl("Unable to load the plugin resources properly");
}
return _Core->GetState();
}
static void VC_ShutdownServer(void) noexcept
{
_Core->OnServerShutdown();
_Core->Terminate();
}
static void VC_Frame(float delta) noexcept
{
_Core->OnServerFrame(delta);
}
static void VC_PlayerConnect(int player) noexcept
{
_Core->ConnectPlayer(player, SQMOD_CREATE_AUTOMATIC, SqObj());
}
static void VC_PlayerDisconnect(int player, int reason) noexcept
{
_Core->DisconnectPlayer(player, reason, SqObj());
}
static void VC_PlayerBeginTyping(int player) noexcept
{
_Core->OnPlayerStartTyping(player);
}
static void VC_PlayerEndTyping(int player) noexcept
{
_Core->OnPlayerStopTyping(player);
}
static int VC_PlayerRequestClass(int player, int offset) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerRequestClass(player, offset);
return _Core->GetState();
}
static int VC_PlayerRequestSpawn(int player) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerRequestSpawn(player);
return _Core->GetState();
}
static void VC_PlayerSpawn(int player) noexcept
{
_Core->OnPlayerSpawn(player);
}
static void VC_PlayerDeath(int player, int killer, int reason, int body_part) noexcept
{
if (_Func->IsPlayerConnected(killer))
{
_Core->OnPlayerKilled(player, killer, reason, body_part);
}
else
{
_Core->OnPlayerWasted(player, reason);
}
}
static void VC_PlayerUpdate(int player, int type) noexcept
{
_Core->OnPlayerUpdate(player, type);
}
static int VC_PlayerRequestEnter(int player, int vehicle, int slot) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerEmbarking(player, vehicle, slot);
return _Core->GetState();
}
static void VC_PlayerEnterVehicle(int player, int vehicle, int slot) noexcept
{
_Core->OnPlayerEmbarked(player, vehicle, slot);
}
static void VC_PlayerExitVehicle(int player, int vehicle) noexcept
{
_Core->OnPlayerDisembark(player, vehicle);
}
static int VC_PickupClaimPicked(int pickup, int player) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPickupClaimed(pickup, player);
return _Core->GetState();
}
static void VC_PickupPickedUp(int pickup, int player) noexcept
{
_Core->OnPickupCollected(pickup, player);
}
static void VC_PickupRespawn(int pickup) noexcept
{
_Core->OnPickupRespawn(pickup);
}
static void VC_VehicleUpdate(int vehicle, int type) noexcept
{
_Core->OnVehicleUpdate(vehicle, type);
}
static void VC_VehicleExplode(int vehicle) noexcept
{
_Core->OnVehicleExplode(vehicle);
}
static void VC_VehicleRespawn(int vehicle) noexcept
{
_Core->OnVehicleRespawn(vehicle);
}
static void VC_ObjectShot(int object, int player, int weapon) noexcept
{
_Core->OnObjectShot(object, player, weapon);
}
static void VC_ObjectBump(int object, int player) noexcept
{
_Core->OnObjectBump(object, player);
}
static int VC_PublicMessage(int player, const char * text) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerChat(player, static_cast<const SQChar *>(text));
return _Core->GetState();
}
static int VC_CommandMessage(int player, const char * text) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerCommand(player, static_cast<const SQChar *>(text));
return _Core->GetState();
}
static int VC_PrivateMessage(int player, int target, const char * text) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnPlayerMessage(player, target, static_cast<const SQChar *>(text));
return _Core->GetState();
}
static int VC_InternalCommand(unsigned int type, const char * text) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnInternalCommand(type, static_cast<const SQChar *>(text));
return _Core->GetState();
}
static int VC_LoginAttempt(char * name, const char * passwd, const char * address) noexcept
{
_Core->SetState(SQMOD_SUCCESS);
_Core->OnLoginAttempt(static_cast<const SQChar *>(name), static_cast<const SQChar *>(passwd), static_cast<const SQChar *>(address));
return _Core->GetState();
}
static void VC_EntityPool(int type, int id, unsigned int deleted) noexcept
{
_Core->OnEntityPool(type, id, static_cast<bool>(deleted));
}
static void VC_KeyBindDown(int player, int bind) noexcept
{
_Core->OnPlayerKeyPress(player, bind);
}
static void VC_KeyBindUp(int player, int bind) noexcept
{
_Core->OnPlayerKeyRelease(player, bind);
}
static void VC_PlayerAway(int player, unsigned int status) noexcept
{
_Core->OnPlayerAway(player, static_cast<bool>(status));
}
static void VC_PlayerSpectate(int player, int target) noexcept
{
_Core->OnPlayerSpectate(player, target);
}
static void VC_PlayerCrashReport(int player, const char * report) noexcept
{
_Core->OnPlayerCrashreport(player, static_cast<const SQChar *>(report));
}
static void VC_ServerPerformanceReport(int count, const char ** description, unsigned long long * millis) noexcept
{
// Ignored for now...
}
static void VC_PlayerName(int player, const char * previous, const char * current) noexcept
{
_Core->OnPlayerName(player, static_cast<const SQChar *>(previous), static_cast<const SQChar *>(current));
}
static void VC_PlayerState(int player, int previous, int current) noexcept
{
_Core->OnPlayerState(player, previous, current);
switch (current)
{
case SQMOD_PLAYER_STATE_NONE:
_Core->OnStateNone(player, previous);
break;
case SQMOD_PLAYER_STATE_NORMAL:
_Core->OnStateNormal(player, previous);
break;
case SQMOD_PLAYER_STATE_SHOOTING:
_Core->OnStateShooting(player, previous);
break;
case SQMOD_PLAYER_STATE_DRIVER:
_Core->OnStateDriver(player, previous);
break;
case SQMOD_PLAYER_STATE_PASSENGER:
_Core->OnStatePassenger(player, previous);
break;
case SQMOD_PLAYER_STATE_ENTERING_AS_DRIVER:
_Core->OnStateEnterDriver(player, previous);
break;
case SQMOD_PLAYER_STATE_ENTERING_AS_PASSENGER:
_Core->OnStateEnterPassenger(player, previous);
break;
case SQMOD_PLAYER_STATE_EXITING_VEHICLE:
_Core->OnStateExitVehicle(player, previous);
break;
case SQMOD_PLAYER_STATE_UNSPAWNED:
_Core->OnStateUnspawned(player, previous);
break;
}
}
static void VC_PlayerAction(int player, int previous, int current) noexcept
{
_Core->OnPlayerAction(player, previous, current);
switch (current)
{
case SQMOD_PLAYER_ACTION_NONE:
_Core->OnActionNone(player, previous);
break;
case SQMOD_PLAYER_ACTION_NORMAL:
_Core->OnActionNormal(player, previous);
break;
case SQMOD_PLAYER_ACTION_AIMING:
_Core->OnActionAiming(player, previous);
break;
case SQMOD_PLAYER_ACTION_SHOOTING:
_Core->OnActionShooting(player, previous);
break;
case SQMOD_PLAYER_ACTION_JUMPING:
_Core->OnActionJumping(player, previous);
break;
case SQMOD_PLAYER_ACTION_LYING_ON_GROUND:
_Core->OnActionLieDown(player, previous);
break;
case SQMOD_PLAYER_ACTION_GETTING_UP:
_Core->OnActionGettingUp(player, previous);
break;
case SQMOD_PLAYER_ACTION_JUMPING_FROM_VEHICLE:
_Core->OnActionJumpVehicle(player, previous);
break;
case SQMOD_PLAYER_ACTION_DRIVING:
_Core->OnActionDriving(player, previous);
break;
case SQMOD_PLAYER_ACTION_DYING:
_Core->OnActionDying(player, previous);
break;
case SQMOD_PLAYER_ACTION_WASTED:
_Core->OnActionWasted(player, previous);
break;
case SQMOD_PLAYER_ACTION_ENTERING_VEHICLE:
_Core->OnActionEmbarking(player, previous);
break;
case SQMOD_PLAYER_ACTION_EXITING_VEHICLE:
_Core->OnActionDisembarking(player, previous);
break;
}
}
static void VC_PlayerOnFire(int player, unsigned int state) noexcept
{
_Core->OnPlayerBurning(player, static_cast<bool>(state));
}
static void VC_PlayerCrouch(int player, unsigned int state) noexcept
{
_Core->OnPlayerCrouching(player, static_cast<bool>(state));
}
static void VC_PlayerGameKeys(int player, int previous, int current) noexcept
{
_Core->OnPlayerGameKeys(player, previous, current);
}
static void VC_OnCheckpointEntered(int checkpoint, int player) noexcept
{
_Core->OnCheckpointEntered(checkpoint, player);
}
static void VC_OnCheckpointExited(int checkpoint, int player) noexcept
{
_Core->OnCheckpointExited(checkpoint, player);
}
static void VC_OnSphereEntered(int sphere, int player) noexcept
{
_Core->OnSphereEntered(sphere, player);
}
static void VC_OnSphereExited(int sphere, int player) noexcept
{
_Core->OnSphereExited(sphere, player);
}
// ------------------------------------------------------------------------------------------------
void BindCallbacks() noexcept
{
_Clbk->OnInitServer = VC_InitServer;
_Clbk->OnShutdownServer = VC_ShutdownServer;
_Clbk->OnFrame = VC_Frame;
_Clbk->OnPlayerConnect = VC_PlayerConnect;
_Clbk->OnPlayerDisconnect = VC_PlayerDisconnect;
_Clbk->OnPlayerBeginTyping = VC_PlayerBeginTyping;
_Clbk->OnPlayerEndTyping = VC_PlayerEndTyping;
_Clbk->OnPlayerRequestClass = VC_PlayerRequestClass;
_Clbk->OnPlayerRequestSpawn = VC_PlayerRequestSpawn;
_Clbk->OnPlayerSpawn = VC_PlayerSpawn;
_Clbk->OnPlayerDeath = VC_PlayerDeath;
_Clbk->OnPlayerUpdate = VC_PlayerUpdate;
_Clbk->OnPlayerRequestEnter = VC_PlayerRequestEnter;
_Clbk->OnPlayerEnterVehicle = VC_PlayerEnterVehicle;
_Clbk->OnPlayerExitVehicle = VC_PlayerExitVehicle;
_Clbk->OnPickupClaimPicked = VC_PickupClaimPicked;
_Clbk->OnPickupPickedUp = VC_PickupPickedUp;
_Clbk->OnPickupRespawn = VC_PickupRespawn;
_Clbk->OnVehicleUpdate = VC_VehicleUpdate;
_Clbk->OnVehicleExplode = VC_VehicleExplode;
_Clbk->OnVehicleRespawn = VC_VehicleRespawn;
_Clbk->OnObjectShot = VC_ObjectShot;
_Clbk->OnObjectBump = VC_ObjectBump;
_Clbk->OnPublicMessage = VC_PublicMessage;
_Clbk->OnCommandMessage = VC_CommandMessage;
_Clbk->OnPrivateMessage = VC_PrivateMessage;
_Clbk->OnInternalCommand = VC_InternalCommand;
_Clbk->OnLoginAttempt = VC_LoginAttempt;
_Clbk->OnEntityPoolChange = VC_EntityPool;
_Clbk->OnKeyBindDown = VC_KeyBindDown;
_Clbk->OnKeyBindUp = VC_KeyBindUp;
_Clbk->OnPlayerAwayChange = VC_PlayerAway;
_Clbk->OnPlayerSpectate = VC_PlayerSpectate;
_Clbk->OnPlayerCrashReport = VC_PlayerCrashReport;
_Clbk->OnServerPerformanceReport = VC_ServerPerformanceReport;
_Clbk->OnPlayerNameChange = VC_PlayerName;
_Clbk->OnPlayerStateChange = VC_PlayerState;
_Clbk->OnPlayerActionChange = VC_PlayerAction;
_Clbk->OnPlayerOnFireChange = VC_PlayerOnFire;
_Clbk->OnPlayerCrouchChange = VC_PlayerCrouch;
_Clbk->OnPlayerGameKeysChange = VC_PlayerGameKeys;
_Clbk->OnCheckpointEntered = VC_OnCheckpointEntered;
_Clbk->OnCheckpointExited = VC_OnCheckpointExited;
_Clbk->OnSphereEntered = VC_OnSphereEntered;
_Clbk->OnSphereExited = VC_OnSphereExited;
}
// ------------------------------------------------------------------------------------------------
SqObj & NullData() noexcept
{
static SqObj d;
d.Release();
return d;
}
} // Namespace:: SqMod

68
source/Common.hpp Normal file
View File

@ -0,0 +1,68 @@
#ifndef _COMMON_HPP_
#define _COMMON_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
#include <vcmp.h>
#include <sqrat.h>
// ------------------------------------------------------------------------------------------------
#include <memory>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
using namespace Sqrat;
/* ------------------------------------------------------------------------------------------------
* ...
*/
typedef ::Sqrat::string SqTag;
typedef ::Sqrat::Object SqObj;
// ------------------------------------------------------------------------------------------------
extern PluginFuncs* _Func;
extern PluginCallbacks* _Clbk;
extern PluginInfo* _Info;
/* ------------------------------------------------------------------------------------------------
* ...
*/
SqObj & NullData() noexcept;
/* ------------------------------------------------------------------------------------------------
* Utility used to transform values into script objects on the default VM
*/
template < typename T > SqObj MakeSqObj(const T & v) noexcept
{
// Push the specified value on the stack
Sqrat::PushVar< T >(Sqrat::DefaultVM::Get(), v);
// Get the object off the stack
Sqrat::Var< SqObj > var(Sqrat::DefaultVM::Get(), -1);
// Pop the object from the stack
sq_pop(Sqrat::DefaultVM::Get(), 1);
// Return the object
return var.value;
}
/* ------------------------------------------------------------------------------------------------
* Utility used to transform values into script objects
*/
template < typename T > SqObj MakeSqObj(HSQUIRRELVM vm, const T & v) noexcept
{
// Push the specified value on the stack
Sqrat::PushVar< T >(vm, v);
// Get the object off the stack
Sqrat::Var< SqObj > var(vm, -1);
// Pop the object from the stack
sq_pop(vm, 1);
// Return the object
return var.value;
}
} // Namespace:: SqMod
#endif // _COMMON_HPP_

1175
source/Config.hpp Normal file

File diff suppressed because it is too large Load Diff

1581
source/Core.cpp Normal file

File diff suppressed because it is too large Load Diff

623
source/Core.hpp Normal file
View File

@ -0,0 +1,623 @@
#ifndef _CORE_HPP_
#define _CORE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
#include "Signal.hpp"
// ------------------------------------------------------------------------------------------------
#include <queue>
#include <vector>
#include <utility>
#include <unordered_map>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
class Core
{
protected:
// --------------------------------------------------------------------------------------------
friend class std::unique_ptr<Core, void(*)(Core *)>;
// --------------------------------------------------------------------------------------------
struct TPlayer
{
SQInt32 Weapon;
SQFloat Health;
SQFloat Armour;
//Vector3 Position;
bool Fresh;
};
// --------------------------------------------------------------------------------------------
struct TVehicle
{
SQFloat Health;
//Vector3 Position;
bool Fresh;
};
// --------------------------------------------------------------------------------------------
typedef std::array<TPlayer, SQMOD_PLAYER_POOL> TPlayerInstPool;
typedef std::array<TVehicle, SQMOD_VEHICLE_POOL> TVehicleInstPool;
// --------------------------------------------------------------------------------------------
typedef std::unique_ptr<RootTable> SqRootTable;
typedef std::unordered_map<String, Script> SqScriptPool;
// --------------------------------------------------------------------------------------------
typedef std::unordered_map<String, String> OptionPool;
public:
// --------------------------------------------------------------------------------------------
typedef std::vector< SQChar > Buffer;
typedef std::queue< Buffer > BufferPool;
private:
// --------------------------------------------------------------------------------------------
SQInteger m_State;
// --------------------------------------------------------------------------------------------
OptionPool m_Options;
// --------------------------------------------------------------------------------------------
HSQUIRRELVM m_VM;
// --------------------------------------------------------------------------------------------
SqRootTable m_RootTable;
SqScriptPool m_Scripts;
// --------------------------------------------------------------------------------------------
String m_ErrorMsg;
// --------------------------------------------------------------------------------------------
TPlayerInstPool m_PlayerTrack;
TVehicleInstPool m_VehicleTrack;
// --------------------------------------------------------------------------------------------
BufferPool m_BufferPool;
protected:
// --------------------------------------------------------------------------------------------
Core() noexcept;
// --------------------------------------------------------------------------------------------
~Core() noexcept;
// --------------------------------------------------------------------------------------------
Core(Core const &) noexcept = delete;
Core(Core &&) noexcept = delete;
// --------------------------------------------------------------------------------------------
Core & operator=(Core const &) noexcept = delete;
Core & operator=(Core &&) noexcept = delete;
// --------------------------------------------------------------------------------------------
static void _Finalizer(Core * ptr) noexcept;
public:
// --------------------------------------------------------------------------------------------
typedef std::unique_ptr<Core, void(*)(Core *)> Pointer;
// --------------------------------------------------------------------------------------------
static Pointer Inst() noexcept;
// --------------------------------------------------------------------------------------------
bool Init() noexcept;
bool Load() noexcept;
// --------------------------------------------------------------------------------------------
void Deinit() noexcept;
void Unload() noexcept;
// --------------------------------------------------------------------------------------------
void Terminate() noexcept;
// --------------------------------------------------------------------------------------------
void SetState(SQInteger val) noexcept;
SQInteger GetState() const noexcept;
// --------------------------------------------------------------------------------------------
String GetOption(const String & name) const noexcept;
void SetOption(const String & name, const String & value) noexcept;
// --------------------------------------------------------------------------------------------
Buffer PullBuffer(unsigned sz = 4096) noexcept;
void PushBuffer(Buffer && buf) noexcept;
void MakeBuffer(unsigned num, unsigned sz = 4096) noexcept;
// --------------------------------------------------------------------------------------------
void ConnectPlayer(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void DisconnectPlayer(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
protected:
// --------------------------------------------------------------------------------------------
bool Configure() noexcept;
// --------------------------------------------------------------------------------------------
bool CreateVM() noexcept;
void DestroyVM() noexcept;
// --------------------------------------------------------------------------------------------
bool LoadScripts() noexcept;
// --------------------------------------------------------------------------------------------
bool Compile(const String & name) noexcept;
bool Execute() noexcept;
// --------------------------------------------------------------------------------------------
void PrintCallstack() noexcept;
public:
// --------------------------------------------------------------------------------------------
static void PrintFunc(HSQUIRRELVM vm, const SQChar * str, ...) noexcept;
static void ErrorFunc(HSQUIRRELVM vm, const SQChar * str, ...) noexcept;
// --------------------------------------------------------------------------------------------
static SQInteger RuntimeErrorHandler(HSQUIRRELVM vm) noexcept;
static void CompilerErrorHandler(HSQUIRRELVM vm, const SQChar * desc, const SQChar * src, SQInteger line, SQInteger column) noexcept;
protected:
/* --------------------------------------------------------------------------------------------
* Destroys a Player created by the server
*/
bool DestroyPlayer(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
public:
/* --------------------------------------------------------------------------------------------
* Creates a new Blip on the server
*/
Reference< CBlip > CreateBlip(SQInt32 index, SQInt32 world, const Vector3 & pos, SQInt32 scale, \
const Color4 & color, SQInt32 sprite, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Checkpoint on the server
*/
Reference< CCheckpoint > CreateCheckpoint(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color4 & color, SQFloat radius, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Keybind on the server
*/
Reference< CKeybind > CreateKeybind(SQInt32 slot, bool release, SQInt32 primary, SQInt32 secondary, \
SQInt32 alternative, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Object on the server
*/
Reference< CObject > CreateObject(const CModel & model, SQInt32 world, const Vector3 & pos, SQInt32 alpha, \
SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Pickup on the server
*/
Reference< CPickup > CreatePickup(const CModel & model, SQInt32 world, SQInt32 quantity, const Vector3 & pos, \
SQInt32 alpha, bool automatic, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Sphere on the server
*/
Reference< CSphere > CreateSphere(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color3 & color, SQFloat radius, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Sprite on the server
*/
Reference< CSprite > CreateSprite(SQInt32 index, const String & file, const Vector2i & pos, const Vector2i & rot, \
SQFloat angle, SQInt32 alpha, bool rel, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Textdraw on the server
*/
Reference< CTextdraw > CreateTextdraw(SQInt32 index, const String & text, const Vector2i & pos, \
const Color4 & color, bool rel, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Vehicle on the server
*/
Reference< CVehicle > CreateVehicle(const CAutomobile & model, SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, const SqObj & payload) noexcept;
public:
/* --------------------------------------------------------------------------------------------
* Destroys a Blip created by the server
*/
bool DestroyBlip(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Checkpoint created by the server
*/
bool DestroyCheckpoint(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Keybind created by the server
*/
bool DestroyKeybind(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Object created by the server
*/
bool DestroyObject(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Pickup created by the server
*/
bool DestroyPickup(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Sphere created by the server
*/
bool DestroySphere(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Sprite created by the server
*/
bool DestroySprite(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Textdraw created by the server
*/
bool DestroyTextdraw(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Vehicle created by the server
*/
bool DestroyVehicle(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
public:
// --------------------------------------------------------------------------------------------
void OnBlipCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnCheckpointCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnKeybindCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnObjectCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPickupCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPlayerCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSphereCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSpriteCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnTextdrawCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnVehicleCreated(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
// --------------------------------------------------------------------------------------------
void OnBlipDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnCheckpointDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnKeybindDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnObjectDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPickupDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPlayerDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSphereDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSpriteDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnTextdrawDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnVehicleDestroyed(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
// --------------------------------------------------------------------------------------------
void OnBlipCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnCheckpointCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnKeybindCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnObjectCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPickupCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnPlayerCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSphereCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnSpriteCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnTextdrawCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
void OnVehicleCustom(SQInt32 id, SQInt32 header, const SqObj & payload) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerAway(SQInt32 player, bool status) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerGameKeys(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept;
void OnPlayerName(SQInt32 player, const SQChar * previous, const SQChar * current) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerRequestClass(SQInt32 player, SQInt32 offset) noexcept;
void OnPlayerRequestSpawn(SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerSpawn(SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerStartTyping(SQInt32 player) noexcept;
void OnPlayerStopTyping(SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerChat(SQInt32 player, const SQChar * message) noexcept;
void OnPlayerCommand(SQInt32 player, const SQChar * command) noexcept;
void OnPlayerMessage(SQInt32 player, SQInt32 receiver, const SQChar * message) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerHealth(SQInt32 player, SQFloat previous, SQFloat current) noexcept;
void OnPlayerArmour(SQInt32 player, SQFloat previous, SQFloat current) noexcept;
void OnPlayerWeapon(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept;
void OnPlayerMove(SQInt32 player, const Vector3 & previous, const Vector3 & current) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerWasted(SQInt32 player, SQInt32 reason) noexcept;
void OnPlayerKilled(SQInt32 player, SQInt32 killer, SQInt32 reason, SQInt32 body_part) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerSpectate(SQInt32 player, SQInt32 target) noexcept;
void OnPlayerCrashreport(SQInt32 player, const SQChar * report) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerBurning(SQInt32 player, bool state) noexcept;
void OnPlayerCrouching(SQInt32 player, bool state) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerState(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept;
void OnPlayerAction(SQInt32 player, SQInt32 previous, SQInt32 current) noexcept;
// --------------------------------------------------------------------------------------------
void OnStateNone(SQInt32 player, SQInt32 previous) noexcept;
void OnStateNormal(SQInt32 player, SQInt32 previous) noexcept;
void OnStateShooting(SQInt32 player, SQInt32 previous) noexcept;
void OnStateDriver(SQInt32 player, SQInt32 previous) noexcept;
void OnStatePassenger(SQInt32 player, SQInt32 previous) noexcept;
void OnStateEnterDriver(SQInt32 player, SQInt32 previous) noexcept;
void OnStateEnterPassenger(SQInt32 player, SQInt32 previous) noexcept;
void OnStateExitVehicle(SQInt32 player, SQInt32 previous) noexcept;
void OnStateUnspawned(SQInt32 player, SQInt32 previous) noexcept;
// --------------------------------------------------------------------------------------------
void OnActionNone(SQInt32 player, SQInt32 previous) noexcept;
void OnActionNormal(SQInt32 player, SQInt32 previous) noexcept;
void OnActionAiming(SQInt32 player, SQInt32 previous) noexcept;
void OnActionShooting(SQInt32 player, SQInt32 previous) noexcept;
void OnActionJumping(SQInt32 player, SQInt32 previous) noexcept;
void OnActionLieDown(SQInt32 player, SQInt32 previous) noexcept;
void OnActionGettingUp(SQInt32 player, SQInt32 previous) noexcept;
void OnActionJumpVehicle(SQInt32 player, SQInt32 previous) noexcept;
void OnActionDriving(SQInt32 player, SQInt32 previous) noexcept;
void OnActionDying(SQInt32 player, SQInt32 previous) noexcept;
void OnActionWasted(SQInt32 player, SQInt32 previous) noexcept;
void OnActionEmbarking(SQInt32 player, SQInt32 previous) noexcept;
void OnActionDisembarking(SQInt32 player, SQInt32 previous) noexcept;
// --------------------------------------------------------------------------------------------
void OnVehicleRespawn(SQInt32 vehicle) noexcept;
void OnVehicleExplode(SQInt32 vehicle) noexcept;
// --------------------------------------------------------------------------------------------
void OnVehicleHealth(SQInt32 vehicle, SQFloat previous, SQFloat current) noexcept;
void OnVehicleMove(SQInt32 vehicle, const Vector3 & previous, const Vector3 & current) noexcept;
// --------------------------------------------------------------------------------------------
void OnPickupRespawn(SQInt32 pickup) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerKeyPress(SQInt32 player, SQInt32 keybind) noexcept;
void OnPlayerKeyRelease(SQInt32 player, SQInt32 keybind) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerEmbarking(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept;
void OnPlayerEmbarked(SQInt32 player, SQInt32 vehicle, SQInt32 slot) noexcept;
void OnPlayerDisembark(SQInt32 player, SQInt32 vehicle) noexcept;
// --------------------------------------------------------------------------------------------
void OnPickupClaimed(SQInt32 pickup, SQInt32 player) noexcept;
void OnPickupCollected(SQInt32 pickup, SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnObjectShot(SQInt32 object, SQInt32 player, SQInt32 weapon) noexcept;
void OnObjectBump(SQInt32 object, SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnCheckpointEntered(SQInt32 checkpoint, SQInt32 player) noexcept;
void OnCheckpointExited(SQInt32 checkpoint, SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnSphereEntered(SQInt32 sphere, SQInt32 player) noexcept;
void OnSphereExited(SQInt32 sphere, SQInt32 player) noexcept;
// --------------------------------------------------------------------------------------------
void OnServerFrame(SQFloat delta) noexcept;
// --------------------------------------------------------------------------------------------
void OnServerStartup() noexcept;
void OnServerShutdown() noexcept;
// --------------------------------------------------------------------------------------------
void OnInternalCommand(SQInt32 type, const SQChar * text) noexcept;
void OnLoginAttempt(const SQChar * name, const SQChar * passwd, const SQChar * ip) noexcept;
// --------------------------------------------------------------------------------------------
void OnCustomEvent(SQInt32 group, SQInt32 header, const SqObj & payload) noexcept;
// --------------------------------------------------------------------------------------------
void OnWorldOption(SQInt32 option, const SqObj & value) noexcept;
void OnWorldToggle(SQInt32 option, bool value) noexcept;
// --------------------------------------------------------------------------------------------
void OnScriptReload(SQInt32 header, const SqObj & payload) noexcept;
// --------------------------------------------------------------------------------------------
void OnLogMessage(SQInt32 type, const SQChar * message) noexcept;
// --------------------------------------------------------------------------------------------
void OnPlayerUpdate(SQInt32 player, SQInt32 type) noexcept;
void OnVehicleUpdate(SQInt32 vehicle, SQInt32 type) noexcept;
void OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept;
public:
// --------------------------------------------------------------------------------------------
EBlipCreated BlipCreated;
ECheckpointCreated CheckpointCreated;
EKeybindCreated KeybindCreated;
EObjectCreated ObjectCreated;
EPickupCreated PickupCreated;
EPlayerCreated PlayerCreated;
ESphereCreated SphereCreated;
ESpriteCreated SpriteCreated;
ETextdrawCreated TextdrawCreated;
EVehicleCreated VehicleCreated;
// --------------------------------------------------------------------------------------------
EBlipDestroyed BlipDestroyed;
ECheckpointDestroyed CheckpointDestroyed;
EKeybindDestroyed KeybindDestroyed;
EObjectDestroyed ObjectDestroyed;
EPickupDestroyed PickupDestroyed;
EPlayerDestroyed PlayerDestroyed;
ESphereDestroyed SphereDestroyed;
ESpriteDestroyed SpriteDestroyed;
ETextdrawDestroyed TextdrawDestroyed;
EVehicleDestroyed VehicleDestroyed;
// --------------------------------------------------------------------------------------------
EBlipCustom BlipCustom;
ECheckpointCustom CheckpointCustom;
EKeybindCustom KeybindCustom;
EObjectCustom ObjectCustom;
EPickupCustom PickupCustom;
EPlayerCustom PlayerCustom;
ESphereCustom SphereCustom;
ESpriteCustom SpriteCustom;
ETextdrawCustom TextdrawCustom;
EVehicleCustom VehicleCustom;
// --------------------------------------------------------------------------------------------
EPlayerAway PlayerAway;
// --------------------------------------------------------------------------------------------
EPlayerGameKeys PlayerGameKeys;
EPlayerRename PlayerRename;
// --------------------------------------------------------------------------------------------
EPlayerRequestClass PlayerRequestClass;
EPlayerRequestSpawn PlayerRequestSpawn;
// --------------------------------------------------------------------------------------------
EPlayerSpawn PlayerSpawn;
// --------------------------------------------------------------------------------------------
EPlayerStartTyping PlayerStartTyping;
EPlayerStopTyping PlayerStopTyping;
// --------------------------------------------------------------------------------------------
EPlayerChat PlayerChat;
EPlayerCommand PlayerCommand;
EPlayerMessage PlayerMessage;
// --------------------------------------------------------------------------------------------
EPlayerHealth PlayerHealth;
EPlayerArmour PlayerArmour;
EPlayerWeapon PlayerWeapon;
EPlayerMove PlayerMove;
// --------------------------------------------------------------------------------------------
EPlayerWasted PlayerWasted;
EPlayerKilled PlayerKilled;
EPlayerTeamKill PlayerTeamKill;
// --------------------------------------------------------------------------------------------
EPlayerSpectate PlayerSpectate;
EPlayerCrashreport PlayerCrashreport;
// --------------------------------------------------------------------------------------------
EPlayerBurning PlayerBurning;
EPlayerCrouching PlayerCrouching;
// --------------------------------------------------------------------------------------------
EPlayerState PlayerState;
EPlayerAction PlayerAction;
// --------------------------------------------------------------------------------------------
EStateNone StateNone;
EStateNormal StateNormal;
EStateShooting StateShooting;
EStateDriver StateDriver;
EStatePassenger StatePassenger;
EStateEnterDriver StateEnterDriver;
EStateEnterPassenger StateEnterPassenger;
EStateExitVehicle StateExitVehicle;
EStateUnspawned StateUnspawned;
// --------------------------------------------------------------------------------------------
EActionNone ActionNone;
EActionNormal ActionNormal;
EActionAiming ActionAiming;
EActionShooting ActionShooting;
EActionJumping ActionJumping;
EActionLieDown ActionLieDown;
EActionGettingUp ActionGettingUp;
EActionJumpVehicle ActionJumpVehicle;
EActionDriving ActionDriving;
EActionDying ActionDying;
EActionWasted ActionWasted;
EActionEmbarking ActionEmbarking;
EActionDisembarking ActionDisembarking;
// --------------------------------------------------------------------------------------------
EVehicleRespawn VehicleRespawn;
EVehicleExplode VehicleExplode;
// --------------------------------------------------------------------------------------------
EVehicleHealth VehicleHealth;
EVehicleMove VehicleMove;
// --------------------------------------------------------------------------------------------
EPickupRespawn PickupRespawn;
// --------------------------------------------------------------------------------------------
EKeybindKeyPress KeybindKeyPress;
EKeybindKeyRelease KeybindKeyRelease;
// --------------------------------------------------------------------------------------------
EVehicleEmbarking VehicleEmbarking;
EVehicleEmbarked VehicleEmbarked;
EVehicleDisembark VehicleDisembark;
// --------------------------------------------------------------------------------------------
EPickupClaimed PickupClaimed;
EPickupCollected PickupCollected;
// --------------------------------------------------------------------------------------------
EObjectShot ObjectShot;
EObjectBump ObjectBump;
// --------------------------------------------------------------------------------------------
ECheckpointEntered CheckpointEntered;
ECheckpointExited CheckpointExited;
// --------------------------------------------------------------------------------------------
ESphereEntered SphereEntered;
ESphereExited SphereExited;
// --------------------------------------------------------------------------------------------
EServerFrame ServerFrame;
// --------------------------------------------------------------------------------------------
EServerStartup ServerStartup;
EServerShutdown ServerShutdown;
// --------------------------------------------------------------------------------------------
EInternalCommand InternalCommand;
ELoginAttempt LoginAttempt;
// --------------------------------------------------------------------------------------------
ECustomEvent CustomEvent;
// --------------------------------------------------------------------------------------------
EWorldOption WorldOption;
EWorldToggle WorldToggle;
};
// ------------------------------------------------------------------------------------------------
extern const Core::Pointer _Core;
} // Namespace:: SqMod
#endif // _CORE_HPP_

14
source/Entity.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "Entity.hpp"
#include "Register.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Entity(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

1548
source/Entity.hpp Normal file

File diff suppressed because it is too large Load Diff

28
source/Entity/Blip.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "Entity/Blip.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CBlip(HSQUIRRELVM vm)
{
if (!Register_Reference< CBlip >(vm, _SC("BaseBlip")))
{
LogDbg("Unable to register the base class <BaseBlip> for <CBlip> type");
return false;
}
LogDbg("Beginning registration of <CBlip> type");
Sqrat::RootTable(vm).Bind(_SC("CBlip"), Sqrat::DerivedClass< CBlip, Reference< CBlip > >(vm, _SC("CBlip"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CBlip> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Blip.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_BLIP_HPP_
#define _ENTITY_BLIP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CBlip : public Reference< CBlip >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_BLIP_HPP_

View File

@ -0,0 +1,29 @@
#include "Entity/Checkpoint.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CCheckpoint(HSQUIRRELVM vm)
{
if (!Register_Reference< CCheckpoint >(vm, _SC("BaseCheckpoint")))
{
LogDbg("Unable to register the base class <BaseCheckpoint> for <CCheckpoint> type");
return false;
}
LogDbg("Beginning registration of <CCheckpoint> type");
Sqrat::RootTable(vm).Bind(_SC("CCheckpoint"), Sqrat::DerivedClass< CCheckpoint, Reference< CCheckpoint > >(vm, _SC("CCheckpoint"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CCheckpoint> type was successful");
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_CHECKPOINT_HPP_
#define _ENTITY_CHECKPOINT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CCheckpoint : public Reference< CCheckpoint >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_CHECKPOINT_HPP_

29
source/Entity/Keybind.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Keybind.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CKeybind(HSQUIRRELVM vm)
{
if (!Register_Reference< CKeybind >(vm, _SC("BaseKeybind")))
{
LogDbg("Unable to register the base class <BaseKeybind> for <CKeybind> type");
return false;
}
LogDbg("Beginning registration of <CKeybind> type");
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, Reference< CKeybind > >(vm, _SC("CKeybind"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CKeybind> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Keybind.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_KEYBIND_HPP_
#define _ENTITY_KEYBIND_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CKeybind : public Reference< CKeybind >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_KEYBIND_HPP_

29
source/Entity/Object.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Object.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CObject(HSQUIRRELVM vm)
{
if (!Register_Reference< CObject >(vm, _SC("BaseObject")))
{
LogDbg("Unable to register the base class <BaseObject> for <CObject> type");
return false;
}
LogDbg("Beginning registration of <CObject> type");
Sqrat::RootTable(vm).Bind(_SC("CObject"), Sqrat::DerivedClass< CObject, Reference< CObject > >(vm, _SC("CObject"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CObject> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Object.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_OBJECT_HPP_
#define _ENTITY_OBJECT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CObject : public Reference< CObject >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_OBJECT_HPP_

29
source/Entity/Pickup.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Pickup.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CPickup(HSQUIRRELVM vm)
{
if (!Register_Reference< CPickup >(vm, _SC("BasePickup")))
{
LogDbg("Unable to register the base class <BasePickup> for <CPickup> type");
return false;
}
LogDbg("Beginning registration of <CPickup> type");
Sqrat::RootTable(vm).Bind(_SC("CPickup"), Sqrat::DerivedClass< CPickup, Reference< CPickup > >(vm, _SC("CPickup"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CPickup> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Pickup.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_PICKUP_HPP_
#define _ENTITY_PICKUP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CPickup : public Reference< CPickup >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_PICKUP_HPP_

29
source/Entity/Player.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Player.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CPlayer(HSQUIRRELVM vm)
{
if (!Register_Reference< CPlayer >(vm, _SC("BasePlayer")))
{
LogDbg("Unable to register the base class <BasePlayer> for <CPlayer> type");
return false;
}
LogDbg("Beginning registration of <CPlayer> type");
Sqrat::RootTable(vm).Bind(_SC("CPlayer"), Sqrat::DerivedClass< CPlayer, Reference< CPlayer > >(vm, _SC("CPlayer"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CPlayer> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Player.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_PLAYER_HPP_
#define _ENTITY_PLAYER_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CPlayer : public Reference< CPlayer >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_PLAYER_HPP_

29
source/Entity/Sphere.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Sphere.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CSphere(HSQUIRRELVM vm)
{
if (!Register_Reference< CSphere >(vm, _SC("BaseSphere")))
{
LogDbg("Unable to register the base class <BaseSphere> for <CSphere> type");
return false;
}
LogDbg("Beginning registration of <CSphere> type");
Sqrat::RootTable(vm).Bind(_SC("CSphere"), Sqrat::DerivedClass< CSphere, Reference< CSphere > >(vm, _SC("CSphere"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CSphere> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Sphere.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_SPHERE_HPP_
#define _ENTITY_SPHERE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CSphere : public Reference< CSphere >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_SPHERE_HPP_

29
source/Entity/Sprite.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Sprite.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CSprite(HSQUIRRELVM vm)
{
if (!Register_Reference< CSprite >(vm, _SC("BaseSprite")))
{
LogDbg("Unable to register the base class <BaseSprite> for <CSprite> type");
return false;
}
LogDbg("Beginning registration of <CSprite> type");
Sqrat::RootTable(vm).Bind(_SC("CSprite"), Sqrat::DerivedClass< CSprite, Reference< CSprite > >(vm, _SC("CSprite"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CSprite> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Sprite.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_SPRITE_HPP_
#define _ENTITY_SPRITE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CSprite : public Reference< CSprite >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_SPRITE_HPP_

View File

@ -0,0 +1,29 @@
#include "Entity/Textdraw.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CTextdraw(HSQUIRRELVM vm)
{
if (!Register_Reference< CTextdraw >(vm, _SC("BaseTextdraw")))
{
LogDbg("Unable to register the base class <BaseTextdraw> for <CTextdraw> type");
return false;
}
LogDbg("Beginning registration of <CTextdraw> type");
Sqrat::RootTable(vm).Bind(_SC("CTextdraw"), Sqrat::DerivedClass< CTextdraw, Reference< CTextdraw > >(vm, _SC("CTextdraw"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CTextdraw> type was successful");
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_TEXTDRAW_HPP_
#define _ENTITY_TEXTDRAW_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CTextdraw : public Reference< CTextdraw >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_TEXTDRAW_HPP_

29
source/Entity/Vehicle.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "Entity/Vehicle.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CVehicle(HSQUIRRELVM vm)
{
if (!Register_Reference< CVehicle >(vm, _SC("BaseVehicle")))
{
LogDbg("Unable to register the base class <BaseVehicle> for <CVehicle> type");
return false;
}
LogDbg("Beginning registration of <CVehicle> type");
Sqrat::RootTable(vm).Bind(_SC("CVehicle"), Sqrat::DerivedClass< CVehicle, Reference< CVehicle > >(vm, _SC("CVehicle"))
.Ctor()
.Ctor< SQInt32 >()
);
LogDbg("Registration of <CVehicle> type was successful");
return true;
}
} // Namespace:: SqMod

22
source/Entity/Vehicle.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef _ENTITY_VEHICLE_HPP_
#define _ENTITY_VEHICLE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CVehicle : public Reference< CVehicle >
{
public:
// --------------------------------------------------------------------------------------------
using RefType::Reference;
};
} // Namespace:: SqMod
#endif // _ENTITY_VEHICLE_HPP_

0
source/Iterators.cpp Normal file
View File

0
source/Iterators.hpp Normal file
View File

13
source/Library/CFG.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/CFG.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CFG(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/CFG.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_CFG_HPP_
#define _LIBRARY_CFG_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_CFG_HPP_

View File

@ -0,0 +1,13 @@
#include "Library/Datetime.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Datetime(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_DATETIME_HPP_
#define _LIBRARY_DATETIME_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_DATETIME_HPP_

13
source/Library/FileIO.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/FileIO.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_FileIO(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/FileIO.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_FILEIO_HPP_
#define _LIBRARY_FILEIO_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_FILEIO_HPP_

166
source/Library/Format.cpp Normal file
View File

@ -0,0 +1,166 @@
#include "Library/Format.hpp"
#include "Register.hpp"
#include "Logger.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
#include <format.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
static const SQChar * GetTypeName(SQObjectType type_id) noexcept
{
switch (type_id)
{
case OT_INTEGER:
return _SC("integer");
case OT_FLOAT:
return _SC("float");
case OT_STRING:
return _SC("string");
case OT_BOOL:
return _SC("boolean");
case OT_USERPOINTER:
return _SC("user pointer");
case OT_NULL:
return _SC("null");
case OT_TABLE:
return _SC("table");
case OT_ARRAY:
return _SC("array");
case OT_CLOSURE:
return _SC("closure");
case OT_NATIVECLOSURE:
return _SC("native closure");
case OT_GENERATOR:
return _SC("generator");
case OT_USERDATA:
return _SC("user data");
case OT_THREAD:
return _SC("thread");
case OT_CLASS:
return _SC("class");
case OT_INSTANCE:
return _SC("instance");
case OT_WEAKREF:
return _SC("weak reference");
default:
return _SC("unknown");
}
}
// ------------------------------------------------------------------------------------------------
String GetFormatStr(HSQUIRRELVM vm, SQInteger arg, SQInteger args) noexcept
{
if (sq_gettype(vm, arg) == OT_STRING)
{
const SQChar * str = 0;
sq_getstring(vm, arg, &str);
return GetFormatStr(vm, (str == NULL ? "" : str), ++arg, args);
}
else
{
LogErr("Expecting format string but got: %s", GetTypeName(sq_gettype(vm, arg)));
}
return String();
}
// ------------------------------------------------------------------------------------------------
String GetFormatStr(HSQUIRRELVM vm, const String & fstr, SQInteger arg, SQInteger args) noexcept
{
using namespace fmt::internal;
String str;
if (args-arg > 15)
{
LogErr("Too many arguments to format");
return str;
}
else if (fstr.empty())
{
return str;
}
else if (arg == args)
{
// Unnecessary but should throw an error when trying to format something without arguments
try
{
str = fmt::format(fstr);
}
catch (const fmt::SystemError & e)
{
LogErr(e.what());
}
return str;
}
const SQChar * sval = 0;
SQInteger ival;
SQFloat fval;
SQUserPointer pval;
std::vector< MakeValue< SQChar > > vlist;
vlist.reserve(args-arg);
std::uint64_t vtype = 0x0;
for (unsigned sh = 0;arg <= args; arg++, sh += 4)
{
switch(sq_gettype(vm, arg))
{
case OT_INTEGER:
sq_getinteger(vm, arg, &ival);
vlist.emplace_back(ival);
vtype |= (MakeValue< SQChar >::type(ival) << sh);
break;
case OT_FLOAT:
sq_getfloat(vm, arg, &fval);
vlist.emplace_back(fval);
vtype |= (MakeValue< SQChar >::type(fval) << sh);
break;
case OT_STRING:
sq_getstring(vm, arg, &sval);
vlist.emplace_back(sval);
vtype |= (MakeValue< SQChar >::type(sval) << sh);
break;
case OT_BOOL:
sq_getinteger(vm, arg, &ival);
vlist.emplace_back(static_cast<unsigned char>(ival));
vtype |= (MakeValue< SQChar >::type(static_cast<unsigned char>(ival)) << sh);
break;
case OT_USERPOINTER:
sq_getuserpointer(vm, arg, &pval);
vlist.emplace_back(static_cast<void *>(pval));
vtype |= (MakeValue< SQChar >::type(static_cast<void *>(pval)) << sh);
break;
default:
LogErr("Cannot format (%s) data type", GetTypeName(sq_gettype(vm, arg)));
return str;
}
}
vlist.shrink_to_fit();
try
{
fmt::BasicMemoryWriter<SQChar> w;
w.write(fstr, fmt::ArgList(vtype, vlist.data()));
str = w.c_str();
}
catch (const fmt::SystemError & e)
{
LogErr("%s", e.what());
}
return str;
}
// ------------------------------------------------------------------------------------------------
bool Register_Format(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/Format.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_FORMAT_HPP_
#define _LIBRARY_FORMAT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
String GetFormatStr(HSQUIRRELVM vm, SQInteger arg, SQInteger args) noexcept;
String GetFormatStr(HSQUIRRELVM vm, const String & fstr, SQInteger arg, SQInteger args) noexcept;
} // Namespace:: SqMod
#endif // _LIBRARY_FORMAT_HPP_

13
source/Library/INI.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/INI.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_INI(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/INI.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_INI_HPP_
#define _LIBRARY_INI_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_INI_HPP_

13
source/Library/JSON.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/JSON.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_JSON(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/JSON.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_JSON_HPP_
#define _LIBRARY_JSON_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_JSON_HPP_

View File

@ -0,0 +1,60 @@
#include "Library/LongInt.hpp"
//#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_LongInt(HSQUIRRELVM vm)
{
/*
Sqrat::RootTable(vm).Bind(_SC("SLongInt"), Sqrat::Class<SLongInt>(vm, _SC("SLongInt"))
.Ctor()
.Ctor(SLongInt::Value)
.Ctor(const SQChar *, SQInteger)
.Prop(_SC("str"), &SLongInt::GetCStr, &SLongInt::SetStr)
.Prop(_SC("num"), &SLongInt::GetSNum, &SLongInt::SetNum)
.Func(_SC("_tostring"), &SLongInt::ToString)
.Func(_SC("_cmp"), &SLongInt::Cmp)
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_add"), &SLongInt::operator +)
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_sub"), &SLongInt::operator -)
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_mul"), &SLongInt::operator *)
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_div"), &SLongInt::operator /)
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_modulo"), &SLongInt::operator %)
.Func<SLongInt (SLongInt::*)(void) const>(_SC("_unm"), &SLongInt::operator -)
.Overload<void (SLongInt::*)(void)>(_SC("random"), &SLongInt::Random)
.Overload<void (SLongInt::*)(SLongInt::Value, SLongInt::Value)>(_SC("random"), &SLongInt::Random)
);
Sqrat::RootTable(vm).Bind(_SC("ULongInt"), Sqrat::Class<ULongInt>(vm, _SC("ULongInt"))
.Ctor()
.Ctor(ULongInt::Value)
.Ctor(const SQChar *, SQInteger)
.Prop(_SC("str"), &ULongInt::GetCStr, &ULongInt::SetStr)
.Prop(_SC("num"), &ULongInt::GetSNum, &ULongInt::SetNum)
.Func(_SC("_tostring"), &ULongInt::ToString)
.Func(_SC("_cmp"), &ULongInt::Cmp)
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_add"), &ULongInt::operator +)
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_sub"), &ULongInt::operator -)
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_mul"), &ULongInt::operator *)
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_div"), &ULongInt::operator /)
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_modulo"), &ULongInt::operator %)
.Func<ULongInt (ULongInt::*)(void) const>(_SC("_unm"), &ULongInt::operator -)
.Overload<void (ULongInt::*)(void)>(_SC("random"), &ULongInt::Random)
.Overload<void (ULongInt::*)(ULongInt::Value, ULongInt::Value)>(_SC("random"), &ULongInt::Random)
);
*/
return true;
}
} // Namespace:: SqMod

243
source/Library/LongInt.hpp Normal file
View File

@ -0,0 +1,243 @@
#ifndef _LIBRARY_LONGINT_HPP_
#define _LIBRARY_LONGINT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
#include <stdexcept>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
template <typename T> class LongInt
{
public:
// --------------------------------------------------------------------------------------------
static_assert(std::is_integral<T>::value, "LongInt type is not an integral type");
// --------------------------------------------------------------------------------------------
typedef T Value;
// --------------------------------------------------------------------------------------------
LongInt() noexcept
: m_Data(0), m_Text()
{
}
template <typename U>
LongInt(U data) noexcept
{
*this = data;
}
// --------------------------------------------------------------------------------------------
LongInt(const SQChar * text) noexcept
{
*this = text;
}
LongInt(const SQChar * text, SQInteger overload = 0) noexcept
{
*this = text;
}
// --------------------------------------------------------------------------------------------
LongInt(const LongInt<T> & i) noexcept
: m_Data(i.m_Data), m_Text(i.m_Text)
{
}
LongInt(LongInt<T> && i) noexcept
: m_Data(i.m_Data), m_Text(std::move(i.m_Text))
{
}
// --------------------------------------------------------------------------------------------
~LongInt()
{
}
// --------------------------------------------------------------------------------------------
LongInt & operator = (const LongInt<T> & i) noexcept
{
m_Data = i.m_Data;
m_Text = i.m_Text;
return *this;
}
LongInt & operator = (LongInt<T> && i) noexcept
{
m_Data = i.m_Data;
m_Text = std::move(i.m_Text);
return *this;
}
// --------------------------------------------------------------------------------------------
template <typename U, typename std::enable_if<std::is_integral<U>::value>::type* = nullptr>
LongInt & operator = (U data) noexcept
{
m_Data = static_cast<Value>(data);
m_Text = std::to_string(m_Data);
return *this;
}
LongInt & operator = (const SQChar * text) noexcept
{
m_Text = text;
try
{
m_Data = SToI<T>(text, 0, 10);
}
catch (const std::invalid_argument & e)
{
LogErr("Unable to extract number: %s", e.what());
}
return *this;
}
// --------------------------------------------------------------------------------------------
bool operator == (const LongInt<T> & x) const noexcept
{
return (m_Data == x.m_Data);
}
bool operator != (const LongInt<T> & x) const noexcept
{
return (m_Data != x.m_Data);
}
bool operator < (const LongInt<T> & x) const noexcept
{
return (m_Data < x.m_Data);
}
bool operator > (const LongInt<T> & x) const noexcept
{
return (m_Data > x.m_Data);
}
bool operator <= (const LongInt<T> & x) const noexcept
{
return (m_Data <= x.m_Data);
}
bool operator >= (const LongInt<T> & x) const noexcept
{
return (m_Data >= x.m_Data);
}
// --------------------------------------------------------------------------------------------
inline operator T () const noexcept
{
return m_Data;
}
// --------------------------------------------------------------------------------------------
LongInt<T> operator + (const LongInt<T> & x) const noexcept
{
return LongInt<T>(m_Data + x.m_Data);
}
LongInt<T> operator - (const LongInt<T> & x) const noexcept
{
return LongInt<T>(m_Data - x.m_Data);
}
LongInt<T> operator * (const LongInt<T> & x) const noexcept
{
return LongInt<T>(m_Data * x.m_Data);
}
LongInt<T> operator / (const LongInt<T> & x) const noexcept
{
return LongInt<T>(m_Data / x.m_Data);
}
LongInt<T> operator % (const LongInt<T> & x) const noexcept
{
return LongInt<T>(m_Data % x.m_Data);
}
// --------------------------------------------------------------------------------------------
LongInt<T> operator - () const noexcept
{
return LongInt<T>(-m_Data);
}
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const LongInt<T> & x) const noexcept
{
return m_Data == x.m_Data ? 0 : (m_Data > x.m_Data ? 1 : -1);
}
const SQChar * ToString() const noexcept
{
return m_Text.c_str();
}
// --------------------------------------------------------------------------------------------
void SetNum(T data) noexcept
{
*this = data;
}
T GetNum() const noexcept
{
return m_Data;
}
SQInteger GetSNum() const noexcept
{
return static_cast<SQInteger>(m_Data);
}
// --------------------------------------------------------------------------------------------
void SetStr(const SQChar * text) noexcept
{
*this = text;
}
const String & GetStr() const noexcept
{
return m_Text;
}
const SQChar * GetCStr() const noexcept
{
return m_Text.c_str();
}
// --------------------------------------------------------------------------------------------
void Random() noexcept
{
m_Data = RandomVal<T>::Get();
m_Text = std::to_string(m_Data);
}
void Random(T min, T max) noexcept
{
m_Data = RandomVal<T>::Get(min, max);
m_Text = std::to_string(m_Data);
}
private:
// --------------------------------------------------------------------------------------------
T m_Data;
String m_Text;
};
// ------------------------------------------------------------------------------------------------
typedef LongInt<Int64> SLongInt;
typedef LongInt<Uint64> ULongInt;
} // Namespace:: SqMod
#endif // _LIBRARY_LONGINT_HPP_

13
source/Library/Math.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/Math.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Math(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/Math.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_MATH_HPP_
#define _LIBRARY_MATH_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_MATH_HPP_

View File

@ -0,0 +1,13 @@
#include "Library/Numeric.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Numeric(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_NUMERIC_HPP_
#define _LIBRARY_NUMERIC_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_NUMERIC_HPP_

14
source/Library/Shared.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "Library/Shared.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Library(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

12
source/Library/Shared.hpp Normal file
View File

@ -0,0 +1,12 @@
#ifndef _LIBRARY_SHARED_HPP_
#define _LIBRARY_SHARED_HPP_
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
} // Namespace:: SqMod
#endif // _LIBRARY_SHARED_HPP_

13
source/Library/String.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/String.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_String(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/String.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_STRING_HPP_
#define _LIBRARY_STRING_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_STRING_HPP_

View File

@ -0,0 +1,13 @@
#include "Library/SysPath.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_SysPath(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_SYSPATH_HPP_
#define _LIBRARY_SYSPATH_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_SYSPATH_HPP_

13
source/Library/System.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/System.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_System(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/System.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_SYSTEM_HPP_
#define _LIBRARY_SYSTEM_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_SYSTEM_HPP_

13
source/Library/Timer.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/Timer.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Timer(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/Timer.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_TIMER_HPP_
#define _LIBRARY_TIMER_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_TIMER_HPP_

13
source/Library/Utils.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/Utils.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Utils(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/Utils.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_UTILS_HPP_
#define _LIBRARY_UTILS_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_UTILS_HPP_

13
source/Library/XML.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Library/XML.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_XML(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

16
source/Library/XML.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef _LIBRARY_XML_HPP_
#define _LIBRARY_XML_HPP_
// ------------------------------------------------------------------------------------------------
#include "Config.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
} // Namespace:: SqMod
#endif // _LIBRARY_XML_HPP_

381
source/Logger.cpp Normal file
View File

@ -0,0 +1,381 @@
#include "Logger.hpp"
// ------------------------------------------------------------------------------------------------
#include <ctime>
#include <cstdio>
#include <cstdarg>
// ------------------------------------------------------------------------------------------------
namespace {
#ifdef SQMOD_OS_WINDOWS
#include <Windows.h>
enum
{
LOG_COLOR_NORMAL = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
LOG_COLOR_WHITE = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
LOG_COLOR_GRAY = FOREGROUND_INTENSITY,
LOG_COLOR_LIGHT_BLUE = FOREGROUND_INTENSITY | FOREGROUND_BLUE,
LOG_COLOR_DARK_BLUE = FOREGROUND_BLUE,
LOG_COLOR_LIGHT_GREEN = FOREGROUND_INTENSITY | FOREGROUND_GREEN,
LOG_COLOR_DARK_GREEN = FOREGROUND_GREEN,
LOG_COLOR_LIGHT_CYAN = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE,
LOG_COLOR_DARK_CYAN = FOREGROUND_GREEN | FOREGROUND_BLUE,
LOG_COLOR_LIGHT_YELLOW = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN,
LOG_COLOR_DARK_YELLOW = FOREGROUND_RED | FOREGROUND_GREEN,
LOG_COLOR_LIGHT_RED = FOREGROUND_INTENSITY | FOREGROUND_RED,
LOG_COLOR_DARK_RED = FOREGROUND_RED,
LOG_COLOR_LIGHT_MAGENTA = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE,
LOG_COLOR_DARK_MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE
};
enum
{
LOG_COLOR_DBG = LOG_COLOR_LIGHT_BLUE,
LOG_COLOR_MSG = LOG_COLOR_GRAY,
LOG_COLOR_SCS = LOG_COLOR_LIGHT_GREEN,
LOG_COLOR_INF = LOG_COLOR_LIGHT_CYAN,
LOG_COLOR_WRN = LOG_COLOR_LIGHT_YELLOW,
LOG_COLOR_ERR = LOG_COLOR_LIGHT_MAGENTA,
LOG_COLOR_FTL = LOG_COLOR_LIGHT_RED
};
#endif // SQMOD_OS_WINDOWS
} // Namespace::
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Logger::Pointer _Log = Logger::Inst();
// ------------------------------------------------------------------------------------------------
inline const char * GetLevelTag(Uint8 type) noexcept
{
switch (type)
{
case Logger::LEVEL_DBG: return "[DBG]";
case Logger::LEVEL_MSG: return "[MSG]";
case Logger::LEVEL_SCS: return "[SCS]";
case Logger::LEVEL_INF: return "[INF]";
case Logger::LEVEL_WRN: return "[WRN]";
case Logger::LEVEL_ERR: return "[ERR]";
case Logger::LEVEL_FTL: return "[FTL]";
default: return "[UNK]";
}
}
#ifdef SQMOD_OS_WINDOWS
// ------------------------------------------------------------------------------------------------
inline Uint16 GetLevelColor(Uint8 type) noexcept
{
switch (type)
{
case Logger::LEVEL_DBG: return LOG_COLOR_DBG;
case Logger::LEVEL_MSG: return LOG_COLOR_MSG;
case Logger::LEVEL_SCS: return LOG_COLOR_SCS;
case Logger::LEVEL_INF: return LOG_COLOR_INF;
case Logger::LEVEL_WRN: return LOG_COLOR_WRN;
case Logger::LEVEL_ERR: return LOG_COLOR_ERR;
case Logger::LEVEL_FTL: return LOG_COLOR_FTL;
default: return LOG_COLOR_NORMAL;
}
}
#else
// ------------------------------------------------------------------------------------------------
inline const char * GetLevelColor(Uint8 type) noexcept
{
return "";
}
#endif // SQMOD_OS_WINDOWS
// ------------------------------------------------------------------------------------------------
Logger::Logger() noexcept
: m_ConsoleTime(false), m_FileTime(true)
, m_ConsoleLevels(Logger::LEVEL_ANY), m_FileLevels(Logger::LEVEL_ANY)
, m_LogPath("./logs/"), m_DebugLevel(SQMOD_DEBUG_LEVEL), m_Verbosity(0)
{
}
// ------------------------------------------------------------------------------------------------
Logger::~Logger()
{
}
// ------------------------------------------------------------------------------------------------
void Logger::_Finalizer(Logger * ptr) noexcept
{
if (ptr) delete ptr;
}
// ------------------------------------------------------------------------------------------------
Logger::Pointer Logger::Inst() noexcept
{
if (!_Log) return Pointer(new Logger(), &Logger::_Finalizer);
return Pointer(nullptr, &Logger::_Finalizer);
}
// ------------------------------------------------------------------------------------------------
bool Logger::Init()
{
return true;
}
bool Logger::Load()
{
return true;
}
// ------------------------------------------------------------------------------------------------
void Logger::Deinit()
{
}
void Logger::Unload()
{
}
// ------------------------------------------------------------------------------------------------
void Logger::Terminate()
{
}
// ------------------------------------------------------------------------------------------------
void Logger::ToggleConsoleTime(bool enabled) noexcept
{
m_ConsoleTime = enabled;
}
void Logger::ToggleFileTime(bool enabled) noexcept
{
m_FileTime = enabled;
}
// ------------------------------------------------------------------------------------------------
bool Logger::HasConsoleTime() const noexcept
{
return m_ConsoleTime;
}
bool Logger::HasFileTime()const noexcept
{
return m_FileTime;
}
// ------------------------------------------------------------------------------------------------
void Logger::SetConsoleLevels(Uint8 levels) noexcept
{
m_ConsoleLevels = levels;
}
void Logger::SetFileLevels(Uint8 levels) noexcept
{
m_FileLevels = levels;
}
// ------------------------------------------------------------------------------------------------
Uint8 Logger::GetConsoleLevels() const noexcept
{
return m_ConsoleLevels;
}
Uint8 Logger::GetFileLevels() const noexcept
{
return m_FileLevels;
}
// ------------------------------------------------------------------------------------------------
void Logger::EnableConsoleLevel(Uint8 level) noexcept
{
m_ConsoleLevels |= level;
}
void Logger::EnableFileLevel(Uint8 level) noexcept
{
m_FileLevels |= level;
}
// ------------------------------------------------------------------------------------------------
void Logger::DisableConsoleLevel(Uint8 level) noexcept
{
if (m_ConsoleLevels & level) m_ConsoleLevels ^= level;
}
void Logger::DisableFileLevel(Uint8 level) noexcept
{
if (m_FileLevels & level) m_FileLevels ^= level;
}
// ------------------------------------------------------------------------------------------------
Uint8 Logger::GetDebugLevel() const noexcept
{
return m_DebugLevel;
}
void Logger::SetDebugLevel(Uint8 level) noexcept
{
m_DebugLevel = level;
}
// ------------------------------------------------------------------------------------------------
SQInt32 Logger::GetVerbosity() const noexcept
{
return m_Verbosity;
}
void Logger::SetVerbosity(SQInt32 level) noexcept
{
m_Verbosity = level;
}
// ------------------------------------------------------------------------------------------------
void Logger::Send(Uint8 type, bool sub, const char * fmt, va_list args) noexcept
{
// Verify that this level is allowed to be streamed
if (!(m_ConsoleLevels & type) && !(m_FileLevels & type)) return;
// Allocate space for the time stamp string
char timebuff[80];
// Grab the local time into a string if required
if (m_ConsoleTime || m_FileTime)
{
// Create the variables required to retrieve the time.
time_t rawtime;
struct tm * timeinfo;
// Retrieve the local time.
time(&rawtime);
timeinfo = localtime(&rawtime);
// Format the retrieved time.
strftime(timebuff, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
}
// Output to console if streaming to console is enabled
if (m_ConsoleLevels & type)
{
#ifdef SQMOD_OS_WINDOWS
// Get the handle to the output stream
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
// Save the current state of the console screen buffer
CONSOLE_SCREEN_BUFFER_INFO csb_state;
GetConsoleScreenBufferInfo(hstdout, &csb_state);
// Set the attributes for the message information
SetConsoleTextAttribute(hstdout, GetLevelColor(type));
// Output the message information
if (m_ConsoleTime)
{
printf("%s %s ", GetLevelTag(type), timebuff);
}
else
{
printf("%s ", GetLevelTag(type));
}
// Set the attributes for the message content
SetConsoleTextAttribute(hstdout, sub ? LOG_COLOR_NORMAL : LOG_COLOR_WHITE);
// Print the specified message
vprintf(fmt, args);
// Restore the state of the console screen buffer
SetConsoleTextAttribute(hstdout, csb_state.wAttributes);
#else
// Output the message information
if (m_ConsoleTime)
{
printf("%s %s ", GetLevelTag(type), timebuff);
}
else
{
printf("%s ", GetLevelTag(type));
}
// Print the specified message
vprintf(fmt, args);
#endif // SQMOD_OS_WINDOWS
// Terminate the line
puts("");
}
}
// ------------------------------------------------------------------------------------------------
#define SQMOD_LOG(N_, L_, S_) /*
*/ void Logger::N_(const char * fmt, ...) noexcept /*
*/ { /*
*/ va_list args; /*
*/ va_start(args, fmt); /*
*/ Send(L_, S_, fmt, args); /*
*/ va_end(args); /*
*/ } /*
*/
// ------------------------------------------------------------------------------------------------
SQMOD_LOG(Dbg, LEVEL_DBG, false)
SQMOD_LOG(Msg, LEVEL_MSG, false)
SQMOD_LOG(Scs, LEVEL_SCS, false)
SQMOD_LOG(Inf, LEVEL_INF, false)
SQMOD_LOG(Wrn, LEVEL_WRN, false)
SQMOD_LOG(Err, LEVEL_ERR, false)
SQMOD_LOG(Ftl, LEVEL_FTL, false)
// ------------------------------------------------------------------------------------------------
SQMOD_LOG(SDbg, LEVEL_DBG, true)
SQMOD_LOG(SMsg, LEVEL_MSG, true)
SQMOD_LOG(SScs, LEVEL_SCS, true)
SQMOD_LOG(SInf, LEVEL_INF, true)
SQMOD_LOG(SWrn, LEVEL_WRN, true)
SQMOD_LOG(SErr, LEVEL_ERR, true)
SQMOD_LOG(SFtl, LEVEL_FTL, true)
// ------------------------------------------------------------------------------------------------
#define SQMOD_CLOG(N_, L_, S_) /*
*/bool Logger::N_(bool c, const char * fmt, ...) noexcept /*
*/ { /*
*/ if (c) /*
*/ { /*
*/ va_list args; /*
*/ va_start(args, fmt); /*
*/ Send(L_, S_, fmt, args); /*
*/ va_end(args); /*
*/ } /*
*/ return c; /*
*/ } /*
*/
// ------------------------------------------------------------------------------------------------
SQMOD_CLOG(cDbg, LEVEL_DBG, false)
SQMOD_CLOG(cMsg, LEVEL_MSG, false)
SQMOD_CLOG(cScs, LEVEL_SCS, false)
SQMOD_CLOG(cInf, LEVEL_INF, false)
SQMOD_CLOG(cWrn, LEVEL_WRN, false)
SQMOD_CLOG(cErr, LEVEL_ERR, false)
SQMOD_CLOG(cFtl, LEVEL_FTL, false)
// ------------------------------------------------------------------------------------------------
SQMOD_CLOG(cSDbg, LEVEL_DBG, true)
SQMOD_CLOG(cSMsg, LEVEL_MSG, true)
SQMOD_CLOG(cSScs, LEVEL_SCS, true)
SQMOD_CLOG(cSInf, LEVEL_INF, true)
SQMOD_CLOG(cSWrn, LEVEL_WRN, true)
SQMOD_CLOG(cSErr, LEVEL_ERR, true)
SQMOD_CLOG(cSFtl, LEVEL_FTL, true)
} // Namespace:: SqMod

147
source/Logger.hpp Normal file
View File

@ -0,0 +1,147 @@
#ifndef _LOGGER_HPP_
#define _LOGGER_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
class Logger
{
public:
// --------------------------------------------------------------------------------------------
static constexpr Uint8 LEVEL_NIL = (1 << 0);
static constexpr Uint8 LEVEL_DBG = (1 << 1);
static constexpr Uint8 LEVEL_MSG = (1 << 2);
static constexpr Uint8 LEVEL_SCS = (1 << 3);
static constexpr Uint8 LEVEL_INF = (1 << 4);
static constexpr Uint8 LEVEL_WRN = (1 << 5);
static constexpr Uint8 LEVEL_ERR = (1 << 6);
static constexpr Uint8 LEVEL_FTL = (1 << 7);
static constexpr Uint8 LEVEL_ANY = 0xFF;
private:
// --------------------------------------------------------------------------------------------
friend class std::unique_ptr<Logger, void(*)(Logger *)>;
// --------------------------------------------------------------------------------------------
Logger() noexcept;
// --------------------------------------------------------------------------------------------
~Logger();
// --------------------------------------------------------------------------------------------
static void _Finalizer(Logger * ptr) noexcept;
// --------------------------------------------------------------------------------------------
public:
// --------------------------------------------------------------------------------------------
typedef std::unique_ptr<Logger, void(*)(Logger *)> Pointer;
// --------------------------------------------------------------------------------------------
static Pointer Inst() noexcept;
// --------------------------------------------------------------------------------------------
bool Init();
bool Load();
// --------------------------------------------------------------------------------------------
void Deinit();
void Unload();
// --------------------------------------------------------------------------------------------
void Terminate();
// --------------------------------------------------------------------------------------------
void ToggleConsoleTime(bool enabled) noexcept;
void ToggleFileTime(bool enabled) noexcept;
bool HasConsoleTime() const noexcept;
bool HasFileTime() const noexcept;
// --------------------------------------------------------------------------------------------
void SetConsoleLevels(Uint8 levels) noexcept;
void SetFileLevels(Uint8 levels) noexcept;
Uint8 GetConsoleLevels() const noexcept;
Uint8 GetFileLevels() const noexcept;
// --------------------------------------------------------------------------------------------
void EnableConsoleLevel(Uint8 level) noexcept;
void EnableFileLevel(Uint8 level) noexcept;
void DisableConsoleLevel(Uint8 level) noexcept;
void DisableFileLevel(Uint8 level) noexcept;
// --------------------------------------------------------------------------------------------
Uint8 GetDebugLevel() const noexcept;
void SetDebugLevel(Uint8 level) noexcept;
// --------------------------------------------------------------------------------------------
SQInt32 GetVerbosity() const noexcept;
void SetVerbosity(SQInt32 level) noexcept;
public:
// --------------------------------------------------------------------------------------------
void Send(Uint8 type, bool sub, const char * fmt, va_list args) noexcept;
// --------------------------------------------------------------------------------------------
void Dbg(const char * fmt, ...) noexcept;
void Msg(const char * fmt, ...) noexcept;
void Scs(const char * fmt, ...) noexcept;
void Inf(const char * fmt, ...) noexcept;
void Wrn(const char * fmt, ...) noexcept;
void Err(const char * fmt, ...) noexcept;
void Ftl(const char * fmt, ...) noexcept;
// --------------------------------------------------------------------------------------------
void SDbg(const char * fmt, ...) noexcept;
void SMsg(const char * fmt, ...) noexcept;
void SScs(const char * fmt, ...) noexcept;
void SInf(const char * fmt, ...) noexcept;
void SWrn(const char * fmt, ...) noexcept;
void SErr(const char * fmt, ...) noexcept;
void SFtl(const char * fmt, ...) noexcept;
// --------------------------------------------------------------------------------------------
bool cDbg(bool cond, const char * fmt, ...) noexcept;
bool cMsg(bool cond, const char * fmt, ...) noexcept;
bool cScs(bool cond, const char * fmt, ...) noexcept;
bool cInf(bool cond, const char * fmt, ...) noexcept;
bool cWrn(bool cond, const char * fmt, ...) noexcept;
bool cErr(bool cond, const char * fmt, ...) noexcept;
bool cFtl(bool cond, const char * fmt, ...) noexcept;
// --------------------------------------------------------------------------------------------
bool cSDbg(bool cond, const char * fmt, ...) noexcept;
bool cSMsg(bool cond, const char * fmt, ...) noexcept;
bool cSScs(bool cond, const char * fmt, ...) noexcept;
bool cSInf(bool cond, const char * fmt, ...) noexcept;
bool cSWrn(bool cond, const char * fmt, ...) noexcept;
bool cSErr(bool cond, const char * fmt, ...) noexcept;
bool cSFtl(bool cond, const char * fmt, ...) noexcept;
private:
// --------------------------------------------------------------------------------------------
bool m_ConsoleTime;
bool m_FileTime;
// --------------------------------------------------------------------------------------------
Uint8 m_ConsoleLevels;
Uint8 m_FileLevels;
// --------------------------------------------------------------------------------------------
String m_LogPath;
// --------------------------------------------------------------------------------------------
Uint8 m_DebugLevel;
// --------------------------------------------------------------------------------------------
SQInt32 m_Verbosity;
};
// --------------------------------------------------------------------------------------------
extern const Logger::Pointer _Log;
} // Namespace:: SqMod
#endif // _LOGGER_HPP_

282
source/Misc/Automobile.cpp Normal file
View File

@ -0,0 +1,282 @@
#include "Misc/Automobile.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector3.hpp"
#include "Entity.hpp"
#include "Register.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const CAutomobile CAutomobile::NIL;
// ------------------------------------------------------------------------------------------------
CAutomobile::CAutomobile() noexcept
: m_ID(SQMOD_UNKNOWN), m_Name()
{
}
CAutomobile::CAutomobile(SQInt32 id) noexcept
: m_ID(VALID_ENTITYGETEX(id, Max)), m_Name(GetAutomobileName(id))
{
}
CAutomobile::CAutomobile(const SQChar * name, SQInt32 id) noexcept
: CAutomobile(IsAutomobileValid(GetAutomobileID(name)) ? GetAutomobileID(name) : id)
{
}
// ------------------------------------------------------------------------------------------------
CAutomobile::CAutomobile(const CAutomobile & a) noexcept
: m_ID(a.m_ID)
, m_Name(a.m_Name)
, m_Tag(a.m_Tag)
, m_Data(a.m_Data)
{
}
CAutomobile::CAutomobile(CAutomobile && a) noexcept
: m_ID(a.m_ID)
, m_Name(a.m_Name)
, m_Tag(a.m_Tag)
, m_Data(a.m_Data)
{
}
// ------------------------------------------------------------------------------------------------
CAutomobile::~CAutomobile()
{
}
// ------------------------------------------------------------------------------------------------
CAutomobile & CAutomobile::operator = (const CAutomobile & a) noexcept
{
m_ID = a.m_ID;
m_Name = a.m_Name;
m_Tag = a.m_Tag;
m_Data = a.m_Data;
return *this;
}
CAutomobile & CAutomobile::operator = (CAutomobile && a) noexcept
{
m_ID = a.m_ID;
m_Name = a.m_Name;
m_Tag = a.m_Tag;
m_Data = a.m_Data;
return *this;
}
// ------------------------------------------------------------------------------------------------
CAutomobile & CAutomobile::operator = (SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetAutomobileName(id);
m_ID = id;
}
return *this;
}
// ------------------------------------------------------------------------------------------------
bool CAutomobile::operator == (const CAutomobile & a) const noexcept
{
return (m_ID == a.m_ID);
}
bool CAutomobile::operator != (const CAutomobile & a) const noexcept
{
return (m_ID != a.m_ID);
}
bool CAutomobile::operator < (const CAutomobile & a) const noexcept
{
return (m_ID < a.m_ID);
}
bool CAutomobile::operator > (const CAutomobile & a) const noexcept
{
return (m_ID < a.m_ID);
}
bool CAutomobile::operator <= (const CAutomobile & a) const noexcept
{
return (m_ID <= a.m_ID);
}
bool CAutomobile::operator >= (const CAutomobile & a) const noexcept
{
return (m_ID >= a.m_ID);
}
// ------------------------------------------------------------------------------------------------
SQInteger CAutomobile::Cmp(const CAutomobile & a) const noexcept
{
return m_ID == a.m_ID ? 0 : (m_ID > a.m_ID ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * CAutomobile::ToString() const noexcept
{
return m_Name.c_str();
}
// ------------------------------------------------------------------------------------------------
SQInteger CAutomobile::GetID() const noexcept
{
return m_ID;
}
void CAutomobile::SetID(SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetAutomobileName(id);
m_ID = id;
}
}
// ------------------------------------------------------------------------------------------------
CAutomobile & CAutomobile::SetnGet(SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetAutomobileName(id);
m_ID = id;
}
return *this;
}
// ------------------------------------------------------------------------------------------------
const SQChar * CAutomobile::GetGlobalTag() const noexcept
{
return GlobalTag(m_ID);
}
void CAutomobile::SetGlobalTag(const SQChar * tag) const noexcept
{
GlobalTag(m_ID, tag);
}
// ------------------------------------------------------------------------------------------------
SqObj & CAutomobile::GetGlobalData() const noexcept
{
return GlobalData(m_ID);
}
void CAutomobile::SetGlobalData(SqObj & data) const noexcept
{
GlobalData(m_ID, data);
}
// ------------------------------------------------------------------------------------------------
const SQChar * CAutomobile::GetLocalTag() const noexcept
{
return m_Tag.c_str();
}
void CAutomobile::SetLocalTag(const SQChar * tag) noexcept
{
m_Tag = tag;
}
// ------------------------------------------------------------------------------------------------
SqObj & CAutomobile::GetLocalData() noexcept
{
return m_Data;
}
void CAutomobile::SetLocalData(SqObj & data) noexcept
{
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CAutomobile::IsValid() const noexcept
{
return (VALID_ENTITYEX(m_ID, SQMOD_VEHICLEID_CAP));
}
// ------------------------------------------------------------------------------------------------
const SQChar * CAutomobile::GetName() const noexcept
{
return m_Name.c_str();
}
// ------------------------------------------------------------------------------------------------
Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 header, const SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, pos, angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, \
const SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, pos, angle, primary, secondary, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle, \
SQInt32 header, const SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, Vector3(x, y, z), angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, \
const SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, Vector3(x, y, z), angle, primary, secondary, header, payload);
}
// ================================================================================================
bool Register_CAutomobile(HSQUIRRELVM vm)
{
// Output debugging information
LogDbg("Beginning registration of <CAutomobile> type");
// Attempt to register the specified type
Sqrat::RootTable(vm).Bind(_SC("CAutomobile"), Sqrat::Class< CAutomobile >(vm, _SC("CAutomobile"))
.Ctor()
.Ctor< SQInt32 >()
.Ctor< const SQChar *, SQInt32 >()
.Func(_SC("_cmp"), &CAutomobile::Cmp)
.Func(_SC("_tostring"), &CAutomobile::ToString)
.Prop(_SC("id"), &CAutomobile::GetID, &CAutomobile::SetID)
.Prop(_SC("gtag"), &CAutomobile::GetGlobalTag, &CAutomobile::SetGlobalTag)
.Prop(_SC("gdata"), &CAutomobile::GetGlobalData, &CAutomobile::SetGlobalData)
.Prop(_SC("ltag"), &CAutomobile::GetLocalTag, &CAutomobile::SetLocalTag)
.Prop(_SC("ldata"), &CAutomobile::GetLocalData, &CAutomobile::SetLocalData)
.Prop(_SC("valid"), &CAutomobile::IsValid)
.Prop(_SC("name"), &CAutomobile::GetName)
.Func(_SC("setng"), &CAutomobile::SetnGet)
.Overload< Reference< CVehicle > (CAutomobile::*)(SQInt32, const Vector3 &, SQFloat, SQInt32, const SqObj &) const > \
(_SC("vehicle"), &CAutomobile::Create)
.Overload< Reference< CVehicle > (CAutomobile::*)(SQInt32, const Vector3 &, SQFloat, SQInt32, SQInt32, SQInt32, const SqObj &) const > \
(_SC("vehicle"), &CAutomobile::Create)
.Overload< Reference< CVehicle > (CAutomobile::*)(SQInt32, SQFloat, SQFloat, SQFloat, SQFloat, SQInt32, const SqObj &) const > \
(_SC("vehicle"), &CAutomobile::Create)
.Overload< Reference< CVehicle > (CAutomobile::*)(SQInt32, SQFloat, SQFloat, SQFloat, SQFloat, SQInt32, SQInt32, SQInt32, const SqObj &) const > \
(_SC("vehicle"), &CAutomobile::Create)
);
// Output debugging information
LogDbg("Registration of <CAutomobile> type was successful");
// Registration succeeded
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,92 @@
#ifndef _MISC_AUTOMOBILE_HPP_
#define _MISC_AUTOMOBILE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Misc/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* ...
*/
class CAutomobile : public IdentifierStorage< CAutomobile, SQMOD_VEHICLEID_CAP >
{
public:
// --------------------------------------------------------------------------------------------
static const CAutomobile NIL;
// --------------------------------------------------------------------------------------------
CAutomobile() noexcept;
CAutomobile(SQInt32 id) noexcept;
CAutomobile(const SQChar * name, SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CAutomobile(const CAutomobile & a) noexcept;
CAutomobile(CAutomobile && a) noexcept;
// --------------------------------------------------------------------------------------------
~CAutomobile();
// --------------------------------------------------------------------------------------------
CAutomobile & operator = (const CAutomobile & a) noexcept;
CAutomobile & operator = (CAutomobile && a) noexcept;
// --------------------------------------------------------------------------------------------
CAutomobile & operator = (SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const CAutomobile & a) const noexcept;
bool operator != (const CAutomobile & a) const noexcept;
bool operator < (const CAutomobile & a) const noexcept;
bool operator > (const CAutomobile & a) const noexcept;
bool operator <= (const CAutomobile & a) const noexcept;
bool operator >= (const CAutomobile & a) const noexcept;
// --------------------------------------------------------------------------------------------
operator SQInt32 () const noexcept { return m_ID; }
operator bool () const noexcept { return IsAutomobileValid(m_ID); }
// --------------------------------------------------------------------------------------------
bool operator ! () const noexcept { return !IsAutomobileValid(m_ID); }
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const CAutomobile & a) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger GetID() const noexcept;
void SetID(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CAutomobile & SetnGet(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetGlobalTag() const noexcept;
void SetGlobalTag(const SQChar * tag) const noexcept;
// --------------------------------------------------------------------------------------------
SqObj & GetGlobalData() const noexcept;
void SetGlobalData(SqObj & data) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetLocalTag() const noexcept;
void SetLocalTag(const SQChar * tag) noexcept;
// --------------------------------------------------------------------------------------------
SqObj & GetLocalData() noexcept;
void SetLocalData(SqObj & data) noexcept;
// --------------------------------------------------------------------------------------------
bool IsValid() const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetName() const noexcept;
// --------------------------------------------------------------------------------------------
Reference < CVehicle > Create(SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 header, const SqObj & payload) const noexcept;
Reference < CVehicle > Create(SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, \
const SqObj & payload) const noexcept;
Reference < CVehicle > Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle, \
SQInt32 header, const SqObj & payload) const noexcept;
Reference < CVehicle > Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, \
const SqObj & payload) const noexcept;
private:
// --------------------------------------------------------------------------------------------
SQInt32 m_ID;
// --------------------------------------------------------------------------------------------
String m_Name;
// --------------------------------------------------------------------------------------------
SqTag m_Tag;
SqObj m_Data;
};
} // Namespace:: SqMod
#endif // _MISC_AUTOMOBILE_HPP_

936
source/Misc/Constants.cpp Normal file
View File

@ -0,0 +1,936 @@
#include "Misc/Constants.hpp"
#include "Signal.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
#include <limits>
#include <cfloat>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Constants(HSQUIRRELVM vm)
{
Sqrat::ConstTable(vm).Enum(_SC("SQMOD"), Sqrat::Enumeration(vm)
.Const(_SC("VERSION"), SQMOD_VERSION)
.Const(_SC("SUCCESS"), SQMOD_SUCCESS)
.Const(_SC("FAILURE"), SQMOD_FAILURE)
.Const(_SC("UNKNOWN"), SQMOD_UNKNOWN)
.Const(_SC("ARCH"), SQMOD_ARCHITECTURE)
.Const(_SC("PLATFORM"), SQMOD_PLATFORM)
.Const(_SC("MIN_CHAR"), _NLMIN(SQChar))
.Const(_SC("MAX_CHAR"), _NLMAX(SQChar))
.Const(_SC("MIN_SHORT"), _NLMIN(Int16))
.Const(_SC("MAX_SHORT"), _NLMAX(Int16))
.Const(_SC("MIN_USHORT"), _NLMIN(Uint16))
.Const(_SC("MAX_USHORT"), _NLMAX(Uint16))
.Const(_SC("MIN_INT"), _NLMIN(SQInteger))
.Const(_SC("MAX_INT"), _NLMAX(SQInteger))
.Const(_SC("MIN_INT32"), _NLMIN(SQInt32))
.Const(_SC("MAX_INT32"), _NLMAX(SQInt32))
.Const(_SC("MIN_FLOAT"), _NLMIN(SQFloat))
.Const(_SC("MAX_FLOAT"), _NLMAX(SQFloat))
);
Sqrat::ConstTable(vm).Enum(_SC("EARCHITECTURE"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNOWN"), SQMOD_ARCH_ID_UNKNOWN)
.Const(_SC("X32_BIT"), SQMOD_ARCH_ID_32_BIT)
.Const(_SC("X64_BIT"), SQMOD_ARCH_ID_64_BIT)
);
Sqrat::ConstTable(vm).Enum(_SC("EPLATFORM"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNOWN"), SQMOD_PLAT_ID_UNKNOWN)
.Const(_SC("WINDOWS"), SQMOD_PLAT_ID_WINDOWS)
.Const(_SC("LINUX"), SQMOD_PLAT_ID_LINUX)
.Const(_SC("MACOS"), SQMOD_PLAT_ID_MACOS)
.Const(_SC("UNIX"), SQMOD_PLAT_ID_UNIX)
);
Sqrat::ConstTable(vm).Enum(_SC("EVENTID"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNOWN"), EVT_UNKNOWN)
.Const(_SC("BLIPCREATED"), EVT_BLIPCREATED)
.Const(_SC("CHECKPOINTCREATED"), EVT_CHECKPOINTCREATED)
.Const(_SC("KEYBINDCREATED"), EVT_KEYBINDCREATED)
.Const(_SC("OBJECTCREATED"), EVT_OBJECTCREATED)
.Const(_SC("PICKUPCREATED"), EVT_PICKUPCREATED)
.Const(_SC("PLAYERCREATED"), EVT_PLAYERCREATED)
.Const(_SC("SPHERECREATED"), EVT_SPHERECREATED)
.Const(_SC("SPRITECREATED"), EVT_SPRITECREATED)
.Const(_SC("TEXTDRAWCREATED"), EVT_TEXTDRAWCREATED)
.Const(_SC("VEHICLECREATED"), EVT_VEHICLECREATED)
.Const(_SC("BLIPDESTROYED"), EVT_BLIPDESTROYED)
.Const(_SC("CHECKPOINTDESTROYED"), EVT_CHECKPOINTDESTROYED)
.Const(_SC("KEYBINDDESTROYED"), EVT_KEYBINDDESTROYED)
.Const(_SC("OBJECTDESTROYED"), EVT_OBJECTDESTROYED)
.Const(_SC("PICKUPDESTROYED"), EVT_PICKUPDESTROYED)
.Const(_SC("PLAYERDESTROYED"), EVT_PLAYERDESTROYED)
.Const(_SC("SPHEREDESTROYED"), EVT_SPHEREDESTROYED)
.Const(_SC("SPRITEDESTROYED"), EVT_SPRITEDESTROYED)
.Const(_SC("TEXTDRAWDESTROYED"), EVT_TEXTDRAWDESTROYED)
.Const(_SC("VEHICLEDESTROYED"), EVT_VEHICLEDESTROYED)
.Const(_SC("BLIPCUSTOM"), EVT_BLIPCUSTOM)
.Const(_SC("CHECKPOINTCUSTOM"), EVT_CHECKPOINTCUSTOM)
.Const(_SC("KEYBINDCUSTOM"), EVT_KEYBINDCUSTOM)
.Const(_SC("OBJECTCUSTOM"), EVT_OBJECTCUSTOM)
.Const(_SC("PICKUPCUSTOM"), EVT_PICKUPCUSTOM)
.Const(_SC("PLAYERCUSTOM"), EVT_PLAYERCUSTOM)
.Const(_SC("SPHERECUSTOM"), EVT_SPHERECUSTOM)
.Const(_SC("SPRITECUSTOM"), EVT_SPRITECUSTOM)
.Const(_SC("TEXTDRAWCUSTOM"), EVT_TEXTDRAWCUSTOM)
.Const(_SC("VEHICLECUSTOM"), EVT_VEHICLECUSTOM)
.Const(_SC("PLAYERAWAY"), EVT_PLAYERAWAY)
.Const(_SC("PLAYERGAMEKEYS"), EVT_PLAYERGAMEKEYS)
.Const(_SC("PLAYERRENAME"), EVT_PLAYERRENAME)
.Const(_SC("PLAYERREQUESTCLASS"), EVT_PLAYERREQUESTCLASS)
.Const(_SC("PLAYERREQUESTSPAWN"), EVT_PLAYERREQUESTSPAWN)
.Const(_SC("PLAYERSPAWN"), EVT_PLAYERSPAWN)
.Const(_SC("PLAYERSTARTTYPING"), EVT_PLAYERSTARTTYPING)
.Const(_SC("PLAYERSTOPTYPING"), EVT_PLAYERSTOPTYPING)
.Const(_SC("PLAYERCHAT"), EVT_PLAYERCHAT)
.Const(_SC("PLAYERCOMMAND"), EVT_PLAYERCOMMAND)
.Const(_SC("PLAYERMESSAGE"), EVT_PLAYERMESSAGE)
.Const(_SC("PLAYERHEALTH"), EVT_PLAYERHEALTH)
.Const(_SC("PLAYERARMOUR"), EVT_PLAYERARMOUR)
.Const(_SC("PLAYERWEAPON"), EVT_PLAYERWEAPON)
.Const(_SC("PLAYERMOVE"), EVT_PLAYERMOVE)
.Const(_SC("PLAYERWASTED"), EVT_PLAYERWASTED)
.Const(_SC("PLAYERKILLED"), EVT_PLAYERKILLED)
.Const(_SC("PLAYERTEAMKILL"), EVT_PLAYERTEAMKILL)
.Const(_SC("PLAYERSPECTATE"), EVT_PLAYERSPECTATE)
.Const(_SC("PLAYERCRASHREPORT"), EVT_PLAYERCRASHREPORT)
.Const(_SC("PLAYERBURNING"), EVT_PLAYERBURNING)
.Const(_SC("PLAYERCROUCHING"), EVT_PLAYERCROUCHING)
.Const(_SC("PLAYERSTATE"), EVT_PLAYERSTATE)
.Const(_SC("PLAYERACTION"), EVT_PLAYERACTION)
.Const(_SC("STATENONE"), EVT_STATENONE)
.Const(_SC("STATENORMAL"), EVT_STATENORMAL)
.Const(_SC("STATESHOOTING"), EVT_STATESHOOTING)
.Const(_SC("STATEDRIVER"), EVT_STATEDRIVER)
.Const(_SC("STATEPASSENGER"), EVT_STATEPASSENGER)
.Const(_SC("STATEENTERDRIVER"), EVT_STATEENTERDRIVER)
.Const(_SC("STATEENTERPASSENGER"), EVT_STATEENTERPASSENGER)
.Const(_SC("STATEEXITVEHICLE"), EVT_STATEEXITVEHICLE)
.Const(_SC("STATEUNSPAWNED"), EVT_STATEUNSPAWNED)
.Const(_SC("ACTIONNONE"), EVT_ACTIONNONE)
.Const(_SC("ACTIONNORMAL"), EVT_ACTIONNORMAL)
.Const(_SC("ACTIONAIMING"), EVT_ACTIONAIMING)
.Const(_SC("ACTIONSHOOTING"), EVT_ACTIONSHOOTING)
.Const(_SC("ACTIONJUMPING"), EVT_ACTIONJUMPING)
.Const(_SC("ACTIONLIEDOWN"), EVT_ACTIONLIEDOWN)
.Const(_SC("ACTIONGETTINGUP"), EVT_ACTIONGETTINGUP)
.Const(_SC("ACTIONJUMPVEHICLE"), EVT_ACTIONJUMPVEHICLE)
.Const(_SC("ACTIONDRIVING"), EVT_ACTIONDRIVING)
.Const(_SC("ACTIONDYING"), EVT_ACTIONDYING)
.Const(_SC("ACTIONWASTED"), EVT_ACTIONWASTED)
.Const(_SC("ACTIONEMBARKING"), EVT_ACTIONEMBARKING)
.Const(_SC("ACTIONDISEMBARKING"), EVT_ACTIONDISEMBARKING)
.Const(_SC("VEHICLERESPAWN"), EVT_VEHICLERESPAWN)
.Const(_SC("VEHICLEEXPLODE"), EVT_VEHICLEEXPLODE)
.Const(_SC("VEHICLEHEALTH"), EVT_VEHICLEHEALTH)
.Const(_SC("VEHICLEMOVE"), EVT_VEHICLEMOVE)
.Const(_SC("PICKUPRESPAWN"), EVT_PICKUPRESPAWN)
.Const(_SC("KEYBINDKEYPRESS"), EVT_KEYBINDKEYPRESS)
.Const(_SC("KEYBINDKEYRELEASE"), EVT_KEYBINDKEYRELEASE)
.Const(_SC("VEHICLEEMBARKING"), EVT_VEHICLEEMBARKING)
.Const(_SC("VEHICLEEMBARKED"), EVT_VEHICLEEMBARKED)
.Const(_SC("VEHICLEDISEMBARK"), EVT_VEHICLEDISEMBARK)
.Const(_SC("PICKUPCLAIMED"), EVT_PICKUPCLAIMED)
.Const(_SC("PICKUPCOLLECTED"), EVT_PICKUPCOLLECTED)
.Const(_SC("OBJECTSHOT"), EVT_OBJECTSHOT)
.Const(_SC("OBJECTBUMP"), EVT_OBJECTBUMP)
.Const(_SC("CHECKPOINTENTERED"), EVT_CHECKPOINTENTERED)
.Const(_SC("CHECKPOINTEXITED"), EVT_CHECKPOINTEXITED)
.Const(_SC("SPHEREENTERED"), EVT_SPHEREENTERED)
.Const(_SC("SPHEREEXITED"), EVT_SPHEREEXITED)
.Const(_SC("SERVERFRAME"), EVT_SERVERFRAME)
.Const(_SC("SERVERSTARTUP"), EVT_SERVERSTARTUP)
.Const(_SC("SERVERSHUTDOWN"), EVT_SERVERSHUTDOWN)
.Const(_SC("INTERNALCOMMAND"), EVT_INTERNALCOMMAND)
.Const(_SC("LOGINATTEMPT"), EVT_LOGINATTEMPT)
.Const(_SC("CUSTOMEVENT"), EVT_CUSTOMEVENT)
.Const(_SC("WORLDOPTION"), EVT_WORLDOPTION)
.Const(_SC("WORLDTOGGLE"), EVT_WORLDTOGGLE)
.Const(_SC("SCRIPTRELOAD"), EVT_SCRIPTRELOAD)
.Const(_SC("LOGMESSAGE"), EVT_LOGMESSAGE)
.Const(_SC("COUNT"), EVT_COUNT)
);
Sqrat::ConstTable(vm).Enum(_SC("ECREATEREASON"), Sqrat::Enumeration(vm)
.Const(_SC("DEFAULT"), SQMOD_CREATE_DEFAULT)
.Const(_SC("MANUAL"), SQMOD_CREATE_MANUAL)
.Const(_SC("POOL"), SQMOD_CREATE_POOL)
.Const(_SC("AUTOMATIC"), SQMOD_CREATE_AUTOMATIC)
.Const(_SC("OVERWRITE"), SQMOD_CREATE_OVERWRITE)
.Const(_SC("RESURECT"), SQMOD_CREATE_RESURECT)
);
Sqrat::ConstTable(vm).Enum(_SC("EDESTROYREASON"), Sqrat::Enumeration(vm)
.Const(_SC("DEFAULT"), SQMOD_DESTROY_DEFAULT)
.Const(_SC("MANUAL"), SQMOD_DESTROY_MANUAL)
.Const(_SC("POOL"), SQMOD_DESTROY_POOL)
.Const(_SC("AUTOMATIC"), SQMOD_DESTROY_AUTOMATIC)
.Const(_SC("OVERWRITE"), SQMOD_DESTROY_OVERWRITE)
.Const(_SC("CLEANUP"), SQMOD_DESTROY_CLEANUP)
);
Sqrat::ConstTable(vm).Enum(_SC("EENTITYPOOLUPD"), Sqrat::Enumeration(vm)
.Const(_SC("VEHICLE"), SQMOD_ENTITY_POOL_VEHICLE)
.Const(_SC("OBJECT"), SQMOD_ENTITY_POOL_OBJECT)
.Const(_SC("PICKUP"), SQMOD_ENTITY_POOL_PICKUP)
.Const(_SC("RADIO"), SQMOD_ENTITY_POOL_RADIO)
.Const(_SC("SPRITE"), SQMOD_ENTITY_POOL_SPRITE)
.Const(_SC("TEXTDRAW"), SQMOD_ENTITY_POOL_TEXTDRAW)
.Const(_SC("BLIP"), SQMOD_ENTITY_POOL_BLIP)
);
Sqrat::ConstTable(vm).Enum(_SC("EVEHICLEUPD"), Sqrat::Enumeration(vm)
.Const(_SC("DRIVER"), SQMOD_VEHICLEUPD_DRIVER)
.Const(_SC("OTHER"), SQMOD_VEHICLEUPD_OTHER)
);
Sqrat::ConstTable(vm).Enum(_SC("EPLAYERUPD"), Sqrat::Enumeration(vm)
.Const(_SC("ONFOOT"), SQMOD_PLAYERUPD_ONFOOT)
.Const(_SC("AIM"), SQMOD_PLAYERUPD_AIM)
.Const(_SC("DRIVER"), SQMOD_PLAYERUPD_DRIVER)
.Const(_SC("PASSENGER"), SQMOD_PLAYERUPD_PASSENGER)
);
Sqrat::ConstTable(vm).Enum(_SC("EPARTREASON"), Sqrat::Enumeration(vm)
.Const(_SC("TIMEOUT"), SQMOD_PARTREASON_TIMEOUT)
.Const(_SC("DISCONNECTED"), SQMOD_PARTREASON_DISCONNECTED)
.Const(_SC("KICKEDBANNED"), SQMOD_PARTREASON_KICKEDBANNED)
.Const(_SC("CRASHED"), SQMOD_PARTREASON_CRASHED)
);
Sqrat::ConstTable(vm).Enum(_SC("EBODYPART"), Sqrat::Enumeration(vm)
.Const(_SC("BODY"), SQMOD_BODYPART_BODY)
.Const(_SC("TORSO"), SQMOD_BODYPART_TORSO)
.Const(_SC("LEFTARM"), SQMOD_BODYPART_LEFTARM)
.Const(_SC("LARM"), SQMOD_BODYPART_LEFTARM)
.Const(_SC("RIGHTARM"), SQMOD_BODYPART_RIGHTARM)
.Const(_SC("RARM"), SQMOD_BODYPART_RIGHTARM)
.Const(_SC("LEFTLEG"), SQMOD_BODYPART_LEFTLEG)
.Const(_SC("LLEG"), SQMOD_BODYPART_LEFTLEG)
.Const(_SC("RIGHTLEG"), SQMOD_BODYPART_RIGHTLEG)
.Const(_SC("RLEG"), SQMOD_BODYPART_RIGHTLEG)
.Const(_SC("HEAD"), SQMOD_BODYPART_HEAD)
);
Sqrat::ConstTable(vm).Enum(_SC("EPLAYERSTATE"), Sqrat::Enumeration(vm)
.Const(_SC("NONE"), SQMOD_PLAYER_STATE_NONE)
.Const(_SC("NORMAL"), SQMOD_PLAYER_STATE_NORMAL)
.Const(_SC("SHOOTING"), SQMOD_PLAYER_STATE_SHOOTING)
.Const(_SC("DRIVER"), SQMOD_PLAYER_STATE_DRIVER)
.Const(_SC("PASSENGER"), SQMOD_PLAYER_STATE_PASSENGER)
.Const(_SC("ENTERING_AS_DRIVER"), SQMOD_PLAYER_STATE_ENTERING_AS_DRIVER)
.Const(_SC("ENTERING_AS_PASSENGER"), SQMOD_PLAYER_STATE_ENTERING_AS_PASSENGER)
.Const(_SC("EXITING_VEHICLE"), SQMOD_PLAYER_STATE_EXITING_VEHICLE)
.Const(_SC("UNSPAWNED"), SQMOD_PLAYER_STATE_UNSPAWNED)
);
Sqrat::ConstTable(vm).Enum(_SC("EPLAYERACTION"), Sqrat::Enumeration(vm)
.Const(_SC("NONE"), SQMOD_PLAYER_ACTION_NONE)
.Const(_SC("NORMAL"), SQMOD_PLAYER_ACTION_NORMAL)
.Const(_SC("AIMING"), SQMOD_PLAYER_ACTION_AIMING)
.Const(_SC("SHOOTING"), SQMOD_PLAYER_ACTION_SHOOTING)
.Const(_SC("JUMPING"), SQMOD_PLAYER_ACTION_JUMPING)
.Const(_SC("LYING_ON_GROUND"), SQMOD_PLAYER_ACTION_LYING_ON_GROUND)
.Const(_SC("GETTING_UP"), SQMOD_PLAYER_ACTION_GETTING_UP)
.Const(_SC("JUMPING_FROM_VEHICLE"), SQMOD_PLAYER_ACTION_JUMPING_FROM_VEHICLE)
.Const(_SC("DRIVING"), SQMOD_PLAYER_ACTION_DRIVING)
.Const(_SC("DYING"), SQMOD_PLAYER_ACTION_DYING)
.Const(_SC("WASTED"), SQMOD_PLAYER_ACTION_WASTED)
.Const(_SC("ENTERING_VEHICLE"), SQMOD_PLAYER_ACTION_ENTERING_VEHICLE)
.Const(_SC("EXITING_VEHICLE"), SQMOD_PLAYER_ACTION_EXITING_VEHICLE)
);
Sqrat::ConstTable(vm).Enum(_SC("EWEATHER"), Sqrat::Enumeration(vm)
.Const(_SC("MOSTLYCLEAR"), SQMOD_WEATHER_MOSTLYCLEAR)
.Const(_SC("OVERCAST"), SQMOD_WEATHER_OVERCAST)
.Const(_SC("THUNDERSTORM"), SQMOD_WEATHER_THUNDERSTORM)
.Const(_SC("STORM"), SQMOD_WEATHER_STORM)
.Const(_SC("STORMY"), SQMOD_WEATHER_STORMY)
.Const(_SC("FOGGY"), SQMOD_WEATHER_FOGGY)
.Const(_SC("FOG"), SQMOD_WEATHER_FOG)
.Const(_SC("CLEAR"), SQMOD_WEATHER_CLEAR)
.Const(_SC("SUNNY"), SQMOD_WEATHER_SUNNY)
.Const(_SC("RAIN"), SQMOD_WEATHER_RAIN)
.Const(_SC("RAINY"), SQMOD_WEATHER_RAINY)
.Const(_SC("DARKCLOUDY"), SQMOD_WEATHER_DARKCLOUDY)
.Const(_SC("LIGHTCLOUDY"), SQMOD_WEATHER_LIGHTCLOUDY)
.Const(_SC("OVERCASTCLOUDY"), SQMOD_WEATHER_OVERCASTCLOUDY)
.Const(_SC("BLACKCLOUDS"), SQMOD_WEATHER_BLACKCLOUDS)
);
Sqrat::ConstTable(vm).Enum(_SC("EWEAPON"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNWON"), SQMOD_UNKNOWN)
.Const(_SC("UNARMED"), SQMOD_WEAPON_UNARMED)
.Const(_SC("BRASSKNUCKLES"), SQMOD_WEAPON_BRASSKNUCKLES)
.Const(_SC("SCREWDRIVER"), SQMOD_WEAPON_SCREWDRIVER)
.Const(_SC("GOLFCLUB"), SQMOD_WEAPON_GOLFCLUB)
.Const(_SC("NIGHTSTICK"), SQMOD_WEAPON_NIGHTSTICK)
.Const(_SC("KNIFE"), SQMOD_WEAPON_KNIFE)
.Const(_SC("BASEBALLBAT"), SQMOD_WEAPON_BASEBALLBAT)
.Const(_SC("HAMMER"), SQMOD_WEAPON_HAMMER)
.Const(_SC("MEATCLEAVER"), SQMOD_WEAPON_MEATCLEAVER)
.Const(_SC("MACHETE"), SQMOD_WEAPON_MACHETE)
.Const(_SC("KATANA"), SQMOD_WEAPON_KATANA)
.Const(_SC("CHAINSAW"), SQMOD_WEAPON_CHAINSAW)
.Const(_SC("GRENADE"), SQMOD_WEAPON_GRENADE)
.Const(_SC("REMOTE"), SQMOD_WEAPON_REMOTE)
.Const(_SC("TEARGAS"), SQMOD_WEAPON_TEARGAS)
.Const(_SC("MOLOTOV"), SQMOD_WEAPON_MOLOTOV)
.Const(_SC("ROCKET"), SQMOD_WEAPON_ROCKET)
.Const(_SC("COLT45"), SQMOD_WEAPON_COLT45)
.Const(_SC("PYTHON"), SQMOD_WEAPON_PYTHON)
.Const(_SC("SHOTGUN"), SQMOD_WEAPON_SHOTGUN)
.Const(_SC("SPAS12"), SQMOD_WEAPON_SPAS12)
.Const(_SC("STUBBY"), SQMOD_WEAPON_STUBBY)
.Const(_SC("TEC9"), SQMOD_WEAPON_TEC9)
.Const(_SC("UZI"), SQMOD_WEAPON_UZI)
.Const(_SC("INGRAM"), SQMOD_WEAPON_INGRAM)
.Const(_SC("MP5"), SQMOD_WEAPON_MP5)
.Const(_SC("M4"), SQMOD_WEAPON_M4)
.Const(_SC("RUGER"), SQMOD_WEAPON_RUGER)
.Const(_SC("SNIPER"), SQMOD_WEAPON_SNIPER)
.Const(_SC("LASERSCOPE"), SQMOD_WEAPON_LASERSCOPE)
.Const(_SC("ROCKETLAUNCHER"), SQMOD_WEAPON_ROCKETLAUNCHER)
.Const(_SC("FLAMETHROWER"), SQMOD_WEAPON_FLAMETHROWER)
.Const(_SC("M60"), SQMOD_WEAPON_M60)
.Const(_SC("MINIGUN"), SQMOD_WEAPON_MINIGUN)
.Const(_SC("BOMB"), SQMOD_WEAPON_BOMB)
.Const(_SC("HELICANNON"), SQMOD_WEAPON_HELICANNON)
.Const(_SC("CAMERA"), SQMOD_WEAPON_CAMERA)
.Const(_SC("VEHICLE"), SQMOD_WEAPON_VEHICLE)
.Const(_SC("EXPLOSION1"), SQMOD_WEAPON_EXPLOSION1)
.Const(_SC("DRIVEBY"), SQMOD_WEAPON_DRIVEBY)
.Const(_SC("DROWNED"), SQMOD_WEAPON_DROWNED)
.Const(_SC("FALL"), SQMOD_WEAPON_FALL)
.Const(_SC("EXPLOSION2"), SQMOD_WEAPON_EXPLOSION2)
.Const(_SC("SUICIDE"), SQMOD_WEAPON_SUICIDE)
);
Sqrat::ConstTable(vm).Enum(_SC("EVEHICLE"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNOWN"), SQMOD_UNKNOWN)
.Const(_SC("LANDSTALKER"), SQMOD_VEHICLE_LANDSTALKER)
.Const(_SC("IDAHO"), SQMOD_VEHICLE_IDAHO)
.Const(_SC("STINGER"), SQMOD_VEHICLE_STINGER)
.Const(_SC("LINERUNNER"), SQMOD_VEHICLE_LINERUNNER)
.Const(_SC("PERENNIAL"), SQMOD_VEHICLE_PERENNIAL)
.Const(_SC("SENTINEL"), SQMOD_VEHICLE_SENTINEL)
.Const(_SC("RIO"), SQMOD_VEHICLE_RIO)
.Const(_SC("FIRETRUCK"), SQMOD_VEHICLE_FIRETRUCK)
.Const(_SC("TRASHMASTER"), SQMOD_VEHICLE_TRASHMASTER)
.Const(_SC("STRETCH"), SQMOD_VEHICLE_STRETCH)
.Const(_SC("MANANA"), SQMOD_VEHICLE_MANANA)
.Const(_SC("INFERNUS"), SQMOD_VEHICLE_INFERNUS)
.Const(_SC("VOODOO"), SQMOD_VEHICLE_VOODOO)
.Const(_SC("PONY"), SQMOD_VEHICLE_PONY)
.Const(_SC("MULE"), SQMOD_VEHICLE_MULE)
.Const(_SC("CHEETAH"), SQMOD_VEHICLE_CHEETAH)
.Const(_SC("AMBULANCE"), SQMOD_VEHICLE_AMBULANCE)
.Const(_SC("FBIWASHINGTON"), SQMOD_VEHICLE_FBIWASHINGTON)
.Const(_SC("MOONBEAM"), SQMOD_VEHICLE_MOONBEAM)
.Const(_SC("ESPERANTO"), SQMOD_VEHICLE_ESPERANTO)
.Const(_SC("TAXI"), SQMOD_VEHICLE_TAXI)
.Const(_SC("WASHINGTON"), SQMOD_VEHICLE_WASHINGTON)
.Const(_SC("BOBCAT"), SQMOD_VEHICLE_BOBCAT)
.Const(_SC("MRWHOOPEE"), SQMOD_VEHICLE_MRWHOOPEE)
.Const(_SC("BFINJECTION"), SQMOD_VEHICLE_BFINJECTION)
.Const(_SC("HUNTER"), SQMOD_VEHICLE_HUNTER)
.Const(_SC("POLICE"), SQMOD_VEHICLE_POLICE)
.Const(_SC("ENFORCER"), SQMOD_VEHICLE_ENFORCER)
.Const(_SC("SECURICAR"), SQMOD_VEHICLE_SECURICAR)
.Const(_SC("BANSHEE"), SQMOD_VEHICLE_BANSHEE)
.Const(_SC("PREDATOR"), SQMOD_VEHICLE_PREDATOR)
.Const(_SC("BUS"), SQMOD_VEHICLE_BUS)
.Const(_SC("RHINO"), SQMOD_VEHICLE_RHINO)
.Const(_SC("BARRACKSOL"), SQMOD_VEHICLE_BARRACKSOL)
.Const(_SC("BARRACKS"), SQMOD_VEHICLE_BARRACKS)
.Const(_SC("CUBANHERMES"), SQMOD_VEHICLE_CUBANHERMES)
.Const(_SC("HELICOPTER"), SQMOD_VEHICLE_HELICOPTER)
.Const(_SC("ANGEL"), SQMOD_VEHICLE_ANGEL)
.Const(_SC("COACH"), SQMOD_VEHICLE_COACH)
.Const(_SC("CABBIE"), SQMOD_VEHICLE_CABBIE)
.Const(_SC("STALLION"), SQMOD_VEHICLE_STALLION)
.Const(_SC("RUMPO"), SQMOD_VEHICLE_RUMPO)
.Const(_SC("RCBANDIT"), SQMOD_VEHICLE_RCBANDIT)
.Const(_SC("HEARSE"), SQMOD_VEHICLE_HEARSE)
.Const(_SC("PACKER"), SQMOD_VEHICLE_PACKER)
.Const(_SC("SENTINELXS"), SQMOD_VEHICLE_SENTINELXS)
.Const(_SC("ADMIRAL"), SQMOD_VEHICLE_ADMIRAL)
.Const(_SC("SQUALO"), SQMOD_VEHICLE_SQUALO)
.Const(_SC("SEASPARROW"), SQMOD_VEHICLE_SEASPARROW)
.Const(_SC("PIZZABOY"), SQMOD_VEHICLE_PIZZABOY)
.Const(_SC("GANGBURRITO"), SQMOD_VEHICLE_GANGBURRITO)
.Const(_SC("AIRTRAIN"), SQMOD_VEHICLE_AIRTRAIN)
.Const(_SC("DEADDODO"), SQMOD_VEHICLE_DEADDODO)
.Const(_SC("SPEEDER"), SQMOD_VEHICLE_SPEEDER)
.Const(_SC("REEFER"), SQMOD_VEHICLE_REEFER)
.Const(_SC("TROPIC"), SQMOD_VEHICLE_TROPIC)
.Const(_SC("FLATBED"), SQMOD_VEHICLE_FLATBED)
.Const(_SC("YANKEE"), SQMOD_VEHICLE_YANKEE)
.Const(_SC("CADDY"), SQMOD_VEHICLE_CADDY)
.Const(_SC("ZEBRA"), SQMOD_VEHICLE_ZEBRA)
.Const(_SC("ZEBRACAB"), SQMOD_VEHICLE_ZEBRACAB)
.Const(_SC("TOPFUN"), SQMOD_VEHICLE_TOPFUN)
.Const(_SC("SKIMMER"), SQMOD_VEHICLE_SKIMMER)
.Const(_SC("PCJ600"), SQMOD_VEHICLE_PCJ600)
.Const(_SC("PCJ"), SQMOD_VEHICLE_PCJ)
.Const(_SC("FAGGIO"), SQMOD_VEHICLE_FAGGIO)
.Const(_SC("FREEWAY"), SQMOD_VEHICLE_FREEWAY)
.Const(_SC("RCBARON"), SQMOD_VEHICLE_RCBARON)
.Const(_SC("RCRAIDER"), SQMOD_VEHICLE_RCRAIDER)
.Const(_SC("GLENDALE"), SQMOD_VEHICLE_GLENDALE)
.Const(_SC("OCEANIC"), SQMOD_VEHICLE_OCEANIC)
.Const(_SC("SANCHEZ"), SQMOD_VEHICLE_SANCHEZ)
.Const(_SC("SPARROW"), SQMOD_VEHICLE_SPARROW)
.Const(_SC("PATRIOT"), SQMOD_VEHICLE_PATRIOT)
.Const(_SC("LOVEFIST"), SQMOD_VEHICLE_LOVEFIST)
.Const(_SC("COASTGUARD"), SQMOD_VEHICLE_COASTGUARD)
.Const(_SC("DINGHY"), SQMOD_VEHICLE_DINGHY)
.Const(_SC("HERMES"), SQMOD_VEHICLE_HERMES)
.Const(_SC("SABRE"), SQMOD_VEHICLE_SABRE)
.Const(_SC("SABRETURBO"), SQMOD_VEHICLE_SABRETURBO)
.Const(_SC("PHOENIX"), SQMOD_VEHICLE_PHOENIX)
.Const(_SC("WALTON"), SQMOD_VEHICLE_WALTON)
.Const(_SC("REGINA"), SQMOD_VEHICLE_REGINA)
.Const(_SC("COMET"), SQMOD_VEHICLE_COMET)
.Const(_SC("DELUXO"), SQMOD_VEHICLE_DELUXO)
.Const(_SC("BURRITO"), SQMOD_VEHICLE_BURRITO)
.Const(_SC("SPANDEX"), SQMOD_VEHICLE_SPANDEX)
.Const(_SC("SPANDEXPRESS"), SQMOD_VEHICLE_SPANDEXPRESS)
.Const(_SC("MARQUIS"), SQMOD_VEHICLE_MARQUIS)
.Const(_SC("BAGGAGE"), SQMOD_VEHICLE_BAGGAGE)
.Const(_SC("BAGGAGEHANDLER"), SQMOD_VEHICLE_BAGGAGEHANDLER)
.Const(_SC("KAUFMAN"), SQMOD_VEHICLE_KAUFMAN)
.Const(_SC("KAUFMANCAB"), SQMOD_VEHICLE_KAUFMANCAB)
.Const(_SC("MAVERICK"), SQMOD_VEHICLE_MAVERICK)
.Const(_SC("VCNMAVERICK"), SQMOD_VEHICLE_VCNMAVERICK)
.Const(_SC("RANCHER"), SQMOD_VEHICLE_RANCHER)
.Const(_SC("FBIRANCHER"), SQMOD_VEHICLE_FBIRANCHER)
.Const(_SC("VIRGO"), SQMOD_VEHICLE_VIRGO)
.Const(_SC("GREENWOOD"), SQMOD_VEHICLE_GREENWOOD)
.Const(_SC("CUBANJETMAX"), SQMOD_VEHICLE_CUBANJETMAX)
.Const(_SC("HOTRING1"), SQMOD_VEHICLE_HOTRING1)
.Const(_SC("HOTRINGRACER1"), SQMOD_VEHICLE_HOTRINGRACER1)
.Const(_SC("SANDKING"), SQMOD_VEHICLE_SANDKING)
.Const(_SC("BLISTA"), SQMOD_VEHICLE_BLISTA)
.Const(_SC("BLISTAC"), SQMOD_VEHICLE_BLISTAC)
.Const(_SC("BLISTACOMPACT"), SQMOD_VEHICLE_BLISTACOMPACT)
.Const(_SC("COMPACT"), SQMOD_VEHICLE_COMPACT)
.Const(_SC("POLICEMAV"), SQMOD_VEHICLE_POLICEMAV)
.Const(_SC("POLICEMAVERICK"), SQMOD_VEHICLE_POLICEMAVERICK)
.Const(_SC("BOXVILLE"), SQMOD_VEHICLE_BOXVILLE)
.Const(_SC("BENSON"), SQMOD_VEHICLE_BENSON)
.Const(_SC("MESA"), SQMOD_VEHICLE_MESA)
.Const(_SC("MESAGRANDE"), SQMOD_VEHICLE_MESAGRANDE)
.Const(_SC("RCGOBLIN"), SQMOD_VEHICLE_RCGOBLIN)
.Const(_SC("HOTRING2"), SQMOD_VEHICLE_HOTRING2)
.Const(_SC("HOTRINGRACER2"), SQMOD_VEHICLE_HOTRINGRACER2)
.Const(_SC("HOTRING3"), SQMOD_VEHICLE_HOTRING3)
.Const(_SC("HOTRINGRACER3"), SQMOD_VEHICLE_HOTRINGRACER3)
.Const(_SC("BLOODRING1"), SQMOD_VEHICLE_BLOODRING1)
.Const(_SC("BLOODRINGBANGER1"), SQMOD_VEHICLE_BLOODRINGBANGER1)
.Const(_SC("BLOODRING2"), SQMOD_VEHICLE_BLOODRING2)
.Const(_SC("BLOODRINGBANGER2"), SQMOD_VEHICLE_BLOODRINGBANGER2)
.Const(_SC("VICECHEE"), SQMOD_VEHICLE_VICECHEE)
.Const(_SC("POLICECHEETAH"), SQMOD_VEHICLE_POLICECHEETAH)
.Const(_SC("FBICHEETAH"), SQMOD_VEHICLE_FBICHEETAH)
.Const(_SC("CHEETAH2"), SQMOD_VEHICLE_CHEETAH2)
);
Sqrat::ConstTable(vm).Enum(_SC("ESKIN"), Sqrat::Enumeration(vm)
.Const(_SC("UNKNOWN"), SQMOD_UNKNOWN)
.Const(_SC("TOMMY_VERCETTI"), SQMOD_SKIN_TOMMY_VERCETTI)
.Const(_SC("COP"), SQMOD_SKIN_COP)
.Const(_SC("SWAT"), SQMOD_SKIN_SWAT)
.Const(_SC("FBI"), SQMOD_SKIN_FBI)
.Const(_SC("ARMY"), SQMOD_SKIN_ARMY)
.Const(_SC("PARAMEDIC"), SQMOD_SKIN_PARAMEDIC)
.Const(_SC("FIREMAN"), SQMOD_SKIN_FIREMAN)
.Const(_SC("GOLF_GUY_A"), SQMOD_SKIN_GOLF_GUY_A)
.Const(_SC("BUM_LADY_A"), SQMOD_SKIN_BUM_LADY_A)
.Const(_SC("BUM_LADY_B"), SQMOD_SKIN_BUM_LADY_B)
.Const(_SC("PUNK_A"), SQMOD_SKIN_PUNK_A)
.Const(_SC("LAWYER"), SQMOD_SKIN_LAWYER)
.Const(_SC("SPANISH_LADY_A"), SQMOD_SKIN_SPANISH_LADY_A)
.Const(_SC("SPANISH_LADY_B"), SQMOD_SKIN_SPANISH_LADY_B)
.Const(_SC("COOL_GUY_A"), SQMOD_SKIN_COOL_GUY_A)
.Const(_SC("ARABIC_GUY"), SQMOD_SKIN_ARABIC_GUY)
.Const(_SC("BEACH_LADY_A"), SQMOD_SKIN_BEACH_LADY_A)
.Const(_SC("BEACH_LADY_B"), SQMOD_SKIN_BEACH_LADY_B)
.Const(_SC("BEACH_GUY_A"), SQMOD_SKIN_BEACH_GUY_A)
.Const(_SC("BEACH_GUY_B"), SQMOD_SKIN_BEACH_GUY_B)
.Const(_SC("OFFICE_LADY_A"), SQMOD_SKIN_OFFICE_LADY_A)
.Const(_SC("WAITRESS_A"), SQMOD_SKIN_WAITRESS_A)
.Const(_SC("FOOD_LADY"), SQMOD_SKIN_FOOD_LADY)
.Const(_SC("PROSTITUTE_A"), SQMOD_SKIN_PROSTITUTE_A)
.Const(_SC("BUM_LADY_C"), SQMOD_SKIN_BUM_LADY_C)
.Const(_SC("BUM_GUY_A"), SQMOD_SKIN_BUM_GUY_A)
.Const(_SC("GARBAGEMAN_A"), SQMOD_SKIN_GARBAGEMAN_A)
.Const(_SC("TAXI_DRIVER_A"), SQMOD_SKIN_TAXI_DRIVER_A)
.Const(_SC("HATIAN_A"), SQMOD_SKIN_HATIAN_A)
.Const(_SC("CRIMINAL_A"), SQMOD_SKIN_CRIMINAL_A)
.Const(_SC("HOOD_LADY"), SQMOD_SKIN_HOOD_LADY)
.Const(_SC("GRANNY_A"), SQMOD_SKIN_GRANNY_A)
.Const(_SC("BUSINESS_MAN_A"), SQMOD_SKIN_BUSINESS_MAN_A)
.Const(_SC("CHURCH_GUY"), SQMOD_SKIN_CHURCH_GUY)
.Const(_SC("CLUB_LADY"), SQMOD_SKIN_CLUB_LADY)
.Const(_SC("CHURCH_LADY"), SQMOD_SKIN_CHURCH_LADY)
.Const(_SC("PIMP"), SQMOD_SKIN_PIMP)
.Const(_SC("BEACH_LADY_C"), SQMOD_SKIN_BEACH_LADY_C)
.Const(_SC("BEACH_GUY_C"), SQMOD_SKIN_BEACH_GUY_C)
.Const(_SC("BEACH_LADY_D"), SQMOD_SKIN_BEACH_LADY_D)
.Const(_SC("BEACH_GUY_D"), SQMOD_SKIN_BEACH_GUY_D)
.Const(_SC("BUSINESS_MAN_B"), SQMOD_SKIN_BUSINESS_MAN_B)
.Const(_SC("PROSTITUTE_B"), SQMOD_SKIN_PROSTITUTE_B)
.Const(_SC("BUM_LADY_D"), SQMOD_SKIN_BUM_LADY_D)
.Const(_SC("BUM_GUY_B"), SQMOD_SKIN_BUM_GUY_B)
.Const(_SC("HATIAN_B"), SQMOD_SKIN_HATIAN_B)
.Const(_SC("CONSTRUCTION_WORKER_A"), SQMOD_SKIN_CONSTRUCTION_WORKER_A)
.Const(_SC("PUNK_B"), SQMOD_SKIN_PUNK_B)
.Const(_SC("PROSTITUTE_C"), SQMOD_SKIN_PROSTITUTE_C)
.Const(_SC("GRANNY_B"), SQMOD_SKIN_GRANNY_B)
.Const(_SC("PUNK_C"), SQMOD_SKIN_PUNK_C)
.Const(_SC("BUSINESS_MAN_C"), SQMOD_SKIN_BUSINESS_MAN_C)
.Const(_SC("SPANISH_LADY_C"), SQMOD_SKIN_SPANISH_LADY_C)
.Const(_SC("SPANISH_LADY_D"), SQMOD_SKIN_SPANISH_LADY_D)
.Const(_SC("COOL_GUY_B"), SQMOD_SKIN_COOL_GUY_B)
.Const(_SC("BUSINESS_MAN_D"), SQMOD_SKIN_BUSINESS_MAN_D)
.Const(_SC("BEACH_LADY_E"), SQMOD_SKIN_BEACH_LADY_E)
.Const(_SC("BEACH_GUY_E"), SQMOD_SKIN_BEACH_GUY_E)
.Const(_SC("BEACH_LADY_F"), SQMOD_SKIN_BEACH_LADY_F)
.Const(_SC("BEACH_GUY_F"), SQMOD_SKIN_BEACH_GUY_F)
.Const(_SC("CONSTRUCTION_WORKER_B"), SQMOD_SKIN_CONSTRUCTION_WORKER_B)
.Const(_SC("GOLF_GUY_B"), SQMOD_SKIN_GOLF_GUY_B)
.Const(_SC("GOLF_LADY"), SQMOD_SKIN_GOLF_LADY)
.Const(_SC("GOLF_GUY_C"), SQMOD_SKIN_GOLF_GUY_C)
.Const(_SC("BEACH_LADY_G"), SQMOD_SKIN_BEACH_LADY_G)
.Const(_SC("BEACH_GUY_G"), SQMOD_SKIN_BEACH_GUY_G)
.Const(_SC("OFFICE_LADY_B"), SQMOD_SKIN_OFFICE_LADY_B)
.Const(_SC("BUSINESS_MAN_E"), SQMOD_SKIN_BUSINESS_MAN_E)
.Const(_SC("BUSINESS_MAN_F"), SQMOD_SKIN_BUSINESS_MAN_F)
.Const(_SC("PROSTITUTE_D"), SQMOD_SKIN_PROSTITUTE_D)
.Const(_SC("BUM_LADY_E"), SQMOD_SKIN_BUM_LADY_E)
.Const(_SC("BUM_GUY_C"), SQMOD_SKIN_BUM_GUY_C)
.Const(_SC("SPANISH_GUY"), SQMOD_SKIN_SPANISH_GUY)
.Const(_SC("TAXI_DRIVER_B"), SQMOD_SKIN_TAXI_DRIVER_B)
.Const(_SC("GYM_LADY"), SQMOD_SKIN_GYM_LADY)
.Const(_SC("GYM_GUY"), SQMOD_SKIN_GYM_GUY)
.Const(_SC("SKATE_LADY"), SQMOD_SKIN_SKATE_LADY)
.Const(_SC("SKATE_GUY"), SQMOD_SKIN_SKATE_GUY)
.Const(_SC("SHOPPER_A"), SQMOD_SKIN_SHOPPER_A)
.Const(_SC("SHOPPER_B"), SQMOD_SKIN_SHOPPER_B)
.Const(_SC("TOURIST_A"), SQMOD_SKIN_TOURIST_A)
.Const(_SC("TOURIST_B"), SQMOD_SKIN_TOURIST_B)
.Const(_SC("CUBAN_A"), SQMOD_SKIN_CUBAN_A)
.Const(_SC("CUBAN_B"), SQMOD_SKIN_CUBAN_B)
.Const(_SC("HATIAN_C"), SQMOD_SKIN_HATIAN_C)
.Const(_SC("HATIAN_D"), SQMOD_SKIN_HATIAN_D)
.Const(_SC("SHARK_A"), SQMOD_SKIN_SHARK_A)
.Const(_SC("SHARK_B"), SQMOD_SKIN_SHARK_B)
.Const(_SC("DIAZ_GUY_A"), SQMOD_SKIN_DIAZ_GUY_A)
.Const(_SC("DIAZ_GUY_B"), SQMOD_SKIN_DIAZ_GUY_B)
.Const(_SC("DBP_SECURITY_A"), SQMOD_SKIN_DBP_SECURITY_A)
.Const(_SC("DBP_SECURITY_B"), SQMOD_SKIN_DBP_SECURITY_B)
.Const(_SC("BIKER_A"), SQMOD_SKIN_BIKER_A)
.Const(_SC("BIKER_B"), SQMOD_SKIN_BIKER_B)
.Const(_SC("VERCETTI_GUY_A"), SQMOD_SKIN_VERCETTI_GUY_A)
.Const(_SC("VERCETTI_GUY_B"), SQMOD_SKIN_VERCETTI_GUY_B)
.Const(_SC("UNDERCOVER_COP_A"), SQMOD_SKIN_UNDERCOVER_COP_A)
.Const(_SC("UNDERCOVER_COP_B"), SQMOD_SKIN_UNDERCOVER_COP_B)
.Const(_SC("UNDERCOVER_COP_C"), SQMOD_SKIN_UNDERCOVER_COP_C)
.Const(_SC("UNDERCOVER_COP_D"), SQMOD_SKIN_UNDERCOVER_COP_D)
.Const(_SC("UNDERCOVER_COP_E"), SQMOD_SKIN_UNDERCOVER_COP_E)
.Const(_SC("UNDERCOVER_COP_F"), SQMOD_SKIN_UNDERCOVER_COP_F)
.Const(_SC("RICH_GUY"), SQMOD_SKIN_RICH_GUY)
.Const(_SC("COOL_GUY_C"), SQMOD_SKIN_COOL_GUY_C)
.Const(_SC("PROSTITUTE_E"), SQMOD_SKIN_PROSTITUTE_E)
.Const(_SC("PROSTITUTE_F"), SQMOD_SKIN_PROSTITUTE_F)
.Const(_SC("LOVE_FIST_A"), SQMOD_SKIN_LOVE_FIST_A)
.Const(_SC("KEN_ROSENBURG"), SQMOD_SKIN_KEN_ROSENBURG)
.Const(_SC("CANDY_SUXX"), SQMOD_SKIN_CANDY_SUXX)
.Const(_SC("HILARY"), SQMOD_SKIN_HILARY)
.Const(_SC("LOVE_FIST_B"), SQMOD_SKIN_LOVE_FIST_B)
.Const(_SC("PHIL"), SQMOD_SKIN_PHIL)
.Const(_SC("ROCKSTAR_GUY"), SQMOD_SKIN_ROCKSTAR_GUY)
.Const(_SC("SONNY"), SQMOD_SKIN_SONNY)
.Const(_SC("LANCE_A"), SQMOD_SKIN_LANCE_A)
.Const(_SC("MERCADES_A"), SQMOD_SKIN_MERCADES_A)
.Const(_SC("LOVE_FIST_C"), SQMOD_SKIN_LOVE_FIST_C)
.Const(_SC("ALEX_SRUB"), SQMOD_SKIN_ALEX_SRUB)
.Const(_SC("LANCE_COP"), SQMOD_SKIN_LANCE_COP)
.Const(_SC("LANCE_B"), SQMOD_SKIN_LANCE_B)
.Const(_SC("CORTEZ"), SQMOD_SKIN_CORTEZ)
.Const(_SC("LOVE_FIST_D"), SQMOD_SKIN_LOVE_FIST_D)
.Const(_SC("COLUMBIAN_GUY_A"), SQMOD_SKIN_COLUMBIAN_GUY_A)
.Const(_SC("HILARY_ROBBER"), SQMOD_SKIN_HILARY_ROBBER)
.Const(_SC("MERCADES_B"), SQMOD_SKIN_MERCADES_B)
.Const(_SC("CAM"), SQMOD_SKIN_CAM)
.Const(_SC("CAM_ROBBER"), SQMOD_SKIN_CAM_ROBBER)
.Const(_SC("PHIL_ONE_ARM"), SQMOD_SKIN_PHIL_ONE_ARM)
.Const(_SC("PHIL_ROBBER"), SQMOD_SKIN_PHIL_ROBBER)
.Const(_SC("COOL_GUY_D"), SQMOD_SKIN_COOL_GUY_D)
.Const(_SC("PIZZAMAN"), SQMOD_SKIN_PIZZAMAN)
.Const(_SC("TAXI_DRIVER_C"), SQMOD_SKIN_TAXI_DRIVER_C)
.Const(_SC("TAXI_DRIVER_D"), SQMOD_SKIN_TAXI_DRIVER_D)
.Const(_SC("SAILOR_A"), SQMOD_SKIN_SAILOR_A)
.Const(_SC("SAILOR_B"), SQMOD_SKIN_SAILOR_B)
.Const(_SC("SAILOR_C"), SQMOD_SKIN_SAILOR_C)
.Const(_SC("CHEF"), SQMOD_SKIN_CHEF)
.Const(_SC("CRIMINAL_B"), SQMOD_SKIN_CRIMINAL_B)
.Const(_SC("FRENCH_GUY"), SQMOD_SKIN_FRENCH_GUY)
.Const(_SC("GARBAGEMAN_B"), SQMOD_SKIN_GARBAGEMAN_B)
.Const(_SC("HATIAN_E"), SQMOD_SKIN_HATIAN_E)
.Const(_SC("WAITRESS_B"), SQMOD_SKIN_WAITRESS_B)
.Const(_SC("SONNY_GUY_A"), SQMOD_SKIN_SONNY_GUY_A)
.Const(_SC("SONNY_GUY_B"), SQMOD_SKIN_SONNY_GUY_B)
.Const(_SC("SONNY_GUY_C"), SQMOD_SKIN_SONNY_GUY_C)
.Const(_SC("COLUMBIAN_GUY_B"), SQMOD_SKIN_COLUMBIAN_GUY_B)
.Const(_SC("THUG_A"), SQMOD_SKIN_THUG_A)
.Const(_SC("BEACH_GUY_H"), SQMOD_SKIN_BEACH_GUY_H)
.Const(_SC("GARBAGEMAN_C"), SQMOD_SKIN_GARBAGEMAN_C)
.Const(_SC("GARBAGEMAN_D"), SQMOD_SKIN_GARBAGEMAN_D)
.Const(_SC("GARBAGEMAN_E"), SQMOD_SKIN_GARBAGEMAN_E)
.Const(_SC("TRANNY"), SQMOD_SKIN_TRANNY)
.Const(_SC("THUG_B"), SQMOD_SKIN_THUG_B)
.Const(_SC("SPANDEX_GUY_A"), SQMOD_SKIN_SPANDEX_GUY_A)
.Const(_SC("SPANDEX_GUY_B"), SQMOD_SKIN_SPANDEX_GUY_B)
.Const(_SC("STRIPPER_A"), SQMOD_SKIN_STRIPPER_A)
.Const(_SC("STRIPPER_B"), SQMOD_SKIN_STRIPPER_B)
.Const(_SC("STRIPPER_C"), SQMOD_SKIN_STRIPPER_C)
.Const(_SC("STORE_CLERK"), SQMOD_SKIN_STORE_CLERK)
);
Sqrat::ConstTable(vm).Enum(_SC("EKEYCODE"), Sqrat::Enumeration(vm)
.Const(_SC("ABNT_C1"), SQMOD_KEYCODE_ABNT_C1)
.Const(_SC("ABNT_C2"), SQMOD_KEYCODE_ABNT_C2)
.Const(_SC("ADD"), SQMOD_KEYCODE_ADD)
.Const(_SC("ATTN"), SQMOD_KEYCODE_ATTN)
.Const(_SC("BACK"), SQMOD_KEYCODE_BACK)
.Const(_SC("CANCEL"), SQMOD_KEYCODE_CANCEL)
.Const(_SC("CLEAR"), SQMOD_KEYCODE_CLEAR)
.Const(_SC("CRSEL"), SQMOD_KEYCODE_CRSEL)
.Const(_SC("DECIMAL"), SQMOD_KEYCODE_DECIMAL)
.Const(_SC("DIVIDE"), SQMOD_KEYCODE_DIVIDE)
.Const(_SC("EREOF"), SQMOD_KEYCODE_EREOF)
.Const(_SC("ESCAPE"), SQMOD_KEYCODE_ESCAPE)
.Const(_SC("EXECUTE"), SQMOD_KEYCODE_EXECUTE)
.Const(_SC("EXSEL"), SQMOD_KEYCODE_EXSEL)
.Const(_SC("ICO_CLEAR"), SQMOD_KEYCODE_ICO_CLEAR)
.Const(_SC("ICO_HELP"), SQMOD_KEYCODE_ICO_HELP)
.Const(_SC("KEY_0"), SQMOD_KEYCODE_KEY_0)
.Const(_SC("KEY_1"), SQMOD_KEYCODE_KEY_1)
.Const(_SC("KEY_2"), SQMOD_KEYCODE_KEY_2)
.Const(_SC("KEY_3"), SQMOD_KEYCODE_KEY_3)
.Const(_SC("KEY_4"), SQMOD_KEYCODE_KEY_4)
.Const(_SC("KEY_5"), SQMOD_KEYCODE_KEY_5)
.Const(_SC("KEY_6"), SQMOD_KEYCODE_KEY_6)
.Const(_SC("KEY_7"), SQMOD_KEYCODE_KEY_7)
.Const(_SC("KEY_8"), SQMOD_KEYCODE_KEY_8)
.Const(_SC("KEY_9"), SQMOD_KEYCODE_KEY_9)
.Const(_SC("KEY_A"), SQMOD_KEYCODE_KEY_A)
.Const(_SC("KEY_B"), SQMOD_KEYCODE_KEY_B)
.Const(_SC("KEY_C"), SQMOD_KEYCODE_KEY_C)
.Const(_SC("KEY_D"), SQMOD_KEYCODE_KEY_D)
.Const(_SC("KEY_E"), SQMOD_KEYCODE_KEY_E)
.Const(_SC("KEY_F"), SQMOD_KEYCODE_KEY_F)
.Const(_SC("KEY_G"), SQMOD_KEYCODE_KEY_G)
.Const(_SC("KEY_H"), SQMOD_KEYCODE_KEY_H)
.Const(_SC("KEY_I"), SQMOD_KEYCODE_KEY_I)
.Const(_SC("KEY_J"), SQMOD_KEYCODE_KEY_J)
.Const(_SC("KEY_K"), SQMOD_KEYCODE_KEY_K)
.Const(_SC("KEY_L"), SQMOD_KEYCODE_KEY_L)
.Const(_SC("KEY_M"), SQMOD_KEYCODE_KEY_M)
.Const(_SC("KEY_N"), SQMOD_KEYCODE_KEY_N)
.Const(_SC("KEY_O"), SQMOD_KEYCODE_KEY_O)
.Const(_SC("KEY_P"), SQMOD_KEYCODE_KEY_P)
.Const(_SC("KEY_Q"), SQMOD_KEYCODE_KEY_Q)
.Const(_SC("KEY_R"), SQMOD_KEYCODE_KEY_R)
.Const(_SC("KEY_S"), SQMOD_KEYCODE_KEY_S)
.Const(_SC("KEY_T"), SQMOD_KEYCODE_KEY_T)
.Const(_SC("KEY_U"), SQMOD_KEYCODE_KEY_U)
.Const(_SC("KEY_V"), SQMOD_KEYCODE_KEY_V)
.Const(_SC("KEY_W"), SQMOD_KEYCODE_KEY_W)
.Const(_SC("KEY_X"), SQMOD_KEYCODE_KEY_X)
.Const(_SC("KEY_Y"), SQMOD_KEYCODE_KEY_Y)
.Const(_SC("KEY_Z"), SQMOD_KEYCODE_KEY_Z)
.Const(_SC("MULTIPLY"), SQMOD_KEYCODE_MULTIPLY)
.Const(_SC("NONAME"), SQMOD_KEYCODE_NONAME)
.Const(_SC("NUMPAD0"), SQMOD_KEYCODE_NUMPAD0)
.Const(_SC("NUMPAD1"), SQMOD_KEYCODE_NUMPAD1)
.Const(_SC("NUMPAD2"), SQMOD_KEYCODE_NUMPAD2)
.Const(_SC("NUMPAD3"), SQMOD_KEYCODE_NUMPAD3)
.Const(_SC("NUMPAD4"), SQMOD_KEYCODE_NUMPAD4)
.Const(_SC("NUMPAD5"), SQMOD_KEYCODE_NUMPAD5)
.Const(_SC("NUMPAD6"), SQMOD_KEYCODE_NUMPAD6)
.Const(_SC("NUMPAD7"), SQMOD_KEYCODE_NUMPAD7)
.Const(_SC("NUMPAD8"), SQMOD_KEYCODE_NUMPAD8)
.Const(_SC("NUMPAD9"), SQMOD_KEYCODE_NUMPAD9)
.Const(_SC("OEM_1"), SQMOD_KEYCODE_OEM_1)
.Const(_SC("OEM_102"), SQMOD_KEYCODE_OEM_102)
.Const(_SC("OEM_2"), SQMOD_KEYCODE_OEM_2)
.Const(_SC("OEM_3"), SQMOD_KEYCODE_OEM_3)
.Const(_SC("OEM_4"), SQMOD_KEYCODE_OEM_4)
.Const(_SC("OEM_5"), SQMOD_KEYCODE_OEM_5)
.Const(_SC("OEM_6"), SQMOD_KEYCODE_OEM_6)
.Const(_SC("OEM_7"), SQMOD_KEYCODE_OEM_7)
.Const(_SC("OEM_8"), SQMOD_KEYCODE_OEM_8)
.Const(_SC("OEM_ATTN"), SQMOD_KEYCODE_OEM_ATTN)
.Const(_SC("OEM_AUTO"), SQMOD_KEYCODE_OEM_AUTO)
.Const(_SC("OEM_AX"), SQMOD_KEYCODE_OEM_AX)
.Const(_SC("OEM_BACKTAB"), SQMOD_KEYCODE_OEM_BACKTAB)
.Const(_SC("OEM_CLEAR"), SQMOD_KEYCODE_OEM_CLEAR)
.Const(_SC("OEM_COMMA"), SQMOD_KEYCODE_OEM_COMMA)
.Const(_SC("OEM_COPY"), SQMOD_KEYCODE_OEM_COPY)
.Const(_SC("OEM_CUSEL"), SQMOD_KEYCODE_OEM_CUSEL)
.Const(_SC("OEM_ENLW"), SQMOD_KEYCODE_OEM_ENLW)
.Const(_SC("OEM_FINISH"), SQMOD_KEYCODE_OEM_FINISH)
.Const(_SC("OEM_FJ_LOYA"), SQMOD_KEYCODE_OEM_FJ_LOYA)
.Const(_SC("OEM_FJ_MASSHOU"), SQMOD_KEYCODE_OEM_FJ_MASSHOU)
.Const(_SC("OEM_FJ_ROYA"), SQMOD_KEYCODE_OEM_FJ_ROYA)
.Const(_SC("OEM_FJ_TOUROKU"), SQMOD_KEYCODE_OEM_FJ_TOUROKU)
.Const(_SC("OEM_JUMP"), SQMOD_KEYCODE_OEM_JUMP)
.Const(_SC("OEM_MINUS"), SQMOD_KEYCODE_OEM_MINUS)
.Const(_SC("OEM_PA1"), SQMOD_KEYCODE_OEM_PA1)
.Const(_SC("OEM_PA2"), SQMOD_KEYCODE_OEM_PA2)
.Const(_SC("OEM_PA3"), SQMOD_KEYCODE_OEM_PA3)
.Const(_SC("OEM_PERIOD"), SQMOD_KEYCODE_OEM_PERIOD)
.Const(_SC("OEM_PLUS"), SQMOD_KEYCODE_OEM_PLUS)
.Const(_SC("OEM_RESET"), SQMOD_KEYCODE_OEM_RESET)
.Const(_SC("OEM_WSCTRL"), SQMOD_KEYCODE_OEM_WSCTRL)
.Const(_SC("PA1"), SQMOD_KEYCODE_PA1)
.Const(_SC("PACKET"), SQMOD_KEYCODE_PACKET)
.Const(_SC("PLAY"), SQMOD_KEYCODE_PLAY)
.Const(_SC("PROCESSKEY"), SQMOD_KEYCODE_PROCESSKEY)
.Const(_SC("RETURN"), SQMOD_KEYCODE_RETURN)
.Const(_SC("SELECT"), SQMOD_KEYCODE_SELECT)
.Const(_SC("SEPARATOR"), SQMOD_KEYCODE_SEPARATOR)
.Const(_SC("SPACE"), SQMOD_KEYCODE_SPACE)
.Const(_SC("SUBTRACT"), SQMOD_KEYCODE_SUBTRACT)
.Const(_SC("TAB"), SQMOD_KEYCODE_TAB)
.Const(_SC("ZOOM"), SQMOD_KEYCODE_ZOOM)
.Const(_SC("ACCEPT"), SQMOD_KEYCODE_ACCEPT)
.Const(_SC("APPS"), SQMOD_KEYCODE_APPS)
.Const(_SC("BROWSER_BACK"), SQMOD_KEYCODE_BROWSER_BACK)
.Const(_SC("BROWSER_FAVORITES"), SQMOD_KEYCODE_BROWSER_FAVORITES)
.Const(_SC("BROWSER_FORWARD"), SQMOD_KEYCODE_BROWSER_FORWARD)
.Const(_SC("BROWSER_HOME"), SQMOD_KEYCODE_BROWSER_HOME)
.Const(_SC("BROWSER_REFRESH"), SQMOD_KEYCODE_BROWSER_REFRESH)
.Const(_SC("BROWSER_SEARCH"), SQMOD_KEYCODE_BROWSER_SEARCH)
.Const(_SC("BROWSER_STOP"), SQMOD_KEYCODE_BROWSER_STOP)
.Const(_SC("CAPITAL"), SQMOD_KEYCODE_CAPITAL)
.Const(_SC("CONVERT"), SQMOD_KEYCODE_CONVERT)
.Const(_SC("DELETE"), SQMOD_KEYCODE_DELETE)
.Const(_SC("DOWN"), SQMOD_KEYCODE_DOWN)
.Const(_SC("END"), SQMOD_KEYCODE_END)
.Const(_SC("F1"), SQMOD_KEYCODE_F1)
.Const(_SC("F10"), SQMOD_KEYCODE_F10)
.Const(_SC("F11"), SQMOD_KEYCODE_F11)
.Const(_SC("F12"), SQMOD_KEYCODE_F12)
.Const(_SC("F13"), SQMOD_KEYCODE_F13)
.Const(_SC("F14"), SQMOD_KEYCODE_F14)
.Const(_SC("F15"), SQMOD_KEYCODE_F15)
.Const(_SC("F16"), SQMOD_KEYCODE_F16)
.Const(_SC("F17"), SQMOD_KEYCODE_F17)
.Const(_SC("F18"), SQMOD_KEYCODE_F18)
.Const(_SC("F19"), SQMOD_KEYCODE_F19)
.Const(_SC("F2"), SQMOD_KEYCODE_F2)
.Const(_SC("F20"), SQMOD_KEYCODE_F20)
.Const(_SC("F21"), SQMOD_KEYCODE_F21)
.Const(_SC("F22"), SQMOD_KEYCODE_F22)
.Const(_SC("F23"), SQMOD_KEYCODE_F23)
.Const(_SC("F24"), SQMOD_KEYCODE_F24)
.Const(_SC("F3"), SQMOD_KEYCODE_F3)
.Const(_SC("F4"), SQMOD_KEYCODE_F4)
.Const(_SC("F5"), SQMOD_KEYCODE_F5)
.Const(_SC("F6"), SQMOD_KEYCODE_F6)
.Const(_SC("F7"), SQMOD_KEYCODE_F7)
.Const(_SC("F8"), SQMOD_KEYCODE_F8)
.Const(_SC("F9"), SQMOD_KEYCODE_F9)
.Const(_SC("FINAL"), SQMOD_KEYCODE_FINAL)
.Const(_SC("HELP"), SQMOD_KEYCODE_HELP)
.Const(_SC("HOME"), SQMOD_KEYCODE_HOME)
.Const(_SC("ICO_00"), SQMOD_KEYCODE_ICO_00)
.Const(_SC("INSERT"), SQMOD_KEYCODE_INSERT)
.Const(_SC("JUNJA"), SQMOD_KEYCODE_JUNJA)
.Const(_SC("KANA"), SQMOD_KEYCODE_KANA)
.Const(_SC("KANJI"), SQMOD_KEYCODE_KANJI)
.Const(_SC("LAUNCH_APP1"), SQMOD_KEYCODE_LAUNCH_APP1)
.Const(_SC("LAUNCH_APP2"), SQMOD_KEYCODE_LAUNCH_APP2)
.Const(_SC("LAUNCH_MAIL"), SQMOD_KEYCODE_LAUNCH_MAIL)
.Const(_SC("LAUNCH_MEDIA_SELECT"), SQMOD_KEYCODE_LAUNCH_MEDIA_SELECT)
.Const(_SC("LBUTTON"), SQMOD_KEYCODE_LBUTTON)
.Const(_SC("LCONTROL"), SQMOD_KEYCODE_LCONTROL)
.Const(_SC("LEFT"), SQMOD_KEYCODE_LEFT)
.Const(_SC("LMENU"), SQMOD_KEYCODE_LMENU)
.Const(_SC("LSHIFT"), SQMOD_KEYCODE_LSHIFT)
.Const(_SC("LWIN"), SQMOD_KEYCODE_LWIN)
.Const(_SC("MBUTTON"), SQMOD_KEYCODE_MBUTTON)
.Const(_SC("MEDIA_NEXT_TRACK"), SQMOD_KEYCODE_MEDIA_NEXT_TRACK)
.Const(_SC("MEDIA_PLAY_PAUSE"), SQMOD_KEYCODE_MEDIA_PLAY_PAUSE)
.Const(_SC("MEDIA_PREV_TRACK"), SQMOD_KEYCODE_MEDIA_PREV_TRACK)
.Const(_SC("MEDIA_STOP"), SQMOD_KEYCODE_MEDIA_STOP)
.Const(_SC("MODECHANGE"), SQMOD_KEYCODE_MODECHANGE)
.Const(_SC("NEXT"), SQMOD_KEYCODE_NEXT)
.Const(_SC("NONCONVERT"), SQMOD_KEYCODE_NONCONVERT)
.Const(_SC("NUMLOCK"), SQMOD_KEYCODE_NUMLOCK)
.Const(_SC("OEM_FJ_JISHO"), SQMOD_KEYCODE_OEM_FJ_JISHO)
.Const(_SC("PAUSE"), SQMOD_KEYCODE_PAUSE)
.Const(_SC("PRINT"), SQMOD_KEYCODE_PRINT)
.Const(_SC("PRIOR"), SQMOD_KEYCODE_PRIOR)
.Const(_SC("RBUTTON"), SQMOD_KEYCODE_RBUTTON)
.Const(_SC("RCONTROL"), SQMOD_KEYCODE_RCONTROL)
.Const(_SC("RIGHT"), SQMOD_KEYCODE_RIGHT)
.Const(_SC("RMENU"), SQMOD_KEYCODE_RMENU)
.Const(_SC("RSHIFT"), SQMOD_KEYCODE_RSHIFT)
.Const(_SC("RWIN"), SQMOD_KEYCODE_RWIN)
.Const(_SC("SCROLL"), SQMOD_KEYCODE_SCROLL)
.Const(_SC("SLEEP"), SQMOD_KEYCODE_SLEEP)
.Const(_SC("SNAPSHOT"), SQMOD_KEYCODE_SNAPSHOT)
.Const(_SC("UP"), SQMOD_KEYCODE_UP)
.Const(_SC("VOLUME_DOWN"), SQMOD_KEYCODE_VOLUME_DOWN)
.Const(_SC("VOLUME_MUTE"), SQMOD_KEYCODE_VOLUME_MUTE)
.Const(_SC("VOLUME_UP"), SQMOD_KEYCODE_VOLUME_UP)
.Const(_SC("XBUTTON1"), SQMOD_KEYCODE_XBUTTON1)
.Const(_SC("XBUTTON2"), SQMOD_KEYCODE_XBUTTON2)
.Const(_SC("NONE"), SQMOD_KEYCODE_NONE)
);
Sqrat::ConstTable(vm).Enum(_SC("EASCII"), Sqrat::Enumeration(vm)
.Const(_SC("NUL"), SQMOD_ASCII_NUL)
.Const(_SC("SOH"), SQMOD_ASCII_SOH)
.Const(_SC("STX"), SQMOD_ASCII_STX)
.Const(_SC("ETX"), SQMOD_ASCII_ETX)
.Const(_SC("EOT"), SQMOD_ASCII_EOT)
.Const(_SC("ENQ"), SQMOD_ASCII_ENQ)
.Const(_SC("ACK"), SQMOD_ASCII_ACK)
.Const(_SC("BEL"), SQMOD_ASCII_BEL)
.Const(_SC("BS"), SQMOD_ASCII_BS)
.Const(_SC("TAB"), SQMOD_ASCII_TAB)
.Const(_SC("LF"), SQMOD_ASCII_LF)
.Const(_SC("VT"), SQMOD_ASCII_VT)
.Const(_SC("FF"), SQMOD_ASCII_FF)
.Const(_SC("CR"), SQMOD_ASCII_CR)
.Const(_SC("SO"), SQMOD_ASCII_SO)
.Const(_SC("SI"), SQMOD_ASCII_SI)
.Const(_SC("DLE"), SQMOD_ASCII_DLE)
.Const(_SC("DC1"), SQMOD_ASCII_DC1)
.Const(_SC("DC2"), SQMOD_ASCII_DC2)
.Const(_SC("DC3"), SQMOD_ASCII_DC3)
.Const(_SC("DC4"), SQMOD_ASCII_DC4)
.Const(_SC("NAK"), SQMOD_ASCII_NAK)
.Const(_SC("SYN"), SQMOD_ASCII_SYN)
.Const(_SC("ETB"), SQMOD_ASCII_ETB)
.Const(_SC("CAN"), SQMOD_ASCII_CAN)
.Const(_SC("EM"), SQMOD_ASCII_EM)
.Const(_SC("SUB"), SQMOD_ASCII_SUB)
.Const(_SC("ESC"), SQMOD_ASCII_ESC)
.Const(_SC("FS"), SQMOD_ASCII_FS)
.Const(_SC("GS"), SQMOD_ASCII_GS)
.Const(_SC("RS"), SQMOD_ASCII_RS)
.Const(_SC("US"), SQMOD_ASCII_US)
.Const(_SC("SPACE"), SQMOD_ASCII_SPACE)
.Const(_SC("EXCLAMATION_POINT"), SQMOD_ASCII_EXCLAMATION_POINT)
.Const(_SC("DOUBLE_QUOTES"), SQMOD_ASCII_DOUBLE_QUOTES)
.Const(_SC("NUMBER_SIGN"), SQMOD_ASCII_NUMBER_SIGN)
.Const(_SC("DOLLAR_SIGN"), SQMOD_ASCII_DOLLAR_SIGN)
.Const(_SC("PERCENT_SIGN"), SQMOD_ASCII_PERCENT_SIGN)
.Const(_SC("AMPERSAND"), SQMOD_ASCII_AMPERSAND)
.Const(_SC("SINGLE_QUOTE"), SQMOD_ASCII_SINGLE_QUOTE)
.Const(_SC("OPENING_PARENTHESIS"), SQMOD_ASCII_OPENING_PARENTHESIS)
.Const(_SC("CLOSING_PARENTHESIS"), SQMOD_ASCII_CLOSING_PARENTHESIS)
.Const(_SC("ASTERISK"), SQMOD_ASCII_ASTERISK)
.Const(_SC("PLUS"), SQMOD_ASCII_PLUS)
.Const(_SC("COMMA"), SQMOD_ASCII_COMMA)
.Const(_SC("MINUS"), SQMOD_ASCII_MINUS)
.Const(_SC("PERIOD"), SQMOD_ASCII_PERIOD)
.Const(_SC("SLASH"), SQMOD_ASCII_SLASH)
.Const(_SC("ZERO"), SQMOD_ASCII_ZERO)
.Const(_SC("ONE"), SQMOD_ASCII_ONE)
.Const(_SC("TWO"), SQMOD_ASCII_TWO)
.Const(_SC("THREE"), SQMOD_ASCII_THREE)
.Const(_SC("FOUR"), SQMOD_ASCII_FOUR)
.Const(_SC("FIVE"), SQMOD_ASCII_FIVE)
.Const(_SC("SIX"), SQMOD_ASCII_SIX)
.Const(_SC("SEVEN"), SQMOD_ASCII_SEVEN)
.Const(_SC("EIGHT"), SQMOD_ASCII_EIGHT)
.Const(_SC("NINE"), SQMOD_ASCII_NINE)
.Const(_SC("COLON"), SQMOD_ASCII_COLON)
.Const(_SC("EMICOLON"), SQMOD_ASCII_EMICOLON)
.Const(_SC("LESS_THAN_SIGN"), SQMOD_ASCII_LESS_THAN_SIGN)
.Const(_SC("EQUAL_SIGN"), SQMOD_ASCII_EQUAL_SIGN)
.Const(_SC("GREATER_THAN_SIGN"), SQMOD_ASCII_GREATER_THAN_SIGN)
.Const(_SC("QUESTION_MARK"), SQMOD_ASCII_QUESTION_MARK)
.Const(_SC("AT"), SQMOD_ASCII_AT)
.Const(_SC("UPPER_A"), SQMOD_ASCII_UPPER_A)
.Const(_SC("UPPER_B"), SQMOD_ASCII_UPPER_B)
.Const(_SC("UPPER_C"), SQMOD_ASCII_UPPER_C)
.Const(_SC("UPPER_D"), SQMOD_ASCII_UPPER_D)
.Const(_SC("UPPER_E"), SQMOD_ASCII_UPPER_E)
.Const(_SC("UPPER_F"), SQMOD_ASCII_UPPER_F)
.Const(_SC("UPPER_G"), SQMOD_ASCII_UPPER_G)
.Const(_SC("UPPER_H"), SQMOD_ASCII_UPPER_H)
.Const(_SC("UPPER_I"), SQMOD_ASCII_UPPER_I)
.Const(_SC("UPPER_J"), SQMOD_ASCII_UPPER_J)
.Const(_SC("UPPER_K"), SQMOD_ASCII_UPPER_K)
.Const(_SC("UPPER_L"), SQMOD_ASCII_UPPER_L)
.Const(_SC("UPPER_M"), SQMOD_ASCII_UPPER_M)
.Const(_SC("UPPER_N"), SQMOD_ASCII_UPPER_N)
.Const(_SC("UPPER_O"), SQMOD_ASCII_UPPER_O)
.Const(_SC("UPPER_P"), SQMOD_ASCII_UPPER_P)
.Const(_SC("UPPER_Q"), SQMOD_ASCII_UPPER_Q)
.Const(_SC("UPPER_R"), SQMOD_ASCII_UPPER_R)
.Const(_SC("UPPER_S"), SQMOD_ASCII_UPPER_S)
.Const(_SC("UPPER_T"), SQMOD_ASCII_UPPER_T)
.Const(_SC("UPPER_U"), SQMOD_ASCII_UPPER_U)
.Const(_SC("UPPER_V"), SQMOD_ASCII_UPPER_V)
.Const(_SC("UPPER_W"), SQMOD_ASCII_UPPER_W)
.Const(_SC("UPPER_X"), SQMOD_ASCII_UPPER_X)
.Const(_SC("UPPER_Y"), SQMOD_ASCII_UPPER_Y)
.Const(_SC("UPPER_Z"), SQMOD_ASCII_UPPER_Z)
.Const(_SC("OPENING_BRACKET"), SQMOD_ASCII_OPENING_BRACKET)
.Const(_SC("BACKSLASH"), SQMOD_ASCII_BACKSLASH)
.Const(_SC("CLOSING_BRACKET"), SQMOD_ASCII_CLOSING_BRACKET)
.Const(_SC("CARET"), SQMOD_ASCII_CARET)
.Const(_SC("UNDERSCORE"), SQMOD_ASCII_UNDERSCORE)
.Const(_SC("GRAVE_ACCENT"), SQMOD_ASCII_GRAVE_ACCENT)
.Const(_SC("LOWER_A"), SQMOD_ASCII_LOWER_A)
.Const(_SC("LOWER_B"), SQMOD_ASCII_LOWER_B)
.Const(_SC("LOWER_C"), SQMOD_ASCII_LOWER_C)
.Const(_SC("LOWER_D"), SQMOD_ASCII_LOWER_D)
.Const(_SC("LOWER_E"), SQMOD_ASCII_LOWER_E)
.Const(_SC("LOWER_F"), SQMOD_ASCII_LOWER_F)
.Const(_SC("LOWER_G"), SQMOD_ASCII_LOWER_G)
.Const(_SC("LOWER_H"), SQMOD_ASCII_LOWER_H)
.Const(_SC("LOWER_I"), SQMOD_ASCII_LOWER_I)
.Const(_SC("LOWER_J"), SQMOD_ASCII_LOWER_J)
.Const(_SC("LOWER_K"), SQMOD_ASCII_LOWER_K)
.Const(_SC("LOWER_L"), SQMOD_ASCII_LOWER_L)
.Const(_SC("LOWER_M"), SQMOD_ASCII_LOWER_M)
.Const(_SC("LOWER_N"), SQMOD_ASCII_LOWER_N)
.Const(_SC("LOWER_O"), SQMOD_ASCII_LOWER_O)
.Const(_SC("LOWER_P"), SQMOD_ASCII_LOWER_P)
.Const(_SC("LOWER_Q"), SQMOD_ASCII_LOWER_Q)
.Const(_SC("LOWER_R"), SQMOD_ASCII_LOWER_R)
.Const(_SC("LOWER_S"), SQMOD_ASCII_LOWER_S)
.Const(_SC("LOWER_T"), SQMOD_ASCII_LOWER_T)
.Const(_SC("LOWER_U"), SQMOD_ASCII_LOWER_U)
.Const(_SC("LOWER_V"), SQMOD_ASCII_LOWER_V)
.Const(_SC("LOWER_W"), SQMOD_ASCII_LOWER_W)
.Const(_SC("LOWER_X"), SQMOD_ASCII_LOWER_X)
.Const(_SC("LOWER_Y"), SQMOD_ASCII_LOWER_Y)
.Const(_SC("LOWER_Z"), SQMOD_ASCII_LOWER_Z)
.Const(_SC("OPENING_BRACE"), SQMOD_ASCII_OPENING_BRACE)
.Const(_SC("VERTICAL_BAR"), SQMOD_ASCII_VERTICAL_BAR)
.Const(_SC("CLOSING_BRACE"), SQMOD_ASCII_CLOSING_BRACE)
.Const(_SC("TILDE"), SQMOD_ASCII_TILDE)
.Const(_SC("UNDEFINED"), SQMOD_ASCII_UNDEFINED)
);
return true;
}
} // Namespace:: SqMod

14
source/Misc/Constants.hpp Normal file
View File

@ -0,0 +1,14 @@
#ifndef _MISC_CONSTANTS_HPP_
#define _MISC_CONSTANTS_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
} // Namespace:: SqMod
#endif // _MISC_CONSTANTS_HPP_

13
source/Misc/Functions.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Misc/Functions.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_Functions(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

11
source/Misc/Functions.hpp Normal file
View File

@ -0,0 +1,11 @@
#ifndef _MISC_FUNCTIONS_HPP_
#define _MISC_FUNCTIONS_HPP_
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
} // Namespace:: SqMod
#endif // _MISC_FUNCTIONS_HPP_

288
source/Misc/Model.cpp Normal file
View File

@ -0,0 +1,288 @@
#include "Misc/Model.hpp"
#include "Base/Vector3.hpp"
#include "Entity.hpp"
#include "Register.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const CModel CModel::NIL;
// ------------------------------------------------------------------------------------------------
CModel::CModel() noexcept
: m_ID(SQMOD_UNKNOWN), m_Name()
{
}
CModel::CModel(SQInt32 id) noexcept
: m_ID(VALID_ENTITYGETEX(id, Max)), m_Name(GetModelName(id))
{
}
CModel::CModel(const SQChar * name, SQInt32 id) noexcept
: CModel(WeaponToModel(IsWeaponValid(GetWeaponID(name)) ? GetWeaponID(name) : id))
{
}
// ------------------------------------------------------------------------------------------------
CModel::CModel(const CModel & m) noexcept
: m_ID(m.m_ID)
, m_Name(m.m_Name)
, m_Tag(m.m_Tag)
, m_Data(m.m_Data)
{
}
CModel::CModel(CModel && m) noexcept
: m_ID(m.m_ID)
, m_Name(m.m_Name)
, m_Tag(m.m_Tag)
, m_Data(m.m_Data)
{
}
// ------------------------------------------------------------------------------------------------
CModel::~CModel()
{
}
// ------------------------------------------------------------------------------------------------
CModel & CModel::operator = (const CModel & m) noexcept
{
m_ID = m.m_ID;
m_Name = m.m_Name;
m_Tag = m.m_Tag;
m_Data = m.m_Data;
return *this;
}
CModel & CModel::operator = (CModel && m) noexcept
{
m_ID = m.m_ID;
m_Name = m.m_Name;
m_Tag = m.m_Tag;
m_Data = m.m_Data;
return *this;
}
// ------------------------------------------------------------------------------------------------
CModel & CModel::operator = (SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetModelName(id);
m_ID = id;
}
return *this;
}
// ------------------------------------------------------------------------------------------------
bool CModel::operator == (const CModel & m) const noexcept
{
return (m_ID == m.m_ID);
}
bool CModel::operator != (const CModel & m) const noexcept
{
return (m_ID != m.m_ID);
}
bool CModel::operator < (const CModel & m) const noexcept
{
return (m_ID < m.m_ID);
}
bool CModel::operator > (const CModel & m) const noexcept
{
return (m_ID < m.m_ID);
}
bool CModel::operator <= (const CModel & m) const noexcept
{
return (m_ID <= m.m_ID);
}
bool CModel::operator >= (const CModel & m) const noexcept
{
return (m_ID >= m.m_ID);
}
// ------------------------------------------------------------------------------------------------
SQInteger CModel::Cmp(const CModel & m) const noexcept
{
return m_ID == m.m_ID ? 0 : (m_ID > m.m_ID ? 1 : -1);
}
// ------------------------------------------------------------------------------------------------
const SQChar * CModel::ToString() const noexcept
{
return m_Name.c_str();
}
// ------------------------------------------------------------------------------------------------
SQInteger CModel::GetID() const noexcept
{
return m_ID;
}
void CModel::SetID(SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetModelName(id);
m_ID = id;
}
}
// ------------------------------------------------------------------------------------------------
CModel & CModel::SetnGet(SQInt32 id) noexcept
{
if (m_ID != id)
{
m_Name = GetModelName(id);
m_ID = id;
}
return *this;
}
// ------------------------------------------------------------------------------------------------
const SQChar * CModel::GetGlobalTag() const noexcept
{
return GlobalTag(m_ID);
}
void CModel::SetGlobalTag(const SQChar * tag) const noexcept
{
GlobalTag(m_ID, tag);
}
// ------------------------------------------------------------------------------------------------
SqObj & CModel::GetGlobalData() const noexcept
{
return GlobalData(m_ID);
}
void CModel::SetGlobalData(SqObj & data) const noexcept
{
GlobalData(m_ID, data);
}
// ------------------------------------------------------------------------------------------------
const SQChar * CModel::GetLocalTag() const noexcept
{
return m_Tag.c_str();
}
void CModel::SetLocalTag(const SQChar * tag) noexcept
{
m_Tag = tag;
}
// ------------------------------------------------------------------------------------------------
SqObj & CModel::GetLocalData() noexcept
{
return m_Data;
}
void CModel::SetLocalData(SqObj & data) noexcept
{
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CModel::IsValid() const noexcept
{
return (m_ID > 0);
}
// ------------------------------------------------------------------------------------------------
const SQChar * CModel::GetName() const noexcept
{
return m_Name.c_str();
}
// ------------------------------------------------------------------------------------------------
bool CModel::IsWeapon() const noexcept
{
return IsModelWeapon(m_ID);
}
bool CModel::IsActuallyWeapon() const noexcept
{
return IsModelActuallyWeapon(m_ID);
}
// ------------------------------------------------------------------------------------------------
Reference< CObject > CModel::Object(SQInt32 world, const Vector3 & pos, SQInt32 alpha, SQInt32 header, \
const SqObj & payload) const noexcept
{
return _Core->CreateObject(*this, world, pos, alpha, header, payload);
}
Reference< CObject > CModel::Object(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, \
SQInt32 header, const SqObj & payload) const noexcept
{
return _Core->CreateObject(*this, world, Vector3(x, y, z), alpha, header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, const Vector3 & pos, SQInt32 alpha, \
bool automatic, SQInt32 header, const SqObj & payload) const noexcept
{
return _Core->CreatePickup(*this, world, quantity, pos, alpha, automatic, header, payload);
}
Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, SQFloat x, SQFloat y, SQFloat z, \
SQInt32 alpha, bool automatic, SQInt32 header, const SqObj & payload) const noexcept
{
return _Core->CreatePickup(*this, world, quantity, Vector3(x, y, z), alpha, automatic, header, payload);
}
// ================================================================================================
bool Register_CModel(HSQUIRRELVM vm)
{
// Output debugging information
LogDbg("Beginning registration of <CModel> type");
// Attempt to register the specified type
Sqrat::RootTable(vm).Bind(_SC("CModel"), Sqrat::Class< CModel >(vm, _SC("CModel"))
.Ctor()
.Ctor< SQInt32 >()
.Ctor< const SQChar *, SQInt32 >()
.Func(_SC("_cmp"), &CModel::Cmp)
.Func(_SC("_tostring"), &CModel::ToString)
.Prop(_SC("id"), &CModel::GetID, &CModel::SetID)
.Prop(_SC("gtag"), &CModel::GetGlobalTag, &CModel::SetGlobalTag)
.Prop(_SC("gdata"), &CModel::GetGlobalData, &CModel::SetGlobalData)
.Prop(_SC("ltag"), &CModel::GetLocalTag, &CModel::SetLocalTag)
.Prop(_SC("ldata"), &CModel::GetLocalData, &CModel::SetLocalData)
.Prop(_SC("valid"), &CModel::IsValid)
.Prop(_SC("name"), &CModel::GetName)
.Prop(_SC("weapon"), &CModel::IsWeapon)
.Prop(_SC("truly_weapon"), &CModel::IsActuallyWeapon)
.Func(_SC("setng"), &CModel::SetnGet)
.Overload< Reference< CObject > (CModel::*)(SQInt32, const Vector3 &, SQInt32, SQInt32, const SqObj &) const >(_SC("object"), &CModel::Object)
.Overload< Reference< CObject > (CModel::*)(SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, SQInt32, const SqObj &) const >(_SC("object"), &CModel::Object)
.Overload< Reference< CPickup > (CModel::*)(SQInt32, SQInt32, const Vector3 &, SQInt32, bool, SQInt32, const SqObj &) const >(_SC("pickup"), &CModel::Pickup)
.Overload< Reference< CPickup > (CModel::*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool, SQInt32, const SqObj &) const >(_SC("pickup"), &CModel::Pickup)
);
// Output debugging information
LogDbg("Registration of <CModel> type was successful");
// Registration succeeded
return true;
}
} // Namespace:: SqMod

92
source/Misc/Model.hpp Normal file
View File

@ -0,0 +1,92 @@
#ifndef _MISC_MODEL_HPP_
#define _MISC_MODEL_HPP_
// ------------------------------------------------------------------------------------------------
#include "Misc/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
class CModel : public IdentifierStorage< CModel, SQMOD_MODELID_CAP >
{
public:
// --------------------------------------------------------------------------------------------
static const CModel NIL;
// --------------------------------------------------------------------------------------------
CModel() noexcept;
CModel(SQInt32 id) noexcept;
CModel(const SQChar * name, SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CModel(const CModel & m) noexcept;
CModel(CModel && m) noexcept;
// --------------------------------------------------------------------------------------------
~CModel();
// --------------------------------------------------------------------------------------------
CModel & operator = (const CModel & m) noexcept;
CModel & operator = (CModel && m) noexcept;
// --------------------------------------------------------------------------------------------
CModel & operator = (SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const CModel & m) const noexcept;
bool operator != (const CModel & m) const noexcept;
bool operator < (const CModel & m) const noexcept;
bool operator > (const CModel & m) const noexcept;
bool operator <= (const CModel & m) const noexcept;
bool operator >= (const CModel & m) const noexcept;
// --------------------------------------------------------------------------------------------
operator SQInt32 () const noexcept { return m_ID; }
operator bool () const noexcept { return IsModelValid(m_ID); }
// --------------------------------------------------------------------------------------------
bool operator ! () const noexcept { return !IsModelValid(m_ID); }
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const CModel & m) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * ToString() const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger GetID() const noexcept;
void SetID(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CModel & SetnGet(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetGlobalTag() const noexcept;
void SetGlobalTag(const SQChar * tag) const noexcept;
// --------------------------------------------------------------------------------------------
SqObj & GetGlobalData() const noexcept;
void SetGlobalData(SqObj & data) const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetLocalTag() const noexcept;
void SetLocalTag(const SQChar * tag) noexcept;
// --------------------------------------------------------------------------------------------
SqObj & GetLocalData() noexcept;
void SetLocalData(SqObj & data) noexcept;
// --------------------------------------------------------------------------------------------
bool IsValid() const noexcept;
// --------------------------------------------------------------------------------------------
const SQChar * GetName() const noexcept;
// --------------------------------------------------------------------------------------------
bool IsWeapon() const noexcept;
bool IsActuallyWeapon() const noexcept;
// --------------------------------------------------------------------------------------------
Reference< CObject > Object(SQInt32 world, const Vector3 & pos, SQInt32 alpha, SQInt32 header, \
const SqObj & payload) const noexcept;
Reference< CObject > Object(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, \
SQInt32 header, const SqObj & payload) const noexcept;
// --------------------------------------------------------------------------------------------
Reference< CPickup > Pickup(SQInt32 world, SQInt32 quantity, const Vector3 & pos, SQInt32 alpha, \
bool automatic, SQInt32 header, const SqObj & payload) const noexcept;
Reference< CPickup > Pickup(SQInt32 world, SQInt32 quantity, SQFloat x, SQFloat y, SQFloat z, \
SQInt32 alpha, bool automatic, SQInt32 header, const SqObj & payload) const noexcept;
private:
// --------------------------------------------------------------------------------------------
SQInt32 m_ID;
// --------------------------------------------------------------------------------------------
String m_Name;
// --------------------------------------------------------------------------------------------
SqTag m_Tag;
SqObj m_Data;
};
} // Namespace:: SqMod
#endif // _MISC_MODEL_HPP_

View File

@ -0,0 +1,12 @@
#include "Misc/PlayerImmunity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CPlayerImmunity(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

View File

@ -0,0 +1,68 @@
#ifndef _MISC_PLAYER_IMMUNITY_HPP_
#define _MISC_PLAYER_IMMUNITY_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
struct CPlayerImmunity
{
// --------------------------------------------------------------------------------------------
CPlayerImmunity() noexcept;
CPlayerImmunity(SQInt32 flags) noexcept;
// --------------------------------------------------------------------------------------------
CPlayerImmunity(const CPlayerImmunity & x) noexcept;
CPlayerImmunity(CPlayerImmunity && x) noexcept;
// --------------------------------------------------------------------------------------------
~CPlayerImmunity();
// --------------------------------------------------------------------------------------------
CPlayerImmunity & operator = (const CPlayerImmunity & x) noexcept;
CPlayerImmunity & operator = (CPlayerImmunity && x) noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const CPlayerImmunity & x) const noexcept;
bool operator != (const CPlayerImmunity & x) const noexcept;
bool operator < (const CPlayerImmunity & x) const noexcept;
bool operator > (const CPlayerImmunity & x) const noexcept;
bool operator <= (const CPlayerImmunity & x) const noexcept;
bool operator >= (const CPlayerImmunity & x) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const CPlayerImmunity & x) const noexcept;
// --------------------------------------------------------------------------------------------
operator SQInt32 () const noexcept;
operator bool () const noexcept;
// --------------------------------------------------------------------------------------------
SQInt32 GetFlags() const noexcept;
void SetFlags(SQInt32 flags) noexcept;
// --------------------------------------------------------------------------------------------
CPlayerImmunity & SetnGet(SQInt32 flags) noexcept;
// --------------------------------------------------------------------------------------------
void Apply(const CPlayer & player) const noexcept;
// --------------------------------------------------------------------------------------------
bool GetBullet() const noexcept;
void SetBullet(bool toggle) noexcept;
// --------------------------------------------------------------------------------------------
bool GetFire() const noexcept;
void SetFire(bool toggle) noexcept;
// --------------------------------------------------------------------------------------------
bool GetExplosion() const noexcept;
void SetExplosion(bool toggle) noexcept;
// --------------------------------------------------------------------------------------------
bool GetCollision() const noexcept;
void SetCollision(bool toggle) noexcept;
// --------------------------------------------------------------------------------------------
bool GetMelee() const noexcept;
void SetMelee(bool toggle) noexcept;
// --------------------------------------------------------------------------------------------
void EnableAll() noexcept;
void DisableAll() noexcept;
protected:
// --------------------------------------------------------------------------------------------
SQInt32 m_Flags;
};
} // Namespace:: SqMod
#endif // _MISC_PLAYER_IMMUNITY_HPP_

12
source/Misc/Radio.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "Misc/Radio.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Register_CRadio(HSQUIRRELVM vm)
{
return true;
}
} // Namespace:: SqMod

56
source/Misc/Radio.hpp Normal file
View File

@ -0,0 +1,56 @@
#ifndef _MISC_RADIO_HPP_
#define _MISC_RADIO_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
class CRadio
{
public:
// --------------------------------------------------------------------------------------------
CRadio() noexcept;
CRadio(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CRadio(const CRadio & x) noexcept;
CRadio(CRadio && x) noexcept;
// --------------------------------------------------------------------------------------------
~CRadio();
// --------------------------------------------------------------------------------------------
CRadio & operator= (const CRadio & x) noexcept;
CRadio & operator= (CRadio && x) noexcept;
// --------------------------------------------------------------------------------------------
CRadio operator+ (const CRadio & x) const noexcept;
CRadio operator- (const CRadio & x) const noexcept;
CRadio operator* (const CRadio & x) const noexcept;
CRadio operator/ (const CRadio & x) const noexcept;
// --------------------------------------------------------------------------------------------
bool operator == (const CRadio & x) const noexcept;
bool operator != (const CRadio & x) const noexcept;
bool operator < (const CRadio & x) const noexcept;
bool operator > (const CRadio & x) const noexcept;
bool operator <= (const CRadio & x) const noexcept;
bool operator >= (const CRadio & x) const noexcept;
// --------------------------------------------------------------------------------------------
SQInteger Cmp(const CRadio & x) const noexcept;
// --------------------------------------------------------------------------------------------
operator SQInt32 () const noexcept;
operator bool () const noexcept;
// --------------------------------------------------------------------------------------------
SQInt32 GetID() const noexcept;
void SetID(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
CRadio & SetnGet(SQInt32 id) noexcept;
// --------------------------------------------------------------------------------------------
void Apply(const CVehicle & vehicle) const noexcept;
protected:
// --------------------------------------------------------------------------------------------
SQInt32 m_ID;
};
} // Namespace:: SqMod
#endif // _MISC_RADIO_HPP_

2482
source/Misc/Shared.cpp Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More