Prepare Atmospherics Machinery for SSatoms (#4501)

* to_chat() replacement.

* Revert calling target.init_dir() before connecting.

* This change was added in https://github.com/PolarisSS13/Polaris/pull/3775 to counteract `dir` not being set prior to New() for dynamically loaded maps.  The root cause was /atom/New() not calling _preloader.load().  Undoing the change now that /atom/New() is fixed.
* The addition of the init_dir() proc itself however, is useful, because there ARE other times some atmos machinery will want to re-initialize its dir, specifically whenever it is rotated.
* init_dir() must be called in the constructor of all atmospherics machines capable of connecting to another.   Since it has to happen for ALL machines, lets move that call to /obj/machinery/atmospherics/New()

* Rename /obj/machinery/atmospherics initialize() to atmos_init()

* These days `initialize()` is used to handle general object initialization that is moved outside of New().  The node connection discovery of atmos machinery needs to happen after all that, and so needs to be in a separate proc.
* Make sure to actually call atmos_init during system startup.
This commit is contained in:
Leshana
2018-01-06 11:52:56 -05:00
committed by Anewbe
parent e23c002eb5
commit 224fe42e77
28 changed files with 238 additions and 297 deletions

View File

@@ -57,24 +57,20 @@
node1 = null
node2 = null
/obj/machinery/atmospherics/binary/initialize()
/obj/machinery/atmospherics/binary/atmos_init()
if(node1 && node2)
return
init_dir()
var/node2_connect = dir
var/node1_connect = turn(dir, 180)
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target

View File

@@ -101,13 +101,13 @@
else if(dir & (EAST|WEST))
initialize_directions = EAST|WEST
initialize()
atmos_init()
build_network()
if (node1)
node1.initialize()
node1.atmos_init()
node1.build_network()
if (node2)
node2.initialize()
node2.atmos_init()
node2.build_network()
else
if(node1)

View File

@@ -166,7 +166,7 @@
return
src.add_fingerprint(usr)
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
usr.set_machine(src)
ui_interact(user)
@@ -240,14 +240,14 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (unlocked)
user << "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -87,7 +87,7 @@
if(istype(W, /obj/item/weapon/wrench))
anchored = !anchored
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding \the [src] to the floor.</span>"
to_chat(user, "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding \the [src] to the floor.</span>")
if(anchored)
if(dir & (NORTH|SOUTH))
@@ -95,13 +95,13 @@
else if(dir & (EAST|WEST))
initialize_directions = NORTH|SOUTH
initialize()
atmos_init()
build_network()
if (node1)
node1.initialize()
node1.atmos_init()
node1.build_network()
if (node2)
node2.initialize()
node2.atmos_init()
node2.build_network()
else
if(node1)
@@ -153,7 +153,7 @@
return null
initialize()
atmos_init()
if(node1 && node2) return
var/node2_connect = turn(dir, -90)
@@ -260,7 +260,7 @@
anchored = !anchored
playsound(src, W.usesound, 50, 1)
turbine = null
user << "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding \the [src] to the floor.</span>"
to_chat(user, "<span class='notice'>You [anchored ? "secure" : "unsecure"] the bolts holding \the [src] to the floor.</span>")
updateConnection()
else
..()

View File

@@ -183,7 +183,7 @@ Thus, the two variables affect pump operation are set in New():
return
src.add_fingerprint(usr)
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
usr.set_machine(src)
ui_interact(user)
@@ -219,14 +219,14 @@ Thus, the two variables affect pump operation are set in New():
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (!(stat & NOPOWER) && use_power)
user << "<span class='warning'>You cannot unwrench this [src], turn it off first.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench this [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -40,10 +40,10 @@
/datum/omni_port/proc/connect()
if(node)
return
master.initialize()
master.atmos_init()
master.build_network()
if(node)
node.initialize()
node.atmos_init()
node.build_network()
/datum/omni_port/proc/disconnect()

View File

@@ -86,7 +86,7 @@
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
playsound(src, W.usesound, 50, 1)
if(do_after(user, 40 * W.toolspeed))
user.visible_message( \
@@ -245,14 +245,13 @@
qdel(P.network)
P.node = null
..()
. = ..()
/obj/machinery/atmospherics/omni/initialize()
/obj/machinery/atmospherics/omni/atmos_init()
for(var/datum/omni_port/P in ports)
if(P.node || P.mode == 0)
continue
for(var/obj/machinery/atmospherics/target in get_step(src, P.dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
P.node = target

View File

@@ -21,10 +21,6 @@
/obj/machinery/atmospherics/portables_connector/init_dir()
initialize_directions = dir
/obj/machinery/atmospherics/portables_connector/New()
init_dir()
..()
/obj/machinery/atmospherics/portables_connector/update_icon()
icon_state = "connector"
@@ -74,16 +70,13 @@
node = null
/obj/machinery/atmospherics/portables_connector/initialize()
/obj/machinery/atmospherics/portables_connector/atmos_init()
if(node)
return
init_dir()
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target
@@ -138,7 +131,7 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (connected_device)
user << "<span class='warning'>You cannot unwrench \the [src], dettach \the [connected_device] first.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], dettach \the [connected_device] first.</span>")
return 1
if (locate(/obj/machinery/portable_atmospherics, src.loc))
return 1
@@ -147,7 +140,7 @@
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -136,7 +136,7 @@
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
@@ -151,7 +151,7 @@
return
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
var/dat
@@ -247,9 +247,7 @@ obj/machinery/atmospherics/trinary/atmos_filter/m_filter/init_dir()
if(WEST)
initialize_directions = WEST|SOUTH|EAST
/obj/machinery/atmospherics/trinary/atmos_filter/m_filter/initialize()
set_frequency(frequency)
/obj/machinery/atmospherics/trinary/atmos_filter/m_filter/atmos_init()
if(node1 && node2 && node3) return
var/node1_connect = turn(dir, -180)

View File

@@ -111,7 +111,7 @@
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
@@ -125,7 +125,7 @@
return
src.add_fingerprint(usr)
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
usr.set_machine(src)
var/dat = {"<b>Power: </b><a href='?src=\ref[src];power=1'>[use_power?"On":"Off"]</a><br>
@@ -192,7 +192,7 @@ obj/machinery/atmospherics/trinary/mixer/t_mixer/init_dir()
if(WEST)
initialize_directions = WEST|NORTH|SOUTH
obj/machinery/atmospherics/trinary/mixer/t_mixer/initialize()
obj/machinery/atmospherics/trinary/mixer/t_mixer/atmos_init()
..()
if(node1 && node2 && node3) return
@@ -237,7 +237,7 @@ obj/machinery/atmospherics/trinary/mixer/m_mixer/init_dir()
if(WEST)
initialize_directions = WEST|SOUTH|EAST
obj/machinery/atmospherics/trinary/mixer/m_mixer/initialize()
obj/machinery/atmospherics/trinary/mixer/m_mixer/atmos_init()
..()
if(node1 && node2 && node3) return

View File

@@ -15,7 +15,6 @@
/obj/machinery/atmospherics/trinary/New()
..()
init_dir()
air1 = new
air2 = new
@@ -71,31 +70,26 @@
node2 = null
node3 = null
/obj/machinery/atmospherics/trinary/initialize()
/obj/machinery/atmospherics/trinary/atmos_init()
if(node1 && node2 && node3)
return
init_dir()
var/node1_connect = turn(dir, -180)
var/node2_connect = turn(dir, -90)
var/node3_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node1_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node3_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target

View File

@@ -46,10 +46,6 @@
/obj/machinery/atmospherics/tvalve/hide(var/i)
update_underlays()
/obj/machinery/atmospherics/tvalve/New()
init_dir()
..()
/obj/machinery/atmospherics/tvalve/init_dir()
switch(dir)
if(NORTH)
@@ -183,31 +179,26 @@
return
/obj/machinery/atmospherics/tvalve/initialize()
/obj/machinery/atmospherics/tvalve/atmos_init()
var/node1_dir
var/node2_dir
var/node3_dir
init_dir()
node1_dir = turn(dir, 180)
node2_dir = turn(dir, -90)
node3_dir = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node3_dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node3 = target
@@ -308,7 +299,7 @@
if(!powered())
return
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
..()
@@ -350,14 +341,14 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (istype(src, /obj/machinery/atmospherics/tvalve/digital))
user << "<span class='warning'>You cannot unwrench \the [src], it's too complicated.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it's too complicated.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warnng'>You cannot unwrench \the [src], it too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
@@ -384,7 +375,7 @@
if(WEST)
initialize_directions = EAST|WEST|SOUTH
/obj/machinery/atmospherics/tvalve/mirrored/initialize()
/obj/machinery/atmospherics/tvalve/mirrored/atmos_init()
var/node1_dir
var/node2_dir
var/node3_dir
@@ -446,7 +437,7 @@
if(!powered())
return
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
..()

View File

@@ -23,7 +23,6 @@
/obj/machinery/atmospherics/unary/freezer/New()
..()
initialize_directions = dir
component_parts = list()
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
@@ -32,7 +31,7 @@
component_parts += new /obj/item/stack/cable_coil(src, 2)
RefreshParts()
/obj/machinery/atmospherics/unary/freezer/initialize()
/obj/machinery/atmospherics/unary/freezer/atmos_init()
if(node)
return

View File

@@ -18,7 +18,7 @@
return
initialize()
atmos_init()
if(!partner)
var/partner_connect = turn(dir,180)
@@ -70,14 +70,14 @@
return ..()
var/turf/T = src.loc
if (level==1 && isturf(T) && !T.is_plating())
user << "<span class='warning'>You must remove the plating first.</span>"
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if (!can_unwrench())
user << "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -23,7 +23,6 @@
/obj/machinery/atmospherics/unary/heater/New()
..()
initialize_directions = dir
component_parts = list()
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/capacitor(src)
@@ -32,7 +31,7 @@
RefreshParts()
/obj/machinery/atmospherics/unary/heater/initialize()
/obj/machinery/atmospherics/unary/heater/atmos_init()
if(node)
return

View File

@@ -13,7 +13,6 @@
/obj/machinery/atmospherics/unary/New()
..()
init_dir()
air_contents = new
air_contents.volume = 200
@@ -42,16 +41,13 @@
node = null
/obj/machinery/atmospherics/unary/initialize()
/obj/machinery/atmospherics/unary/atmos_init()
if(node)
return
init_dir()
var/node_connect = dir
for(var/obj/machinery/atmospherics/target in get_step(src,node_connect))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node = target

View File

@@ -357,7 +357,7 @@
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if (WT.remove_fuel(0,user))
user << "<span class='notice'>Now welding the vent.</span>"
to_chat(user, "<span class='notice'>Now welding the vent.</span>")
if(do_after(user, 20 * WT.toolspeed))
if(!src || !WT.isOn()) return
playsound(src.loc, WT.usesound, 50, 1)
@@ -370,9 +370,9 @@
welded = 0
update_icon()
else
user << "<span class='notice'>The welding tool needs to be on to start this task.</span>"
to_chat(user, "<span class='notice'>The welding tool needs to be on to start this task.</span>")
else
user << "<span class='warning'>You need more welding fuel to complete this task.</span>"
to_chat(user, "<span class='warning'>You need more welding fuel to complete this task.</span>")
return 1
else
..()
@@ -395,18 +395,18 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (!(stat & NOPOWER) && use_power)
user << "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
user << "<span class='warning'>You must remove the plating first.</span>"
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -266,18 +266,18 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (!(stat & NOPOWER) && use_power)
user << "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>"
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], turn it off first.</span>")
return 1
var/turf/T = src.loc
if (node && node.level==1 && isturf(T) && !T.is_plating())
user << "<span class='warning'>You must remove the plating first.</span>"
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \

View File

@@ -140,8 +140,7 @@
return
/obj/machinery/atmospherics/valve/initialize()
init_dir()
/obj/machinery/atmospherics/valve/atmos_init()
normalize_dir()
var/node1_dir
@@ -155,13 +154,11 @@
node2_dir = direction
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
target.init_dir()
if(target.initialize_directions & get_dir(target,src))
if (check_connect_types(target,src))
node2 = target
@@ -239,7 +236,7 @@
if(!powered())
return
if(!src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return
..()
@@ -292,14 +289,14 @@
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (istype(src, /obj/machinery/atmospherics/valve/digital) && !src.allowed(user))
user << "<span class='warning'>Access denied.</span>"
to_chat(user, "<span class='warning'>Access denied.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
user << "<span class='notice'>You begin to unfasten \the [src]...</span>"
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \