Skip to content

Commit 7eda064

Browse files
authored
Fix setPedOnFire(ped, false) doesn't cancel TASK_SIMPLE_PLAYER_ON_FIRE (again) (#4188)
1 parent 63be6db commit 7eda064

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

Client/game_sa/CFireSA.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "CFireSA.h"
1515
#include "CGameSA.h"
1616
#include "CPoolsSA.h"
17+
#include <game/CTaskManager.h>
18+
#include <game/TaskTypes.h>
1719

1820
extern CGameSA* pGame;
1921

@@ -209,3 +211,43 @@ void CFireSA::SetNumGenerationsAllowed(char generations)
209211
{
210212
internalInterface->nNumGenerationsAllowed = generations;
211213
}
214+
215+
////////////////////////////////////////////////////////////////////////
216+
// CFire::Extinguish
217+
//
218+
// Fix GH #3249 (PLAYER_ON_FIRE task is not aborted after the fire is extinguished)
219+
////////////////////////////////////////////////////////////////////////
220+
static void AbortFireTask(CEntitySAInterface* entityOnFire)
221+
{
222+
auto ped = pGame->GetPools()->GetPed(reinterpret_cast<DWORD*>(entityOnFire));
223+
if (!ped || !ped->pEntity)
224+
return;
225+
226+
CTaskManager* taskManager = ped->pEntity->GetPedIntelligence()->GetTaskManager();
227+
if (!taskManager)
228+
return;
229+
230+
taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM, TASK_SIMPLE_PLAYER_ON_FIRE);
231+
}
232+
233+
#define HOOKPOS_CFire_Extinguish 0x539429
234+
#define HOOKSIZE_CFire_Extinguish 6
235+
static constexpr std::uintptr_t CONTINUE_CFire_Extinguish = 0x53942F;
236+
static void _declspec(naked) HOOK_CFire_Extinguish()
237+
{
238+
_asm
239+
{
240+
mov [eax+730h], edi
241+
242+
push eax
243+
call AbortFireTask
244+
add esp, 4
245+
246+
jmp CONTINUE_CFire_Extinguish
247+
}
248+
}
249+
250+
void CFireSA::StaticSetHooks()
251+
{
252+
EZHookInstall(CFire_Extinguish);
253+
}

Client/game_sa/CFireSA.h

+2
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ class CFireSA : public CFire
6464
void SetStrength(float fStrength);
6565
void SetNumGenerationsAllowed(char generations);
6666
CFireSAInterface* GetInterface() { return internalInterface; }
67+
68+
static void StaticSetHooks();
6769
};

Client/game_sa/CGameSA.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ CGameSA::CGameSA()
247247
CVehicleSA::StaticSetHooks();
248248
CCheckpointSA::StaticSetHooks();
249249
CHudSA::StaticSetHooks();
250+
CFireSA::StaticSetHooks();
250251
CPtrNodeSingleLinkPoolSA::StaticSetHooks();
251252
CVehicleAudioSettingsManagerSA::StaticSetHooks();
252253
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ bool CLuaElementDefs::SetLowLodElement(lua_State* luaVM, CClientEntity* pEntity,
25222522

25232523
bool CLuaElementDefs::SetElementOnFire(CClientEntity* entity, bool onFire) noexcept
25242524
{
2525-
if (!entity->IsLocalEntity())
2525+
if (!entity->IsLocalEntity() && entity != CStaticFunctionDefinitions::GetLocalPlayer())
25262526
return false;
25272527

25282528
return entity->SetOnFire(onFire);

0 commit comments

Comments
 (0)