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

Don't silently fail when attempting to modify vits #1476

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented Apr 23, 2022

Summary

SUMMARY: Fixes vitamin bug that prevents new chars from gaining/losing vitamins.

Purpose of change

Fixes #1466 so that newly created characters will have vitamins change, particularly useful in our case for mutagenic toxins.

Does this by porting 42044 from DDA.

Describe the solution

Stop silently failing when attempting to modify a vitamin that is not already contained, and instead add it to the vitamin_levels map, and change the character loading function to avoid the behavior that hid this problem in the past - filling out the vitamin map completely even if there was nothing to load for it.

Describe alternatives you've considered

Testing

Created new custom character, add mutant lard and waited 30 minutes. Checked that mutagenic toxins rose. Saved and loaded char and ensured progression of mutagenic toxins continued.

Additional context

For some reason, attempting to modify a vitamin would silently fail when
the character's `vitamin_levels` map did not contain that vitamin.
However, this map never actually had vitamins added to it... except when
the game was loaded, in deserializing the character's vitamin levels.
This doesn't appear to be very purposeful, just a side effect of using
the ids of the vitamins as keys for the amount of that vitamin, and not
bailing out if the key was not found.

This meant on the first time a new character was loaded, before you
saved and reloaded, any vitamins would not work, particularly the blood
vitamins.

Stop silently failing when attempting to modify a vitamin that is not
already contained, and instead add it to the `vitamin_levels` map, and
change the character loading function to avoid the behavior that hid
this problem in the past - filling out the vitamin map completely even
if there was nothing to load for it.
@Coolthulhu Coolthulhu self-assigned this Apr 25, 2022
@Coolthulhu Coolthulhu merged commit 941e713 into cataclysmbnteam:upload Apr 26, 2022
@KheirFerrum KheirFerrum deleted the Vitamin-fix branch April 26, 2022 23:18
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.

Mutagenic toxins seem to be non-functional
3 participants