@@ -16,9 +16,9 @@ CScriptDebugging::CScriptDebugging(CLuaManager* pLuaManager)
16
16
{
17
17
m_pLuaManager = pLuaManager;
18
18
m_uiLogFileLevel = 0 ;
19
- m_pLogFile = NULL ;
19
+ m_pLogFile = nullptr ;
20
20
m_bTriggeringMessageEvent = false ;
21
- m_flushTimerHandle = NULL ;
21
+ m_flushTimerHandle = nullptr ;
22
22
}
23
23
24
24
CScriptDebugging::~CScriptDebugging ()
@@ -33,13 +33,13 @@ CScriptDebugging::~CScriptDebugging()
33
33
fprintf (m_pLogFile, " INFO: Logging to this file ended\n " );
34
34
35
35
// if we have a flush timer
36
- if (m_flushTimerHandle != NULL )
36
+ if (m_flushTimerHandle)
37
37
{
38
38
// delete our flush timer
39
- DeleteTimerQueueTimer (NULL , m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish
39
+ DeleteTimerQueueTimer (nullptr , m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish
40
40
}
41
41
fclose (m_pLogFile);
42
- m_pLogFile = NULL ;
42
+ m_pLogFile = nullptr ;
43
43
}
44
44
}
45
45
@@ -52,7 +52,7 @@ void CScriptDebugging::LogBadLevel(lua_State* luaVM, unsigned int uiRequiredLeve
52
52
void CALLBACK TimerProc (void * lpParametar, BOOLEAN TimerOrWaitFired)
53
53
{
54
54
// Got a logfile?
55
- if (CScriptDebugging::m_pLogFile != NULL )
55
+ if (CScriptDebugging::m_pLogFile)
56
56
{
57
57
// flush our log file
58
58
fflush ((FILE*)CScriptDebugging::m_pLogFile);
@@ -68,13 +68,13 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel)
68
68
{
69
69
fprintf (m_pLogFile, " INFO: Logging to this file ended\n " );
70
70
// if we have a flush timer
71
- if (m_flushTimerHandle != NULL )
71
+ if (m_flushTimerHandle)
72
72
{
73
73
// delete our flush timer
74
- DeleteTimerQueueTimer (NULL , m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish
74
+ DeleteTimerQueueTimer (nullptr , m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish
75
75
}
76
76
fclose (m_pLogFile);
77
- m_pLogFile = NULL ;
77
+ m_pLogFile = nullptr ;
78
78
}
79
79
80
80
// Apply log size limit
@@ -102,38 +102,46 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel)
102
102
// round 37.5 to 38 because we can't have half a message
103
103
// 8 * 256 bytes = 6004B
104
104
// round 6004 up to the nearest divisible by 1024 = 6144
105
- // we have our buffer size.
106
- setvbuf (pFile, NULL , _IOFBF, 6144 );
105
+ setvbuf (pFile, nullptr , _IOFBF, 6144 );
107
106
108
107
// Set the new pointer and level and return true
109
108
m_uiLogFileLevel = uiLevel;
110
109
m_pLogFile = pFile;
111
110
112
111
// Create a timer
113
- ::CreateTimerQueueTimer (&m_flushTimerHandle, NULL , TimerProc, NULL , 50 , 50 , WT_EXECUTEINTIMERTHREAD);
112
+ ::CreateTimerQueueTimer (&m_flushTimerHandle, nullptr , TimerProc, nullptr , 50 , 50 , WT_EXECUTEINTIMERTHREAD);
114
113
return true ;
115
114
}
116
115
117
116
return false ;
118
117
}
119
118
119
+
120
120
void CScriptDebugging::UpdateLogOutput ()
121
121
{
122
122
SLogLine line;
123
123
while (m_DuplicateLineFilter.PopOutputLine (line))
124
124
{
125
- // Log it to the file if enough level
126
125
bool sufficientDebugLevel = CheckForSufficientDebugLevel (m_uiLogFileLevel, line.uiMinimumDebugLevel );
127
126
128
127
if (sufficientDebugLevel)
129
128
{
130
129
PrintLog (line.strText );
131
130
}
131
+
132
132
#ifdef MTA_DEBUG
133
133
if (!g_pCore->IsDebugVisible ())
134
134
return ;
135
135
#endif
136
- g_pCore->DebugEchoColor (line.strText , line.ucRed , line.ucGreen , line.ucBlue );
136
+
137
+ std::uint8_t clientDebugLevel = 0 ;
138
+ auto * localPlayer = g_pClientGame->GetPlayerManager ()->GetLocalPlayer ();
139
+ if (localPlayer)
140
+ clientDebugLevel = localPlayer->GetPlayerScriptDebugLevel ();
141
+
142
+ bool shouldDisplayInConsole = CheckForSufficientDebugLevel (clientDebugLevel, line.uiMinimumDebugLevel );
143
+ if (shouldDisplayInConsole)
144
+ g_pCore->DebugEchoColor (line.strText , line.ucRed , line.ucGreen , line.ucBlue );
137
145
}
138
146
}
139
147
0 commit comments