FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.69k stars 394 forks source link

Turret infinite power #8949

Closed Torca2001 closed 2 years ago

Torca2001 commented 2 years ago

Description Connecting the power connection to a different pin that is not power_in will allow the turret to shoot and take no power from the super capacitors

Steps To Reproduce Load up the humpback, rewire a turret so the power coming in goes to set light instead of the power pin. Fire the turret when it has sufficient charge Charge of the capacitor won't go down.

Version Windows v0.17.12.0 & Unstable v0.17.13.0

Additional information The problem arises from the GetAvailableInstantaneousBatteryPower function in Powered.cs It looks through all directly connected powerContainers to any of the turret's pins. Hence it sees the capacity of the connected capacitor's and passes the check to fire. But the firing function of the turret gets the connected powerContainers uses the GetConnectedBatteries function in Powered.cs Which uses the new grids to find all the output side connected powerContainers on a grid only on the power_In pin. Hence the power check is passed and the action of drawing power finds no powerContainers and doesn't take from them. This also brings up the other inconsistency that the turret is only considering devices directly connected to the turret and not the grid. Thus trying to power a turret through a junction box connected to a superCapacitor won't work.

Also just to entertain the idea, but possibly since discharge coils can draw a load from the grid instead of taking directly from batteries, maybe turrets should do the same? This would allow for relays (provided sufficient throughput) can be used to switch super capacitor between turrets or for a reactor that is overloading to power turrets directly.

Regalis11 commented 2 years ago

Fixed in https://github.com/Regalis11/Barotrauma-development/commit/8af35f9897251c8f38a4d57152b20e9fc8277930

Rokvach commented 2 years ago

Tested, working correctly. Closing.