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

Use cata::optional for mutation value calculations #42932

Merged
merged 1 commit into from
Aug 16, 2020

Conversation

mqrause
Copy link
Contributor

@mqrause mqrause commented Aug 15, 2020

Summary

SUMMARY: Infrastructure "Use cata::optional for mutation value calculations"

Purpose of change

When looking into #42853 I found that all mutations will always have all values despite them having nothing to do with them. They will also all need to be initialized to different values (0 or 1) depending on how they're intended to be used. Using optional values streamlines the initialization and makes sure only mutations with explicitly stated values will get accounted for in calculations.

Describe the solution

Change types from float to cata::optional and initialize with cata::nullopt.

Describe alternatives you've considered

Leaving as is and hoping there won't be another issue like that.

Testing

Loaded a game with a character with some traits I changed and tested if they still work.

Additional context

There are still a bunch of normal values in mutation.h because I only changed the ones used in the calc_mutation_value, calc_mutation_value_additive and calc_mutation_value_multiplicative methods.

…tional

- adjust calc_mutation_value methods to only use mutations with a set value
@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies labels Aug 15, 2020
@mqrause
Copy link
Contributor Author

mqrause commented Aug 15, 2020

@ZhilkinSerg This isn't really a bugfix. The bug from the issue got fixed in #42923. This is more of a followup cleanup to reduce the chance of similar bugs popping up again.

@ZhilkinSerg ZhilkinSerg added Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style and removed <Bugfix> This is a fix for a bug (or closes open issue) labels Aug 15, 2020
@ZhilkinSerg ZhilkinSerg merged commit 404f991 into CleverRaven:master Aug 16, 2020
@mqrause mqrause deleted the optional_mutation_values branch August 24, 2020 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants