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 double execution of killed event #7531

Closed
wants to merge 5 commits into from
Closed

fix double execution of killed event #7531

wants to merge 5 commits into from

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Feb 16, 2020

When merged this pull request will:

  • I can't reproduce the error if I don't return values when the unit is dead.

Don't ask why this works.

@commy2 commy2 added the kind/bug-fix Release Notes: **FIXED:** label Feb 16, 2020
@commy2 commy2 added this to the 3.13.1 milestone Feb 16, 2020
@commy2
Copy link
Contributor Author

commy2 commented Feb 16, 2020

Please test with:

["CAManBase", "Init", { 
    params ["_unit"]; 
 
    _unit addEventHandler ["Killed", { 
        systemChat str _this;
    }]; 
}, nil, nil, true] call CBA_fnc_addClassEventHandler; 

, because:

["CAManBase", "Killed", { 
    systemChat str _this;
}] call CBA_fnc_addClassEventHandler; 

is already covered by CBATeam/CBA_A3#1291

@jonpas
Copy link
Member

jonpas commented Feb 16, 2020

Write a comment directly in the code, so it won't get cleaned up one day.

@commy2
Copy link
Contributor Author

commy2 commented Feb 16, 2020

Done.

@PabstMirror
Copy link
Contributor

Seems to report correct killer, will do mp testing soon

@PabstMirror PabstMirror self-assigned this Feb 17, 2020
_unit addEventHandler ["HandleDamage", {
// Not returning anything for dead units prevents double execution of Killed events.
private _return = _this call FUNC(handleDamage);
if (alive _unit) then {_return};
Copy link
Member

Choose a reason for hiding this comment

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

_unit is nil in this scope.

Copy link
Contributor

@PabstMirror PabstMirror Feb 18, 2020

Choose a reason for hiding this comment

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

Sadly, this is what was making it "work", our EH always just returned nil; which meant the unit just died from vanilla medical.

@PabstMirror
Copy link
Contributor

PabstMirror commented Feb 18, 2020

Still getting double killed EH

Mission [47792]: ace_medical_death event [id: 1] - [a2]
"calling setStructuralDamage (setDamage 1)"
Mission [47792]: ace_medical_woundReceived event [id: 1] - [a2,"Head",3.30751,a1,"B_65x39_Caseless",[0,3.30751,1,0,2,0.0232521,3,0.111614,4,0,5,0]]
Mission [47792]: ace_killed event [id: 0] - [a2,"FatalInjury:Death",a1,a1]
Mission [47792]: BIS addEventHandler killed [id: 1] - [a2,a2,<NULL-object>,true]
Mission [47792]: CBA addClassEventHandler killed [id: any] - [a2,a2,<NULL-object>,true] // using dev cba w/ double killed fix
Mission [47792]: BIS addEventHandler killed [id: 1] - [a2,a1,a1,true] // (modifyKilledArray disabled in handleDamage)

@commy2
Copy link
Contributor Author

commy2 commented Feb 18, 2020

@PabstMirror What does it report with this?

@PabstMirror
Copy link
Contributor

both of these caused double killed

private _return = _this call FUNC(handleDamage);
if (!alive param [0]) exitWith {diag_log "ret nil"; nil};
_return
private _return = _this call FUNC(handleDamage);
if (alive param [0]) then { _return } else {nil};

@PabstMirror PabstMirror modified the milestones: 3.13.1, Ongoing Feb 22, 2020
@jonpas jonpas deleted the fix-doubleKilled branch February 29, 2020 22:10
@jonpas jonpas modified the milestones: Ongoing, 3.13.1 Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix Release Notes: **FIXED:** status/WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants