-
-
Notifications
You must be signed in to change notification settings - Fork 478
Fix client side debugscript level filtering (#3498) #4323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MohabCodeX
wants to merge
13
commits into
multitheftauto:master
Choose a base branch
from
MohabCodeX:debugscript-client-behavior
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27
−26
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9e2e7d0
Fix client debugscript level filtering (#3498)
MohabCodeX 4d425e8
Merge branch 'master' into debugscript-client-behavior
MohabCodeX c05bbf4
Merge branch 'master' into debugscript-client-behavior
MohabCodeX da54ca9
simplify logic and remove unused enums
MohabCodeX c50dfb5
Merge branch 'debugscript-client-behavior' of https://github.com/Moha…
MohabCodeX 65e2905
Merge branch 'master' into debugscript-client-behavior
MohabCodeX 1d37b34
Merge branch 'master' into debugscript-client-behavior
MohabCodeX a6ab9ab
Merge branch 'master' into debugscript-client-behavior
MohabCodeX 9bb68a3
Merge branch 'master' into debugscript-client-behavior
MohabCodeX e8e1094
Merge branch 'master' into debugscript-client-behavior
MohabCodeX e1c3af7
Merge branch 'master' into debugscript-client-behavior
MohabCodeX f819ebc
Merge branch 'master' into debugscript-client-behavior
MohabCodeX 543f3d1
Merge branch 'master' into debugscript-client-behavior
MohabCodeX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ CScriptDebugging::CScriptDebugging(CLuaManager* pLuaManager) | |
{ | ||
m_pLuaManager = pLuaManager; | ||
m_uiLogFileLevel = 0; | ||
m_pLogFile = NULL; | ||
m_pLogFile = nullptr; | ||
m_bTriggeringMessageEvent = false; | ||
m_flushTimerHandle = NULL; | ||
m_flushTimerHandle = nullptr; | ||
} | ||
|
||
CScriptDebugging::~CScriptDebugging() | ||
|
@@ -33,13 +33,13 @@ CScriptDebugging::~CScriptDebugging() | |
fprintf(m_pLogFile, "INFO: Logging to this file ended\n"); | ||
|
||
// if we have a flush timer | ||
if (m_flushTimerHandle != NULL) | ||
if (m_flushTimerHandle != nullptr) | ||
{ | ||
// delete our flush timer | ||
DeleteTimerQueueTimer(NULL, m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish | ||
DeleteTimerQueueTimer(nullptr, m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish | ||
} | ||
fclose(m_pLogFile); | ||
m_pLogFile = NULL; | ||
m_pLogFile = nullptr; | ||
} | ||
} | ||
|
||
|
@@ -52,7 +52,7 @@ void CScriptDebugging::LogBadLevel(lua_State* luaVM, unsigned int uiRequiredLeve | |
void CALLBACK TimerProc(void* lpParametar, BOOLEAN TimerOrWaitFired) | ||
{ | ||
// Got a logfile? | ||
if (CScriptDebugging::m_pLogFile != NULL) | ||
if (CScriptDebugging::m_pLogFile != nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be reduced: |
||
{ | ||
// flush our log file | ||
fflush((FILE*)CScriptDebugging::m_pLogFile); | ||
|
@@ -68,13 +68,13 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel) | |
{ | ||
fprintf(m_pLogFile, "INFO: Logging to this file ended\n"); | ||
// if we have a flush timer | ||
if (m_flushTimerHandle != NULL) | ||
if (m_flushTimerHandle != nullptr) | ||
{ | ||
// delete our flush timer | ||
DeleteTimerQueueTimer(NULL, m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish | ||
DeleteTimerQueueTimer(nullptr, m_flushTimerHandle, INVALID_HANDLE_VALUE); // INVALID_HANDLE_VALUE = wait for running callbacks to finish | ||
} | ||
fclose(m_pLogFile); | ||
m_pLogFile = NULL; | ||
m_pLogFile = nullptr; | ||
} | ||
|
||
// Apply log size limit | ||
|
@@ -102,38 +102,46 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel) | |
// round 37.5 to 38 because we can't have half a message | ||
// 8 * 256 bytes = 6004B | ||
// round 6004 up to the nearest divisible by 1024 = 6144 | ||
// we have our buffer size. | ||
setvbuf(pFile, NULL, _IOFBF, 6144); | ||
setvbuf(pFile, nullptr, _IOFBF, 6144); | ||
|
||
// Set the new pointer and level and return true | ||
m_uiLogFileLevel = uiLevel; | ||
m_pLogFile = pFile; | ||
|
||
// Create a timer | ||
::CreateTimerQueueTimer(&m_flushTimerHandle, NULL, TimerProc, NULL, 50, 50, WT_EXECUTEINTIMERTHREAD); | ||
::CreateTimerQueueTimer(&m_flushTimerHandle, nullptr, TimerProc, nullptr, 50, 50, WT_EXECUTEINTIMERTHREAD); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
|
||
void CScriptDebugging::UpdateLogOutput() | ||
{ | ||
SLogLine line; | ||
while (m_DuplicateLineFilter.PopOutputLine(line)) | ||
{ | ||
// Log it to the file if enough level | ||
bool sufficientDebugLevel = CheckForSufficientDebugLevel(m_uiLogFileLevel, line.uiMinimumDebugLevel); | ||
|
||
if (sufficientDebugLevel) | ||
{ | ||
PrintLog(line.strText); | ||
} | ||
|
||
#ifdef MTA_DEBUG | ||
if (!g_pCore->IsDebugVisible()) | ||
return; | ||
#endif | ||
g_pCore->DebugEchoColor(line.strText, line.ucRed, line.ucGreen, line.ucBlue); | ||
|
||
std::uint8_t clientDebugLevel = 0; | ||
auto* pLocalPlayer = g_pClientGame->GetPlayerManager()->GetLocalPlayer(); | ||
if (pLocalPlayer) | ||
clientDebugLevel = pLocalPlayer->GetPlayerScriptDebugLevel(); | ||
|
||
bool shouldDisplayInConsole = CheckForSufficientDebugLevel(clientDebugLevel, line.uiMinimumDebugLevel); | ||
if (shouldDisplayInConsole) | ||
g_pCore->DebugEchoColor(line.strText, line.ucRed, line.ucGreen, line.ucBlue); | ||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be reduced:
if (m_flushTimerHandle)