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 Vitals - Extract update logic to separate functions #10566

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

LinkIsGrim
Copy link
Contributor

When merged this pull request will:

  • Makes more sense IMO. Intent is for events to be used as API (IV medication/incompatible blood transfusions, for example).

Event deferral is just to keep any code from the events out of the vitals counter, but they can just be raised straight with no problems.

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 marked this pull request as draft December 17, 2024 22:05
@LinkIsGrim LinkIsGrim added the kind/cleanup Release Notes: **CHANGED:** label Dec 17, 2024
@LinkIsGrim
Copy link
Contributor Author

On another note:

  • VAR_HEMORRHAGE doesn't have any usage (and I don't think it's API?)
  • VAR_IN_PAIN could be replaced with a comparison with GET_PAIN_PERCEIVED > 0 (which is what is done in the state update, point is, we could drop the network update by doing a cheap comparison)

Drop 'em?

@LinkIsGrim LinkIsGrim changed the title Medical Vitals - Extract iv/medication consumption & state update Medical Vitals - Extract update logic to separate functions Dec 18, 2024
};
} forEachReversed _ivBags;

(GVAR(deferredEvents) getOrDefault [_unit, [], true]) pushBack ([QEGVAR(medical,consumedIVs), [_unit, _consumedIVs]]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Key can't be an object, you need to use hashValue first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally not a huge fan of having a global hashmap for this kind of thing:

  1. If the unit is deleted, you need to handle the removal from the hashmap.
  2. If the unit switches locality, this can't handle it. Idk how important that is though.

Why not use an object variable instead? Handles 1) and no longer requires hashValue _unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hashmap is slightly faster (might not be with hashvalue), that was the only incentive. If we don't have to worry about keeping 3rd-party code out of the counter, I'd rather just raise the events outright.
locality change and deletion won't (shouldn't) happen mid-execution, deferred events are still executed on the same frame, so it'll be either before or after handleUnitVitals is executed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather just raise the events outright

Do that then, makes more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Release Notes: **CHANGED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants