Skip to content

Commit ce9d3de

Browse files
committed
Check clothes type parameter in several cases
Thanks to Inder00#1
1 parent c620178 commit ce9d3de

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

Client/mods/deathmatch/logic/CClientPlayerClothes.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ const SPlayerClothing* CClientPlayerClothes::GetClothing(unsigned char ucType)
323323

324324
void CClientPlayerClothes::AddClothes(const char* szTexture, const char* szModel, unsigned char ucType, bool bAddToModel)
325325
{
326+
if (ucType >= PLAYER_CLOTHING_SLOTS)
327+
return;
328+
326329
const SPlayerClothing* pClothing = GetClothing(szTexture, szModel, ucType);
327330
if (pClothing && pClothing != m_Clothes[ucType])
328331
{
@@ -359,6 +362,9 @@ void CClientPlayerClothes::InternalAddClothes(const SPlayerClothing* pClothing,
359362

360363
bool CClientPlayerClothes::RemoveClothes(unsigned char ucType, bool bRemoveFromModel)
361364
{
365+
if (ucType >= PLAYER_CLOTHING_SLOTS)
366+
return false;
367+
362368
// Do we have any set clothes on this slot?
363369
if (m_Clothes[ucType])
364370
{

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,29 +2235,37 @@ bool CStaticFunctionDefinitions::SetPedMoveAnim(CClientEntity& Entity, unsigned
22352235

22362236
bool CStaticFunctionDefinitions::AddPedClothes(CClientEntity& Entity, const char* szTexture, const char* szModel, unsigned char ucType)
22372237
{
2238-
RUN_CHILDREN(AddPedClothes(**iter, szTexture, szModel, ucType))
2239-
// Is he a player?
2240-
if (IS_PED(&Entity))
2238+
if (ucType < PLAYER_CLOTHING_SLOTS)
22412239
{
2242-
CClientPed& Ped = static_cast<CClientPed&>(Entity);
2243-
Ped.GetClothes()->AddClothes(szTexture, szModel, ucType, false);
2244-
Ped.RebuildModel(true);
2245-
return true;
2240+
RUN_CHILDREN(AddPedClothes(**iter, szTexture, szModel, ucType))
2241+
2242+
// Is he a player?
2243+
if (IS_PED(&Entity))
2244+
{
2245+
CClientPed& Ped = static_cast<CClientPed&>(Entity);
2246+
Ped.GetClothes()->AddClothes(szTexture, szModel, ucType, false);
2247+
Ped.RebuildModel(true);
2248+
return true;
2249+
}
22462250
}
22472251

22482252
return false;
22492253
}
22502254

22512255
bool CStaticFunctionDefinitions::RemovePedClothes(CClientEntity& Entity, unsigned char ucType)
22522256
{
2253-
RUN_CHILDREN(RemovePedClothes(**iter, ucType))
2254-
// Is he a player?
2255-
if (IS_PED(&Entity))
2257+
if (ucType < PLAYER_CLOTHING_SLOTS)
22562258
{
2257-
CClientPed& Ped = static_cast<CClientPed&>(Entity);
2258-
Ped.GetClothes()->RemoveClothes(ucType, false);
2259-
Ped.RebuildModel(true);
2260-
return true;
2259+
RUN_CHILDREN(RemovePedClothes(**iter, ucType))
2260+
2261+
// Is he a player?
2262+
if (IS_PED(&Entity))
2263+
{
2264+
CClientPed& Ped = static_cast<CClientPed&>(Entity);
2265+
Ped.GetClothes()->RemoveClothes(ucType, false);
2266+
Ped.RebuildModel(true);
2267+
return true;
2268+
}
22612269
}
22622270

22632271
return false;

Server/mods/deathmatch/logic/CPlayerClothes.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ const SPlayerClothing* CPlayerClothes::GetClothing(unsigned char ucType)
308308

309309
void CPlayerClothes::AddClothes(const char* szTexture, const char* szModel, unsigned char ucType)
310310
{
311+
if (ucType >= PLAYER_CLOTHING_SLOTS)
312+
return;
313+
311314
const SPlayerClothing* pClothing = GetClothing(szTexture, szModel, ucType);
312315
if (pClothing && pClothing != m_Clothes[ucType])
313316
{
@@ -318,6 +321,9 @@ void CPlayerClothes::AddClothes(const char* szTexture, const char* szModel, unsi
318321

319322
bool CPlayerClothes::RemoveClothes(unsigned char ucType)
320323
{
324+
if (ucType >= PLAYER_CLOTHING_SLOTS)
325+
return false;
326+
321327
// Do we have any set clothes on this slot?
322328
if (m_Clothes[ucType])
323329
{

0 commit comments

Comments
 (0)