Skip to content
Browse files

Fixed potential negative energy gain when shield boosters got damaged…

…. Added comment at the point in the core where such condition is allowed to oocur, but left it unchanged in case OXPs rely on this behaviour.
  • Loading branch information...
AnotherCommander committed Jan 4, 2016
1 parent d73c8b3 commit 623f9efd1b7ae5259fc1a27766e355d834ca38b6
Showing with 10 additions and 0 deletions.
  1. +2 −0 Resources/Scripts/oolite-equipment-control.js
  2. +8 −0 src/Core/Entities/PlayerEntity.m
@@ -191,7 +191,9 @@ this.$equipmentEnable["EQ_SHIELD_BOOSTER"] = this.$equipmentEnable["EQ_NAVAL_SHI
this.$equipmentDisable["EQ_SHIELD_BOOSTER"] = this.$equipmentDisable["EQ_NAVAL_SHIELD_BOOSTER"] = function(info)
player.ship.maxForwardShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
if (player.ship.forwardShield > player.ship.maxForwardShield) player.ship.forwardShield = player.ship.maxForwardShield;
player.ship.maxAftShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
if (player.ship.aftShield > player.ship.maxAftShield) player.ship.aftShield = player.ship.maxAftShield;
player.ship.forwardShieldRechargeRate /= parseFloat(info.scriptInfo.oolite_shield_recharge_multiplier);
player.ship.aftShieldRechargeRate /= parseFloat(info.scriptInfo.oolite_shield_recharge_multiplier);
if (player.ship.docked)
@@ -2563,6 +2563,14 @@ - (void) doBookkeeping:(double) delta_t
float aftMax = [self maxAftShieldLevel];
float shieldRechargeFwd = [self forwardShieldRechargeRate] * delta_t;
float shieldRechargeAft = [self aftShieldRechargeRate] * delta_t;
/* there is potential for negative rechargeFwd and rechargeAFt values here
(e.g. getting shield boosters damaged while shields are full). This may
lead to energy being gained rather than consumed when recharging. Leaving
as-is for now, as there might be OXPs that rely in such behaviour.
Boosters case example mentioned above is the only known core equipment
occurrence at this time and it has been fixed inside the
oolite-equipment-control.js script. - Nikos 20160104.
float rechargeFwd = MIN(shieldRechargeFwd, fwdMax - forward_shield);
float rechargeAft = MIN(shieldRechargeAft, aftMax - aft_shield);

1 comment on commit 623f9ef


This comment has been minimized.

Copy link
Member Author

commented on 623f9ef Jan 4, 2016

The word "negative" in the commit comment shouldn't be there - it should read "Fixed potential energy gain when shield boosters got damaged…". Sorry for any confusion caused.

Please sign in to comment.
You can’t perform that action at this time.