Skip to content

Commit

Permalink
Changes power_change() to respect parent calls, modernizes and makes …
Browse files Browse the repository at this point in the history
…it suck less (#9865)

* tgstation/tgstation#46486

* CONVEYOR FIXES
  • Loading branch information
Tsar-Salat authored Sep 29, 2023
1 parent 121e182 commit 11851ed
Show file tree
Hide file tree
Showing 59 changed files with 119 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#define COMSIG_MACHINE_CLOSE "machine_close"
//from /obj/machinery/obj_break(damage_flag): (damage_flag)
#define COMSIG_MACHINERY_BROKEN "machinery_broken"
///from base power_change() when power is lost
#define COMSIG_MACHINERY_POWER_LOST "machinery_power_lost"
///from base power_change() when power is restored
#define COMSIG_MACHINERY_POWER_RESTORED "machinery_power_restored"
///from /obj/machinery/set_occupant(atom/movable/O): (new_occupant)
#define COMSIG_MACHINERY_SET_OCCUPANT "machinery_set_occupant"

Expand Down
5 changes: 0 additions & 5 deletions code/game/machinery/PDApainter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,6 @@
storedid = null
update_icon()

/obj/machinery/pdapainter/power_change()
..()
update_icon()


/proc/get_card_style_list(emagged)
var/static/valid_jobs = list(
"----Command----", "Command (Custom)",JOB_NAME_CAPTAIN,"Acting Captain",
Expand Down
10 changes: 7 additions & 3 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,14 @@ Class Procs:
if(processing_flags & START_PROCESSING_ON_INIT)
begin_processing()

power_change()
RegisterSignal(src, COMSIG_MOVABLE_ENTERED_AREA, PROC_REF(power_change))

if(occupant_typecache)
occupant_typecache = typecacheof(occupant_typecache)

if(!seller_department)
seller_department = dept_req_for_free

return INITIALIZE_HINT_LATELOAD

/obj/machinery/proc/set_occupant(atom/movable/new_occupant)
SHOULD_CALL_PARENT(TRUE)

Expand All @@ -184,6 +183,11 @@ Class Procs:
var/datum/controller/subsystem/processing/subsystem = locate(subsystem_type) in Master.subsystems
STOP_PROCESSING(subsystem, src)

/obj/machinery/LateInitialize()
. = ..()
power_change()
RegisterSignal(src, COMSIG_MOVABLE_ENTERED_AREA, PROC_REF(power_change))

/obj/machinery/Destroy()
GLOB.machines.Remove(src)
if(datum_flags & DF_ISPROCESSING) // A sizeable portion of machines stops processing before qdel
Expand Down
13 changes: 4 additions & 9 deletions code/game/machinery/ai_slipper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
. = ..()
. += "<span class='notice'>It has <b>[uses]</b> uses of foam remaining.</span>"

/obj/machinery/ai_slipper/power_change()
/obj/machinery/ai_slipper/update_icon()
if(machine_stat & BROKEN)
return
if((machine_stat & NOPOWER) || cooldown_time > world.time || !uses)
icon_state = "ai-slipper0"
else
if(powered())
set_machine_stat(machine_stat & ~NOPOWER)
else
set_machine_stat(machine_stat | NOPOWER)
if((machine_stat & (NOPOWER|BROKEN)) || cooldown_time > world.time || !uses)
icon_state = "ai-slipper0"
else
icon_state = "ai-slipper1"
icon_state = "ai-slipper1"

/obj/machinery/ai_slipper/interact(mob/user)
if(!allowed(user))
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/announcement_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ GLOBAL_LIST_EMPTY(announcement_systems)
GLOB.announcement_systems -= src //"OH GOD WHY ARE THERE 100,000 LISTED ANNOUNCEMENT SYSTEMS?!!"
return ..()

/obj/machinery/announcement_system/power_change()
..()
update_icon()

/obj/machinery/announcement_system/attackby(obj/item/P, mob/user, params)
if(P.tool_behaviour == TOOL_SCREWDRIVER)
P.play_tool_sound(src)
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/aug_manipulator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,3 @@
return
else
eject_part(user)

/obj/machinery/aug_manipulator/power_change()
..()
update_icon()
4 changes: 0 additions & 4 deletions code/game/machinery/buttons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@

addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, update_icon)), 15)

/obj/machinery/button/power_change()
..()
update_icon()


