[MIRROR] Replacing magic numbers with defines in robot code (#2801)

* Replacing magic numbers with defines in robot code (#56241)

While scouring robot code for some (hopefully upcoming) fixes, I found a bunch of gross numbers. These numbers are now letters.

* Replacing magic numbers with defines in robot code

Co-authored-by: dragomagol <66640614+dragomagol@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-01-20 03:40:05 +01:00
committed by GitHub
parent 2d87d491ae
commit d4b939c2c9
5 changed files with 43 additions and 39 deletions
+5
View File
@@ -61,3 +61,8 @@
#define BORG_MODULE_ALL_DISABLED (1<<0)
#define BORG_MODULE_TWO_DISABLED (1<<1)
#define BORG_MODULE_THREE_DISABLED (1<<2)
/// Defines for borg module selection
#define BORG_CHOOSE_MODULE_ONE 1
#define BORG_CHOOSE_MODULE_TWO 2
#define BORG_CHOOSE_MODULE_THREE 3
+3 -3
View File
@@ -271,11 +271,11 @@
var/obj/item/I = R.held_items[i]
if(I)
switch(i)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
I.screen_loc = ui_inv1
if(2)
if(BORG_CHOOSE_MODULE_TWO)
I.screen_loc = ui_inv2
if(3)
if(BORG_CHOOSE_MODULE_THREE)
I.screen_loc = ui_inv3
else
return
+16 -16
View File
@@ -8,8 +8,8 @@
icon_state = "cyborg_upgrade"
w_class = WEIGHT_CLASS_SMALL
var/locked = FALSE
var/installed = 0
var/require_module = 0
var/installed = FALSE
var/require_module = FALSE
var/list/module_type = null
/// Bitflags listing module compatibility. Used in the exosuit fabricator for creating sub-categories.
var/list/module_flags = NONE
@@ -77,7 +77,7 @@
name = "cyborg rapid disabler cooling module"
desc = "Used to cool a mounted disabler, increasing the potential current in it and thus its recharge rate."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/security)
module_flags = BORG_MODULE_SECURITY
@@ -127,7 +127,7 @@
name = "mining cyborg diamond drill"
desc = "A diamond drill replacement for the mining module's standard drill."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/miner)
module_flags = BORG_MODULE_MINER
@@ -160,7 +160,7 @@
name = "mining cyborg satchel of holding"
desc = "A satchel of holding replacement for mining cyborg's ore satchel module."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/miner)
module_flags = BORG_MODULE_MINER
@@ -188,7 +188,7 @@
name = "janitor cyborg trash bag of holding"
desc = "A trash bag of holding replacement for the janiborg's standard trash bag."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/janitor)
module_flags = BORG_MODULE_JANITOR
@@ -216,7 +216,7 @@
name = "janitor cyborg advanced mop"
desc = "An advanced mop replacement for the janiborg's standard mop."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/janitor)
module_flags = BORG_MODULE_JANITOR
@@ -244,7 +244,7 @@
name = "janitor cyborg plating repair tool"
desc = "A tiny heating device to repair burnt and damaged hull platings with."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/janitor)
module_flags = BORG_MODULE_JANITOR
@@ -265,7 +265,7 @@
name = "illegal equipment module"
desc = "Unlocks the hidden, deadlier functions of a cyborg."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
/obj/item/borg/upgrade/syndicate/action(mob/living/silicon/robot/R, user = usr)
. = ..()
@@ -273,7 +273,7 @@
if(R.emagged)
return FALSE
R.SetEmagged(1)
R.SetEmagged(TRUE)
R.logevent("WARN: hardware installed with missing security certificate!") //A bit of fluff to hint it was an illegal tech item
R.logevent("WARN: root privleges granted to PID [num2hex(rand(1,65535), -1)][num2hex(rand(1,65535), -1)].") //random eight digit hex value. Two are used because rand(1,4294967295) throws an error
@@ -289,7 +289,7 @@
desc = "An upgrade kit to apply specialized coolant systems and insulation layers to a mining cyborg's chassis, enabling them to withstand exposure to molten rock."
icon_state = "ash_plating"
resistance_flags = LAVA_PROOF | FIRE_PROOF
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/miner)
module_flags = BORG_MODULE_MINER
@@ -307,7 +307,7 @@
name = "self-repair module"
desc = "This module will repair the cyborg over time."
icon_state = "cyborg_upgrade5"
require_module = 1
require_module = TRUE
var/repair_amount = -1
/// world.time of next repair
var/next_repair = 0
@@ -409,7 +409,7 @@
desc = "An upgrade to the Medical module cyborg's hypospray, allowing it \
to produce more advanced and complex medical reagents."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/medical)
module_flags = BORG_MODULE_MEDICAL
var/list/additional_reagents = list()
@@ -466,7 +466,7 @@
desc = "An upgrade to the Medical module, installing a built-in \
defibrillator, for on the scene revival."
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/medical)
module_flags = BORG_MODULE_MEDICAL
@@ -520,7 +520,7 @@
capable of scanning surgery disks and carrying \
out procedures"
icon_state = "cyborg_upgrade3"
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/medical, /obj/item/robot_module/syndicate_medical)
module_flags = BORG_MODULE_MEDICAL
@@ -576,7 +576,7 @@
R.notransform = TRUE
var/prev_lockcharge = R.lockcharge
R.SetLockdown(1)
R.SetLockdown(TRUE)
R.set_anchored(TRUE)
var/datum/effect_system/smoke_spread/smoke = new
smoke.set_up(1, R.loc)
@@ -56,11 +56,11 @@
hud_used.toggle_show_robot_modules()
storage_was_closed = TRUE
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
item_module.screen_loc = inv1.screen_loc
if(2)
if(BORG_CHOOSE_MODULE_TWO)
item_module.screen_loc = inv2.screen_loc
if(3)
if(BORG_CHOOSE_MODULE_THREE)
item_module.screen_loc = inv3.screen_loc
held_items[module_num] = item_module
@@ -111,13 +111,13 @@
module_active = null
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
if(!(disabled_modules & BORG_MODULE_ALL_DISABLED))
inv1.icon_state = initial(inv1.icon_state)
if(2)
if(BORG_CHOOSE_MODULE_TWO)
if(!(disabled_modules & BORG_MODULE_TWO_DISABLED))
inv2.icon_state = initial(inv2.icon_state)
if(3)
if(BORG_CHOOSE_MODULE_THREE)
if(!(disabled_modules & BORG_MODULE_THREE_DISABLED))
inv3.icon_state = initial(inv3.icon_state)
@@ -147,7 +147,7 @@
return FALSE
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
if(disabled_modules & BORG_MODULE_ALL_DISABLED)
return FALSE
@@ -163,7 +163,7 @@
to_chat(src, "<span class='userdanger'>CRITICAL ERROR: ALL modules OFFLINE.</span>")
if(2)
if(BORG_CHOOSE_MODULE_TWO)
if(disabled_modules & BORG_MODULE_TWO_DISABLED)
return FALSE
@@ -174,7 +174,7 @@
audible_message("<span class='warning'>[src] sounds an alarm! \"SYSTEM ERROR: Module [module_num] OFFLINE.\"</span>")
to_chat(src, "<span class='userdanger'>SYSTEM ERROR: Module [module_num] OFFLINE.</span>")
if(3)
if(BORG_CHOOSE_MODULE_THREE)
if(disabled_modules & BORG_MODULE_THREE_DISABLED)
return FALSE
@@ -205,7 +205,7 @@
return FALSE
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
if(!(disabled_modules & BORG_MODULE_ALL_DISABLED))
return FALSE
@@ -214,13 +214,13 @@
if(builtInCamera)
builtInCamera.status = TRUE
to_chat(src, "<span class='notice'>You hear your built in security camera focus adjust as it comes back online!</span>")
if(2)
if(BORG_CHOOSE_MODULE_TWO)
if(!(disabled_modules & BORG_MODULE_TWO_DISABLED))
return FALSE
inv2.icon_state = initial(inv2.icon_state)
disabled_modules &= ~BORG_MODULE_TWO_DISABLED
if(3)
if(BORG_CHOOSE_MODULE_THREE)
if(!(disabled_modules & BORG_MODULE_THREE_DISABLED))
return FALSE
@@ -331,13 +331,13 @@
return FALSE
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
if(module_active != held_items[module_num])
inv1.icon_state = "[initial(inv1.icon_state)] +a"
if(2)
if(BORG_CHOOSE_MODULE_TWO)
if(module_active != held_items[module_num])
inv2.icon_state = "[initial(inv2.icon_state)] +a"
if(3)
if(BORG_CHOOSE_MODULE_THREE)
if(module_active != held_items[module_num])
inv3.icon_state = "[initial(inv3.icon_state)] +a"
module_active = held_items[module_num]
@@ -350,13 +350,13 @@
*/
/mob/living/silicon/robot/proc/deselect_module(module_num)
switch(module_num)
if(1)
if(BORG_CHOOSE_MODULE_ONE)
if(module_active == held_items[module_num])
inv1.icon_state = initial(inv1.icon_state)
if(2)
if(BORG_CHOOSE_MODULE_TWO)
if(module_active == held_items[module_num])
inv2.icon_state = initial(inv2.icon_state)
if(3)
if(BORG_CHOOSE_MODULE_THREE)
if(module_active == held_items[module_num])
inv3.icon_state = initial(inv3.icon_state)
module_active = null
@@ -405,4 +405,3 @@
/mob/living/silicon/robot/can_hold_items(obj/item/I)
return (I && (I in module.modules)) //Only if it's part of our module.
@@ -238,7 +238,7 @@
icon = 'icons/obj/objects.dmi'
icon_state = "modkit"
w_class = WEIGHT_CLASS_SMALL
require_module = 1
require_module = TRUE
module_type = list(/obj/item/robot_module/miner)
module_flags = BORG_MODULE_MINER
var/denied_type = null