diff --git a/code/game/area/area_power.dm b/code/game/area/area_power.dm index f83bccc067d..28b9828780d 100644 --- a/code/game/area/area_power.dm +++ b/code/game/area/area_power.dm @@ -26,12 +26,6 @@ /area/proc/power_change() SEND_SIGNAL(src, COMSIG_AREA_POWER_CHANGE) - //One day, this will only use the signal, but that day is not today - for(var/obj/machinery/M in src) // for each machine in the area - M.power_change() // reverify power status (to update icons etc.) - if (fire || eject || party) - update_icon() - /area/proc/usage(var/chan) switch(chan) if(AREA_USAGE_LIGHT) diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index 99262d273a0..088817fce79 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -404,6 +404,7 @@ pixel_x = 10; return ..() /obj/machinery/alarm/LateInitialize() + . = ..() apply_mode() /obj/machinery/alarm/Initialize(mapload, var/dir, var/building = 0) diff --git a/code/game/machinery/atmoalter/portable_atmospherics.dm b/code/game/machinery/atmoalter/portable_atmospherics.dm index 7d53e8dfa25..aead7185779 100644 --- a/code/game/machinery/atmoalter/portable_atmospherics.dm +++ b/code/game/machinery/atmoalter/portable_atmospherics.dm @@ -34,6 +34,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/portable_atmospherics/canister/LateInitialize() + . = ..() update_icon() /obj/machinery/portable_atmospherics/process() diff --git a/code/game/machinery/autolathe/autolathe.dm b/code/game/machinery/autolathe/autolathe.dm index 692c9c93cce..bd104f75a5f 100644 --- a/code/game/machinery/autolathe/autolathe.dm +++ b/code/game/machinery/autolathe/autolathe.dm @@ -56,6 +56,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/autolathe/LateInitialize() + . = ..() populate_lathe_recipes() /obj/machinery/autolathe/Destroy() diff --git a/code/game/machinery/bluespace_drive.dm b/code/game/machinery/bluespace_drive.dm index bd54d0339d4..45ca4a9e052 100644 --- a/code/game/machinery/bluespace_drive.dm +++ b/code/game/machinery/bluespace_drive.dm @@ -113,6 +113,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/bluespacedrive/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if(istype(my_sector, /obj/effect/overmap/visitable/ship)) @@ -496,6 +497,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/bluespacedrive/LateInitialize() + . = ..() linked_bluespace_drive = locate() in get_area(src) diff --git a/code/game/machinery/computer/pod.dm b/code/game/machinery/computer/pod.dm index 364871f7a74..b3c7ef2d477 100644 --- a/code/game/machinery/computer/pod.dm +++ b/code/game/machinery/computer/pod.dm @@ -19,6 +19,7 @@ . = INITIALIZE_HINT_LATELOAD /obj/machinery/computer/pod/LateInitialize() + . = ..() for(var/obj/machinery/mass_driver/M in SSmachinery.machinery) if(M.id == id) connected = M diff --git a/code/game/machinery/distress_button.dm b/code/game/machinery/distress_button.dm index 25a93e290c2..e7f69743022 100644 --- a/code/game/machinery/distress_button.dm +++ b/code/game/machinery/distress_button.dm @@ -9,6 +9,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/button/distress/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index c5399bfab4a..31a8bb5b7e9 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -36,6 +36,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/door_timer/LateInitialize() + . = ..() for(var/obj/machinery/door/airlock/glass_security/D in SSmachinery.machinery) if(D.id_tag == src.id) // Airlocks use "id_tag" instead of "id". targets += D diff --git a/code/game/machinery/firealarm.dm b/code/game/machinery/firealarm.dm index 8734e441e1a..bd0529956de 100644 --- a/code/game/machinery/firealarm.dm +++ b/code/game/machinery/firealarm.dm @@ -18,6 +18,7 @@ var/seclevel ///looping sound datum for our fire alarm siren. var/datum/looping_sound/firealarm/soundloop + always_area_sensitive = TRUE /obj/machinery/firealarm/Initialize(mapload, var/dir, var/building = 0) . = ..(mapload) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 92a15699211..df21a1aeca1 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -149,6 +149,10 @@ Class Procs: */ var/manufacturer = null + ///Do we want to hook into on_enter_area and on_exit_area? + ///Disables some optimizations + var/always_area_sensitive = FALSE + /obj/machinery/feedback_hints(mob/user, distance, is_adjacent) . = list() if(signaler && is_adjacent) @@ -190,6 +194,8 @@ Class Procs: if(component_parts.len) RefreshParts() + return INITIALIZE_HINT_LATELOAD + /obj/machinery/Destroy() //Stupid macro used in power usage CAN_BE_REDEFINED(TRUE) diff --git a/code/game/machinery/nuclear_bomb.dm b/code/game/machinery/nuclear_bomb.dm index c7a985c6d1d..4defdc5d264 100644 --- a/code/game/machinery/nuclear_bomb.dm +++ b/code/game/machinery/nuclear_bomb.dm @@ -430,6 +430,7 @@ GLOBAL_VAR(bomb_set) return INITIALIZE_HINT_LATELOAD /obj/machinery/nuclearbomb/station/LateInitialize() + . = ..() for(var/turf/simulated/floor/T in RANGE_TURFS(1, src)) T.set_flooring(GET_SINGLETON(/singleton/flooring/reinforced/circuit/red)) flash_tiles += T diff --git a/code/game/machinery/telecomms/computers/message.dm b/code/game/machinery/telecomms/computers/message.dm index 3ede3172170..c65a2f54c6c 100644 --- a/code/game/machinery/telecomms/computers/message.dm +++ b/code/game/machinery/telecomms/computers/message.dm @@ -41,6 +41,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/message_monitor/LateInitialize() + . = ..() //If the server isn't linked to a server, and there's a server available, default it to the first one in the list. if(!linkedServer) for(var/obj/machinery/telecomms/message_server/S in SSmachinery.all_telecomms) diff --git a/code/game/machinery/telecomms/presets.dm b/code/game/machinery/telecomms/presets.dm index 7285d50cd80..3b5621b99d0 100644 --- a/code/game/machinery/telecomms/presets.dm +++ b/code/game/machinery/telecomms/presets.dm @@ -2,6 +2,7 @@ //HUB /obj/machinery/telecomms/hub/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -19,8 +20,6 @@ "[name_lower]_server" ) - return ..() - /obj/machinery/telecomms/hub/preset id = "Hub" network = "tcommsat" @@ -39,6 +38,7 @@ var/use_common = FALSE /obj/machinery/telecomms/receiver/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -56,8 +56,6 @@ "[name_lower]_receiver" ) - return ..() - /obj/machinery/telecomms/receiver/preset_right id = "Receiver A" network = "tcommsat" @@ -83,6 +81,7 @@ var/use_common = FALSE /obj/machinery/telecomms/bus/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -101,8 +100,6 @@ "[name_lower]_server" ) - return ..() - /obj/machinery/telecomms/bus/preset_one id = "Bus 1" network = "tcommsat" @@ -144,6 +141,7 @@ //Processors /obj/machinery/telecomms/processor/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -158,8 +156,6 @@ "[name_lower]_processor" ) - return ..() - /obj/machinery/telecomms/processor/preset_one id = "Processor 1" network = "tcommsat" @@ -191,6 +187,7 @@ var/use_common = FALSE /obj/machinery/telecomms/server/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -211,8 +208,6 @@ "[name_lower]_server" ) - return ..() - /obj/machinery/telecomms/server/presets network = "tcommsat" @@ -281,6 +276,7 @@ //--PRESET LEFT--// /obj/machinery/telecomms/broadcaster/preset_map/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -295,8 +291,6 @@ "[name_lower]_broadcaster" ) - return ..() - /obj/machinery/telecomms/broadcaster/preset_right id = "Broadcaster A" network = "tcommsat" diff --git a/code/game/machinery/telecomms/telecommunications.dm b/code/game/machinery/telecomms/telecommunications.dm index 86eb1ec5437..c54db8ecbd3 100644 --- a/code/game/machinery/telecomms/telecommunications.dm +++ b/code/game/machinery/telecomms/telecommunications.dm @@ -96,6 +96,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/telecomms/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/game/machinery/turret_control.dm b/code/game/machinery/turret_control.dm index ad51378af4a..a400d15cb26 100644 --- a/code/game/machinery/turret_control.dm +++ b/code/game/machinery/turret_control.dm @@ -72,6 +72,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/turretid/LateInitialize() + . = ..() power_change() turretModes() diff --git a/code/game/machinery/vending/_vending.dm b/code/game/machinery/vending/_vending.dm index ca98c9c9363..e04b8702ff0 100644 --- a/code/game/machinery/vending/_vending.dm +++ b/code/game/machinery/vending/_vending.dm @@ -278,6 +278,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/vending/LateInitialize() + . = ..() v_asset = get_asset_datum(/datum/asset/spritesheet/vending) /obj/machinery/vending/proc/reset_light() diff --git a/code/modules/atmospherics/atmospherics.dm b/code/modules/atmospherics/atmospherics.dm index 772e0595013..d5cecd4fed7 100644 --- a/code/modules/atmospherics/atmospherics.dm +++ b/code/modules/atmospherics/atmospherics.dm @@ -52,6 +52,7 @@ Pipelines + Other Objects -> Pipe network // atmos_init() and Initialize() must be separate, as atmos_init() can be called multiple times after the machine has been initialized. /obj/machinery/atmospherics/LateInitialize() + . = ..() atmos_init() /obj/machinery/atmospherics/attackby(obj/item/attacking_item, mob/user) diff --git a/code/modules/atmospherics/components/portables_connector.dm b/code/modules/atmospherics/components/portables_connector.dm index 7d734c7c9d3..88533010c92 100644 --- a/code/modules/atmospherics/components/portables_connector.dm +++ b/code/modules/atmospherics/components/portables_connector.dm @@ -44,6 +44,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/atmospherics/portables_connector/LateInitialize() + . = ..() toggle_process() /obj/machinery/atmospherics/portables_connector/update_icon() diff --git a/code/modules/mining/machine_stacking.dm b/code/modules/mining/machine_stacking.dm index d52c3d0dd3e..07d113e68c6 100644 --- a/code/modules/mining/machine_stacking.dm +++ b/code/modules/mining/machine_stacking.dm @@ -25,6 +25,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/mineral/stacking_unit_console/LateInitialize() + . = ..() setup_machine(null) /obj/machinery/mineral/stacking_unit_console/Destroy() diff --git a/code/modules/mob/living/simple_animal/hostile/vannatusk.dm b/code/modules/mob/living/simple_animal/hostile/vannatusk.dm index 69d8fbc0abd..e0fe113d165 100644 --- a/code/modules/mob/living/simple_animal/hostile/vannatusk.dm +++ b/code/modules/mob/living/simple_animal/hostile/vannatusk.dm @@ -88,17 +88,3 @@ /mob/living/simple_animal/hostile/vannatusk/dead/Initialize() . = ..() death() - -/obj/machinery/vannatusk_spawner - name = "telepad" - desc = "A bluespace telepad used for creating bluespace portals." - icon = 'icons/obj/telescience.dmi' - icon_state = "pad-idle" - anchored = TRUE - use_power = POWER_USE_IDLE - -/obj/machinery/vannatusk_spawner/power_change() - ..() - spark(src, 3, GLOB.alldirs) - new /mob/living/simple_animal/hostile/vannatusk(get_turf(src)) - qdel(src) diff --git a/code/modules/overmap/ship_weaponry/_ship_ammo_loader.dm b/code/modules/overmap/ship_weaponry/_ship_ammo_loader.dm index c9e523d3a9b..46d0a790faf 100644 --- a/code/modules/overmap/ship_weaponry/_ship_ammo_loader.dm +++ b/code/modules/overmap/ship_weaponry/_ship_ammo_loader.dm @@ -22,6 +22,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/ammunition_loader/LateInitialize() + . = ..() for(var/obj/machinery/ship_weapon/SW in SSmachinery.machinery) if(SW.weapon_id == weapon_id) if(get_area(SW) == get_area(src)) diff --git a/code/modules/overmap/ship_weaponry/_ship_gun.dm b/code/modules/overmap/ship_weaponry/_ship_gun.dm index d460a1af82f..6673b74176a 100644 --- a/code/modules/overmap/ship_weaponry/_ship_gun.dm +++ b/code/modules/overmap/ship_weaponry/_ship_gun.dm @@ -78,6 +78,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/ship_weapon/LateInitialize() + . = ..() SSshuttle.weapons_to_initialize += src if(SSshuttle.initialized) SSshuttle.initialize_ship_weapons() diff --git a/code/modules/overmap/ship_weaponry/_targeting_console.dm b/code/modules/overmap/ship_weaponry/_targeting_console.dm index 956f485682e..9d17f37e7d8 100644 --- a/code/modules/overmap/ship_weaponry/_targeting_console.dm +++ b/code/modules/overmap/ship_weaponry/_targeting_console.dm @@ -30,6 +30,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/ship/targeting/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if(istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/modules/overmap/ship_weaponry/weaponry/leviathan.dm b/code/modules/overmap/ship_weaponry/weaponry/leviathan.dm index 3476b8920ac..fea7ff1aa9e 100644 --- a/code/modules/overmap/ship_weaponry/weaponry/leviathan.dm +++ b/code/modules/overmap/ship_weaponry/weaponry/leviathan.dm @@ -178,6 +178,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/zat_lever/LateInitialize() + . = ..() for(var/obj/machinery/ship_weapon/leviathan/cannon in get_area(src)) ZAT = cannon break @@ -287,6 +288,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/leviathan_safeguard/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) @@ -359,6 +361,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/leviathan_button/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/modules/overmap/ships/identification.dm b/code/modules/overmap/ships/identification.dm index 4e9cb98cec0..d654aa2207d 100644 --- a/code/modules/overmap/ships/identification.dm +++ b/code/modules/overmap/ships/identification.dm @@ -23,6 +23,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/iff_beacon/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/modules/power/antimatter/shielding.dm b/code/modules/power/antimatter/shielding.dm index 7516817c64f..ada68278fcf 100644 --- a/code/modules/power/antimatter/shielding.dm +++ b/code/modules/power/antimatter/shielding.dm @@ -51,6 +51,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/am_shielding/LateInitialize() + . = ..() update_icon() /obj/machinery/am_shielding/proc/link_control(var/obj/machinery/power/am_control_unit/AMC) diff --git a/code/modules/power/breaker_box.dm b/code/modules/power/breaker_box.dm index a93fec2f24b..763d2099e9c 100644 --- a/code/modules/power/breaker_box.dm +++ b/code/modules/power/breaker_box.dm @@ -51,6 +51,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/power/breakerbox/activated/LateInitialize() + . = ..() set_state(1) /obj/machinery/power/breakerbox/attack_ai(mob/user) diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 112647a5e20..939d8dece39 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -454,6 +454,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/gravity_generator/main/LateInitialize() + ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/modules/power/lights/fixtures.dm b/code/modules/power/lights/fixtures.dm index 75bf8f19f87..ce662d1469c 100644 --- a/code/modules/power/lights/fixtures.dm +++ b/code/modules/power/lights/fixtures.dm @@ -16,6 +16,7 @@ idle_power_usage = 2 active_power_usage = 20 power_channel = AREA_USAGE_LIGHT //Lights are calc'd via area so they dont need to be in the machine list + always_area_sensitive = TRUE gfi_layer_rotation = GFI_ROTATION_DEFDIR obj_flags = OBJ_FLAG_MOVES_UNSUPPORTED var/brightness_range = 8 // luminosity when on, also used in power calculation diff --git a/code/modules/power/power_usage.dm b/code/modules/power/power_usage.dm index 2c840a74d81..17dcf3582cc 100644 --- a/code/modules/power/power_usage.dm +++ b/code/modules/power/power_usage.dm @@ -78,7 +78,6 @@ This is /obj/machinery level code to properly manage power usage from the area. /obj/machinery/Initialize(mapload, d = 0, populate_components = TRUE, is_internal = FALSE) internal = is_internal REPORT_POWER_CONSUMPTION_CHANGE(0, get_power_usage()) - RegisterSignal(src, COMSIG_MOVABLE_MOVED, PROC_REF(update_power_on_move)) power_init_complete = TRUE . = ..() @@ -88,20 +87,24 @@ This is /obj/machinery level code to properly manage power usage from the area. REPORT_POWER_CONSUMPTION_CHANGE(get_power_usage(), 0) . = ..() -/obj/machinery/proc/update_power_on_move(atom/movable/mover, atom/old_loc, dir, forced, list/old_locs) - area_changed(get_area(old_loc), get_area(src)) +/obj/machinery/LateInitialize() + post_machine_initialize() + +/** + * Called in LateInitialize meant to be the machine replacement to it + * This sets up power for the machine and requires parent be called, + * ensuring power works on all machines unless exempted with POWER_USE_OFF. + * This is the proc to override if you want to do anything in LateInitialize. + */ +/obj/machinery/proc/post_machine_initialize() + PROTECTED_PROC(TRUE) + SHOULD_CALL_PARENT(TRUE) -/obj/machinery/proc/area_changed(area/old_area, area/new_area) - if(old_area == new_area) - return - var/power = get_power_usage() - if(!power) - return // This is the most likely case anyway. - if(old_area) - old_area.power_use_change(power, 0, power_channel) - if(new_area) - new_area.power_use_change(0, power, power_channel) power_change() + if(use_power == POWER_USE_OFF) + return + update_current_power_usage() + setup_area_power_relationship() // The three procs below are the only allowed ways of modifying the corresponding variables. /// Use this to modify the use_power variable of machines, do not modify them directly! @@ -116,6 +119,80 @@ This is /obj/machinery level code to properly manage power usage from the area. var/new_power = get_power_usage() REPORT_POWER_CONSUMPTION_CHANGE(old_power, new_power) +/// Makes this machine draw power from its area according to which use_power mode it is set to. +/obj/machinery/proc/update_current_power_usage() + var/area/our_area = get_area(src) + if(!our_area) + return FALSE + + var/new_usage = 0 + switch(use_power) + if(POWER_USE_IDLE) + new_usage = idle_power_usage + if(POWER_USE_ACTIVE) + new_usage = active_power_usage + if(POWER_USE_OFF) + return + + if(new_usage) + update_use_power(new_usage) + + return TRUE + +/** + * proc to call when the machine starts to require power after a duration of not requiring power + * sets up power related connections to its area if it exists and becomes area sensitive + * does not affect power usage itself + * + * Returns TRUE if it triggered a full registration, FALSE otherwise + * We do this so machinery that want to sidestep the area sensitiveity optimization can + */ +/obj/machinery/proc/setup_area_power_relationship() + var/area/our_area = get_area(src) + if(our_area) + RegisterSignal(our_area, COMSIG_AREA_POWER_CHANGE, PROC_REF(power_change)) + + if(HAS_TRAIT_FROM(src, TRAIT_AREA_SENSITIVE, INNATE_TRAIT)) // If we for some reason have not lost our area sensitivity, there's no reason to set it back up + return FALSE + + become_area_sensitive(INNATE_TRAIT) + RegisterSignal(src, COMSIG_ENTER_AREA, PROC_REF(on_enter_area)) + RegisterSignal(src, COMSIG_EXIT_AREA, PROC_REF(on_exit_area)) + return TRUE + +/** + * proc to call when the machine stops requiring power after a duration of requiring power + * saves memory by removing the power relationship with its area if it exists and loses area sensitivity + * does not affect power usage itself + */ +/obj/machinery/proc/remove_area_power_relationship() + var/area/our_area = get_area(src) + if(our_area) + UnregisterSignal(our_area, COMSIG_AREA_POWER_CHANGE) + + if(always_area_sensitive) + return + + lose_area_sensitivity(INNATE_TRAIT) + UnregisterSignal(src, COMSIG_ENTER_AREA) + UnregisterSignal(src, COMSIG_EXIT_AREA) + +/obj/machinery/proc/on_enter_area(datum/source, area/area_to_register) + SIGNAL_HANDLER + // If we're always area sensitive, and this is called while we have no power usage, do nothing and return + if(always_area_sensitive && use_power == POWER_USE_OFF) + return + update_current_power_usage() + power_change() + RegisterSignal(area_to_register, COMSIG_AREA_POWER_CHANGE, PROC_REF(power_change)) + +/obj/machinery/proc/on_exit_area(datum/source, area/area_to_unregister) + SIGNAL_HANDLER + // If we're always area sensitive, and this is called while we have no power usage, do nothing and return + if(always_area_sensitive && use_power == POWER_USE_OFF) + return + UnregisterSignal(area_to_unregister, COMSIG_AREA_POWER_CHANGE) + /// Use this to modify the power channel variable of machines, do not modify them directly! /obj/machinery/proc/update_power_channel(new_channel) if(power_channel == new_channel) diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm index 855d81c58bc..f0631994876 100644 --- a/code/modules/power/smes_construction.dm +++ b/code/modules/power/smes_construction.dm @@ -204,6 +204,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/power/smes/buildable/LateInitialize() + . = ..() recalc_coils() // Proc: attack_hand() diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 31b4fb30467..80958fb7510 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -369,6 +369,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/terminal/turbine_computer/LateInitialize() + . = ..() for(var/obj/machinery/power/compressor/C in SSmachinery.machinery) if(id == C.comp_id) compressor = C diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index 328917b1ede..7bd962bcaeb 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -141,6 +141,7 @@ return data /obj/machinery/chem_master/LateInitialize() + . = ..() if(!chem_asset) chem_asset = get_asset_datum(/datum/asset/spritesheet/chem_master) diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 8ff3f40c544..2659efcc19d 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -137,6 +137,7 @@ won't update every console in existence) but it's more of a hassle to do. Also, return INITIALIZE_HINT_LATELOAD /obj/machinery/computer/rdconsole/LateInitialize() + . = ..() SyncTechs() screen = 1.0 diff --git a/code/modules/security levels/keycard authentication.dm b/code/modules/security levels/keycard authentication.dm index dc72b5c9db7..26101c3353e 100644 --- a/code/modules/security levels/keycard authentication.dm +++ b/code/modules/security levels/keycard authentication.dm @@ -27,6 +27,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/keycard_auth/LateInitialize() + . = ..() if(SSatlas.current_map.use_overmap && !linked) var/my_sector = GLOB.map_sectors["[z]"] if (istype(my_sector, /obj/effect/overmap/visitable)) diff --git a/code/modules/shieldgen/shield_capacitor.dm b/code/modules/shieldgen/shield_capacitor.dm index 24d4fc7de6a..ec6a0d6112a 100644 --- a/code/modules/shieldgen/shield_capacitor.dm +++ b/code/modules/shieldgen/shield_capacitor.dm @@ -26,6 +26,7 @@ return INITIALIZE_HINT_LATELOAD /obj/machinery/shield_capacitor/LateInitialize() + . = ..() for(var/obj/machinery/shield_gen/possible_gen in range(1, src)) if(get_dir(src, possible_gen) == dir) possible_gen.owned_capacitor = src diff --git a/html/changelogs/Bat-PowerChangeSignal.yml b/html/changelogs/Bat-PowerChangeSignal.yml new file mode 100644 index 00000000000..8849b0ac569 --- /dev/null +++ b/html/changelogs/Bat-PowerChangeSignal.yml @@ -0,0 +1,13 @@ +# Your name. +author: Batrachophrenoboocosmomachia + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - refactor: "Performance improvement: area /power_change() proc uses signals instead of for loop." diff --git a/maps/dungeon_spawns/vannatusk_unique.dmm b/maps/dungeon_spawns/vannatusk_unique.dmm index 6f46ae45317..c705006bea9 100644 --- a/maps/dungeon_spawns/vannatusk_unique.dmm +++ b/maps/dungeon_spawns/vannatusk_unique.dmm @@ -108,10 +108,6 @@ }, /turf/simulated/floor/tiled/asteroid, /area/dungeon/bluespace_outpost) -"au" = ( -/obj/machinery/vannatusk_spawner, -/turf/simulated/floor/tiled/asteroid, -/area/dungeon/bluespace_outpost) "av" = ( /obj/structure/trash_pile, /obj/effect/floor_decal/industrial/warning/dust{ @@ -1251,7 +1247,7 @@ Nw Nw Iu ar -au +ac bs bo ad