/obj/machinery/button/door
name = "door button"
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
. += emissive_appearance(icon, icon_screen)

/obj/machinery/computer/power_change()
..()
. = ..()
if(!.)
return // reduce unneeded light changes
if(machine_stat & NOPOWER)
set_light(FALSE)
else
set_light(TRUE)
update_appearance()
return

/obj/machinery/computer/screwdriver_act(mob/living/user, obj/item/I)
if(..())
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/dna_scanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
//running
icon_state = initial(icon_state)+ (state_open ? "_open" : "")

/obj/machinery/dna_scannernew/power_change()
..()
update_icon()

/obj/machinery/dna_scannernew/proc/toggle_open(mob/user)
if(locked)
to_chat(user, "<span class='notice'>The bolts are locked down, securing the door [state_open ? "open" : "shut"].</span>")
Expand Down
5 changes: 0 additions & 5 deletions code/game/machinery/doors/brigdoors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@
timer_end() // open doors, reset timer, clear status screen
update_icon()

// has the door power sitatuation changed, if so update icon.
/obj/machinery/door_timer/power_change()
..()
update_icon()

// open/closedoor checks if door_timer has power, if so it checks if the
// linked door is open/closed (by density) then opens it/closes it.
/obj/machinery/door_timer/proc/timer_start()
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
else
layer = initial(layer)

/obj/machinery/door/power_change()
..()
update_icon()

/obj/machinery/door/Destroy()
update_freelook_sight()
GLOB.airlocks -= src
Expand Down
7 changes: 2 additions & 5 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@


/obj/machinery/door/firedoor/power_change()
if(powered(power_channel))
set_machine_stat(machine_stat & ~NOPOWER)
INVOKE_ASYNC(src, PROC_REF(latetoggle))
else
set_machine_stat(machine_stat | NOPOWER)
. = ..()
INVOKE_ASYNC(src, PROC_REF(latetoggle))

/obj/machinery/door/firedoor/attack_hand(mob/user)
. = ..()
Expand Down
16 changes: 9 additions & 7 deletions code/game/machinery/doppler_array.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,18 @@

return TRUE

/obj/machinery/doppler_array/power_change()
/obj/machinery/doppler_array/powered()
if(!anchored)
return FALSE
return ..()

/obj/machinery/doppler_array/update_icon()
if(machine_stat & BROKEN)
icon_state = "[initial(icon_state)]-broken"
else if(powered())
icon_state = initial(icon_state)
else
if(powered() && anchored)
icon_state = initial(icon_state)
set_machine_stat(machine_stat & ~NOPOWER)
else
icon_state = "[initial(icon_state)]-off"
set_machine_stat(machine_stat | NOPOWER)
icon_state = "[initial(icon_state)]-off"

//Portable version, built into EOD equipment. It simply provides an explosion's three damage levels.
/obj/machinery/doppler_array/integrated
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/droneDispenser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@
if((mode == DRONE_RECHARGING) && !machine_stat && recharging_text)
. += "<span class='warning'>[recharging_text]</span>"

/obj/machinery/droneDispenser/power_change()
..()
update_icon()

/obj/machinery/droneDispenser/process()
if((machine_stat & (NOPOWER|BROKEN)) || !anchored)
return
Expand Down
7 changes: 1 addition & 6 deletions code/game/machinery/embedded_controller/access_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@
else
icon_state = "access_button_standby"

/obj/machinery/doorButtons/access_button/power_change()
..()
update_icon()

/obj/machinery/doorButtons/access_button/removeMe(obj/O)
if(O == door)
door = null
Expand Down Expand Up @@ -229,13 +225,12 @@
cycleOpen(interiorAirlock)

/obj/machinery/doorButtons/airlock_controller/power_change()
..()
. = ..()
if(machine_stat & NOPOWER)
lostPower = TRUE
else
if(!busy)
lostPower = FALSE
update_icon()

/obj/machinery/doorButtons/airlock_controller/findObjsByTag()
for(var/obj/machinery/door/airlock/A in GLOB.machines)
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
LAZYREMOVE(myarea.firealarms, src)
return ..()

/obj/machinery/firealarm/power_change()
..()
update_appearance()

/obj/machinery/firealarm/update_overlays()
. = ..()
var/area/A = src.loc
Expand Down
11 changes: 7 additions & 4 deletions code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@
QDEL_NULL(bulb)
return ..()

