Skip to content

Commit

Permalink
Powernet Fixes (#5891)
Browse files Browse the repository at this point in the history
# About the pull request

This PR should address some issues with SMES not connecting to the
powernet and reactors that get changed via nightmare inserts throwing
runtimes. It seems that qdeleted reactors were trying to connect to the
powernet in nullspace.

# Explain why it's good for the game

Less runtimes; and hopefully better powernet utilization.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Drathek
fix: Fixes some issues with SMES and reactors connecting to the powernet
/:cl:
  • Loading branch information
Drulikar authored Mar 7, 2024
1 parent d2ede14 commit 5b611b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions code/game/machinery/fusion_engine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
/obj/structure/machinery/power/reactor/LateInitialize() //Need to wait for powernets to start existing first
. = ..()

if(QDELETED(src))
return
if(powernet)
return

if(!connect_to_network()) //Make sure its connected to a powernet
CRASH("[src] has failed to connect to a power network. Check that it has been mapped correctly.")

Expand Down
17 changes: 13 additions & 4 deletions code/modules/power/smes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

/obj/structure/machinery/power/smes/Initialize()
. = ..()
if(!powernet)
connect_to_network()

dir_loop:
for(var/d in GLOB.cardinals)
Expand All @@ -56,14 +54,25 @@
stat |= BROKEN
return
terminal.master = src
if(!terminal.powernet)
terminal.connect_to_network()
updateicon()
start_processing()

if(!should_be_mapped)
warning("Non-buildable or Non-magical SMES at [src.x]X [src.y]Y [src.z]Z")

return INITIALIZE_HINT_ROUNDSTART

/obj/structure/machinery/power/smes/LateInitialize()
. = ..()

if(QDELETED(src))
return

if(!powernet && !connect_to_network())
CRASH("[src] has failed to connect to a power network. Check that it has been mapped correctly.")
if(terminal && !terminal.powernet)
terminal.connect_to_network()

/obj/structure/machinery/power/smes/proc/updateicon()
overlays.Cut()
if(stat & BROKEN) return
Expand Down

0 comments on commit 5b611b5

Please sign in to comment.