1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-20 17:17:13 +02:00

Initial implementation of the new event system.

Initial implementation of the new signals and slots class.
Fixed command parsing which compared a pointer to a character.
Buffer overflow fix in routines which used the limits from the entity tasks.
Switched from Sqrat::Object to Sqrat::LightObj in most places to avoid the overhead of the VM pointer.
Various other adjustments and improvements.
The plugin is currently in a broken state and crashes at shutdown. The bug is unknown at this point.
This commit is contained in:
Sandu Liviu Catalin
2017-02-21 21:24:59 +02:00
parent 178b30bb20
commit 41e04e5167
39 changed files with 4859 additions and 3992 deletions

View File

@ -108,6 +108,11 @@ bool SToB(CSStr str);
*/
Object & NullObject();
/* ------------------------------------------------------------------------------------------------
* Retrieve a reference to a null script object.
*/
LightObj & NullLightObj();
/* ------------------------------------------------------------------------------------------------
* Retrieve a reference to a null/empty script table.
*/
@ -1303,83 +1308,6 @@ typedef BitGuard< Uint8 > BitGuardU8;
typedef BitGuard< Uint16 > BitGuardU16;
typedef BitGuard< Uint32 > BitGuardU32;
/* ------------------------------------------------------------------------------------------------
* RAII approach to make sure an instance is deleted regardless of what exceptions are thrown.
*/
template < typename T > struct DeleteGuard
{
private:
// --------------------------------------------------------------------------------------------
T * m_Ptr; // Pointer to the instance to manage.
public:
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
DeleteGuard(T * ptr)
: m_Ptr(ptr)
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
DeleteGuard(const DeleteGuard & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
DeleteGuard(DeleteGuard && o) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~DeleteGuard()
{
if (m_Ptr)
{
delete m_Ptr;
}
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
DeleteGuard & operator = (const DeleteGuard & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
DeleteGuard & operator = (DeleteGuard && o) = delete;
/* --------------------------------------------------------------------------------------------
* Implicit conversion the managed instance type.
*/
operator T * () const
{
return m_Ptr;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the managed instance.
*/
T * Get() const
{
return m_Ptr;
}
/* --------------------------------------------------------------------------------------------
* Release the managed instance.
*/
void Release()
{
m_Ptr = nullptr;
}
};
/* ------------------------------------------------------------------------------------------------
* RAII approach to make sure a value is assigned regardless of what exceptions are thrown.
*/

View File

@ -235,6 +235,14 @@ Object & NullObject()
return o;
}
// ------------------------------------------------------------------------------------------------
LightObj & NullLightObj()
{
static LightObj o;
o.Release();
return o;
}
// ------------------------------------------------------------------------------------------------
Table & NullTable()
{