From 8d5c2027747fee26396a2efebabe498c5e855e1c Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Mon, 29 May 2017 09:14:01 -0500 Subject: [PATCH] Speeds up apc visual updates --- code/modules/power/apc.dm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index e58240b045..e526d6ba6d 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -27,8 +27,6 @@ #define APC_UPOVERLAY_OPERATING 8192 -#define APC_UPDATE_ICON_COOLDOWN 200 // 20 seconds - // the Area Power Controller (APC), formerly Power Distribution Unit (PDU) // one per area, needs wire conection to power network through a terminal @@ -93,7 +91,7 @@ var/force_update = 0 var/update_state = -1 var/update_overlay = -1 - + var/icon_update_needed = FALSE /obj/machinery/power/apc/connect_to_network() //Override because the APC does not directly connect to the network; it goes through a terminal. @@ -212,11 +210,11 @@ // update the APC icon to show the three base states // also add overlays for indicator lights /obj/machinery/power/apc/update_icon() - var/update = check_updates() //returns 0 if no need to update icons. // 1 if we need to update the icon_state // 2 if we need to update the overlays if(!update) + icon_update_needed = FALSE return if(update & 1) // Updating the icon state @@ -272,8 +270,9 @@ else set_light(0) -/obj/machinery/power/apc/proc/check_updates() + icon_update_needed = FALSE +/obj/machinery/power/apc/proc/check_updates() var/last_update_state = update_state var/last_update_overlay = update_overlay update_state = 0 @@ -344,7 +343,7 @@ // Used in process so it doesn't update the icon too much /obj/machinery/power/apc/proc/queue_icon_update() - addtimer(CALLBACK(src, .proc/update_icon), APC_UPDATE_ICON_COOLDOWN, TIMER_UNIQUE) + icon_update_needed = TRUE //attack with an item - open/close cover, insert cell, or (un)lock interface @@ -937,7 +936,8 @@ return 0 /obj/machinery/power/apc/process() - + if(icon_update_needed) + update_icon() if(stat & (BROKEN|MAINT)) return if(!area.requires_power)