Skip to content

Commit e33e92c

Browse files
Stations with no living players will no longer lose power + maxed SMES at 5 players and less (#38354)
* power * fix
1 parent cf2ea35 commit e33e92c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

code/controllers/subsystem/power.dm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var/list/cable_list = list() //Index for all cables, so that powernets don't hav
1515
var/list/currentrun_cables
1616
var/list/currentrun_powerents
1717
var/list/currentrun_power_machines
18+
var/no_pop_mode // Will make powernets provide power when there's no players online.
1819

1920

2021
/datum/subsystem/power/New()
@@ -48,12 +49,19 @@ var/list/cable_list = list() //Index for all cables, so that powernets don't hav
4849
if (PC.build_status && PC.rebuild_from() && MC_TICK_CHECK)
4950
return
5051

52+
if(istype(ticker.mode, /datum/gamemode/dynamic))
53+
var/datum/gamemode/dynamic/D = ticker.mode
54+
if(!D.living_players.len)
55+
no_pop_mode = TRUE
56+
else
57+
no_pop_mode = FALSE
5158
while (currentrun_powerents.len)
5259
var/datum/powernet/powerNetwork = currentrun_powerents[currentrun_powerents.len]
5360
currentrun_powerents.len--
5461
if (!powerNetwork || powerNetwork.gcDestroyed)
5562
continue
5663

64+
powerNetwork.no_pop_mode = no_pop_mode
5765
powerNetwork.reset()
5866
if (MC_TICK_CHECK)
5967
return

code/game/gamemodes/gameticker.dm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,12 @@ var/datum/controller/gameticker/ticker
742742
play_vox_sound(sound,map.zMainStation,null)
743743

744744
create_random_orders(3) //Populate the order system so cargo has something to do
745+
if(istype(mode, /datum/gamemode/dynamic))
746+
var/datum/gamemode/dynamic/D = mode
747+
if(D.living_players.len < 6) // Fill all the SMES to capacity if there's 5 or less players, to give players more time to set up the power.
748+
for(var/obj/machinery/power/battery/smes/S in power_machines)
749+
if(S.charge) //Only do this if the SMES has any charge in the first place
750+
S.charge = S.capacity
745751

746752
// -- Tag mode!
747753
/datum/controller/gameticker/proc/tag_mode(var/mob/user)

code/modules/power/powernet.dm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// An unsatisfied_priority of 0 means either there was either no power or more than enough to cover every load, so priorities get the
1616
// same satisfaction (0% for no power, 100% for excess)
1717
var/haspulsedemon = 0
18+
var/no_pop_mode = FALSE // If on, will always fulfill load demand. This is toggled on by having zero players.
1819

1920
////////////////////////////////////////////
2021
// POWERNET DATUM PROCS
@@ -120,11 +121,13 @@
120121
// Apply loads, calculate satisfaction, and see how much excess we're left with (if any)
121122
netexcess = max(avail, 0)
122123
unsatisfied_priority = 0
123-
if (!netexcess)
124+
if (!netexcess && !no_pop_mode)
124125
satisfaction = 0 // No power -> 0% satisfaction for all
125126
else
126127
satisfaction = 1 // Assume 100% satisfaction for all, for now
127128
for (var/i in 1 to load.len)
129+
if(no_pop_mode)
130+
load[i] = 0
128131
if (netexcess >= load[i]) // Go through all loads and substract them from excess
129132
netexcess -= load[i]
130133

0 commit comments

Comments
 (0)