mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 17:41:05 +00:00
## About The Pull Request
Infinite capacity power cells and megacells were returning TRUE (which
evaluates to 1) instead of the actual amount used in their use()
methods. This caused bugs when large electrical loads were applied, as
the power system expected the actual amount consumed to be returned for
proper power accounting. Without this fix, the infinite capacity
megacell would not work properly on the main power grid of the station
as the load would be too big, and it would choke the power grid.
This is the use() method.
```C
/// Use power from the cell.
/// Args:
/// - used: Amount of power in joules to use.
/// - force: If true, uses the remaining power from the cell if there isn't enough power to supply the demand.
/// Returns: The power used from the cell in joules.
/obj/item/stock_parts/power_store/use(used, force = FALSE)
var/power_used = min(used, charge) // Calculate how much power we can actually provide
if(rigged && power_used > 0)
explode()
return 0 // Cell exploded, no power provided
if(!force && charge < used)
return 0 // Not enough charge and force=FALSE, no power provided
charge -= power_used // Reduce the cell's charge by the amount used
if(!istype(loc, /obj/machinery/power/apc))
SSblackbox.record_feedback("tally", "cell_used", 1, type)
return power_used // Return the actual amount of power provided
```
It is overridden in battery.dm and cell.dm but the override is
implemented inccorectly. This PR fixes that.
Changes:
- battery.dm: Changed infinite battery use() to return used instead of
TRUE
- cell.dm: Changed infinite cell use() to return used instead of TRUE
## Why It's Good For The Game
Its a bug fix.
## Changelog
🆑
fix: Fixed a bug where infinite capacity power cells and megacells
wouldn't work on large power grids (high loads).
/🆑
91 lines
3.3 KiB
Plaintext
91 lines
3.3 KiB
Plaintext
/obj/item/stock_parts/power_store/battery
|
|
name = "megacell"
|
|
desc = "A series of rechargeable electrochemical cells wired together to hold significantly more power than a standard power cell."
|
|
icon = 'icons/obj/machines/cell_charger.dmi'
|
|
icon_state = "cellbig"
|
|
cell_size_prefix = "cellbig"
|
|
inhand_icon_state = "cell"
|
|
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
force = 10
|
|
throwforce = 5
|
|
throw_speed = 2
|
|
throw_range = 2
|
|
custom_materials = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT*12, /datum/material/glass=SMALL_MATERIAL_AMOUNT*2)
|
|
grind_results = list(/datum/reagent/lithium = 60, /datum/reagent/iron = 10, /datum/reagent/silicon = 10)
|
|
rating_base = STANDARD_BATTERY_CHARGE
|
|
maxcharge = STANDARD_BATTERY_CHARGE
|
|
chargerate = STANDARD_BATTERY_RATE
|
|
|
|
/obj/item/stock_parts/power_store/battery/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/upgraded
|
|
name = "upgraded megacell"
|
|
desc = "A battery with a slightly higher capacity than normal!"
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 2.5
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT*2.5)
|
|
chargerate = STANDARD_BATTERY_RATE * 0.5
|
|
|
|
/obj/item/stock_parts/power_store/battery/high
|
|
name = "high-capacity megacell"
|
|
icon_state = "hcellbig"
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 10
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT * 3)
|
|
chargerate = STANDARD_BATTERY_RATE * 0.75
|
|
|
|
/obj/item/stock_parts/power_store/battery/high/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/super
|
|
name = "super-capacity megacell"
|
|
icon_state = "scellbig"
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 20
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT * 4)
|
|
chargerate = STANDARD_BATTERY_RATE
|
|
|
|
/obj/item/stock_parts/power_store/battery/super/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/hyper
|
|
name = "hyper-capacity megacell"
|
|
icon_state = "hpcellbig"
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 30
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT * 5)
|
|
chargerate = STANDARD_BATTERY_RATE * 1.5
|
|
|
|
/obj/item/stock_parts/power_store/battery/hyper/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/bluespace
|
|
name = "bluespace megacell"
|
|
desc = "A rechargeable transdimensional megacell."
|
|
icon_state = "bscellbig"
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 40
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT*6)
|
|
chargerate = STANDARD_BATTERY_RATE * 2
|
|
|
|
/obj/item/stock_parts/power_store/battery/bluespace/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/crap
|
|
name = "\improper Nanotrasen brand rechargeable AA megacell"
|
|
desc = "You can't top the plasma top." //TOTALLY TRADEMARK INFRINGEMENT
|
|
maxcharge = STANDARD_BATTERY_CHARGE * 0.5
|
|
custom_materials = list(/datum/material/glass=SMALL_MATERIAL_AMOUNT*1)
|
|
|
|
/obj/item/stock_parts/power_store/battery/crap/empty
|
|
empty = TRUE
|
|
|
|
/obj/item/stock_parts/power_store/battery/infinite
|
|
name = "infinite-capacity megacell"
|
|
desc = "A transdimensional megacell with an inexhaustible capacity."
|
|
icon_state = "icellbig"
|
|
maxcharge = INFINITY
|
|
chargerate = INFINITY
|
|
ratingdesc = FALSE
|
|
|
|
/obj/item/stock_parts/power_store/battery/infinite/use(used, force = FALSE)
|
|
return used
|