mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Updated the global event type and it's filters to used the new debugging system.
This commit is contained in:
parent
8061c485fc
commit
77b00ef97d
@ -49,7 +49,7 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended)
|
||||
, m_Vehicles(this)
|
||||
{
|
||||
// Attach to the specified event signal
|
||||
Attach();
|
||||
Attach("constructor");
|
||||
// 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! */
|
||||
@ -59,7 +59,7 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended)
|
||||
GlobalEvent::~GlobalEvent()
|
||||
{
|
||||
// Detach from the specified event signal
|
||||
Detach();
|
||||
Detach("destructor");
|
||||
// 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! */
|
||||
@ -171,18 +171,19 @@ void GlobalEvent::SetType(SQInt32 type)
|
||||
// Make sure the newly specified event is compatible
|
||||
if (!Compatible(type))
|
||||
{
|
||||
LogErr("Cannot change the event to an incompatible type: %s", GetEventName(type));
|
||||
DbgErr("GlobalEvent", "@type", "Cannot change the event to an incompatible type: %s",
|
||||
GetEventName(type));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear anything that cannot adapt to the new event type
|
||||
Adaptable(type);
|
||||
// Detach from the current event type
|
||||
Detach();
|
||||
Detach("@type");
|
||||
// Set the new event type
|
||||
m_Type = type;
|
||||
// Attach to the new event type
|
||||
Attach();
|
||||
Attach("@type");
|
||||
/* We don't need to hook back filters that could adapt because they're already hooked! */
|
||||
}
|
||||
}
|
||||
@ -1416,7 +1417,7 @@ bool GlobalEvent::Trigger()
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void GlobalEvent::Attach()
|
||||
void GlobalEvent::Attach(const char * func)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
@ -1673,12 +1674,13 @@ void GlobalEvent::Attach()
|
||||
_Core->SphereExited.Connect< GlobalEvent, &GlobalEvent::SphereExited >(this);
|
||||
break;
|
||||
default:
|
||||
LogErr("Attempting to <attach> to an unknown event type: %d", _SCI32(m_Type));
|
||||
DbgErr("GlobalEvent", func, "Attempting to <attach event> to an unknown type: %d",
|
||||
_SCI32(m_Type));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void GlobalEvent::Detach()
|
||||
void GlobalEvent::Detach(const char * func)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
@ -1935,7 +1937,8 @@ void GlobalEvent::Detach()
|
||||
_Core->SphereExited.Disconnect< GlobalEvent, &GlobalEvent::SphereExited >(this);
|
||||
break;
|
||||
default:
|
||||
LogErr("Attempting to <detach> from an unknown event type: %d", _SCI32(m_Type));
|
||||
DbgErr("GlobalEvent", func, "Attempting to <dettach event> from an unknown type: %d",
|
||||
_SCI32(m_Type));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,8 +161,9 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWrn("Cannot test whether a <%s> entity is filtered or not using an invalid instance: %d", \
|
||||
EntType::Name, _SCI32(ent));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "enabled",
|
||||
"Attempting to <see whether entity is filtered> using an invalid reference: %d", \
|
||||
_SCI32(ent));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1045,12 +1046,12 @@ protected:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
void Attach();
|
||||
void Attach(const char * func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
void Detach();
|
||||
void Detach(const char * func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
@ -1135,14 +1136,15 @@ template < class T > bool GlobalFilter< T >::Include(const RefType & ent, SQInt3
|
||||
// Make sure the entity is valid before we proceed
|
||||
if (!ent)
|
||||
{
|
||||
LogErr("Attempting to <filter %s events> using an invalid entity instance: %d", \
|
||||
EntType::Name, _SCI32(ent));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include",
|
||||
"Attempting to <filter events> using an invalid reference: %d", _SCI32(ent));
|
||||
}
|
||||
// Make sure the entity type is allowed for this event type
|
||||
else if (!EntType::InEvent(m_Event->m_Type))
|
||||
{
|
||||
LogErr("Attempting to <filter %s events> using an incompatible event type: %s", \
|
||||
EntType::Name, GetEventName(m_Event->m_Type));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include",
|
||||
"Attempting to <filter events> for an incompatible event type: %s",
|
||||
GetEventName(m_Event->m_Type));
|
||||
}
|
||||
// Make sure the entity is not already included in the filter
|
||||
else if (!m_Filter[_SCU32(ent)])
|
||||
@ -1181,14 +1183,15 @@ template < class T > bool GlobalFilter< T >::Exclude(const RefType & ent, SQInt3
|
||||
// Make sure the entity is valid before we proceed
|
||||
if (!ent)
|
||||
{
|
||||
LogErr("Attempting to <unfilter %s events> using an invalid entity instance: %d", \
|
||||
EntType::Name, _SCI32(ent));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude",
|
||||
"Attempting to <unfilter events> using an invalid reference: %d", _SCI32(ent));
|
||||
}
|
||||
// Make sure the entity type is allowed for this event type
|
||||
else if (!EntType::InEvent(m_Event->m_Type))
|
||||
{
|
||||
LogErr("Attempting to <unfilter %s events> using an incompatible event type: %s", \
|
||||
EntType::Name, GetEventName(m_Event->m_Type));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude",
|
||||
"Attempting to <filter events> for an incompatible event type: %s",
|
||||
GetEventName(m_Event->m_Type));
|
||||
}
|
||||
// Make sure the entity is not already excluded fom the filter
|
||||
else if (m_Filter[_SCU32(ent)])
|
||||
@ -1227,8 +1230,9 @@ template < class T > void GlobalFilter< T >::Clear(SQInt32 header)
|
||||
// Make sure the filter is compatible with the specified event type
|
||||
if (!EntType::InEvent(m_Event->m_Type))
|
||||
{
|
||||
LogWrn("Attempting to <clear %s filter> using an incompatible event type: %s", \
|
||||
EntType::Name, GetEventName(m_Event->m_Type));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "clear",
|
||||
"Attempting to <clear filter> for an incompatible event type: %s",
|
||||
GetEventName(m_Event->m_Type));
|
||||
}
|
||||
// Don't even attempt to clear if there's nothing to be cleared
|
||||
else if (m_Filter.any())
|
||||
@ -1243,6 +1247,7 @@ template < class T > void GlobalFilter< T >::Clear(SQInt32 header)
|
||||
// Now it's safe to reset the filter
|
||||
m_Filter.reset();
|
||||
}
|
||||
|
||||
SQMOD_UNUSED_VAR(header);
|
||||
}
|
||||
|
||||
@ -1252,8 +1257,9 @@ template < class T > void GlobalFilter< T >::Flip(SQInt32 header)
|
||||
// Make sure the filter is compatible with the parent event type
|
||||
if (!EntType::InEvent(m_Event->m_Type))
|
||||
{
|
||||
LogWrn("Attempting to <flip %s filter> using an incompatible event type: %s", \
|
||||
EntType::Name, GetEventName(m_Event->m_Type));
|
||||
DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "flip",
|
||||
"Attempting to <flip filter> for an incompatible event type: %s",
|
||||
GetEventName(m_Event->m_Type));
|
||||
}
|
||||
// Now it's safe to proceed with reversing the filters
|
||||
else
|
||||
@ -1265,6 +1271,7 @@ template < class T > void GlobalFilter< T >::Flip(SQInt32 header)
|
||||
// Hook from the newly filtered entities
|
||||
Hook();
|
||||
}
|
||||
|
||||
SQMOD_UNUSED_VAR(header);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user