mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-20 17:17:13 +02:00
Various.
This commit is contained in:
@ -34,12 +34,16 @@ BasicEvent::BasicEvent(SQInt32 type, bool suspended) noexcept
|
||||
, m_Suspended(suspended)
|
||||
{
|
||||
Attach();
|
||||
// Receive notification when the VM is about to be closed to release object references
|
||||
_Core->VMClose.Connect< BasicEvent, &BasicEvent::VMClose >(this);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
BasicEvent::~BasicEvent()
|
||||
{
|
||||
Detach();
|
||||
// Stop receiving notification when the VM is about to be closed
|
||||
_Core->VMClose.Disconnect< BasicEvent, &BasicEvent::VMClose >(this);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -1901,6 +1905,23 @@ void BasicEvent::Detach() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BasicEvent::VMClose() noexcept
|
||||
{
|
||||
LogInf("[BasicEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
|
||||
// Release the reference to the specified callback
|
||||
m_OnTrigger.Release();
|
||||
|
||||
LogInf("]BasicEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
bool Register_BasicEvent(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -1911,8 +1932,8 @@ bool Register_BasicEvent(HSQUIRRELVM vm)
|
||||
// Attempt to register the specified type
|
||||
Sqrat::RootTable(vm).Bind(_SC("BasicEvent"), Sqrat::Class< BasicEvent, Allocator >(vm, _SC("BasicEvent"))
|
||||
.Ctor()
|
||||
.Ctor<SQInt32>()
|
||||
.Ctor<SQInt32, bool>()
|
||||
.Ctor< SQInt32 >()
|
||||
.Ctor< SQInt32, bool >()
|
||||
|
||||
.Func(_SC("_cmp"), &BasicEvent::Cmp)
|
||||
.Func(_SC("_tostring"), &BasicEvent::GetName)
|
||||
|
@ -757,6 +757,11 @@ public:
|
||||
*/
|
||||
void LogMessage(SQInt32 type, const SQChar * message) noexcept;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
void VMClose() noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
|
@ -50,6 +50,8 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended) noexcept
|
||||
{
|
||||
// Attach to the specified event signal
|
||||
Attach();
|
||||
// Receive notification when the VM is about to be closed to release object references
|
||||
_Core->VMClose.Connect< GlobalEvent, &GlobalEvent::VMClose >(this);
|
||||
/* Entity filters are empty so there's nothing to hook to! */
|
||||
}
|
||||
|
||||
@ -58,6 +60,8 @@ GlobalEvent::~GlobalEvent()
|
||||
{
|
||||
// Detach from the specified event signal
|
||||
Detach();
|
||||
// Stop receiving notification when the VM is about to be closed
|
||||
_Core->VMClose.Disconnect< GlobalEvent, &GlobalEvent::VMClose >(this);
|
||||
/* We're expecting the entity filters to unhook themselves from the destroy signal! */
|
||||
}
|
||||
|
||||
@ -2059,6 +2063,23 @@ void GlobalEvent::Adaptable(SQInt32 type) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void GlobalEvent::VMClose() noexcept
|
||||
{
|
||||
LogInf("[GlobalEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
|
||||
// Release the reference to the specified callback
|
||||
m_OnTrigger.Release();
|
||||
|
||||
LogInf("]GlobalEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
template < class T > static bool Register_GlobalFilter(HSQUIRRELVM vm, const SQChar * cname)
|
||||
{
|
||||
@ -2093,6 +2114,7 @@ template < class T > static bool Register_GlobalFilter(HSQUIRRELVM vm, const SQC
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_GlobalEvent(HSQUIRRELVM vm)
|
||||
{
|
||||
// Register dependencies
|
||||
|
@ -1005,6 +1005,11 @@ public:
|
||||
*/
|
||||
void SphereExited(SQInt32 player, SQInt32 sphere) noexcept;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
void VMClose() noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
|
@ -48,6 +48,8 @@ LocalEvent::LocalEvent(SQInt32 type, bool suspended) noexcept
|
||||
, m_Textdraws(this)
|
||||
, m_Vehicles(this)
|
||||
{
|
||||
// Receive notification when the VM is about to be closed to release object references
|
||||
_Core->VMClose.Connect< LocalEvent, &LocalEvent::VMClose >(this);
|
||||
/* Entity filters are empty so there's nothing to hook right now! */
|
||||
}
|
||||
|
||||
@ -56,6 +58,8 @@ LocalEvent::~LocalEvent()
|
||||
{
|
||||
// Detach from all attached signals
|
||||
Detach();
|
||||
// Stop receiving notification when the VM is about to be closed
|
||||
_Core->VMClose.Disconnect< LocalEvent, &LocalEvent::VMClose >(this);
|
||||
/* The entity filters should to unhook themselves from the destroy signal! */
|
||||
}
|
||||
|
||||
@ -254,7 +258,7 @@ void LocalEvent::SetInversed(bool toggle) noexcept
|
||||
// Toggle the inversed option
|
||||
m_Inversed = toggle;
|
||||
// Attach back to the new event type
|
||||
Attach();
|
||||
Attach();
|
||||
}
|
||||
// Just set the option to what was requested
|
||||
else
|
||||
@ -2202,6 +2206,23 @@ void LocalEvent::Adaptable(SQInt32 type, bool inversed) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void LocalEvent::VMClose() noexcept
|
||||
{
|
||||
LogInf("[LocalEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
|
||||
// Release the reference to the specified callback
|
||||
m_OnTrigger.Release();
|
||||
|
||||
LogInf("]LocalEvent::VMClose() %d %d",
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetEnv()),
|
||||
sq_getrefcount(m_OnTrigger.GetVM(), &m_OnTrigger.GetFunc())
|
||||
);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
template < class T > static bool Register_LocalFilter(HSQUIRRELVM vm, const SQChar * cname)
|
||||
{
|
||||
@ -2236,6 +2257,7 @@ template < class T > static bool Register_LocalFilter(HSQUIRRELVM vm, const SQCh
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_LocalEvent(HSQUIRRELVM vm)
|
||||
{
|
||||
// Register dependencies
|
||||
|
@ -1005,6 +1005,11 @@ public:
|
||||
*/
|
||||
void SphereExited(SQInt32 player, SQInt32 sphere) noexcept;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
void VMClose() noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user