Skip to content

Commit c5278e2

Browse files
committed
Allow transferring energy from shields to work properly at full shields.
A conditional originally added to shield_add_strength() to make shields not recharge beyond the recharge limit forgot to check that the amount shields are changing by was positive (unlike a couple other conditionals added/modified around the same time), so a call to shield_add_strength() with a negative delta (e.g. when transferring energy from shields to weapons) when the current shield strength is at or above the recharge limit (i.e. full strength when a recharge limit isn't specified) would immediately return without doing anything. This would, of course, result in no change to shield strength... so if you had full shields and had drained your weapon batteries dry, you could get free energy by hitting the button to transfer energy from your shields.
1 parent fe1e9ca commit c5278e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code/object/objectshield.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void shield_add_strength(object *objp, float delta) {
8787
float shield_str = shield_get_strength(objp);
8888
float shield_recharge_limit = shield_get_max_strength(objp);
8989

90-
if (shield_str >= shield_recharge_limit)
90+
if ((delta > 0.0f) && (shield_str >= shield_recharge_limit))
9191
return;
9292

9393
if (!(Ai_info[Ships[objp->instance].ai_index].ai_profile_flags[AI::Profile_Flags::Smart_shield_management])

0 commit comments

Comments
 (0)