diff --git a/source/Event/Global.cpp b/source/Event/Global.cpp index e86b212c..b5a6a881 100644 --- a/source/Event/Global.cpp +++ b/source/Event/Global.cpp @@ -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 to an unknown event type: %d", _SCI32(m_Type)); + DbgErr("GlobalEvent", func, "Attempting to 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 from an unknown event type: %d", _SCI32(m_Type)); + DbgErr("GlobalEvent", func, "Attempting to from an unknown type: %d", + _SCI32(m_Type)); } } diff --git a/source/Event/Global.hpp b/source/Event/Global.hpp index f0e3cf76..34615590 100644 --- a/source/Event/Global.hpp +++ b/source/Event/Global.hpp @@ -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 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 using an invalid entity instance: %d", \ - EntType::Name, _SCI32(ent)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include", + "Attempting to 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 using an incompatible event type: %s", \ - EntType::Name, GetEventName(m_Event->m_Type)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "include", + "Attempting to 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 using an invalid entity instance: %d", \ - EntType::Name, _SCI32(ent)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude", + "Attempting to 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 using an incompatible event type: %s", \ - EntType::Name, GetEventName(m_Event->m_Type)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "exclude", + "Attempting to 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 using an incompatible event type: %s", \ - EntType::Name, GetEventName(m_Event->m_Type)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "clear", + "Attempting to 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 using an incompatible event type: %s", \ - EntType::Name, GetEventName(m_Event->m_Type)); + DbgErr(ToStrF("%sGlobalFilter", EntType::Name), "flip", + "Attempting to 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); }