ACE3 icon indicating copy to clipboard operation
ACE3 copied to clipboard

Medical - Change medical to use hashmaps for wound storage

Open kymckay opened this issue 2 years ago • 2 comments

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:

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

IMPORTANT

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

kymckay avatar May 29 '22 17:05 kymckay

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 avatar May 29 '22 17:05 kymckay

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.

kymckay avatar May 29 '22 17:05 kymckay

Removed comment, raised in https://github.com/acemod/ACE3/issues/9244

tbeswick96 avatar Jul 08 '23 22:07 tbeswick96