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 - Change medical to use hashmaps for wound storage #8926

Merged
merged 5 commits into from
Jun 24, 2023

Conversation

kymckay
Copy link
Member

@kymckay kymckay commented May 29, 2022

When merged this pull request will:

  • We most frequently want to access wounds by body part, so this makes
    that a constant time lookup.
  • The body part index is no longer stored in every wound since it's
    inherent in the wound storage.
  • Using body part names as the keys of the hashmap to improve code
    clarity (no more magic numbers).

closes #6468

I've tested these relevant parts of medical which access the wound structures:

  • Wound creation still works.
  • Menu and action displays still work.
  • Damage effect updates (limping).
  • Bandaging still works.
  • Stitching still works (inc. testing incremental behaviour).
  • Wound reopening still works.
  • AI treatment still works.
  • Litter creation still works.

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}.

- We most frequently want to access wounds by body part, so this makes
  that a constant time lookup.
- The body part index is no longer stored in every wound since it's
  inherent in the wound storage.
- Using body part names as the keys of the hashmap to improve code
  clarity (no more magic numbers).

closes #6468
@kymckay kymckay added the kind/optimization Release Notes: **IMPROVED:** label May 29, 2022
@kymckay
Copy link
Member Author

kymckay commented May 29, 2022

The most awkward part to rework with hashmaps was stitching so give that code particular attention when reviewing. I've tested it pretty extensively though.

@kymckay
Copy link
Member Author

kymckay commented May 29, 2022

One consideration I just had is that this will break de-serialization across versions. I should probably add some migration code there to convert any array into a hashmap appropriately.

Will migrate from old form array wound storage to the new hashmap
strucutre during deserlization. This is relevant for communities piping
medical state out to a database or similar between sessions.
@LinkIsGrim LinkIsGrim merged commit 0236560 into master Jun 24, 2023
4 of 5 checks passed
@kymckay kymckay deleted the ky/wound-hash branch June 24, 2023 07:19
@tbeswick96
Copy link
Contributor

tbeswick96 commented Jul 8, 2023

Removed comment, raised in #9244

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

Successfully merging this pull request may close these issues.

Optimise unit wound storage
5 participants