Cleanup of Shield Hitpoint Threshold#6851
Merged
wookieejedi merged 5 commits intoJul 24, 2025
Merged
Conversation
Overall cleanup that does a few things: 1) Changes `ship_is_shield_up` from integer to bool. 2) `ship_is_shield_up` was only ever called to look at one quadrant, never for all quadrants, so took the opportunity to update the 'all-quadrant' block to account for ships with a non-standard number of shield quadrants. 3) ` MAX(2.0f, Shield_percent_skips_damage * shield_get_max_quad(ship_objp)` was used many times throughout the code (and will be used at least 2 more times with scp-fs2open#6848), so simply consolidated all of those uses into a new function called `ship_shield_hitpoint_threshold`. Happy to edit the name however. 4) Removed un-needed redundant comments from `ship_is_shield_up` definition in `ship.h` since those comments were already present in the actual function within `shield.cpp`, and all the other functions used comments in that file instead. Again happy to tune or edit with any other choices.
Goober5000
approved these changes
Jul 24, 2025
Kestrellius
pushed a commit
to Kestrellius/fs2open.github.com
that referenced
this pull request
Jul 26, 2025
* Cleanup of Shield Hitpoint Threshold Overall cleanup that does a few things: 1) Changes `ship_is_shield_up` from integer to bool. 2) `ship_is_shield_up` was only ever called to look at one quadrant, never for all quadrants, so took the opportunity to update the 'all-quadrant' block to account for ships with a non-standard number of shield quadrants. 3) ` MAX(2.0f, Shield_percent_skips_damage * shield_get_max_quad(ship_objp)` was used many times throughout the code (and will be used at least 2 more times with scp-fs2open#6848), so simply consolidated all of those uses into a new function called `ship_shield_hitpoint_threshold`. Happy to edit the name however. 4) Removed un-needed redundant comments from `ship_is_shield_up` definition in `ship.h` since those comments were already present in the actual function within `shield.cpp`, and all the other functions used comments in that file instead. Again happy to tune or edit with any other choices. * use proper default arg style * actually commit the updated files * appease modern clang * clang round 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overall cleanup that does a few things:
Changes
ship_is_shield_upfrom integer to bool.ship_is_shield_upwas only ever called to look at one quadrant, never for all quadrants, so took the opportunity to update the 'all-quadrant' block to account for ships with a non-standard number of shield quadrants.MAX(2.0f, Shield_percent_skips_damage * shield_get_max_quad(ship_objp)was used many times throughout the code (and will be used at least 2 more times with Handle impacts for obscure code paths #6848), so simply consolidated all of those uses into a new function calledship_shield_hitpoint_threshold. Happy to edit the name however.Removed un-needed redundant comments from
ship_is_shield_updefinition inship.hsince those comments were already present in the actual function withinshield.cpp, and all the other functions used comments in that file instead.Again happy to tune or edit with any other choices.