mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-07-01 06:27:11 +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:
@ -8,7 +8,7 @@
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Manages Blip instances.
|
||||
* Manages a single blip entity.
|
||||
*/
|
||||
class CBlip
|
||||
{
|
||||
@ -17,20 +17,19 @@ class CBlip
|
||||
|
||||
private:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Cached identifiers for fast integer to string conversion.
|
||||
*/
|
||||
static SQChar s_StrID[SQMOD_BLIP_POOL][8];
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Identifier of the managed entity.
|
||||
*/
|
||||
Int32 m_ID;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* User tag and data associated with this instance.
|
||||
* User tag associated with this instance.
|
||||
*/
|
||||
String m_Tag;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* User data associated with this instance.
|
||||
*/
|
||||
Object m_Data;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -38,20 +37,22 @@ private:
|
||||
*/
|
||||
CBlip(Int32 id);
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Maximum possible number that could represent an identifier for this entity type.
|
||||
*/
|
||||
static const Int32 Max;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
CBlip(const CBlip &);
|
||||
CBlip(const CBlip &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
CBlip & operator = (const CBlip &);
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static const Int32 Max;
|
||||
CBlip(CBlip &&) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -59,14 +60,22 @@ public:
|
||||
~CBlip();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether this instance manages a valid entity.
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
bool Validate() const
|
||||
CBlip & operator = (const CBlip &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
CBlip & operator = (CBlip &&) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether this instance manages a valid entity otherwise throw an exception.
|
||||
*/
|
||||
void Validate() const
|
||||
{
|
||||
if (VALID_ENTITY(m_ID))
|
||||
return true;
|
||||
SqThrow("Invalid blip reference [%s]", m_Tag.c_str());
|
||||
return false;
|
||||
if (INVALID_ENTITY(m_ID))
|
||||
SqThrowF("Invalid blip reference [%s]", m_Tag.c_str());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -77,27 +86,33 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to convert an instance of this type to a string.
|
||||
*/
|
||||
CSStr ToString() const;
|
||||
const String & ToString() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the entity managed by this instance.
|
||||
*/
|
||||
Int32 GetID() const { return m_ID; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the maximum possible identifier to an entity of this type.
|
||||
*/
|
||||
Int32 GetMaxID() const { return SQMOD_BLIP_POOL; }
|
||||
Int32 GetID() const
|
||||
{
|
||||
return m_ID;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether this instance manages a valid entity.
|
||||
*/
|
||||
bool IsActive() const { return VALID_ENTITY(m_ID); }
|
||||
bool IsActive() const
|
||||
{
|
||||
return VALID_ENTITY(m_ID);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated user tag.
|
||||
*/
|
||||
CSStr GetTag() const;
|
||||
const String & GetTag() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the associated user tag.
|
||||
@ -115,29 +130,89 @@ public:
|
||||
void SetData(Object & data);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destroy the managed entity instance.
|
||||
* Destroy the managed blip entity.
|
||||
*/
|
||||
bool Destroy()
|
||||
{
|
||||
return Destroy(0, NullObject());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destroy the managed blip entity.
|
||||
*/
|
||||
bool Destroy(Int32 header)
|
||||
{
|
||||
return Destroy(header, NullObject());
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destroy the managed blip entity.
|
||||
*/
|
||||
bool Destroy(Int32 header, Object & payload);
|
||||
bool Destroy() { return Destroy(0, NullObject()); }
|
||||
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
bool BindEvent(Int32 evid, Object & env, Function & func) const;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Bind to an event supported by this entity type.
|
||||
*/
|
||||
void BindEvent(Int32 evid, Object & env, Function & func) const;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the world in which the referenced blip entity exists.
|
||||
*/
|
||||
Int32 GetWorld() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the scale of the managed blip entity.
|
||||
*/
|
||||
Int32 GetScale() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position of the managed blip entity.
|
||||
*/
|
||||
const Vector3 & GetPosition() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the color of the managed blip entity.
|
||||
*/
|
||||
const Color4 & GetColor() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the identifier of the sprite used by the managed blip entity.
|
||||
*/
|
||||
Int32 GetSprID() const;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position on the x axis of the managed blip entity.
|
||||
*/
|
||||
Float32 GetPosX() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position on the y axis of the managed blip entity.
|
||||
*/
|
||||
Float32 GetPosY() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position on the z axis of the managed blip entity.
|
||||
*/
|
||||
Float32 GetPosZ() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the red color of the managed blip entity.
|
||||
*/
|
||||
Int32 GetColorR() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the green color of the managed blip entity.
|
||||
*/
|
||||
Int32 GetColorG() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the blue color of the managed blip entity.
|
||||
*/
|
||||
Int32 GetColorB() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the alpha transparency of the managed blip entity.
|
||||
*/
|
||||
Int32 GetColorA() const;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user