mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-12 16:37:19 +01:00
Refactored the machinery operable procs (#19274)
Refactored the machinery operable procs into a single one, DMDoc'd, SDMM marked, made more readable. Fixed suspension field generator not being able to be used as it was not checking the power cell for operability. Fixes #19249
This commit is contained in:
@@ -194,7 +194,7 @@
|
||||
if(!M.use_power) // Not using power at all
|
||||
to_chat(user, SPAN_NOTICE("ERROR: No power grid connection. Unable to overload."))
|
||||
return
|
||||
if(M.inoperable()) // Not functional
|
||||
if(!M.operable()) // Not functional
|
||||
to_chat(user, SPAN_NOTICE("ERROR: Unknown error. Machine is probably damaged or power supply is nonfunctional."))
|
||||
return
|
||||
else // Not a machine at all (what the hell is this doing in Machines list anyway??)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
return attack_hand(user)
|
||||
|
||||
/obj/machinery/computer/security/check_eye(var/mob/user as mob)
|
||||
if (user.stat || user.blinded || inoperable())
|
||||
if (user.stat || user.blinded || !operable())
|
||||
return -1
|
||||
if(!current_camera)
|
||||
return 0
|
||||
@@ -37,7 +37,7 @@
|
||||
return viewflag
|
||||
|
||||
/obj/machinery/computer/security/grants_equipment_vision(var/mob/user as mob)
|
||||
if(user.stat || user.blinded || inoperable())
|
||||
if(user.stat || user.blinded || !operable())
|
||||
return FALSE
|
||||
if(!current_camera)
|
||||
return FALSE
|
||||
@@ -131,7 +131,7 @@
|
||||
A.client.eye = A.eyeobj
|
||||
return 1
|
||||
|
||||
if (user.stat || user.blinded || inoperable())
|
||||
if (user.stat || user.blinded || !operable())
|
||||
return 0
|
||||
set_current(C)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/computer/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = TRUE)
|
||||
if(inoperable() || isNotStationLevel(z) || user.stat)
|
||||
if(!operable() || isNotStationLevel(z) || user.stat)
|
||||
user.unset_machine()
|
||||
return
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
|
||||
|
||||
/obj/machinery/computer/pod/process()
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return
|
||||
if(timing)
|
||||
if(time > 0)
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
return
|
||||
|
||||
if(ishuman(M) || isrobot(M) || isbot(M) || istype(M, /mob/living/simple_animal/spiderbot) || ismech(M))
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
if(do_after(M, 1 SECOND, src))
|
||||
// The VM here is before open and the wording is backwards because density gets set after a background sleep in open
|
||||
visible_message("\The [M] [density ? "pushes" : "pulls"] \the [src] [density ? "open" : "closed"].")
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
/obj/machinery/door/window/allowed(mob/M)
|
||||
. = ..()
|
||||
if(inoperable() || !density) // Unpowered windoors can just be slid open, open windoors can always be closed
|
||||
if(!operable() || !density) // Unpowered windoors can just be slid open, open windoors can always be closed
|
||||
return TRUE
|
||||
use_power_oneoff(50) // Just powering the RFID and maybe a weak motor
|
||||
if(operable() && . == FALSE)
|
||||
@@ -183,7 +183,7 @@
|
||||
return TRUE
|
||||
|
||||
if(isobj(attacking_item) && attacking_item.iscrowbar() && user.a_intent == I_HELP)
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
visible_message("\The [user] forces \the [src] [density ? "open" : "closed"].")
|
||||
if(density)
|
||||
open(TRUE)
|
||||
@@ -207,7 +207,7 @@
|
||||
src.add_fingerprint(user)
|
||||
|
||||
if(allowed(user))
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
if(!do_after(user, 1 SECOND, src))
|
||||
return TRUE
|
||||
visible_message("\The [user] [density ? "pushes" : "pulls"] \the [src] [density ? "open" : "closed"].")
|
||||
@@ -229,7 +229,7 @@
|
||||
|
||||
|
||||
/obj/machinery/door/window/brigdoor/allowed(mob/M)
|
||||
if(inoperable()) // Brigdoors are the exception to the "fail open" windoor - they lock closed
|
||||
if(!operable()) // Brigdoors are the exception to the "fail open" windoor - they lock closed
|
||||
to_chat(M, SPAN_WARNING("\The [src] refuses to budge in its unpowered state."))
|
||||
return FALSE
|
||||
. = ..()
|
||||
|
||||
@@ -226,19 +226,26 @@ Class Procs:
|
||||
return
|
||||
return
|
||||
|
||||
/proc/is_operable(var/obj/machinery/M, var/mob/user)
|
||||
return istype(M) && M.operable()
|
||||
/**
|
||||
* Check to see if the machine is operable
|
||||
*
|
||||
* * `additional_flags` - Additional flags to check for, that could have been added to the `stat` variable
|
||||
*
|
||||
* Returns `TRUE` if the machine is operable, `FALSE` otherwise
|
||||
*/
|
||||
/obj/machinery/proc/operable(additional_flags = 0)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
SHOULD_BE_PURE(TRUE)
|
||||
|
||||
/obj/machinery/proc/operable(var/additional_flags = 0)
|
||||
return !inoperable(additional_flags)
|
||||
|
||||
/obj/machinery/proc/inoperable(var/additional_flags = 0)
|
||||
return (stat & (NOPOWER|BROKEN|additional_flags))
|
||||
if(stat & (NOPOWER|BROKEN|additional_flags))
|
||||
return FALSE
|
||||
else
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/proc/toggle_power(power_set = -1, additional_flags = 0)
|
||||
if(power_set >= 0)
|
||||
update_use_power(power_set)
|
||||
else if (use_power || inoperable(additional_flags))
|
||||
else if (use_power || !operable(additional_flags))
|
||||
update_use_power(POWER_USE_OFF)
|
||||
else
|
||||
update_use_power(initial(use_power))
|
||||
@@ -277,7 +284,7 @@ Class Procs:
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/attack_hand(mob/user as mob)
|
||||
if(inoperable(MAINT))
|
||||
if(!operable(MAINT))
|
||||
return 1
|
||||
if(user.lying || user.stat)
|
||||
return 1
|
||||
@@ -373,7 +380,7 @@ Class Procs:
|
||||
playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0) //TODO: Check if that one is the correct sound
|
||||
|
||||
/obj/machinery/proc/shock(mob/user, prb)
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return 0
|
||||
if(!prob(prb))
|
||||
return 0
|
||||
|
||||
@@ -450,7 +450,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
//err... hacking code, which has no reason for existing... but anyway... it was once supposed to unlock priority 3 messanging on that console (EXTREME priority...), but the code for that was removed.
|
||||
/obj/machinery/requests_console/attackby(obj/item/attacking_item, mob/user)
|
||||
if (istype(attacking_item, /obj/item/card/id))
|
||||
if(inoperable(MAINT)) return TRUE
|
||||
if(!operable(MAINT)) return TRUE
|
||||
if(screen == RCS_MESSAUTH)
|
||||
var/obj/item/card/id/T = attacking_item
|
||||
msgVerified = text("<font color='green'><b>Verified by [T.registered_name], [T.assignment]</b></font>")
|
||||
@@ -466,7 +466,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
updateUsrDialog()
|
||||
return TRUE
|
||||
else if (istype(attacking_item, /obj/item/stamp))
|
||||
if(inoperable(MAINT)) return
|
||||
if(!operable(MAINT)) return
|
||||
if(screen == RCS_MESSAUTH)
|
||||
var/obj/item/stamp/T = attacking_item
|
||||
msgStamped = SPAN_NOTICE("<b>Stamped with the [T.name]</b>")
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
/obj/machinery/telecomms/message_server/receive_information(datum/signal/subspace/pda/signal, obj/machinery/telecomms/machine_from)
|
||||
// can't log non-PDA signals
|
||||
if(!istype(signal) || !signal.data["message"] || !use_power || inoperable())
|
||||
if(!istype(signal) || !signal.data["message"] || !use_power || !operable())
|
||||
return
|
||||
|
||||
// log the signal
|
||||
@@ -119,7 +119,7 @@
|
||||
authmsg += "[stamp]<br>"
|
||||
for (var/obj/machinery/requests_console/Console in allConsoles)
|
||||
if (ckey(Console.department) == ckey(recipient))
|
||||
if(Console.inoperable())
|
||||
if(!Console.operable())
|
||||
Console.message_log += "<B>Message lost due to console failure.</B><BR>Please contact [station_name()] system adminsitrator or AI for technical assistance.<BR>"
|
||||
continue
|
||||
if(Console.newmessagepriority < priority)
|
||||
@@ -154,7 +154,7 @@
|
||||
return
|
||||
|
||||
/obj/machinery/telecomms/message_server/attackby(obj/item/attacking_item, mob/user)
|
||||
if (use_power && !inoperable(EMPED) && (spamfilter_limit < MESSAGE_SERVER_DEFAULT_SPAM_LIMIT*2) && \
|
||||
if (use_power && operable(EMPED) && (spamfilter_limit < MESSAGE_SERVER_DEFAULT_SPAM_LIMIT*2) && \
|
||||
istype(attacking_item, /obj/item/circuitboard/message_monitor) && istype(user))
|
||||
spamfilter_limit += round(MESSAGE_SERVER_DEFAULT_SPAM_LIMIT / 2)
|
||||
user.drop_from_inventory(attacking_item, get_turf(src))
|
||||
@@ -164,7 +164,7 @@
|
||||
..()
|
||||
|
||||
/obj/machinery/telecomms/message_server/update_icon()
|
||||
if(inoperable(EMPED))
|
||||
if(!operable(EMPED))
|
||||
icon_state = "server-nopower"
|
||||
else if (!use_power)
|
||||
icon_state = "server-off"
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
/obj/machinery/telecomms/process()
|
||||
if(!use_power) return PROCESS_KILL
|
||||
if(inoperable(EMPED))
|
||||
if(!operable(EMPED))
|
||||
toggle_power(additional_flags = EMPED)
|
||||
return PROCESS_KILL
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
delay = initial(delay)
|
||||
|
||||
/obj/machinery/telecomms/proc/produce_heat()
|
||||
if (!produces_heat || !use_power || inoperable(EMPED))
|
||||
if (!produces_heat || !use_power || !operable(EMPED))
|
||||
return
|
||||
|
||||
var/turf/simulated/L = loc
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/binary/oxyregenerator/process()
|
||||
. = ..()
|
||||
if((inoperable()) || !use_power)
|
||||
if((!operable()) || !use_power)
|
||||
return
|
||||
|
||||
var/power_draw = -1
|
||||
|
||||
@@ -204,7 +204,7 @@ GLOBAL_LIST_EMPTY_TYPED(holodeck_controls, /obj/machinery/computer/holodeck_cont
|
||||
holographic_mobs -= P
|
||||
P.derez()
|
||||
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return
|
||||
if(active)
|
||||
use_power_oneoff(item_power_usage * (holographic_objs.len + holographic_mobs.len))
|
||||
|
||||
@@ -113,7 +113,7 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov
|
||||
return FALSE
|
||||
|
||||
var/flags = issilicon(user) ? USE_ALLOW_NON_ADJACENT : 0
|
||||
if (use_check_and_message(user, flags) || user.blinded || inoperable() || !linked)
|
||||
if (use_check_and_message(user, flags) || user.blinded || !operable() || !linked)
|
||||
return -1
|
||||
else
|
||||
return SEE_THRU
|
||||
|
||||
@@ -921,7 +921,7 @@
|
||||
return wires.is_cut(wireIndex)
|
||||
|
||||
/obj/machinery/power/apc/proc/can_use(mob/user, var/loud = 0) //used by attack_hand() and Topic()
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return FALSE
|
||||
var/use_flags = issilicon(user) && USE_ALLOW_NON_ADJACENT // AIs and borgs can use it at range
|
||||
use_flags |= (check_rights(R_ADMIN, FALSE, user) && USE_ALLOW_NONLIVING) // admins can use the UI when ghosting
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
/obj/machinery/fusion_fuel_injector/process()
|
||||
if(injecting)
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
StopInjecting()
|
||||
else
|
||||
Inject()
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
harvesting.Cut()
|
||||
|
||||
/obj/machinery/kinetic_harvester/update_icon()
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
icon_state = "broken"
|
||||
else if(use_power >= POWER_USE_ACTIVE)
|
||||
icon_state = "on"
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/chem_master/attack_hand(mob/user as mob)
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return
|
||||
user.set_machine(src)
|
||||
ui_interact(user)
|
||||
@@ -428,7 +428,7 @@
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/reagentgrinder/interact(mob/user as mob) // The microwave Menu
|
||||
if(inoperable())
|
||||
if(!operable())
|
||||
return
|
||||
user.set_machine(src)
|
||||
var/is_chamber_empty = 0
|
||||
|
||||
@@ -38,6 +38,14 @@
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/suspension_gen/operable(additional_flags)
|
||||
if(stat & (BROKEN|additional_flags))
|
||||
return FALSE
|
||||
if(!cell.charge)
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/suspension_gen/attackby(obj/item/attacking_item, mob/user)
|
||||
if(attacking_item.isscrewdriver())
|
||||
if(!open)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# - (fixes bugs)
|
||||
# wip
|
||||
# - (work in progress)
|
||||
# qol
|
||||
# - (quality of life)
|
||||
# soundadd
|
||||
# - (adds a sound)
|
||||
# sounddel
|
||||
# - (removes a sound)
|
||||
# rscadd
|
||||
# - (adds a feature)
|
||||
# rscdel
|
||||
# - (removes a feature)
|
||||
# imageadd
|
||||
# - (adds an image or sprite)
|
||||
# imagedel
|
||||
# - (removes an image or sprite)
|
||||
# spellcheck
|
||||
# - (fixes spelling or grammar)
|
||||
# experiment
|
||||
# - (experimental change)
|
||||
# balance
|
||||
# - (balance changes)
|
||||
# code_imp
|
||||
# - (misc internal code change)
|
||||
# refactor
|
||||
# - (refactors code)
|
||||
# config
|
||||
# - (makes a change to the config files)
|
||||
# admin
|
||||
# - (makes changes to administrator tools)
|
||||
# server
|
||||
# - (miscellaneous changes to server)
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: FluffyGhost
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
|
||||
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- refactor: "Refactored the machinery operable procs into a single one, DMDoc'd, SDMM marked, made more readable."
|
||||
- bugfix: "Fixed suspension field generator not being able to be used as it was not checking the power cell for operability."
|
||||
Reference in New Issue
Block a user