From 572815485b8f5d52941b0ec4fed941f05b6a43d5 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:13:49 +0300 Subject: [PATCH 1/5] add validation --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 11 ++++++++++- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 87cd379ea5d..1346b82458a 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2481,16 +2481,25 @@ bool CLuaPedDefs::SetPedExitVehicle(CClientPed* pPed) return pPed->ExitVehicle(); } -bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept +bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) { switch (taskType) { case taskType::PRIMARY_TASK: { + if (taskNumber == 4) + throw LuaFunctionError("Killing TASK_PRIORITY_DEFAULT is not allowed"); + + if (taskNumber > 3) + throw LuaFunctionError("Invaild task slot number"); + return ped->KillTask(taskNumber, gracefully.value_or(true)); } case taskType::SECONDARY_TASK: { + if (taskNumber > 5) + throw LuaFunctionError("Invaild task slot number"); + return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); } default: diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 37169ddefb0..52bd0e858a7 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -117,5 +117,5 @@ class CLuaPedDefs : public CLuaDefs static bool IsPedBleeding(CClientPed* ped); static bool SetPedBleeding(CClientPed* ped, bool bleeding); - static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept; + static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully); }; From 1742f9d531b45c3e0b4b2c5af22573180eb460e1 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:27:32 +0300 Subject: [PATCH 2/5] typo --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 1346b82458a..d884d0ed4fb 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2491,14 +2491,14 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t throw LuaFunctionError("Killing TASK_PRIORITY_DEFAULT is not allowed"); if (taskNumber > 3) - throw LuaFunctionError("Invaild task slot number"); + throw LuaFunctionError("Invalid task slot number"); return ped->KillTask(taskNumber, gracefully.value_or(true)); } case taskType::SECONDARY_TASK: { if (taskNumber > 5) - throw LuaFunctionError("Invaild task slot number"); + throw LuaFunctionError("Invalid task slot number"); return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); } From 57163c426efee37cd7da04f0bb1563c329020591 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Fri, 21 Feb 2025 20:47:06 +0300 Subject: [PATCH 3/5] use enums --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index d884d0ed4fb..1513dc4dd16 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2487,17 +2487,17 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t { case taskType::PRIMARY_TASK: { - if (taskNumber == 4) + if (taskNumber == TASK_PRIORITY_DEFAULT) throw LuaFunctionError("Killing TASK_PRIORITY_DEFAULT is not allowed"); - if (taskNumber > 3) + if (taskNumber > TASK_PRIORITY_MAX) throw LuaFunctionError("Invalid task slot number"); return ped->KillTask(taskNumber, gracefully.value_or(true)); } case taskType::SECONDARY_TASK: { - if (taskNumber > 5) + if (taskNumber > TASK_SECONDARY_MAX) throw LuaFunctionError("Invalid task slot number"); return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); From fbd23c950cf06e0fd45c58c883d3713d74c915f3 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 22 Feb 2025 23:09:45 +0300 Subject: [PATCH 4/5] fix check --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 1513dc4dd16..02eceda364e 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2490,14 +2490,14 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t if (taskNumber == TASK_PRIORITY_DEFAULT) throw LuaFunctionError("Killing TASK_PRIORITY_DEFAULT is not allowed"); - if (taskNumber > TASK_PRIORITY_MAX) + if (taskNumber > TASK_PRIORITY_DEFAULT) throw LuaFunctionError("Invalid task slot number"); return ped->KillTask(taskNumber, gracefully.value_or(true)); } case taskType::SECONDARY_TASK: { - if (taskNumber > TASK_SECONDARY_MAX) + if (taskNumber > TASK_SECONDARY_IK) throw LuaFunctionError("Invalid task slot number"); return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); From 2f3c824d5a3a32a1811341db1f3d830d51d16c83 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 23 Feb 2025 13:20:41 +0300 Subject: [PATCH 5/5] code wise --- Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 02eceda364e..edaad4359b5 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2490,14 +2490,14 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t if (taskNumber == TASK_PRIORITY_DEFAULT) throw LuaFunctionError("Killing TASK_PRIORITY_DEFAULT is not allowed"); - if (taskNumber > TASK_PRIORITY_DEFAULT) + if (taskNumber >= TASK_PRIORITY_MAX) throw LuaFunctionError("Invalid task slot number"); return ped->KillTask(taskNumber, gracefully.value_or(true)); } case taskType::SECONDARY_TASK: { - if (taskNumber > TASK_SECONDARY_IK) + if (taskNumber >= TASK_SECONDARY_MAX) throw LuaFunctionError("Invalid task slot number"); return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true));