Skip to content

Commit 7e9324b

Browse files
committed
Make onDebugMessage/onClientDebugMessage cancel-able
It can for example be used to filter specific debug messages or rewrite message based on some additional information
1 parent 02924e2 commit 7e9324b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Shared/mods/deathmatch/logic/CScriptDebugging.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ void CScriptDebugging::LogString (const char* szPrePend, const SLuaDebugInfo& lu
180180
}
181181

182182
// Check whether on(Client)DebugMessage is currently being triggered
183+
bool notCancelled = false;
183184
if (!m_bTriggeringMessageEvent)
184185
{
185186
// Make sure the state of on(Client)DebugMessage being triggered can be retrieved later
@@ -209,16 +210,17 @@ void CScriptDebugging::LogString (const char* szPrePend, const SLuaDebugInfo& lu
209210

210211
// Call on(Client)DebugMessage
211212
#ifdef MTA_CLIENT
212-
g_pClientGame->GetRootEntity ()->CallEvent ("onClientDebugMessage", Arguments, false);
213+
notCancelled = g_pClientGame->GetRootEntity ()->CallEvent ("onClientDebugMessage", Arguments, false);
213214
#else
214-
g_pGame->GetMapManager ()->GetRootElement ()->CallEvent ("onDebugMessage", Arguments);
215+
notCancelled = g_pGame->GetMapManager ()->GetRootElement ()->CallEvent ("onDebugMessage", Arguments);
215216
#endif
216217

217218
// Reset trigger state, so onDebugMessage can be called again at a later moment
218219
m_bTriggeringMessageEvent = false;
219220
}
220221

221-
m_DuplicateLineFilter.AddLine ({ strText, uiMinimumDebugLevel, ucRed, ucGreen, ucBlue });
222+
if (notCancelled)
223+
m_DuplicateLineFilter.AddLine ({ strText, uiMinimumDebugLevel, ucRed, ucGreen, ucBlue });
222224

223225
#ifdef MTA_CLIENT
224226
if (g_pCore->GetCVars ()->GetValue < bool > ("filter_duplicate_log_lines") == false)

0 commit comments

Comments
 (0)