Skip to content

Commit

Permalink
[MIRROR] Fixes smart pipe & cryo gas reallocation (#2070) (#2954)
Browse files Browse the repository at this point in the history
* Fixes smart pipe & cryo gas reallocation (#82701)

## About The Pull Request

**1. Smart Pipe Problem**
 - Fill a pipe with any gas, plasma for e.g.
 - Unwrench the pipe to deconstruct
- The pressure sends you flying but notice plasma is nowhere to be seen
from the now destroyed pipe
 
**2. Cryo pipe connector problem**
The gas gets reallocated when the object is deleted. We only want this
when its deconstructed not deleted to prevent any side effects

This PR fixes them

## Changelog
:cl:
fix: smart pipes release their gases into the air when unwrenched
fix: cryo pipe connector component has no side effects of gas
reallocation when deleted
/:cl:

* Fixes smart pipe & cryo gas reallocation

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: SyncIt21 <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent 119558e commit b4069e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
var/obj/machinery/atmospherics/components/unary/gas_connector

/datum/gas_machine_connector/New(location, obj/machinery/connecting_machine = null, direction = SOUTH, gas_volume)
gas_connector = new(location)

connected_machine = connecting_machine
if(!connected_machine)
QDEL_NULL(gas_connector)
qdel(src)
return

gas_connector = new(location)
gas_connector.dir = connected_machine.dir
gas_connector.airs[1].volume = gas_volume

Expand Down Expand Up @@ -41,7 +39,8 @@
RegisterSignal(connected_machine, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(pre_move_connected_machine))
RegisterSignal(connected_machine, COMSIG_MOVABLE_MOVED, PROC_REF(moved_connected_machine))
RegisterSignal(connected_machine, COMSIG_MACHINERY_DEFAULT_ROTATE_WRENCH, PROC_REF(wrenched_connected_machine))
RegisterSignal(connected_machine, COMSIG_QDELETING, PROC_REF(deconstruct_connected_machine))
RegisterSignal(connected_machine, COMSIG_OBJ_DECONSTRUCT, PROC_REF(deconstruct_connected_machine))
RegisterSignal(connected_machine, COMSIG_QDELETING, PROC_REF(destroy_connected_machine))

/**
* Unregister the signals previously registered
Expand All @@ -51,7 +50,8 @@
COMSIG_MOVABLE_MOVED,
COMSIG_MOVABLE_PRE_MOVE,
COMSIG_MACHINERY_DEFAULT_ROTATE_WRENCH,
COMSIG_QDELETING,
COMSIG_OBJ_DECONSTRUCT,
COMSIG_QDELETING
))

/**
Expand Down Expand Up @@ -82,12 +82,18 @@
*/
/datum/gas_machine_connector/proc/deconstruct_connected_machine()
SIGNAL_HANDLER

relocate_airs()

/**
* Called when the machine has been destroyed
*/
/datum/gas_machine_connector/proc/destroy_connected_machine()
SIGNAL_HANDLER

disconnect_connector()
SSair.stop_processing_machine(connected_machine)
unregister_from_machine()
connected_machine = null
QDEL_NULL(gas_connector)
qdel(src)

/**
Expand Down
12 changes: 6 additions & 6 deletions code/modules/atmospherics/machinery/pipes/pipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE) //if changing this, change the subtypes RemoveElements too, because thats how bespoke works

/obj/machinery/atmospherics/pipe/on_deconstruction(disassembled)
releaseAirToTurf()
//we delete the parent here so it initializes air_temporary for us. See /datum/pipeline/Destroy() which calls temporarily_store_air()
QDEL_NULL(parent)

if(air_temporary)
var/turf/T = loc
T.assume_air(air_temporary)

return ..()

Expand All @@ -61,11 +66,6 @@
replace_pipenet(parent, new /datum/pipeline)
return list(parent)

/obj/machinery/atmospherics/pipe/proc/releaseAirToTurf()
if(air_temporary)
var/turf/T = loc
T.assume_air(air_temporary)

/obj/machinery/atmospherics/pipe/return_air()
if(air_temporary)
return air_temporary
Expand Down

0 comments on commit b4069e5

Please sign in to comment.