From 7ce27f76fdc12bab94b74ee96791b25d58ef73e1 Mon Sep 17 00:00:00 2001 From: PsiOmegaDelta Date: Wed, 16 Sep 2015 12:57:14 +0200 Subject: [PATCH] Macro refactoring. Turns several of the is* procs into istype defines. --- code/__defines/_macros.dm | 32 +++++ code/game/machinery/alarm.dm | 12 +- code/game/machinery/computer/robot.dm | 6 +- code/game/machinery/doors/airlock.dm | 2 +- code/game/machinery/doors/firedoor.dm | 4 +- code/game/machinery/portable_turret.dm | 4 +- .../machinery/telecomms/telecomunications.dm | 2 +- code/game/machinery/turret_control.dm | 6 +- code/modules/admin/topic.dm | 2 +- code/modules/mob/mob_helpers.dm | 124 +----------------- code/modules/nano/modules/alarm_monitor.dm | 2 +- code/modules/nano/modules/atmos_control.dm | 2 +- code/modules/nano/modules/crew_monitor.dm | 4 +- code/modules/nano/modules/law_manager.dm | 4 +- 14 files changed, 59 insertions(+), 147 deletions(-) diff --git a/code/__defines/_macros.dm b/code/__defines/_macros.dm index affbf2086d..c7bf1bf70d 100644 --- a/code/__defines/_macros.dm +++ b/code/__defines/_macros.dm @@ -1,2 +1,34 @@ #define Clamp(x, y, z) (x <= y ? y : (x >= z ? z : x)) #define CLAMP01(x) (Clamp(x, 0, 1)) + +#define isAI(A) istype(A, /mob/living/silicon/ai) + +#define isalien(A) istype(A, /mob/living/carbon/alien) + +#define isanimal(A) istype(A, /mob/living/simple_animal) + +#define isbrain(A) istype(A, /mob/living/carbon/brain) + +#define iscarbon(A) istype(A, /mob/living/carbon) + +#define iscorgi(A) istype(A, /mob/living/simple_animal/corgi) + +#define ishuman(A) istype(A, /mob/living/carbon/human) + +#define isliving(A) istype(A, /mob/living) + +#define ismouse(A) istype(A, /mob/living/simple_animal/mouse) + +#define isnewplayer(A) istype(A, /mob/new_player) + +#define isobserver(A) istype(A, /mob/dead/observer) + +#define isorgan(A) istype(A, /obj/item/organ/external) + +#define ispAI(A) istype(A, /mob/living/silicon/pai) + +#define isrobot(A) istype(A, /mob/living/silicon/robot) + +#define issilicon(A) istype(A, /mob/living/silicon) + +#define isslime(A) istype(A, /mob/living/carbon/slime) diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index f6c47c16bc..5dc7b13b48 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -326,7 +326,7 @@ if (2) icon_state = "alarm1" new_color = "#DA0205" - + set_light(l_range = 2, l_power = 0.5, l_color = new_color) /obj/machinery/alarm/receive_signal(datum/signal/signal) @@ -488,7 +488,7 @@ remote_connection = href["remote_connection"] // Remote connection means we're non-adjacent/connecting from another computer remote_access = href["remote_access"] // Remote access means we also have the privilege to alter the air alarm. - data["locked"] = locked && !user.isSilicon() + data["locked"] = locked && !issilicon(user) data["remote_connection"] = remote_connection data["remote_access"] = remote_access data["rcon"] = rcon_setting @@ -496,7 +496,7 @@ populate_status(data) - if(!(locked && !remote_connection) || remote_access || user.isSilicon()) + if(!(locked && !remote_connection) || remote_access || issilicon(user)) populate_controls(data) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -609,7 +609,7 @@ if(buildstage != 2) return STATUS_CLOSE - if(aidisabled && user.isMobAI()) + if(aidisabled && isAI(user)) user << "AI control for \the [src] interface has been disabled." return STATUS_CLOSE @@ -654,7 +654,7 @@ // hrefs that need the AA unlocked -walter0o var/extra_href = state.href_list(usr) - if(!(locked && !extra_href["remote_connection"]) || extra_href["remote_access"] || usr.isSilicon()) + if(!(locked && !extra_href["remote_connection"]) || extra_href["remote_access"] || issilicon(usr)) if(href_list["command"]) var/device_id = href_list["id_tag"] switch(href_list["command"]) @@ -910,7 +910,7 @@ FIRE ALARM if("blue") set_light(l_range = 2, l_power = 0.5, l_color = "#1024A9") if("red") set_light(l_range = 4, l_power = 2, l_color = "#ff0000") if("delta") set_light(l_range = 4, l_power = 2, l_color = "#FF6633") - + src.overlays += image('icons/obj/monitors.dmi', "overlay_[seclevel]") /obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume) diff --git a/code/game/machinery/computer/robot.dm b/code/game/machinery/computer/robot.dm index 5c09c08e21..636701fc07 100644 --- a/code/game/machinery/computer/robot.dm +++ b/code/game/machinery/computer/robot.dm @@ -21,7 +21,7 @@ data["robots"] = get_cyborgs(user) data["safety"] = safety // Also applies for cyborgs. Hides the manual self-destruct button. - data["is_ai"] = user.isSilicon() + data["is_ai"] = issilicon(user) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -44,7 +44,7 @@ var/mob/living/silicon/robot/target = get_cyborg_by_name(href_list["detonate"]) if(!target || !istype(target)) return - if(user.isMobAI() && (target.connected_ai != user)) + if(isAI(user) && (target.connected_ai != user)) user << "Access Denied. This robot is not linked to you." return // Cyborgs may blow up themselves via the console @@ -76,7 +76,7 @@ if(!target || !istype(target)) return - if(user.isMobAI() && (target.connected_ai != user)) + if(isAI(user) && (target.connected_ai != user)) user << "Access Denied. This robot is not linked to you." return diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 911c89ce03..646488abee 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -656,7 +656,7 @@ About the new airlock wires panel: return /obj/machinery/door/airlock/CanUseTopic(var/mob/user) - if(!user.isSilicon()) + if(issilicon(user)) return STATUS_CLOSE if(operating < 0) //emagged diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index bc5b2f1b56..6bedde46b3 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -147,7 +147,7 @@ "\The [src]", "Yes, [density ? "open" : "close"]", "No") if(answer == "No") return - if(user.stat || user.stunned || user.weakened || user.paralysis || (!user.canmove && !user.isSilicon()) || (get_dist(src, user) > 1 && !isAI(user))) + if(user.incapacitated() || (get_dist(src, user) > 1 && !issilicon(user))) user << "Sorry, you must remain able bodied and close to \the [src] in order to use it." return if(density && (stat & (BROKEN|NOPOWER))) //can still close without power @@ -167,7 +167,7 @@ if(alarmed) // Accountability! users_to_open |= user.name - needs_to_close = !user.isSilicon() + needs_to_close = !issilicon(user) spawn() open() else diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index c587046cf7..553cf612d5 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -174,11 +174,11 @@ var/list/turret_icons icon_state = "turretCover" /obj/machinery/porta_turret/proc/isLocked(mob/user) - if(ailock && user.isSilicon()) + if(ailock && issilicon(user)) user << "There seems to be a firewall preventing you from accessing this device." return 1 - if(locked && !user.isSilicon()) + if(locked && !issilicon(user)) user << "Access denied." return 1 diff --git a/code/game/machinery/telecomms/telecomunications.dm b/code/game/machinery/telecomms/telecomunications.dm index d1ac6df4c5..8797e7af8b 100644 --- a/code/game/machinery/telecomms/telecomunications.dm +++ b/code/game/machinery/telecomms/telecomunications.dm @@ -552,7 +552,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list() log.parameters["intelligible"] = 1 else if(M.isMonkey()) race = "Monkey" - else if(M.isSilicon()) + else if(issilicon(M)) race = "Artificial Life" log.parameters["intelligible"] = 1 else if(isslime(M)) diff --git a/code/game/machinery/turret_control.dm b/code/game/machinery/turret_control.dm index 2ea1424522..967b7799ed 100644 --- a/code/game/machinery/turret_control.dm +++ b/code/game/machinery/turret_control.dm @@ -64,11 +64,11 @@ return /obj/machinery/turretid/proc/isLocked(mob/user) - if(ailock && user.isSilicon()) + if(ailock && issilicon(user)) user << "There seems to be a firewall preventing you from accessing this device." return 1 - if(locked && !user.isSilicon()) + if(locked && !issilicon(user)) user << "Access denied." return 1 @@ -93,7 +93,7 @@ user << "You [ locked ? "lock" : "unlock"] the panel." return return ..() - + /obj/machinery/turretid/emag_act(var/remaining_charges, var/mob/user) if(!emagged) user << "You short out the turret controls' access analysis module." diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index e3a2a83aab..cb0dcf00ce 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1334,7 +1334,7 @@ src.owner << "You sent [input] to [L] via a secure channel." log_admin("[src.owner] replied to [key_name(L)]'s Centcomm message with the message [input].") message_admins("[src.owner] replied to [key_name(L)]'s Centcom message with: \"[input]\"") - if(!L.isMobAI()) + if(!isAI(L)) L << "You hear something crackle in your headset for a moment before a voice speaks." L << "Please stand by for a message from Central Command." L << "Message as follows." diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 647875ca4b..1fadadf64f 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -1,14 +1,4 @@ // fun if you want to typecast humans/monkeys/etc without writing long path-filled lines. -/proc/ishuman(A) - if(istype(A, /mob/living/carbon/human)) - return 1 - return 0 - -/proc/isalien(A) - if(istype(A, /mob/living/carbon/alien)) - return 1 - return 0 - /proc/isxenomorph(A) if(istype(A, /mob/living/carbon/human)) var/mob/living/carbon/human/H = A @@ -22,79 +12,7 @@ return 1 return 0 -/proc/isbrain(A) - if(A && istype(A, /mob/living/carbon/brain)) - return 1 - return 0 - -/proc/isslime(A) - if(istype(A, /mob/living/carbon/slime)) - return 1 - return 0 - -/proc/isrobot(A) - if(istype(A, /mob/living/silicon/robot)) - return 1 - return 0 - -/proc/isanimal(A) - if(istype(A, /mob/living/simple_animal)) - return 1 - return 0 - -/proc/iscorgi(A) - if(istype(A, /mob/living/simple_animal/corgi)) - return 1 - return 0 - -/proc/iscrab(A) - if(istype(A, /mob/living/simple_animal/crab)) - return 1 - return 0 - -/proc/iscat(A) - if(istype(A, /mob/living/simple_animal/cat)) - return 1 - return 0 - -/proc/ismouse(A) - if(istype(A, /mob/living/simple_animal/mouse)) - return 1 - return 0 - -/proc/isbear(A) - if(istype(A, /mob/living/simple_animal/hostile/bear)) - return 1 - return 0 - -/proc/iscarp(A) - if(istype(A, /mob/living/simple_animal/hostile/carp)) - return 1 - return 0 - -/proc/isclown(A) - if(istype(A, /mob/living/simple_animal/hostile/retaliate/clown)) - return 1 - return 0 - -/mob/proc/isSilicon() - return 0 - -/mob/living/silicon/isSilicon() - return 1 - -/proc/isAI(A) - if(istype(A, /mob/living/silicon/ai)) - return 1 - return 0 - -/mob/proc/isMobAI() - return 0 - -/mob/living/silicon/ai/isMobAI() - return 1 - -/mob/proc/isSynthetic() +/mob/living/proc/isSynthetic() return 0 /mob/living/carbon/human/isSynthetic() @@ -107,56 +25,18 @@ /mob/living/silicon/isSynthetic() return 1 -/mob/living/carbon/human/isMonkey() - return istype(species, /datum/species/monkey) - /mob/proc/isMonkey() return 0 /mob/living/carbon/human/isMonkey() return istype(species, /datum/species/monkey) -/proc/ispAI(A) - if(istype(A, /mob/living/silicon/pai)) - return 1 - return 0 - -/proc/iscarbon(A) - if(istype(A, /mob/living/carbon)) - return 1 - return 0 - -/proc/issilicon(A) - if(istype(A, /mob/living/silicon)) - return 1 - return 0 - -/proc/isliving(A) - if(istype(A, /mob/living)) - return 1 - return 0 - -proc/isobserver(A) - if(istype(A, /mob/dead/observer)) - return 1 - return 0 - -proc/isorgan(A) - if(istype(A, /obj/item/organ/external)) - return 1 - return 0 - proc/isdeaf(A) if(istype(A, /mob)) var/mob/M = A return (M.sdisabilities & DEAF) || M.ear_deaf return 0 -proc/isnewplayer(A) - if(istype(A, /mob/new_player)) - return 1 - return 0 - proc/hasorgans(A) // Fucking really?? return ishuman(A) @@ -644,7 +524,7 @@ proc/is_blind(A) // A proper CentCom id is hard currency. else if(id && istype(id, /obj/item/weapon/card/id/centcom)) return SAFE_PERP - + if(check_access && !access_obj.allowed(src)) threatcount += 4 diff --git a/code/modules/nano/modules/alarm_monitor.dm b/code/modules/nano/modules/alarm_monitor.dm index b0012de1e5..29ae55b04a 100644 --- a/code/modules/nano/modules/alarm_monitor.dm +++ b/code/modules/nano/modules/alarm_monitor.dm @@ -65,7 +65,7 @@ var/cameras[0] var/lost_sources[0] - if(user.isMobAI()) + if(isAI(user)) for(var/obj/machinery/camera/C in A.cameras()) cameras[++cameras.len] = C.nano_structure() for(var/datum/alarm_source/AS in A.sources) diff --git a/code/modules/nano/modules/atmos_control.dm b/code/modules/nano/modules/atmos_control.dm index b3d2b5abd0..b84cacad0a 100644 --- a/code/modules/nano/modules/atmos_control.dm +++ b/code/modules/nano/modules/atmos_control.dm @@ -69,4 +69,4 @@ return extra_href /datum/topic_state/air_alarm/proc/has_access(var/mob/user) - return user && (user.isMobAI() || atmos_control.access.allowed(user) || atmos_control.emagged || air_alarm.rcon_setting == RCON_YES || (air_alarm.alarm_area.atmosalm && air_alarm.rcon_setting == RCON_AUTO)) + return user && (isAI(user) || atmos_control.access.allowed(user) || atmos_control.emagged || air_alarm.rcon_setting == RCON_YES || (air_alarm.alarm_area.atmosalm && air_alarm.rcon_setting == RCON_AUTO)) diff --git a/code/modules/nano/modules/crew_monitor.dm b/code/modules/nano/modules/crew_monitor.dm index 4074ea1b92..bb5e28ca04 100644 --- a/code/modules/nano/modules/crew_monitor.dm +++ b/code/modules/nano/modules/crew_monitor.dm @@ -8,7 +8,7 @@ usr << "Unable to establish a connection: You're too far away from the station!" return 0 if(href_list["track"]) - if(usr.isMobAI()) + if(isAI(usr)) var/mob/living/silicon/ai/AI = usr var/mob/living/carbon/human/H = locate(href_list["track"]) in mob_list if(hassensorlevel(H, SUIT_SENSOR_TRACKING)) @@ -19,7 +19,7 @@ var/data[0] var/turf/T = get_turf(nano_host()) - data["isAI"] = user.isMobAI() + data["isAI"] = isAI(user) data["crewmembers"] = crew_repository.health_data(T) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) diff --git a/code/modules/nano/modules/law_manager.dm b/code/modules/nano/modules/law_manager.dm index 798a4c4dfc..2c691349e0 100644 --- a/code/modules/nano/modules/law_manager.dm +++ b/code/modules/nano/modules/law_manager.dm @@ -136,7 +136,7 @@ if(href_list["notify_laws"]) owner << "Law Notice" owner.laws.show_laws(owner) - if(owner.isMobAI()) + if(isAI(owner)) var/mob/living/silicon/ai/AI = owner for(var/mob/living/silicon/robot/R in AI.connected_robots) R << "Law Notice" @@ -163,7 +163,7 @@ package_laws(data, "inherent_laws", owner.laws.inherent_laws) package_laws(data, "supplied_laws", owner.laws.supplied_laws) - data["isAI"] = owner.isMobAI() + data["isAI"] = isAI(owner) data["isMalf"] = is_malf(user) data["isSlaved"] = owner.is_slaved() data["isAdmin"] = is_admin(user)