Skip to content

Commit 7dc5dc1

Browse files
authored
Merge branch 'master' into change_p_uf
2 parents ef76b31 + 274d865 commit 7dc5dc1

File tree

706 files changed

+26956
-32031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

706 files changed

+26956
-32031
lines changed

Client/mods/deathmatch/logic/CScriptDebugging.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ CScriptDebugging::CScriptDebugging(CLuaManager* pLuaManager)
1616
{
1717
m_pLuaManager = pLuaManager;
1818
m_uiLogFileLevel = 0;
19-
m_pLogFile = NULL;
19+
m_pLogFile = nullptr;
2020
m_bTriggeringMessageEvent = false;
21-
m_flushTimerHandle = NULL;
21+
m_flushTimerHandle = nullptr;
2222
}
2323

2424
CScriptDebugging::~CScriptDebugging()
@@ -33,13 +33,13 @@ CScriptDebugging::~CScriptDebugging()
3333
fprintf(m_pLogFile, "INFO: Logging to this file ended\n");
3434

3535
// if we have a flush timer
36-
if (m_flushTimerHandle != NULL)
36+
if (m_flushTimerHandle)
3737
{
3838
// 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
4040
}
4141
fclose(m_pLogFile);
42-
m_pLogFile = NULL;
42+
m_pLogFile = nullptr;
4343
}
4444
}
4545

@@ -52,7 +52,7 @@ void CScriptDebugging::LogBadLevel(lua_State* luaVM, unsigned int uiRequiredLeve
5252
void CALLBACK TimerProc(void* lpParametar, BOOLEAN TimerOrWaitFired)
5353
{
5454
// Got a logfile?
55-
if (CScriptDebugging::m_pLogFile != NULL)
55+
if (CScriptDebugging::m_pLogFile)
5656
{
5757
// flush our log file
5858
fflush((FILE*)CScriptDebugging::m_pLogFile);
@@ -68,13 +68,13 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel)
6868
{
6969
fprintf(m_pLogFile, "INFO: Logging to this file ended\n");
7070
// if we have a flush timer
71-
if (m_flushTimerHandle != NULL)
71+
if (m_flushTimerHandle)
7272
{
7373
// 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
7575
}
7676
fclose(m_pLogFile);
77-
m_pLogFile = NULL;
77+
m_pLogFile = nullptr;
7878
}
7979

8080
// Apply log size limit
@@ -102,38 +102,46 @@ bool CScriptDebugging::SetLogfile(const char* szFilename, unsigned int uiLevel)
102102
// round 37.5 to 38 because we can't have half a message
103103
// 8 * 256 bytes = 6004B
104104
// 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);
107106

108107
// Set the new pointer and level and return true
109108
m_uiLogFileLevel = uiLevel;
110109
m_pLogFile = pFile;
111110

112111
// 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);
114113
return true;
115114
}
116115

117116
return false;
118117
}
119118

119+
120120
void CScriptDebugging::UpdateLogOutput()
121121
{
122122
SLogLine line;
123123
while (m_DuplicateLineFilter.PopOutputLine(line))
124124
{
125-
// Log it to the file if enough level
126125
bool sufficientDebugLevel = CheckForSufficientDebugLevel(m_uiLogFileLevel, line.uiMinimumDebugLevel);
127126

128127
if (sufficientDebugLevel)
129128
{
130129
PrintLog(line.strText);
131130
}
131+
132132
#ifdef MTA_DEBUG
133133
if (!g_pCore->IsDebugVisible())
134134
return;
135135
#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);
137145
}
138146
}
139147

Client/mods/deathmatch/logic/CScriptDebugging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class CScriptDebugging
6868
SString ComposeErrorMessage(const char* szPrePend, const SLuaDebugInfo& luaDebugInfo, const char* szMessage);
6969
void LogString(const char* szPrePend, const SLuaDebugInfo& luaDebugInfo, const char* szMessage, unsigned int uiMinimumDebugLevel, unsigned char ucRed = 255,
7070
unsigned char ucGreen = 255, unsigned char ucBlue = 255);
71-
bool CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept;
7271
void PrintLog(const char* szText);
72+
bool CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept;
7373

7474
public:
7575
static FILE* m_pLogFile;

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6676,6 +6676,11 @@ bool CStaticFunctionDefinitions::GetGarageSize(unsigned char ucGarageID, float&
66766676
if (pGarage)
66776677
{
66786678
pGarage->GetSize(fHeight, fWidth, fDepth);
6679+
6680+
CVector vecPosition;
6681+
pGarage->GetPosition(vecPosition);
6682+
fHeight -= vecPosition.fZ;
6683+
66796684
return true;
66806685
}
66816686

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,9 @@ int CLuaWorldDefs::GetGarageSize(lua_State* luaVM)
678678

679679
if (CStaticFunctionDefinitions::GetGarageSize(iGarageID, fHeight, fWidth, fDepth))
680680
{
681-
lua_pushnumber(luaVM, fHeight);
682681
lua_pushnumber(luaVM, fWidth);
683682
lua_pushnumber(luaVM, fDepth);
683+
lua_pushnumber(luaVM, fHeight);
684684
return 3;
685685
}
686686
}

0 commit comments

Comments
 (0)