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

Medical - Prevent running FUNC(deserializeState) in scheduled environment #9662

Merged
merged 1 commit into from Dec 11, 2023

Conversation

LinkIsGrim
Copy link
Contributor

When merged this pull request will:

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

@LinkIsGrim LinkIsGrim added the kind/bug-fix Release Notes: **FIXED:** label Nov 23, 2023
@LinkIsGrim LinkIsGrim added this to the 3.16.2 milestone Nov 23, 2023
@LinkIsGrim LinkIsGrim changed the title Medical - Preventrunning FUNC(deserializeState) in scheduled environment Medical - Prevent running FUNC(deserializeState) in scheduled environment Nov 23, 2023
@johnb432
Copy link
Contributor

// Handle wound hashmaps deserialized as CBA_namespaces
if (!isNil "_value" && {_value isEqualType locationNull}) then {
    private _keys = allVariables _value;
    private _values = _keys apply {_value getVariable _x};
    _value = _keys createHashMapFromArray _values;
};

// Treat null as nil
if (isNil "_value" || {_value isEqualTo objNull}) then {
    _value = _default;
};

The suggested code above still throws an error in scheduled, so your fix is needed.

I added the !isNil "_value" and isNil "_value" checks, so that it's explicitly written. I also changed typeName _value == "LOCATION" to _value isEqualType locationNull.

@LinkIsGrim
Copy link
Contributor Author

You're gonna have to ELI5 above, besides the typeName change

@johnb432
Copy link
Contributor

You're gonna have to ELI5 above, besides the typeName change

// Handle wound hashmaps deserialized as CBA_namespaces
if (typeName _value == "LOCATION") then {
private _keys = allVariables _value;
private _values = _keys apply {_value getVariable _x};
_value = _keys createHashMapFromArray _values;
};
// Treat null as nil
if (_value isEqualTo objNull) then {
_value = _default;
};

Replace these lines with the ones I put above.

Essentially, we now are doing isNil checks where there were none previously. _value isEqualTo objNull, with _value being nil, would not behave as expected.

@PabstMirror
Copy link
Contributor

{
    private _value = _state getVariable _x;
    if (typeName _value == "LOCATION") then {
 
} forEach [
    [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME],

I'm pretty sure _value should always be defined
_x is an array not a string

@johnb432 johnb432 merged commit 892671c into master Dec 11, 2023
5 checks passed
@jonpas jonpas deleted the desearialize-directCall branch December 11, 2023 23:11
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:**
Projects
None yet
3 participants