Skip to content

Cleanup of Shield Hitpoint Threshold#6851

Merged
wookieejedi merged 5 commits into
scp-fs2open:masterfrom
wookieejedi:shield-threshold-cleanup
Jul 24, 2025
Merged

Cleanup of Shield Hitpoint Threshold#6851
wookieejedi merged 5 commits into
scp-fs2open:masterfrom
wookieejedi:shield-threshold-cleanup

Conversation

@wookieejedi

Copy link
Copy Markdown
Member

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 Handle impacts for obscure code paths #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.

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.
@wookieejedi wookieejedi added the cleanup A modification or rewrite of code to make it more understandable or easier to maintain. label Jul 20, 2025
@wookieejedi wookieejedi merged commit 168b331 into scp-fs2open:master Jul 24, 2025
20 checks passed
@wookieejedi wookieejedi deleted the shield-threshold-cleanup branch July 24, 2025 12:40
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup A modification or rewrite of code to make it more understandable or easier to maintain.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants