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:
+89
-74
@@ -9,355 +9,370 @@
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Class used to represent a two-dimensional circle.
|
||||
*/
|
||||
struct Circle
|
||||
{
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* The type of value used by components of type.
|
||||
*/
|
||||
typedef float Value;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Helper instances for common values mostly used as return types or comparison.
|
||||
*/
|
||||
static const Circle NIL;
|
||||
static const Circle MIN;
|
||||
static const Circle MAX;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* The delimiter character to be used when extracting values from strings.
|
||||
*/
|
||||
static SQChar Delim;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* The position and radius components of this type.
|
||||
*/
|
||||
Vector2 pos;
|
||||
Value rad;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Default constructor.
|
||||
*/
|
||||
Circle();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Construct a circle at position 0,0 using the specified radius.
|
||||
*/
|
||||
Circle(Value rv);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Construct a circle at the specified position using the specified radius.
|
||||
*/
|
||||
Circle(const Vector2 & pv, Value rv);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Construct a circle at the specified position using the specified radius.
|
||||
*/
|
||||
Circle(Value xv, Value yv, Value rv);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Copy constructor.
|
||||
*/
|
||||
Circle(const Circle & o);
|
||||
Circle(const Circle & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Move constructor.
|
||||
*/
|
||||
~Circle();
|
||||
Circle(Circle && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Destructor.
|
||||
*/
|
||||
Circle & operator = (const Circle & o);
|
||||
~Circle() = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Copy assignment operator.
|
||||
*/
|
||||
Circle & operator = (const Circle & o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Circle & operator = (Circle && o) = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Radius assignment operator.
|
||||
*/
|
||||
Circle & operator = (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position assignment operator.
|
||||
*/
|
||||
Circle & operator = (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Addition assignment operator.
|
||||
*/
|
||||
Circle & operator += (const Circle & c);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Subtraction assignment operator.
|
||||
*/
|
||||
Circle & operator -= (const Circle & c);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Multiplication assignment operator.
|
||||
*/
|
||||
Circle & operator *= (const Circle & c);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Division assignment operator.
|
||||
*/
|
||||
Circle & operator /= (const Circle & c);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Modulo assignment operator.
|
||||
*/
|
||||
Circle & operator %= (const Circle & c);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius addition assignment operator.
|
||||
*/
|
||||
Circle & operator += (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius subtraction assignment operator.
|
||||
*/
|
||||
Circle & operator -= (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius multiplication assignment operator.
|
||||
*/
|
||||
Circle & operator *= (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius division assignment operator.
|
||||
*/
|
||||
Circle & operator /= (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius modulo assignment operator.
|
||||
*/
|
||||
Circle & operator %= (Value r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position addition assignment operator.
|
||||
*/
|
||||
Circle & operator += (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position subtraction assignment operator.
|
||||
*/
|
||||
Circle & operator -= (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position multiplication assignment operator.
|
||||
*/
|
||||
Circle & operator *= (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position division assignment operator.
|
||||
*/
|
||||
Circle & operator /= (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position modulo assignment operator.
|
||||
*/
|
||||
Circle & operator %= (const Vector2 & p);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Pre-increment operator.
|
||||
*/
|
||||
Circle & operator ++ ();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Pre-decrement operator.
|
||||
*/
|
||||
Circle & operator -- ();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Post-increment operator.
|
||||
*/
|
||||
Circle operator ++ (int);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Post-decrement operator.
|
||||
*/
|
||||
Circle operator -- (int);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Addition operator.
|
||||
*/
|
||||
Circle operator + (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Subtraction operator.
|
||||
*/
|
||||
Circle operator - (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Multiplication operator.
|
||||
*/
|
||||
Circle operator * (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Division operator.
|
||||
*/
|
||||
Circle operator / (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Modulo operator.
|
||||
*/
|
||||
Circle operator % (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius addition operator.
|
||||
*/
|
||||
Circle operator + (Value r) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius subtraction operator.
|
||||
*/
|
||||
Circle operator - (Value r) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius multiplication operator.
|
||||
*/
|
||||
Circle operator * (Value r) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius division operator.
|
||||
*/
|
||||
Circle operator / (Value r) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Radius modulo operator.
|
||||
*/
|
||||
Circle operator % (Value r) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position addition operator.
|
||||
*/
|
||||
Circle operator + (const Vector2 & p) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position subtraction operator.
|
||||
*/
|
||||
Circle operator - (const Vector2 & p) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position multiplication operator.
|
||||
*/
|
||||
Circle operator * (const Vector2 & p) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position division operator.
|
||||
*/
|
||||
Circle operator / (const Vector2 & p) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Position modulo operator.
|
||||
*/
|
||||
Circle operator % (const Vector2 & p) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Unary plus operator.
|
||||
*/
|
||||
Circle operator + () const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Unary minus operator.
|
||||
*/
|
||||
Circle operator - () const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Equality comparison operator.
|
||||
*/
|
||||
bool operator == (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Inequality comparison operator.
|
||||
*/
|
||||
bool operator != (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Less than comparison operator.
|
||||
*/
|
||||
bool operator < (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Greater than comparison operator.
|
||||
*/
|
||||
bool operator > (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Less than or equal comparison operator.
|
||||
*/
|
||||
bool operator <= (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Greater than or equal comparison operator.
|
||||
*/
|
||||
bool operator >= (const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Used by the script engine to compare two instances of this type.
|
||||
*/
|
||||
Int32 Cmp(const Circle & c) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set the specified radius.
|
||||
*/
|
||||
void Set(Value nr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Copy the circle from another instance of this type.
|
||||
*/
|
||||
void Set(const Circle & nc);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Set the position from the specified position.
|
||||
*/
|
||||
void Set(const Vector2 & np);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Set the specified position and radius.
|
||||
*/
|
||||
void Set(const Vector2 & np, Value nr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Set the specified position.
|
||||
*/
|
||||
void Set(Value nx, Value ny);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Set the specified position and radius.
|
||||
*/
|
||||
void Set(Value nx, Value ny, Value nr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Set the values extracted from the specified string using the specified delimiter.
|
||||
*/
|
||||
void Set(CSStr values, SQChar delim);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Generate a randomly sized and positioned circle.
|
||||
*/
|
||||
void Generate();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Generate a randomly sized or positioned circle within the specified bounds.
|
||||
*/
|
||||
void Generate(Value min, Value max, bool r);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Generate a randomly positioned circle within the specified bounds.
|
||||
*/
|
||||
void Generate(Value xmin, Value xmax, Value ymin, Value ymax);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Generate a randomly sized and positioned circle within the specified bounds.
|
||||
*/
|
||||
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Clear the component values to default.
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
@@ -365,7 +380,7 @@ struct Circle
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
* Retrieve a new instance of this type with absolute component values.
|
||||
*/
|
||||
Circle Abs() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user