/obj/machinery/flasher/power_change()
if (powered() && anchored && bulb)
set_machine_stat(machine_stat & ~NOPOWER)
/obj/machinery/flasher/powered()
if(!anchored || !bulb)
return FALSE
return ..()

/obj/machinery/flasher/update_icon()
if (powered())
if(bulb.burnt_out)
icon_state = "[base_state]1-p"
else
icon_state = "[base_state]1"
else
set_machine_stat(machine_stat | NOPOWER)
icon_state = "[base_state]1-p"

//Don't want to render prison breaks impossible
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/gulag_teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ The console is located at computer/gulag_teleporter.dm
linked_reclaimer.linked_teleporter = null
return ..()

/obj/machinery/gulag_teleporter/power_change()
..()
update_icon()

/obj/machinery/gulag_teleporter/interact(mob/user)
. = ..()
if(locked)
Expand Down
6 changes: 2 additions & 4 deletions code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ Possible to do for anyone motivated enough:
return ..()

/obj/machinery/holopad/power_change()
if (powered())
set_machine_stat(machine_stat & ~NOPOWER)
else
set_machine_stat(machine_stat | NOPOWER)
. = ..()
if (!powered())
if(replay_mode)
replay_stop()
if(record_mode)
Expand Down
38 changes: 18 additions & 20 deletions code/game/machinery/igniter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

use_power(50)
on = !( on )
icon_state = "igniter[on]"
update_icon()

/obj/machinery/igniter/process() //ugh why is this even in process()?
if (src.on && !(machine_stat & NOPOWER) )
Expand All @@ -58,11 +58,11 @@

return ..()

/obj/machinery/igniter/power_change()
if(!( machine_stat & NOPOWER) )
icon_state = "igniter[src.on]"
else
/obj/machinery/igniter/update_icon()
if(machine_stat & NOPOWER)
icon_state = "igniter0"
else
icon_state = "igniter[on]"

// Wall mounted remote-control igniter.

Expand All @@ -76,7 +76,6 @@
var/id = null
var/disable = 0
var/last_spark = 0
var/base_state = "migniter"
var/datum/effect_system/spark_spread/spark_system

/obj/machinery/sparker/toxmix
Expand All @@ -92,29 +91,28 @@
QDEL_NULL(spark_system)
return ..()

/obj/machinery/sparker/power_change()
if ( powered() && disable == 0 )
set_machine_stat(machine_stat & ~NOPOWER)
icon_state = "[base_state]"
// src.sd_SetLuminosity(2)
/obj/machinery/sparker/update_icon()
if(disable)
icon_state = "[initial(icon_state)]-d"
else if(powered())
icon_state = "[initial(icon_state)]"
else
set_machine_stat(machine_stat | NOPOWER)
icon_state = "[base_state]-p"
// src.sd_SetLuminosity(0)
icon_state = "[initial(icon_state)]-p"

/obj/machinery/sparker/powered()
if(!disable)
return FALSE
return ..()

/obj/machinery/sparker/attackby(obj/item/W, mob/user, params)
if (W.tool_behaviour == TOOL_SCREWDRIVER)
add_fingerprint(user)
src.disable = !src.disable
if (src.disable)
user.visible_message("[user] has disabled \the [src]!", "<span class='notice'>You disable the connection to \the [src].</span>")
icon_state = "[base_state]-d"
if (!src.disable)
user.visible_message("[user] has reconnected \the [src]!", "<span class='notice'>You fix the connection to \the [src].</span>")
if(src.powered())
icon_state = "[base_state]"
else
icon_state = "[base_state]-p"
update_icon()
else
return ..()

Expand All @@ -132,7 +130,7 @@
return


flick("[base_state]-spark", src)
flick("[initial(icon_state)]-spark", src)
spark_system.start()
last_spark = world.time
use_power(1000)
Expand Down
8 changes: 2 additions & 6 deletions code/game/machinery/lightswitch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@
return

/obj/machinery/light_switch/power_change()
SHOULD_CALL_PARENT(FALSE)
if(area == get_area(src))
if(powered(AREA_USAGE_LIGHT))
set_machine_stat(machine_stat & ~NOPOWER)
else
set_machine_stat(machine_stat | NOPOWER)

update_appearance(updates = UPDATE_ICON|UPDATE_OVERLAYS)
return ..()

/obj/machinery/light_switch/emp_act(severity)
. = ..()
Expand Down
Loading

0 comments on commit 11851ed

Please sign in to comment.