From f2acf55c5ca4cdd0d691c8b44a7d04b2c86ab5d9 Mon Sep 17 00:00:00 2001 From: Rockdtben Date: Sun, 17 Nov 2013 10:20:53 -0600 Subject: [PATCH] APC Serverside Validation --- code/modules/power/apc.dm | 66 ++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index df608c245bd..982535fca8d 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -488,10 +488,7 @@ return ui_interact(user) -/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main") - if(!user) - return - +/obj/machinery/power/apc/proc/get_malf_status(mob/user) var/malfStatus if (ticker && ticker.mode && (user.mind in ticker.mode.malf_ai) && istype(user, /mob/living/silicon/ai)) if (src.malfai == (user:parent ? user:parent : user)) @@ -505,6 +502,14 @@ malfStatus = 1 // 1 = APC not hacked. else malfStatus = 0 // 0 = User is not a Malf AI + return malfStatus + + +/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main") + if(!user) + return + + var/malfStatus = get_malf_status(user) var/list/data = list( "locked" = locked, @@ -653,37 +658,40 @@ usr.set_machine(src) if (href_list["lock"]) - coverlocked = !coverlocked + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + coverlocked = !coverlocked else if (href_list["breaker"]) - toggle_breaker() + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + toggle_breaker() else if (href_list["cmode"]) - chargemode = !chargemode - if(!chargemode) - charging = 0 - update_icon() + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + chargemode = !chargemode + if(!chargemode) + charging = 0 + update_icon() else if (href_list["eqp"]) - var/val = text2num(href_list["eqp"]) - - equipment = setsubsystem(val) - update_icon() - update() + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + var/val = text2num(href_list["eqp"]) + equipment = setsubsystem(val) + update_icon() + update() else if (href_list["lgt"]) - var/val = text2num(href_list["lgt"]) - - lighting = setsubsystem(val) - update_icon() - update() + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + var/val = text2num(href_list["lgt"]) + lighting = setsubsystem(val) + update_icon() + update() else if (href_list["env"]) - var/val = text2num(href_list["env"]) - - environ = setsubsystem(val) - update_icon() - update() + if(!locked || (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)) + var/val = text2num(href_list["env"]) + environ = setsubsystem(val) + update_icon() + update() else if( href_list["close"] ) usr << browse(null, "window=apc") @@ -700,7 +708,7 @@ else if (href_list["malfhack"]) var/mob/living/silicon/ai/malfai = usr - if( istype(malfai, /mob/living/silicon/ai) && !src.aidisabled && (ticker && ticker.mode && (malfai.mind in ticker.mode.malf_ai)) ) + if(get_malf_status(usr)) if (malfai.malfhacking) malfai << "You are already hacking an APC." return 1 @@ -724,10 +732,12 @@ update_icon() else if (href_list["occupyapc"]) - malfoccupy(usr) + if(get_malf_status(usr)) + malfoccupy(usr) else if (href_list["deoccupyapc"]) - malfvacate() + if(get_malf_status(usr)) + malfvacate() else if (href_list["toggleaccess"]) if (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)