From 2c0ebf27283a8bf126327e8a053d3873c1c274e4 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 27 Jul 2020 01:24:59 -0700 Subject: [PATCH] converts aicontroldisabled into a define, also mochi suggestions --- code/__DEFINES/construction.dm | 6 +++++ code/datums/wires/airlock.dm | 34 ++++++++++++++-------------- code/game/machinery/doors/airlock.dm | 29 ++++++++++-------------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/code/__DEFINES/construction.dm b/code/__DEFINES/construction.dm index fc5b6eb74b9..b2a8a16419e 100644 --- a/code/__DEFINES/construction.dm +++ b/code/__DEFINES/construction.dm @@ -28,6 +28,12 @@ #define AIRLOCK_ASSEMBLY_NEEDS_ELECTRONICS 1 #define AIRLOCK_ASSEMBLY_NEEDS_SCREWDRIVER 2 +//used by airlocks and airlock wires. +#define AICONTROLDISABLED_OFF 1 // Silicons can control the airlock normally. +#define AICONTROLDISABLED_ON 2 // Silicons cannot control the airlock, but can hack the airlock. +#define AICONTROLDISABLED_BYPASS 3 // Silicons can control the airlock because they succeeded on the hack +#define AICONTROLDISABLED_PERMA 4 // Wire cutting has rendered it permanently bypassed + //plastic flaps construction states #define PLASTIC_FLAPS_NORMAL 0 #define PLASTIC_FLAPS_DETACHED 1 diff --git a/code/datums/wires/airlock.dm b/code/datums/wires/airlock.dm index dcde08d7ec1..4db560a0749 100644 --- a/code/datums/wires/airlock.dm +++ b/code/datums/wires/airlock.dm @@ -71,7 +71,7 @@ . += "The door bolts [A.locked ? "have fallen!" : "look up."]" . += "The door bolt lights are [(A.lights && haspower) ? "on." : "off!"]" . += "The test light is [haspower ? "on." : "off!"]" - . += "The 'AI control allowed' light is [(A.aiControlDisabled == 0 && !A.emagged && haspower) ? "on" : "off"]." + . += "The 'AI control allowed' light is [(A.aiControlDisabled == AICONTROLDISABLED_OFF && !A.emagged && haspower) ? "on" : "off"]." . += "The 'Check Wiring' light is [(A.safe == 0 && haspower) ? "on" : "off"]." . += "The 'Check Timing Mechanism' light is [(A.normalspeed == 0 && haspower) ? "on" : "off"]." . += "The emergency lights are [(A.emergency && haspower) ? "on" : "off"]." @@ -114,15 +114,15 @@ if(!mended) //one wire for AI control. Cutting this prevents the AI from controlling the door unless it has hacked the door through the power connection (which takes about a minute). If both main and backup power are cut, as well as this wire, then the AI cannot operate or hack the door at all. //aiControlDisabled: If 1, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in. - if(A.aiControlDisabled == 0) - A.aiControlDisabled = 1 - else if(A.aiControlDisabled == -1) - A.aiControlDisabled = 2 + if(A.aiControlDisabled == AICONTROLDISABLED_OFF) + A.aiControlDisabled = AICONTROLDISABLED_ON + else if(A.aiControlDisabled == AICONTROLDISABLED_PERMA) + A.aiControlDisabled = AICONTROLDISABLED_BYPASS else - if(A.aiControlDisabled == 1) - A.aiControlDisabled = 0 - else if(A.aiControlDisabled == 2) - A.aiControlDisabled = -1 + if(A.aiControlDisabled == AICONTROLDISABLED_ON) + A.aiControlDisabled = AICONTROLDISABLED_OFF + else if(A.aiControlDisabled == AICONTROLDISABLED_BYPASS) + A.aiControlDisabled = AICONTROLDISABLED_PERMA if(AIRLOCK_WIRE_ELECTRIFY) if(!mended) @@ -174,17 +174,17 @@ //two wires for backup power. Sending a pulse through either one causes a breaker to trip, but this does not disable it unless main power is down too (in which case it is disabled for 1 minute or however long it takes main power to come back, whichever is shorter). A.loseBackupPower() if(AIRLOCK_WIRE_AI_CONTROL) - if(A.aiControlDisabled == 0) - A.aiControlDisabled = 1 - else if(A.aiControlDisabled == -1) - A.aiControlDisabled = 2 + if(A.aiControlDisabled == AICONTROLDISABLED_OFF) + A.aiControlDisabled = AICONTROLDISABLED_ON + else if(A.aiControlDisabled == AICONTROLDISABLED_PERMA) + A.aiControlDisabled = AICONTROLDISABLED_BYPASS spawn(10) if(A) - if(A.aiControlDisabled == 1) - A.aiControlDisabled = 0 - else if(A.aiControlDisabled == 2) - A.aiControlDisabled = -1 + if(A.aiControlDisabled == AICONTROLDISABLED_ON) + A.aiControlDisabled = AICONTROLDISABLED_OFF + else if(A.aiControlDisabled == AICONTROLDISABLED_BYPASS) + A.aiControlDisabled = AICONTROLDISABLED_PERMA if(AIRLOCK_WIRE_ELECTRIFY) //one wire for electrifying the door. Sending a pulse through this electrifies the door for 30 seconds. diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index d67cd45f922..86a72238cca 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -42,6 +42,7 @@ #define TGUI_ORANGE 1 #define TGUI_RED 0 + GLOBAL_LIST_EMPTY(airlock_overlays) /obj/machinery/door/airlock @@ -58,7 +59,7 @@ GLOBAL_LIST_EMPTY(airlock_overlays) normalspeed = 1 siemens_strength = 1 var/security_level = 0 //How much are wires secured - var/aiControlDisabled = FALSE //If TRUE, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in. + var/aiControlDisabled = AICONTROLDISABLED_OFF var/hackProof = FALSE // if TRUE, this door can't be hacked by the AI var/electrified_until = 0 // World time when the door is no longer electrified. -1 if it is permanently electrified until someone fixes it. var/main_power_lost_until = 0 //World time when main power is restored. @@ -197,10 +198,10 @@ About the new airlock wires panel: return wires.IsIndexCut(wireIndex) /obj/machinery/door/airlock/proc/canAIControl() - return ((aiControlDisabled != 1) && (!isAllPowerLoss())) + return ((aiControlDisabled != AICONTROLDISABLED_ON) && (!isAllPowerLoss())) /obj/machinery/door/airlock/proc/canAIHack() - return ((aiControlDisabled == 1) && (!hackProof) && (!isAllPowerLoss())) + return ((aiControlDisabled == AICONTROLDISABLED_ON) && (!hackProof) && (!isAllPowerLoss())) /obj/machinery/door/airlock/proc/arePowerSystemsOn() if(stat & (NOPOWER|BROKEN)) @@ -665,7 +666,7 @@ About the new airlock wires panel: to_chat(user, "Transfer complete. Forcing airlock to execute program.") sleep(50) //disable blocked control - aiControlDisabled = 2 + aiControlDisabled = AICONTROLDISABLED_BYPASS to_chat(user, "Receiving control information from airlock.") sleep(10) //bring up airlock dialog @@ -784,6 +785,7 @@ About the new airlock wires panel: else to_chat(usr, "Unable to interface: Connection refused.") return + . = TRUE switch(action) if("disrupt-main") if(!main_power_lost_until) @@ -791,21 +793,20 @@ About the new airlock wires panel: update_icon() else to_chat(usr, "Main power is already offline.") - . = TRUE + . = FALSE if("disrupt-backup") if(!backup_power_lost_until) loseBackupPower() update_icon() else to_chat(usr, "Backup power is already offline.") - . = TRUE if("shock-restore") to_chat(usr, "The door is now un-electrified.") electrify(0) - . = TRUE if("shock-temp") if(isWireCut(AIRLOCK_WIRE_ELECTRIFY)) to_chat(usr, "The electrification wire is cut - Door permanently electrified.") + . = FALSE else //electrify door for 30 seconds shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])") @@ -813,27 +814,26 @@ About the new airlock wires panel: add_attack_logs(usr, src, "Electrified", ATKLOG_ALL) to_chat(usr, "The door is now electrified for thirty seconds.") electrify(30) - . = TRUE if("shock-perm") if(isWireCut(AIRLOCK_WIRE_ELECTRIFY)) to_chat(usr, "The electrification wire is cut - Cannot electrify the door.") + . = FALSE else shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])") usr.create_attack_log("Electrified the [name] at [x] [y] [z]") add_attack_logs(usr, src, "Electrified", ATKLOG_ALL) to_chat(usr, "The door is now electrified.") electrify(-1) - . = TRUE if("idscan-toggle") if(isWireCut(AIRLOCK_WIRE_IDSCAN)) to_chat(usr, "The IdScan wire has been cut - IdScan feature permanently disabled.") + . = FALSE else if(aiDisabledIdScanner) aiDisabledIdScanner = FALSE to_chat(usr, "IdScan feature has been enabled.") else aiDisabledIdScanner = TRUE to_chat(usr, "IdScan feature has been disabled.") - . = TRUE if("emergency-toggle") emergency = !emergency if(emergency) @@ -841,7 +841,6 @@ About the new airlock wires panel: else to_chat(usr, "Emergency access has been disabled.") update_icon() - . = TRUE if("bolt-toggle") if(isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) to_chat(usr, "The door bolt control wire has been cut - Door bolts permanently dropped.") @@ -849,7 +848,6 @@ About the new airlock wires panel: to_chat(usr, "The door bolts have been dropped.") else if(unlock()) to_chat(usr, "The door bolts have been raised.") - . = TRUE if("light-toggle") if(isWireCut(AIRLOCK_WIRE_LIGHT)) to_chat(usr, "The bolt lights wire has been cut - The door bolt lights are permanently disabled.") @@ -860,7 +858,6 @@ About the new airlock wires panel: lights = 1 to_chat(usr, "The door bolt lights have been enabled.") update_icon() - . = TRUE if("safe-toggle") if(isWireCut(AIRLOCK_WIRE_SAFETY)) to_chat(usr, "The safety wire is cut - Cannot secure the door.") @@ -868,7 +865,6 @@ About the new airlock wires panel: safe = 0 else safe = 1 - . = TRUE if("speed-toggle") if(isWireCut(AIRLOCK_WIRE_SPEED)) to_chat(usr, "The timing wire is cut - Cannot alter timing.") @@ -876,7 +872,6 @@ About the new airlock wires panel: normalspeed = 0 else normalspeed = 1 - . = TRUE if("open-close") if(welded) to_chat(usr, "The airlock has been welded shut!") @@ -886,7 +881,8 @@ About the new airlock wires panel: open() else close() - . = TRUE + else + . = FALSE /obj/machinery/door/airlock/attackby(obj/item/C, mob/user, params) add_fingerprint(user) @@ -1461,4 +1457,3 @@ About the new airlock wires panel: #undef TGUI_GREEN #undef TGUI_ORANGE #undef TGUI_RED -