From 4b5d896856489e9ac81d3a45e218c96e48c65efb Mon Sep 17 00:00:00 2001 From: MLGTASTICa Date: Sun, 18 Apr 2021 20:37:59 +0300 Subject: [PATCH 1/6] proper branch --- code/__DEFINES/components.dm | 2 + code/game/area/areas.dm | 1 + code/game/machinery/alarm.dm | 14 +++--- .../objects/items/devices/radio/intercom.dm | 47 ++++++++++--------- code/modules/power/apc.dm | 1 + 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 151fab1a873..a6645e3f9f4 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -92,6 +92,8 @@ //machinery #define COMSIG_AREA_APC_OPERATING "area_operating" //from apc process() +#define COMSIG_AREA_APC_DELETED "area_apc_gone" +#define COMSIG_AREA_APC_POWER_CHANGE "area_apc_power_change" #define COMSING_DESTRUCTIVE_ANALIZER "destructive_analizer" #define COMSIG_TURRENT "create_turrent" diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 83abe54cf80..49eff8bb5d6 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -205,6 +205,7 @@ /area/proc/power_change() for(var/obj/machinery/M in src) // for each machine in the area M.power_change() // reverify power status (to update icons etc.) + SEND_SIGNAL(src, COMSIG_AREA_APC_POWER_CHANGE) if (fire || eject || party) updateicon() diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index f0a433f5272..eac5997d16f 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -1084,15 +1084,15 @@ FIRE ALARM if(stat & (NOPOWER|BROKEN)) return - if(src.timing) - if(src.time > 0) - src.time = src.time - ((world.timeofday - last_process)/10) + if(timing) + if(time > 0) + time = time - ((world.timeofday - last_process)/10) else - src.alarm() - src.time = 0 - src.timing = 0 + alarm() + time = 0 + timing = 0 STOP_PROCESSING(SSmachines, src) - src.updateDialog() + updateDialog() last_process = world.timeofday if(locate(/obj/fire) in loc) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index ad2e8415328..d8e5a4e5a96 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -9,7 +9,7 @@ canhear_range = 2 flags = CONDUCT | NOBLOODY var/number = 0 - var/last_tick //used to delay the powercheck + var/area/linked_area = null /obj/item/device/radio/intercom/custom name = "station intercom (Custom)" @@ -39,7 +39,7 @@ /obj/item/device/radio/intercom/New() ..() - START_PROCESSING(SSobj, src) + loop_area_check() /obj/item/device/radio/intercom/department/medbay/New() ..() @@ -64,10 +64,6 @@ ..() internal_channels[num2text(SYND_FREQ)] = list(access_syndicate) -/obj/item/device/radio/intercom/Destroy() - STOP_PROCESSING(SSobj, src) - . = ..() - /obj/item/device/radio/intercom/attack_ai(mob/user as mob) src.add_fingerprint(user) spawn (0) @@ -93,23 +89,28 @@ return canhear_range -/obj/item/device/radio/intercom/Process() - if(((world.timeofday - last_tick) > 30) || ((world.timeofday - last_tick) < 0)) - last_tick = world.timeofday - - if(!src.loc) - on = FALSE - else - var/area/A = get_area(src) - if(!A) - on = FALSE - else - on = A.powered(EQUIP) // set "on" to the power status - - if(!on) - icon_state = "intercom-p" - else - icon_state = "intercom" +/obj/item/device/radio/intercom/proc/change_status() + on = linked_area.powered(EQUIP) + icon_state = on ? "intercom" : "intercom-p" + +/obj/item/device/radio/intercom/proc/loop_area_check() + var/area/target_area = get_area(src) + if(!target_area) + addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) + return FALSE + if(!(target_area.apc)) + addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) // We don't proces if there is no APC , no point in doing so is there ? + return FALSE + linked_area = target_area + RegisterSignal(target_area, COMSIG_AREA_APC_DELETED, .proc/on_apc_removal) + RegisterSignal(target_area, COMSIG_AREA_APC_POWER_CHANGE, .proc/change_status) + +/obj/item/device/radio/intercom/proc/on_apc_removal() + UnregisterSignal(linked_area , COMSIG_AREA_APC_DELETED) + UnregisterSignal(linked_area, COMSIG_AREA_APC_POWER_CHANGE) + linked_area = null + on = FALSE + addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) /obj/item/device/radio/intercom/broadcasting broadcasting = 1 diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 7daf65aed39..e36f55f07f5 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -188,6 +188,7 @@ /obj/machinery/power/apc/Destroy() update() area.apc = null + SEND_SIGNAL(area, COMSIG_AREA_APC_DELETED) area.power_light = 0 area.power_equip = 0 area.power_environ = 0 From e60204f55987b8dfdd10d75bb431785faf367d93 Mon Sep 17 00:00:00 2001 From: MLGTASTICa <61350382+MLGTASTICa@users.noreply.github.com> Date: Sun, 18 Apr 2021 20:41:40 +0300 Subject: [PATCH 2/6] Update code/game/machinery/alarm.dm Co-authored-by: Evankhell561 <49106866+Evankhell561@users.noreply.github.com> --- code/game/machinery/alarm.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index eac5997d16f..daea8036d61 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -1086,7 +1086,7 @@ FIRE ALARM if(timing) if(time > 0) - time = time - ((world.timeofday - last_process)/10) + time -= (world.timeofday - last_process)/10 else alarm() time = 0 @@ -1304,4 +1304,3 @@ Just a object used in constructing fire alarms var/tp = text2num(href_list["tp"]) time += tp time = min(max(round(time), 0), 120) - From 7033aeaeed5f7ae053bf3d17d6e982cc6561b76b Mon Sep 17 00:00:00 2001 From: MLGTASTICa <61350382+MLGTASTICa@users.noreply.github.com> Date: Sun, 18 Apr 2021 20:41:56 +0300 Subject: [PATCH 3/6] Update code/game/objects/items/devices/radio/intercom.dm Co-authored-by: Evankhell561 <49106866+Evankhell561@users.noreply.github.com> --- code/game/objects/items/devices/radio/intercom.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index d8e5a4e5a96..14cba0f15d7 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -9,7 +9,7 @@ canhear_range = 2 flags = CONDUCT | NOBLOODY var/number = 0 - var/area/linked_area = null + var/area/linked_area /obj/item/device/radio/intercom/custom name = "station intercom (Custom)" From 26dc7106c1003163fe811443924032b1cc500529 Mon Sep 17 00:00:00 2001 From: MLGTASTICa <61350382+MLGTASTICa@users.noreply.github.com> Date: Sun, 18 Apr 2021 20:49:37 +0300 Subject: [PATCH 4/6] Update code/game/objects/items/devices/radio/intercom.dm Co-authored-by: Evankhell561 <49106866+Evankhell561@users.noreply.github.com> --- code/game/objects/items/devices/radio/intercom.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index 14cba0f15d7..636e5ddf345 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -98,7 +98,7 @@ if(!target_area) addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) return FALSE - if(!(target_area.apc)) + if(!target_area.apc) addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) // We don't proces if there is no APC , no point in doing so is there ? return FALSE linked_area = target_area From 6713a3569c253b5384c7a7b91e2cb2411098974b Mon Sep 17 00:00:00 2001 From: MLGTASTICa Date: Mon, 19 Apr 2021 02:37:04 +0300 Subject: [PATCH 5/6] better code , fix for something i forgot. --- code/game/objects/items/devices/radio/intercom.dm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index d8e5a4e5a96..5cdb5ea583b 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -95,10 +95,7 @@ /obj/item/device/radio/intercom/proc/loop_area_check() var/area/target_area = get_area(src) - if(!target_area) - addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) - return FALSE - if(!(target_area.apc)) + if(!target_area?.apc) addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) // We don't proces if there is no APC , no point in doing so is there ? return FALSE linked_area = target_area @@ -110,6 +107,7 @@ UnregisterSignal(linked_area, COMSIG_AREA_APC_POWER_CHANGE) linked_area = null on = FALSE + icon_state = "intercom-p" addtimer(CALLBACK(src, .proc/loop_area_check), 30 SECONDS) /obj/item/device/radio/intercom/broadcasting From dee1b97dc130f248f3bf74a73b425fe578310481 Mon Sep 17 00:00:00 2001 From: MLGTASTICa <61350382+MLGTASTICa@users.noreply.github.com> Date: Sat, 24 Apr 2021 05:23:10 +0300 Subject: [PATCH 6/6] Update code/game/objects/items/devices/radio/intercom.dm Co-authored-by: Evankhell561 <49106866+Evankhell561@users.noreply.github.com> --- code/game/objects/items/devices/radio/intercom.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index 5cdb5ea583b..2019ff0315d 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -9,7 +9,7 @@ canhear_range = 2 flags = CONDUCT | NOBLOODY var/number = 0 - var/area/linked_area = null + var/area/linked_area /obj/item/device/radio/intercom/custom name = "station intercom (Custom)"