From 81f917db29799dbea2c676ef0fa6359fbcbbdbb6 Mon Sep 17 00:00:00 2001 From: Nichlas Pihl Date: Sat, 9 Nov 2019 22:18:25 +0000 Subject: [PATCH] code cleanup (#6936) * code cleanup part 1 * Update cult_items.dm * Update maths.dm --- .github/CONTRIBUTING.md | 7 +---- code/__DEFINES/maths.dm | 4 ++- code/__HELPERS/names.dm | 29 ------------------- code/modules/antagonists/cult/cult_items.dm | 11 ++++--- .../atmospherics/machinery/atmosmachinery.dm | 14 ++++----- code/modules/cargo/exports/seeds.dm | 10 +++---- code/modules/jobs/job_types/janitor.dm | 1 - code/modules/mining/mine_items.dm | 6 ++-- 8 files changed, 24 insertions(+), 58 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 73481ad75779..3a4b64ffd128 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -50,9 +50,6 @@ datum var varname1 = 1 varname2 - static - varname3 - varname4 proc proc1() code @@ -77,8 +74,6 @@ The previous code made compliant: /datum/datum1 var/varname1 var/varname2 - var/static/varname3 - var/static/varname4 /datum/datum1/proc/proc1() code @@ -393,4 +388,4 @@ If you are porting features/tools from other codebases, you must give them credi Regarding sprites & sounds, you must credit the artist and possibly the codebase. All yogstation assets including icons and sound are under a [Creative Commons 3.0 BY-SA license](https://creativecommons.org/licenses/by-sa/3.0/) unless otherwise indicated. However if you are porting assets from GoonStation or usually any assets under the [Creative Commons 3.0 BY-NC-SA license](https://creativecommons.org/licenses/by-nc-sa/3.0/) are to go into the 'goon' folder of the yogstation codebase. ## A word on Git -All .dmm .dm .md .txt .html are required to end with CRLF(DOS/WINDOWS) line endings,git will enforce said line endings automatically. Other file types have non enforced line endings. \ No newline at end of file +All .dmm .dm .md .txt .html are required to end with CRLF(DOS/WINDOWS) line endings,git will enforce said line endings automatically. Other file types have non enforced line endings. diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index d344f7f01018..54adf366739b 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -141,7 +141,9 @@ #define ACCURACY 10000 /proc/gaussian(mean, stddev) var/static/gaussian_next - var/R1;var/R2;var/working + var/R1 + var/R2 + var/working if(gaussian_next != null) R1 = gaussian_next gaussian_next = null diff --git a/code/__HELPERS/names.dm b/code/__HELPERS/names.dm index aee9665e62e0..1ee2dbca4e7c 100644 --- a/code/__HELPERS/names.dm +++ b/code/__HELPERS/names.dm @@ -19,23 +19,6 @@ /proc/moth_name() return "[pick(GLOB.moth_first)] [pick(GLOB.moth_last)]" -/proc/church_name() - var/static/church_name - if (church_name) - return church_name - - var/name = "" - - name += pick("Holy", "United", "First", "Second", "Last") - - if (prob(20)) - name += " Space" - - name += " " + pick("Church", "Cathedral", "Body", "Worshippers", "Movement", "Witnesses") - name += " of [religion_name()]" - - return name - GLOBAL_VAR(command_name) /proc/command_name() if (GLOB.command_name) @@ -52,18 +35,6 @@ GLOBAL_VAR(command_name) return name -/proc/religion_name() - var/static/religion_name - if (religion_name) - return religion_name - - var/name = "" - - name += pick("bee", "science", "edu", "captain", "assistant", "monkey", "alien", "space", "unit", "sprocket", "gadget", "bomb", "revolution", "beyond", "station", "goon", "robot", "ivor", "hobnob") - name += pick("ism", "ia", "ology", "istism", "ites", "ick", "ian", "ity") - - return capitalize(name) - /proc/station_name() if(!GLOB.station_name) var/newname diff --git a/code/modules/antagonists/cult/cult_items.dm b/code/modules/antagonists/cult/cult_items.dm index 9303533cbb21..a92e032aa583 100644 --- a/code/modules/antagonists/cult/cult_items.dm +++ b/code/modules/antagonists/cult/cult_items.dm @@ -489,12 +489,13 @@ color = "#333333" list_reagents = list(/datum/reagent/fuel/unholywater = 50) +GLOBAL_VAR_INIT(curselimit, 0) + /obj/item/shuttle_curse name = "cursed orb" desc = "You peer within this smokey orb and glimpse terrible fates befalling the escape shuttle." icon = 'icons/obj/cult.dmi' icon_state ="shuttlecurse" - var/global/curselimit = 0 /obj/item/shuttle_curse/attack_self(mob/living/user) if(!iscultist(user)) @@ -502,7 +503,7 @@ user.Paralyze(100) to_chat(user, "A powerful force shoves you away from [src]!") return - if(curselimit > 1) + if(GLOB.curselimit >= 2) to_chat(user, "We have exhausted our ability to curse the shuttle.") return if(locate(/obj/singularity/narsie) in GLOB.poi_list) @@ -529,9 +530,7 @@ playsound(user.loc, 'sound/effects/glassbr1.ogg', 50, 1) qdel(src) sleep(20) - var/global/list/curses - if(!curses) - curses = list("A fuel technician just slit his own throat and begged for death.", + var/curses = list("A fuel technician just slit his own throat and begged for death.", "The shuttle's navigation programming was replaced by a file containing just two words: IT COMES.", "The shuttle's custodian was found washing the windows with their own blood.", "A shuttle engineer began screaming 'DEATH IS NOT THE END' and ripped out wires until an arc flash seared off her flesh.", @@ -541,7 +540,7 @@ var/message = pick_n_take(curses) message += " The shuttle will be delayed by three minutes." priority_announce("[message]", "System Failure", 'sound/misc/notice1.ogg') - curselimit++ + GLOB.curselimit++ /obj/item/cult_shift name = "veil shifter" diff --git a/code/modules/atmospherics/machinery/atmosmachinery.dm b/code/modules/atmospherics/machinery/atmosmachinery.dm index 6ce7abcaccdf..2b473f0f96c1 100644 --- a/code/modules/atmospherics/machinery/atmosmachinery.dm +++ b/code/modules/atmospherics/machinery/atmosmachinery.dm @@ -26,8 +26,8 @@ var/piping_layer = PIPING_LAYER_DEFAULT var/pipe_flags = NONE - var/global/list/iconsetids = list() - var/global/list/pipeimages = list() + GLOBAL_LIST_EMPTY(iconsetids) + GLOBAL_LIST_EMPTY(pipeimages) var/image/pipe_vision_img = null @@ -247,15 +247,15 @@ /obj/machinery/atmospherics/proc/getpipeimage(iconset, iconstate, direction, col=rgb(255,255,255), piping_layer=2) //Add identifiers for the iconset - if(iconsetids[iconset] == null) - iconsetids[iconset] = num2text(iconsetids.len + 1) + if(GLOB.iconsetids[iconset] == null) + GLOB.iconsetids[iconset] = num2text(GLOB.iconsetids.len + 1) //Generate a unique identifier for this image combination - var/identifier = iconsetids[iconset] + "_[iconstate]_[direction]_[col]_[piping_layer]" + var/identifier = GLOB.iconsetids[iconset] + "_[iconstate]_[direction]_[col]_[piping_layer]" - if((!(. = pipeimages[identifier]))) + if((!(. = GLOB.pipeimages[identifier]))) var/image/pipe_overlay - pipe_overlay = . = pipeimages[identifier] = image(iconset, iconstate, dir = direction) + pipe_overlay = . = GLOB.pipeimages[identifier] = image(iconset, iconstate, dir = direction) pipe_overlay.color = col PIPING_LAYER_SHIFT(pipe_overlay, piping_layer) diff --git a/code/modules/cargo/exports/seeds.dm b/code/modules/cargo/exports/seeds.dm index a879b0c4fefe..8b8751d67996 100644 --- a/code/modules/cargo/exports/seeds.dm +++ b/code/modules/cargo/exports/seeds.dm @@ -4,13 +4,13 @@ unit_name = "new plant species sample" export_types = list(/obj/item/seeds) var/needs_discovery = FALSE // Only for undiscovered species - var/global/list/discoveredPlants = list() + GLOBAL_LIST_EMPTY(discoveredPlants) /datum/export/seed/get_cost(obj/O) var/obj/item/seeds/S = O - if(!needs_discovery && (S.type in discoveredPlants)) + if(!needs_discovery && (S.type in GLOB.discoveredPlants)) return 0 - if(needs_discovery && !(S.type in discoveredPlants)) + if(needs_discovery && !(S.type in GLOB.discoveredPlants)) return 0 return ..() * S.rarity // That's right, no bonus for potency. Send a crappy sample first to "show improvement" later. @@ -18,7 +18,7 @@ . = ..() if(.) var/obj/item/seeds/S = O - discoveredPlants[S.type] = S.potency + GLOB.discoveredPlants[S.type] = S.potency /datum/export/seed/potency @@ -33,6 +33,6 @@ if(!cost) return 0 - var/potDiff = (S.potency - discoveredPlants[S.type]) + var/potDiff = (S.potency - GLOB.discoveredPlants[S.type]) return round(..() * potDiff) diff --git a/code/modules/jobs/job_types/janitor.dm b/code/modules/jobs/job_types/janitor.dm index c3238c335a1b..a1053fcdc1cb 100644 --- a/code/modules/jobs/job_types/janitor.dm +++ b/code/modules/jobs/job_types/janitor.dm @@ -8,7 +8,6 @@ spawn_positions = 1 supervisors = "the head of personnel" selection_color = "#bbe291" - var/global/janitors = 0 outfit = /datum/outfit/job/janitor diff --git a/code/modules/mining/mine_items.dm b/code/modules/mining/mine_items.dm index a1ba493d4663..baa805b0d469 100644 --- a/code/modules/mining/mine_items.dm +++ b/code/modules/mining/mine_items.dm @@ -63,6 +63,7 @@ new /obj/item/assault_pod/mining(src) +GLOBAL_LIST_EMPTY(dumb_rev_heads) /**********************Shuttle Computer**************************/ /obj/machinery/computer/shuttle/mining @@ -72,13 +73,12 @@ shuttleId = "mining" possible_destinations = "mining_home;mining_away;landing_zone_dock;mining_public" no_destination_swap = 1 - var/global/list/dumb_rev_heads = list() //ATTACK HAND IGNORING PARENT RETURN VALUE /obj/machinery/computer/shuttle/mining/attack_hand(mob/user) - if(is_station_level(user.z) && user.mind && is_head_revolutionary(user) && !(user.mind in dumb_rev_heads)) + if(is_station_level(user.z) && user.mind && is_head_revolutionary(user) && !(user.mind in GLOB.dumb_rev_heads)) to_chat(user, "You get a feeling that leaving the station might be a REALLY dumb idea...") - dumb_rev_heads += user.mind + GLOB.dumb_rev_heads += user.mind return . = ..()