From c00cdcde3f9c3c31173b0ad620a46b917b79e3de Mon Sep 17 00:00:00 2001 From: FileEX Date: Mon, 6 Jan 2025 17:14:39 +0100 Subject: [PATCH 1/2] Fix bug --- Client/game_sa/CPedSA.cpp | 14 ++++++++++---- .../logic/CStaticFunctionDefinitions.cpp | 2 +- .../deathmatch/logic/luadefs/CLuaElementDefs.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Client/game_sa/CPedSA.cpp b/Client/game_sa/CPedSA.cpp index 3818e0cb4d..7e8f47440b 100644 --- a/Client/game_sa/CPedSA.cpp +++ b/Client/game_sa/CPedSA.cpp @@ -854,7 +854,7 @@ void CPedSA::SetBleeding(bool bBleeding) bool CPedSA::SetOnFire(bool onFire) { CPedSAInterface* pInterface = GetPedInterface(); - if (onFire == !!pInterface->pFireOnPed) + if (onFire && pInterface->pFireOnPed) return false; auto* fireManager = static_cast(pGame->GetFireManager()); @@ -877,10 +877,16 @@ bool CPedSA::SetOnFire(bool onFire) else { CFire* fire = fireManager->GetFire(static_cast(pInterface->pFireOnPed)); - if (!fire) - return false; + if (fire) + fire->Extinguish(); - fire->Extinguish(); + CTaskManager* taskManager = m_pPedIntelligence->GetTaskManager(); + if (taskManager) + { + CTask* task = taskManager->GetTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM); + if (task && task->GetTaskType() == TASK_SIMPLE_PLAYER_ON_FIRE) + taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM); + } } return true; diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index fdb7a897a8..1688bd7219 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -2594,7 +2594,7 @@ bool CStaticFunctionDefinitions::SetPedOnFire(CClientEntity& Entity, bool bOnFir { if (IS_PED(&Entity)) { - if (!Entity.IsLocalEntity()) + if (!Entity.IsLocalEntity() && &Entity != GetLocalPlayer()) return false; CClientPed& Ped = static_cast(Entity); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index daea88e46f..436e03d812 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -2520,7 +2520,7 @@ bool CLuaElementDefs::SetLowLodElement(lua_State* luaVM, CClientEntity* pEntity, bool CLuaElementDefs::SetElementOnFire(CClientEntity* entity, bool onFire) noexcept { - if (!entity->IsLocalEntity()) + if (!entity->IsLocalEntity() && entity != CStaticFunctionDefinitions::GetLocalPlayer()) return false; return entity->SetOnFire(onFire); From ec5a337e746de4d2414ffa0da6ad2c099679f6d3 Mon Sep 17 00:00:00 2001 From: FileEX Date: Sat, 11 Jan 2025 14:43:29 +0100 Subject: [PATCH 2/2] Review --- Client/game_sa/CPedSA.cpp | 12 ++++++------ Client/game_sa/CTaskManagerSA.cpp | 12 ++++++++++++ Client/game_sa/CTaskManagerSA.h | 1 + Client/sdk/game/CTaskManager.h | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Client/game_sa/CPedSA.cpp b/Client/game_sa/CPedSA.cpp index 7e8f47440b..c27efabed6 100644 --- a/Client/game_sa/CPedSA.cpp +++ b/Client/game_sa/CPedSA.cpp @@ -876,17 +876,17 @@ bool CPedSA::SetOnFire(bool onFire) } else { + bool wasFire = false; + CFire* fire = fireManager->GetFire(static_cast(pInterface->pFireOnPed)); if (fire) + { fire->Extinguish(); + wasFire = true; + } CTaskManager* taskManager = m_pPedIntelligence->GetTaskManager(); - if (taskManager) - { - CTask* task = taskManager->GetTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM); - if (task && task->GetTaskType() == TASK_SIMPLE_PLAYER_ON_FIRE) - taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM); - } + return wasFire || (taskManager && taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM, TASK_SIMPLE_PLAYER_ON_FIRE)); } return true; diff --git a/Client/game_sa/CTaskManagerSA.cpp b/Client/game_sa/CTaskManagerSA.cpp index 15589de95f..c8873c3552 100644 --- a/Client/game_sa/CTaskManagerSA.cpp +++ b/Client/game_sa/CTaskManagerSA.cpp @@ -151,6 +151,18 @@ void CTaskManagerSA::RemoveTaskSecondary(const int iTaskPriority) SetTaskSecondary(NULL, iTaskPriority); } +bool CTaskManagerSA::RemoveTaskSecondary(const int taskPriority, const int taskType) +{ + CTask* task = GetTaskSecondary(taskPriority); + if (task && task->GetTaskType() == taskType) + { + RemoveTaskSecondary(taskPriority); + return true; + } + + return false; +} + void CTaskManagerSA::SetTaskSecondary(CTaskSA* pTaskSecondary, const int iType) { DWORD dwFunc = FUNC_SetTaskSecondary; diff --git a/Client/game_sa/CTaskManagerSA.h b/Client/game_sa/CTaskManagerSA.h index bb99366621..946f3d4a1e 100644 --- a/Client/game_sa/CTaskManagerSA.h +++ b/Client/game_sa/CTaskManagerSA.h @@ -57,6 +57,7 @@ class CTaskManagerSA : public CTaskManager CTask* FindActiveTaskByType(const int iTaskType); CTask* FindTaskByType(const int iPriority, const int iTaskType); void RemoveTaskSecondary(const int iTaskPriority); + bool RemoveTaskSecondary(const int taskPriority, const int taskType); void SetTaskSecondary(CTaskSA* pTaskSecondary, const int iType); CTask* GetTaskSecondary(const int iType); // code it bool HasTaskSecondary(const CTask* pTaskSecondary); // code it diff --git a/Client/sdk/game/CTaskManager.h b/Client/sdk/game/CTaskManager.h index f89d145dd4..edf794ce44 100644 --- a/Client/sdk/game/CTaskManager.h +++ b/Client/sdk/game/CTaskManager.h @@ -60,6 +60,7 @@ class CTaskManager virtual CTask* FindActiveTaskByType(const int iTaskType) = 0; virtual CTask* FindTaskByType(const int iPriority, const int iTaskType) = 0; virtual void RemoveTaskSecondary(const int iTaskPriority) = 0; + virtual bool RemoveTaskSecondary(const int taskPriority, const int taskType) = 0; // virtual void SetTaskSecondary(CTask* pTaskSecondary, const int iType)=0; virtual CTask* GetTaskSecondary(const int iType) = 0; virtual bool HasTaskSecondary(const CTask* pTaskSecondary) = 0;