1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-18 19:47:15 +01:00

Updated the global event type and it's filters to used the new debugging system.

This commit is contained in:
Sandu Liviu Catalin 2015-11-11 12:14:38 +02:00
parent 8061c485fc
commit 77b00ef97d
2 changed files with 35 additions and 25 deletions

View File

@ -49,7 +49,7 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended)
, m_Vehicles(this) , m_Vehicles(this)
{ {
// Attach to the specified event signal // Attach to the specified event signal
Attach(); Attach("constructor");
// Receive notification when the VM is about to be closed to release object references // Receive notification when the VM is about to be closed to release object references
_Core->VMClose.Connect< GlobalEvent, &GlobalEvent::VMClose >(this); _Core->VMClose.Connect< GlobalEvent, &GlobalEvent::VMClose >(this);
/* Entity filters are empty so there's nothing to hook to! */ /* Entity filters are empty so there's nothing to hook to! */
@ -59,7 +59,7 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended)
GlobalEvent::~GlobalEvent() GlobalEvent::~GlobalEvent()
{ {
// Detach from the specified event signal // Detach from the specified event signal
Detach(); Detach("destructor");
// Stop receiving notification when the VM is about to be closed // Stop receiving notification when the VM is about to be closed
_Core->VMClose.Disconnect< GlobalEvent, &GlobalEvent::VMClose >(this); _Core->VMClose.Disconnect< GlobalEvent, &GlobalEvent::VMClose >(this);
/* We're expecting the entity filters to unhook themselves from the destroy signal! */ /* 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 // Make sure the newly specified event is compatible
if (!Compatible(type)) 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 else
{ {
// Clear anything that cannot adapt to the new event type // Clear anything that cannot adapt to the new event type
Adaptable(type); Adaptable(type);
// Detach from the current event type // Detach from the current event type
Detach(); Detach("@type");
// Set the new event type // Set the new event type
m_Type = type; m_Type = type;
// Attach to the new event 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! */ /* 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) switch (m_Type)
{ {
@ -1673,12 +1674,13 @@ void GlobalEvent::Attach()
_Core->SphereExited.Connect< GlobalEvent, &GlobalEvent::SphereExited >(this); _Core->SphereExited.Connect< GlobalEvent, &GlobalEvent::SphereExited >(this);
break; break;
default: 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) switch (m_Type)
{ {
@ -1935,7 +1937,8 @@ void GlobalEvent::Detach()
_Core->SphereExited.Disconnect< GlobalEvent, &GlobalEvent::SphereExited >(this); _Core->SphereExited.Disconnect< GlobalEvent, &GlobalEvent::SphereExited >(this);
break; break;
default: 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));
} }
} }

View File

@ -161,8 +161,9 @@ public:
} }
else else
{ {
LogWrn("Cannot test whether a <%s> entity is filtered or not using an invalid instance: %d", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "enabled",
EntType::Name, _SCI32(ent)); "Attempting to <see whether entity is filtered> using an invalid reference: %d", \
_SCI32(ent));
} }
return false; 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 // Make sure the entity is valid before we proceed
if (!ent) if (!ent)
{ {
LogErr("Attempting to <filter %s events> using an invalid entity instance: %d", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include",
EntType::Name, _SCI32(ent)); "Attempting to <filter events> using an invalid reference: %d", _SCI32(ent));
} }
// Make sure the entity type is allowed for this event type // Make sure the entity type is allowed for this event type
else if (!EntType::InEvent(m_Event->m_Type)) else if (!EntType::InEvent(m_Event->m_Type))
{ {
LogErr("Attempting to <filter %s events> using an incompatible event type: %s", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include",
EntType::Name, GetEventName(m_Event->m_Type)); "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 // Make sure the entity is not already included in the filter
else if (!m_Filter[_SCU32(ent)]) 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 // Make sure the entity is valid before we proceed
if (!ent) if (!ent)
{ {
LogErr("Attempting to <unfilter %s events> using an invalid entity instance: %d", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude",
EntType::Name, _SCI32(ent)); "Attempting to <unfilter events> using an invalid reference: %d", _SCI32(ent));
} }
// Make sure the entity type is allowed for this event type // Make sure the entity type is allowed for this event type
else if (!EntType::InEvent(m_Event->m_Type)) else if (!EntType::InEvent(m_Event->m_Type))
{ {
LogErr("Attempting to <unfilter %s events> using an incompatible event type: %s", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude",
EntType::Name, GetEventName(m_Event->m_Type)); "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 // Make sure the entity is not already excluded fom the filter
else if (m_Filter[_SCU32(ent)]) 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 // Make sure the filter is compatible with the specified event type
if (!EntType::InEvent(m_Event->m_Type)) if (!EntType::InEvent(m_Event->m_Type))
{ {
LogWrn("Attempting to <clear %s filter> using an incompatible event type: %s", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "clear",
EntType::Name, GetEventName(m_Event->m_Type)); "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 // Don't even attempt to clear if there's nothing to be cleared
else if (m_Filter.any()) 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 // Now it's safe to reset the filter
m_Filter.reset(); m_Filter.reset();
} }
SQMOD_UNUSED_VAR(header); 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 // Make sure the filter is compatible with the parent event type
if (!EntType::InEvent(m_Event->m_Type)) if (!EntType::InEvent(m_Event->m_Type))
{ {
LogWrn("Attempting to <flip %s filter> using an incompatible event type: %s", \ DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "flip",
EntType::Name, GetEventName(m_Event->m_Type)); "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 // Now it's safe to proceed with reversing the filters
else else
@ -1265,6 +1271,7 @@ template < class T > void GlobalFilter< T >::Flip(SQInt32 header)
// Hook from the newly filtered entities // Hook from the newly filtered entities
Hook(); Hook();
} }
SQMOD_UNUSED_VAR(header); SQMOD_UNUSED_VAR(header);
} }