Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setPedOnFire(ped, false) doesn't cancel TASK_SIMPLE_PLAYER_ON_FIRE #3930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Jan 6, 2025

Fixed #3249

@@ -2594,7 +2594,7 @@ bool CStaticFunctionDefinitions::SetPedOnFire(CClientEntity& Entity, bool bOnFir
{
if (IS_PED(&Entity))
{
if (!Entity.IsLocalEntity())
if (!Entity.IsLocalEntity() && &Entity != GetLocalPlayer())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This function should work with local peds too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is agreed with botder and dutchman

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain? Why should not local peds use this function?

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setPedOnFire(ped, false) doesn't return false if the ped wasn't on fire

Comment on lines +886 to +888
CTask* task = taskManager->GetTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM);
if (task && task->GetTaskType() == TASK_SIMPLE_PLAYER_ON_FIRE)
taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call RemoveTaskSecondary without task checks? If you are unable to do so, please add RemoveSecondaryTaskIfExists in CTaskManager

Copy link
Contributor Author

@FileEX FileEX Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what's wrong with this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@TheNormalnij TheNormalnij Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can be reusable and has its own logical scope. So you can extract a method here for better readability

if (taskManager)
    taskManager->RemoveTaskSecondaryIfExists(TASK_SECONDARY_PARTIAL_ANIM, TASK_SIMPLE_PLAYER_ON_FIRE);

Or overload the RemoveTaskSecondary method:

if (taskManager)
    taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM, TASK_SIMPLE_PLAYER_ON_FIRE);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setPedOnFire(ped, false) doesn't cancel TASK_SIMPLE_PLAYER_ON_FIRE
2 participants