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

Stop power armors and FB51 optical cloak from eating peoples energy while being inactive #36840

Merged
merged 1 commit into from
Jan 9, 2020

Conversation

park66665
Copy link
Contributor

Summary

SUMMARY: Bugfixes "Fix issues related with UPS-using worn items"

Purpose of change

A few items are processed by player::process_items(). Most of the items are not processed by the function like a good boy. Inactive power armors and inactive FB51 optical cloak should be good boys too and left unprocessed.

Restoration of the natural order of things will fix five unpleasant behaviors:

  1. FB51 optical cloak spamming Your cloaking flickers and becomes opaque. while there is no power; it should be shown only once.
  2. FB51 optical cloak consuming UPS charges despite being inactive.
  3. Power armors spamming Your power armor disengages. while there is no power; it should be shown only once.
  4. Power armors consuming bionic power despite being inactive: fixes Power armor drains power while deactivated #35885
  5. Power armors consuming UPS charges despite being inactive: also mentioned in Power armor drains power while deactivated #35885

Describe the solution

Before #35295 there was a if( !w.active ) { continue; } in the for( item &w : worn ) loop that prevented cloak and power_armor from pointing inactive items, but it was removed at #35295. Since cloak and power_armor pointers should only point to active items, I simply restored that behavior by duct-taping if( w.active ).

Describe alternatives you've considered

  1. Using if( !w.active ) { continue; }. Simpler if( w.active ) approach was chosen due to its visibility.
  2. Adding && w.active at each if statements. Felt a little bit duplicative.
  3. Making a new for loop. It is kinda meaningless.
  4. Completely rewrite the whole function and move it to Character or something. It is too much hassle.

Testing

I astyled it, I compiled it, and I tested it.

Screenshot_2020-01-09_14-50-30

Don't panic about the time! I'm not from the future. It's just UTC+09:00.

I also field-tested the changes. Everything worked as expected.

Additional context

tbh I spent too much time on this.

@park66665 park66665 changed the title Stop power armors and FB optical cloak from eating peoples energy while being inactive Stop power armors and FB51 optical cloak from eating peoples energy while being inactive Jan 9, 2020
@Rivet-the-Zombie Rivet-the-Zombie merged commit b8625b0 into CleverRaven:master Jan 9, 2020
fengjixuchui added a commit to fengjixuchui/Cataclysm-DDA that referenced this pull request Jan 9, 2020
Merge pull request CleverRaven#36840 from park66665/fixitxenomedes
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.

Power armor drains power while deactivated
2 participants