From 65bb7bfab722d34e497fafc5b280f3cde1c81e34 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:52:34 +0300 Subject: [PATCH] use enum --- .../logic/lua/CLuaFunctionParseHelpers.cpp | 5 +++++ .../logic/lua/CLuaFunctionParseHelpers.h | 1 + .../deathmatch/logic/luadefs/CLuaPedDefs.cpp | 22 ++++++++++++------- .../deathmatch/logic/luadefs/CLuaPedDefs.h | 2 +- Client/sdk/game/CTaskManager.h | 7 ++++++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index 64708dea0c..230a85733e 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -910,6 +910,11 @@ ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions") ADD_ENUM(PreloadAreaOption::ALL, "all") IMPLEMENT_ENUM_CLASS_END("preload-area-option") +IMPLEMENT_ENUM_CLASS_BEGIN(taskType) +ADD_ENUM(taskType::PRIMARY_TASK, "primary") +ADD_ENUM(taskType::SECONDARY_TASK, "secondary") +IMPLEMENT_ENUM_CLASS_END("tasks-types") + // // CResource from userdata // diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index e134a73bea..210a3e7eea 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -88,6 +88,7 @@ DECLARE_ENUM(ePools); DECLARE_ENUM(eWorldProperty); DECLARE_ENUM_CLASS(eModelLoadState); DECLARE_ENUM_CLASS(PreloadAreaOption); +DECLARE_ENUM_CLASS(taskType); class CRemoteCall; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index b8d87b0913..6caf245618 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -2495,13 +2495,19 @@ bool CLuaPedDefs::SetPedExitVehicle(CClientPed* pPed) return pPed->ExitVehicle(); } -bool CLuaPedDefs::killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept +bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept { - if (taskType == "primary") // PRIMARY - return ped->KillTask(taskNumber, gracefully.value_or(true)); - - else if (taskType == "secondary") // SECONDARY - return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); - - return false; + switch (taskType) + { + case taskType::PRIMARY_TASK: + { + return ped->KillTask(taskNumber, gracefully.value_or(true)); + } + case taskType::SECONDARY_TASK: + { + return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); + } + default: + return false; + } } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 2ff0fbbb19..76b9771332 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -116,5 +116,5 @@ class CLuaPedDefs : public CLuaDefs static bool IsPedBleeding(CClientPed* ped); static bool SetPedBleeding(CClientPed* ped, bool bleeding); - static bool killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept; + static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept; }; diff --git a/Client/sdk/game/CTaskManager.h b/Client/sdk/game/CTaskManager.h index 3467f34928..f89d145dd4 100644 --- a/Client/sdk/game/CTaskManager.h +++ b/Client/sdk/game/CTaskManager.h @@ -41,6 +41,13 @@ enum ABORT_PRIORITY_IMMEDIATE }; +enum taskType +{ + PRIMARY_TASK = 0, + SECONDARY_TASK +}; + + class CTaskManager { public: