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

Consolidate waking up code #40069

Merged
merged 1 commit into from
May 2, 2020

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

Almost the same code was present in avatar::wake_up and player_hardcoded_effects. In particular, this code duplication meant that I missed some wake up cases when I added the event for waking up, making the survival achievement fail to trigger sometimes.

Describe the solution

Consolidate the two into one implementation.

Describe alternatives you've considered

The two were very slightly different. Based on my analysis of the code I think my merged implementation is equivalent or better, but it's hard to think about (or test) every corner case. Waking up interacts with alarms in a complicated way.

Testing

I played the game and ensured that waking normally and via an alarm seemed to work as expected.

Additional context

Discovered while testing achievements.

Almost the same code was present in avatar::wake_up and
player_hardcoded_effects.  Consolidate the two into one implementation.
Comment on lines -1254 to -1255
get_effect( effect_slept_through_alarm ).set_duration( 0_turns );
remove_effect( effect_alarm_clock );
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see these two lines present after the change. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

avatar::wake_up calls Character::wake_up, and that removes these two effects (albeit with slightly different code).

@ifreund ifreund added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels May 2, 2020
Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

Thanks!

@ifreund ifreund merged commit 771b6be into CleverRaven:master May 2, 2020
@jbytheway jbytheway deleted the consolidate_wake_up_code branch May 2, 2020 13:19
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants