Skip to content

Commit 5987e31

Browse files
authored
Merge branch 'master' into bugfix/isPedOnGround
2 parents a2e8799 + d3bf6f7 commit 5987e31

Some content is hidden

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

59 files changed

+5943
-5033
lines changed

Client/core/DXHook/CProxyDirect3DDevice9.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ ULONG CProxyDirect3DDevice9::Release()
117117
// Call event handler
118118
CDirect3DEvents9::OnDirect3DDeviceDestroy(m_pDevice);
119119
delete this;
120+
return ulRefCount - 1;
120121
}
121122

122123
return m_pDevice->Release();

Client/core/Graphics/CRenderItemManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ CVectorGraphicItem* CRenderItemManager::CreateVectorGraphic(uint width, uint hei
167167
}
168168

169169
UpdateMemoryUsage();
170-
170+
171171
return pVectorItem;
172172
}
173173

@@ -723,7 +723,7 @@ void CRenderItemManager::UpdateMemoryUsage()
723723
continue;
724724
int iMemoryKBUsed = pRenderItem->GetVideoMemoryKBUsed();
725725

726-
if (pRenderItem->IsA(CFileTextureItem::GetClassId()))
726+
if (pRenderItem->IsA(CFileTextureItem::GetClassId()) || pRenderItem->IsA(CVectorGraphicItem::GetClassId()))
727727
m_iTextureMemoryKBUsed += iMemoryKBUsed;
728728
else if (pRenderItem->IsA(CRenderTargetItem::GetClassId()) || pRenderItem->IsA(CScreenSourceItem::GetClassId()))
729729
m_iRenderTargetMemoryKBUsed += iMemoryKBUsed;

Client/core/Graphics/CVideoModeManager.cpp

Lines changed: 175 additions & 70 deletions
Large diffs are not rendered by default.

Client/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ void CClientEntity::CallEventNoParent(const char* szName, const CLuaArguments& A
791791
// Call it on all our children
792792
if (!m_Children.empty())
793793
{
794-
for (CClientEntity* pEntity : *GetChildrenListSnapshot())
794+
CElementListSnapshotRef pChildrenSnapshot = GetChildrenListSnapshot();
795+
for (CClientEntity* pEntity : *pChildrenSnapshot)
795796
{
796797
if (!pEntity->IsBeingDeleted())
797798
{

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,7 @@ void CClientGame::AddBuiltInEvents()
26482648
m_Events.AddEvent("onClientPlayerRadioSwitch", "", NULL, false);
26492649
m_Events.AddEvent("onClientPlayerDamage", "attacker, weapon, bodypart", NULL, false);
26502650
m_Events.AddEvent("onClientPlayerWeaponFire", "weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement", NULL, false);
2651+
m_Events.AddEvent("onClientPlayerWeaponReload", "weapon, clip, ammo", nullptr, false);
26512652
m_Events.AddEvent("onClientPlayerWasted", "ammo, killer, weapon, bodypart, isStealth, animGroup, animID", nullptr, false);
26522653
m_Events.AddEvent("onClientPlayerChoke", "", NULL, false);
26532654
m_Events.AddEvent("onClientPlayerVoiceStart", "", NULL, false);
@@ -2666,6 +2667,7 @@ void CClientGame::AddBuiltInEvents()
26662667
m_Events.AddEvent("onClientPedVehicleEnter", "vehicle, seat", NULL, false);
26672668
m_Events.AddEvent("onClientPedVehicleExit", "vehicle, seat", NULL, false);
26682669
m_Events.AddEvent("onClientPedWeaponFire", "weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement", NULL, false);
2670+
m_Events.AddEvent("onClientPedWeaponReload", "weapon, clip, ammo", nullptr, false);
26692671
m_Events.AddEvent("onClientPedWasted", "", NULL, false);
26702672
m_Events.AddEvent("onClientPedChoke", "", NULL, false);
26712673
m_Events.AddEvent("onClientPedHeliKilled", "heli", NULL, false);

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6119,6 +6119,21 @@ bool CClientPed::ReloadWeapon() noexcept
61196119
if (!CanReloadWeapon() || (task && task->GetTaskType() == TASK_SIMPLE_USE_GUN))
61206120
return false;
61216121

6122+
CLuaArguments args;
6123+
args.PushNumber(weapon->GetType());
6124+
args.PushNumber(weapon->GetAmmoInClip());
6125+
args.PushNumber(weapon->GetAmmoTotal());
6126+
6127+
bool result = false;
6128+
6129+
if (IS_PLAYER(this))
6130+
result = CallEvent("onClientPlayerWeaponReload", args, true);
6131+
else
6132+
result = CallEvent("onClientPedWeaponReload", args, true);
6133+
6134+
if (!result)
6135+
return false;
6136+
61226137
weapon->SetState(WEAPONSTATE_RELOADING);
61236138
return true;
61246139
}

Client/mods/deathmatch/logic/CMapEventManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool CMapEventManager::Call(const char* szName, const CLuaArguments& Arguments,
222222
lua_pushresource(pState, pSourceResource);
223223
lua_setglobal(pState, "sourceResource");
224224

225-
lua_pushelement(pState, pSourceResource->GetResourceDynamicEntity());
225+
lua_pushelement(pState, pSourceResource->GetResourceEntity());
226226
lua_setglobal(pState, "sourceResourceRoot");
227227
}
228228
else
@@ -400,4 +400,4 @@ void CMapEventManager::GetHandles(CLuaMain* pLuaMain, const char* szName, lua_St
400400
}
401401
}
402402
}
403-
}
403+
}

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,8 @@ void CPacketHandler::Packet_ChatEcho(NetBitStreamInterface& bitStream)
14121412
bitStream.Read(szMessage, iNumberOfBytesUsed);
14131413
szMessage[iNumberOfBytesUsed] = 0;
14141414
// actual limits enforced on the remote client, this is the maximum a string can be to be printed.
1415-
if (MbUTF8ToUTF16(szMessage).size() <=
1415+
SString textToProcess = bColorCoded ? RemoveColorCodes(szMessage) : szMessage;
1416+
if (MbUTF8ToUTF16(textToProcess).size() <=
14161417
MAX_CHATECHO_LENGTH + 6) // Extra 6 characters to fix #7125 (Teamsay + long name + long message = too long message)
14171418
{
14181419
// Strip it for bad characters

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;

0 commit comments

Comments
 (0)