Skip to content

Vitals - Fix bloodGas getting stuck on nil/NaN on client join - #875

Open
Andx667 wants to merge 1 commit into
KAT-Advanced-Medical:dev-Tomcatfrom
Andx667:fix/873-vitals-bloodgas-nan
Open

Andx667 wants to merge 1 commit into
KAT-Advanced-Medical:dev-Tomcatfrom
Andx667:fix/873-vitals-bloodgas-nan

Conversation

@Andx667

@Andx667 Andx667 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

When merged this pull request will:

  • Keep the default 760 mmHg for a vitals tick if ACE barometric pressure returns nil or NaN
  • Recover PaO2 from a stored nil or NaN value, so one bad tick no longer breaks SpO2 and handleEffects for the rest of the session

Fixes #873

Cause

On a client joining in progress, the first vitals tick can run before ACE common's postInit:

  • ace_weather_fnc_calculateBarometricPressure depends on ace_common_mapAltitude, which has no preInit default and is only set in ACE common's postInit.
  • ACE creates the medical state machine in preInit, so its per-frame loop can already run.
  • A JIP client receives the real CBA_missionTime early, so it passes the 1-second vitals check. A client present at mission start stays near 0 and does not.

PaO2 is calculated from its previous value, so the single nil then carries forward on every tick, even after the inputs are valid again.

Evidence

The client RPT from the reporter (KAM 3.2.1, ACE 3.21.2, CBA 3.19.0, didJIP=true) shows:

  • CBA PreInit finishes at line 1132, the only handleOxygenFunction error is at line 1160, and PostInit starts at line 1175 with mission time already at 371 s.
  • ACE pressure is a valid 993.4 hPa by 16:01:48, but bloodGas stays [40, any, NaN, 24, 7.4, 37], causing 189 handleEffects errors.
  • "Transfer of uninitialized variables" repeats 17 times, 10 to 15 s apart. This fits the vitals sync interval, so the broken bloodGas is most likely being broadcast as well.

The RPT does not print ace_common_mapAltitude itself, so that variable is inferred from the init order and the ACE source.

Testing

  • hemtt check passes, with no warnings in the changed files

IMPORTANT

  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

🤖 Generated with Claude Code

Ignore an invalid ACE barometric pressure for that tick and recover
PaO2 from a nil or NaN stored value, so one bad tick cannot break the
unit's SpO2 and feedback effects for the rest of the session.

Fixes KAT-Advanced-Medical#873

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Vitals - Player bloodGas becomes [40, nil, NaN, ...] on MP client join, causing endless handleEffects errors

1 participant