Skip to content

Commit 65bb7bf

Browse files
committed
use enum
1 parent f5d4a05 commit 65bb7bf

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,11 @@ ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions")
910910
ADD_ENUM(PreloadAreaOption::ALL, "all")
911911
IMPLEMENT_ENUM_CLASS_END("preload-area-option")
912912

913+
IMPLEMENT_ENUM_CLASS_BEGIN(taskType)
914+
ADD_ENUM(taskType::PRIMARY_TASK, "primary")
915+
ADD_ENUM(taskType::SECONDARY_TASK, "secondary")
916+
IMPLEMENT_ENUM_CLASS_END("tasks-types")
917+
913918
//
914919
// CResource from userdata
915920
//

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ DECLARE_ENUM(ePools);
8888
DECLARE_ENUM(eWorldProperty);
8989
DECLARE_ENUM_CLASS(eModelLoadState);
9090
DECLARE_ENUM_CLASS(PreloadAreaOption);
91+
DECLARE_ENUM_CLASS(taskType);
9192

9293
class CRemoteCall;
9394

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,13 +2495,19 @@ bool CLuaPedDefs::SetPedExitVehicle(CClientPed* pPed)
24952495
return pPed->ExitVehicle();
24962496
}
24972497

2498-
bool CLuaPedDefs::killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept
2498+
bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept
24992499
{
2500-
if (taskType == "primary") // PRIMARY
2501-
return ped->KillTask(taskNumber, gracefully.value_or(true));
2502-
2503-
else if (taskType == "secondary") // SECONDARY
2504-
return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true));
2505-
2506-
return false;
2500+
switch (taskType)
2501+
{
2502+
case taskType::PRIMARY_TASK:
2503+
{
2504+
return ped->KillTask(taskNumber, gracefully.value_or(true));
2505+
}
2506+
case taskType::SECONDARY_TASK:
2507+
{
2508+
return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true));
2509+
}
2510+
default:
2511+
return false;
2512+
}
25072513
}

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ class CLuaPedDefs : public CLuaDefs
116116
static bool IsPedBleeding(CClientPed* ped);
117117
static bool SetPedBleeding(CClientPed* ped, bool bleeding);
118118

119-
static bool killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept;
119+
static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept;
120120
};

Client/sdk/game/CTaskManager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ enum
4141
ABORT_PRIORITY_IMMEDIATE
4242
};
4343

44+
enum taskType
45+
{
46+
PRIMARY_TASK = 0,
47+
SECONDARY_TASK
48+
};
49+
50+
4451
class CTaskManager
4552
{
4653
public:

0 commit comments

Comments
 (0)