1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2026-07-09 01:57:09 +02:00

Migrated the host module to C++ exceptions as well.

Also enabled the latest C++ revision in the project.
Replaced the Random library with the one provided by C++11.
Implemented a simple AES256 encryption class.
Various other fixes and improvements.
This commit is contained in:
Sandu Liviu Catalin
2016-03-10 05:57:13 +02:00
parent 3162221e7f
commit 70e5f0ba21
124 changed files with 14873 additions and 14062 deletions
+19 -38
View File
@@ -14,6 +14,14 @@ const Sphere Sphere::MAX = Sphere(NumLimit< Sphere::Value >::Max);
// ------------------------------------------------------------------------------------------------
SQChar Sphere::Delim = ',';
// ------------------------------------------------------------------------------------------------
SQInteger Sphere::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("Sphere");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
Sphere::Sphere()
: pos(0.0), rad(0.0)
@@ -42,27 +50,6 @@ Sphere::Sphere(Value xv, Value yv, Value zv, Value rv)
/* ... */
}
// ------------------------------------------------------------------------------------------------
Sphere::Sphere(const Sphere & o)
: pos(o.pos), rad(o.rad)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Sphere::~Sphere()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator = (const Sphere & o)
{
pos = o.pos;
rad = o.rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Sphere & Sphere::operator = (Value r)
{
@@ -341,7 +328,7 @@ Int32 Sphere::Cmp(const Sphere & o) const
// ------------------------------------------------------------------------------------------------
CSStr Sphere::ToString() const
{
return ToStringF("%f,%f,%f,%f", pos.x, pos.y, pos.z, rad);
return ToStrF("%f,%f,%f,%f", pos.x, pos.y, pos.z, rad);
}
// ------------------------------------------------------------------------------------------------
@@ -395,35 +382,28 @@ void Sphere::Generate()
void Sphere::Generate(Value min, Value max, bool r)
{
if (EpsLt(max, min))
{
SqThrow("max value is lower than min value");
}
SqThrowF("max value is lower than min value");
else if (r)
{
rad = GetRandomFloat32(min, max);
}
else
{
pos.Generate(min, max);
}
}
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
{
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
SqThrowF("max value is lower than min value");
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)
{
if (EpsLt(rmax, rmin))
{
SqThrow("max value is lower than min value");
}
else
{
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
rad = GetRandomFloat32(rmin, rmax);
}
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(rmax, rmin))
SqThrowF("max value is lower than min value");
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax);
rad = GetRandomFloat32(rmin, rmax);
}
// ------------------------------------------------------------------------------------------------
@@ -452,6 +432,7 @@ void Register_Sphere(HSQUIRRELVM vm)
.Prop(_SC("abs"), &Sphere::Abs)
/* Core Metamethods */
.Func(_SC("_tostring"), &Sphere::ToString)
.SquirrelFunc(_SC("_typename"), &Sphere::Typename)
.Func(_SC("_cmp"), &Sphere::Cmp)
/* Metamethods */
.Func<Sphere (Sphere::*)(const Sphere &) const>(_SC("_add"), &Sphere::operator +)