diff --git a/code/_onclick/ai.dm b/code/_onclick/ai.dm
index f82677440b8..50c5314d0b4 100644
--- a/code/_onclick/ai.dm
+++ b/code/_onclick/ai.dm
@@ -194,26 +194,22 @@
// AIRLOCKS
/obj/machinery/door/airlock/AIAltShiftClick(mob/user) // Sets/Unsets Emergency Access Override
- if(emagged)
- to_chat(user, "Unable to interface: Internal error.")
+ if(!ai_control_check(user))
return
toggle_emergency_status(user)
/obj/machinery/door/airlock/AIShiftClick(mob/user) // Opens and closes doors!
- if(emagged)
- to_chat(user, "Unable to interface: Internal error.")
+ if(!ai_control_check(user))
return
open_close(user)
/obj/machinery/door/airlock/AICtrlClick(mob/living/silicon/user) // Bolts doors
- if(emagged)
- to_chat(user, "Unable to interface: Internal error.")
+ if(!ai_control_check(user))
return
toggle_bolt(user)
/obj/machinery/door/airlock/AIAltClick(mob/living/silicon/user) // Electrifies doors.
- if(emagged)
- to_chat(user, "Unable to interface: Internal error.")
+ if(!ai_control_check(user))
return
if(wires.is_cut(WIRE_ELECTRIFY))
to_chat(user, "The electrification wire is cut - Cannot electrify the door.")
@@ -224,8 +220,7 @@
/obj/machinery/door/airlock/AIMiddleClick(mob/living/user) // Toggles door bolt lights.
- if(emagged)
- to_chat(user, "Unable to interface: Internal error.")
+ if(!ai_control_check(user))
return
toggle_light(user)
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index c7a028ddd1f..1d6b572d9e5 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -757,6 +757,22 @@ About the new airlock wires panel:
else
try_to_activate_door(user)
+/obj/machinery/door/airlock/proc/ai_control_check(mob/user)
+ if(!issilicon(user))
+ return TRUE
+ if(emagged)
+ to_chat(user, "Unable to interface: Internal error.")
+ return FALSE
+ if(!canAIControl())
+ if(canAIHack(user))
+ hack(user)
+ else
+ if(isAllPowerLoss())
+ to_chat(user, "Unable to interface: Connection timed out.")
+ else
+ to_chat(user, "Unable to interface: Connection refused.")
+ return FALSE
+ return TRUE
/obj/machinery/door/airlock/tgui_act(action, params)
if(..())
@@ -764,17 +780,7 @@ About the new airlock wires panel:
if(!issilicon(usr) && !usr.can_admin_interact())
to_chat(usr, "Access denied. Only silicons may use this interface.")
return
- if(issilicon(usr) && emagged)
- to_chat(usr, "Unable to interface: Internal error.")
- return
- if(!canAIControl() && !isobserver(usr))
- if(canAIHack(usr))
- hack(usr)
- else
- if(isAllPowerLoss())
- to_chat(usr, "Unable to interface: Connection timed out.")
- else
- to_chat(usr, "Unable to interface: Connection refused.")
+ if(!ai_control_check(usr))
return
. = TRUE
switch(action)