From d097050d1d6d7f4ec3144387083294ba7565dbd8 Mon Sep 17 00:00:00 2001 From: OrionTheFox <76465278+OrionTheFox@users.noreply.github.com> Date: Sun, 26 Feb 2023 13:20:38 -0700 Subject: [PATCH] [Manual Mirror] Adds checkgrep for improper or missing atom Initialize args (mapload) (#19539) * Adds checkgrep for improper or missing atom Initialize args (`mapload`) (#72846) ## About The Pull Request Adds a grep for atom initialize overrides which does not include mapload Regex used `^/(obj|mob|turf|area|atom)/.+/Initialize\((?!mapload).*\)` Also replaced some space indentation with some tab indentation in some other greps ![image](https://user-images.githubusercontent.com/51863163/213883049-ef6d953a-e11f-4876-9852-c09633ddc289.png) ## Why It's Good For The Game See #69107, #61759, #61623 ## Changelog No player facing changes * Missed by #8374 * Add (mapload) to a //Skyrat Edit so that it passes --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/_onclick/hud/rendering/plane_master.dm | 2 +- code/game/objects/items/food/bread.dm | 2 +- .../machinery/air_alarm/air_alarm_variants.dm | 4 ++-- code/modules/clothing/suits/bio.dm | 2 +- code/modules/clothing/suits/labcoat.dm | 11 +++++------ .../food_and_drinks/machinery/coffeemaker.dm | 2 +- code/modules/mob/living/basic/farm_animals/pig.dm | 2 +- code/modules/paperwork/filingcabinet.dm | 2 +- code/modules/paperwork/paperwork.dm | 14 +++++++------- tools/ci/check_grep.sh | 15 +++++++++++---- 10 files changed, 31 insertions(+), 25 deletions(-) diff --git a/code/_onclick/hud/rendering/plane_master.dm b/code/_onclick/hud/rendering/plane_master.dm index 9b970ac364b..3dc95408f44 100644 --- a/code/_onclick/hud/rendering/plane_master.dm +++ b/code/_onclick/hud/rendering/plane_master.dm @@ -428,7 +428,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/plane_master) plane = GAME_PLANE_UPPER_FOV_HIDDEN render_relay_planes = list(RENDER_PLANE_GAME_WORLD) -/atom/movable/screen/plane_master/game_world_upper_fov_hidden/Initialize() +/atom/movable/screen/plane_master/game_world_upper_fov_hidden/Initialize(mapload) . = ..() // Dupe of the other hidden plane add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE)) diff --git a/code/game/objects/items/food/bread.dm b/code/game/objects/items/food/bread.dm index 9808feefe93..27d32e79b73 100644 --- a/code/game/objects/items/food/bread.dm +++ b/code/game/objects/items/food/bread.dm @@ -331,7 +331,7 @@ /// whether this is in fake swordplay mode or not var/fake_swordplay = FALSE -/obj/item/food/baguette/Initialize() +/obj/item/food/baguette/Initialize(mapload) . = ..() register_context() diff --git a/code/modules/atmospherics/machinery/air_alarm/air_alarm_variants.dm b/code/modules/atmospherics/machinery/air_alarm/air_alarm_variants.dm index 4997ac2e5bf..d6230bbe204 100644 --- a/code/modules/atmospherics/machinery/air_alarm/air_alarm_variants.dm +++ b/code/modules/atmospherics/machinery/air_alarm/air_alarm_variants.dm @@ -1,14 +1,14 @@ /obj/machinery/airalarm/server -/obj/machinery/airalarm/server/Initialize() +/obj/machinery/airalarm/server/Initialize(mapload) . = ..() tlv_collection["temperature"] = new /datum/tlv/no_checks tlv_collection["pressure"] = new /datum/tlv/no_checks /obj/machinery/airalarm/kitchen_cold_room -/obj/machinery/airalarm/kitchen_cold_room/Initialize() +/obj/machinery/airalarm/kitchen_cold_room/Initialize(mapload) . = ..() tlv_collection["temperature"] = new /datum/tlv/cold_room_temperature tlv_collection["pressure"] = new /datum/tlv/cold_room_pressure diff --git a/code/modules/clothing/suits/bio.dm b/code/modules/clothing/suits/bio.dm index 60cc43a4dbe..81c7f5eb4a3 100644 --- a/code/modules/clothing/suits/bio.dm +++ b/code/modules/clothing/suits/bio.dm @@ -14,7 +14,7 @@ resistance_flags = ACID_PROOF flags_cover = HEADCOVERSEYES | HEADCOVERSMOUTH | PEPPERPROOF -/obj/item/clothing/head/bio_hood/Initialize() +/obj/item/clothing/head/bio_hood/Initialize(mapload) . = ..() AddComponent(/datum/component/clothing_fov_visor, FOV_90_DEGREES) diff --git a/code/modules/clothing/suits/labcoat.dm b/code/modules/clothing/suits/labcoat.dm index e04da705b22..e233b2ee82b 100644 --- a/code/modules/clothing/suits/labcoat.dm +++ b/code/modules/clothing/suits/labcoat.dm @@ -46,8 +46,8 @@ . = ..() allowed += list( /obj/item/melee/baton/telescopic, - /obj/item/gun/energy/cell_loaded/medigun, //SKYRAT EDIT MEDIGUNS - /obj/item/storage/medkit //SKYRAT EDIT - ADDITION + /obj/item/gun/energy/cell_loaded/medigun, //SKYRAT EDIT ADDITION - MEDIGUNS + /obj/item/storage/medkit, //SKYRAT EDIT ADDITION ) /obj/item/clothing/suit/toggle/labcoat/paramedic @@ -56,13 +56,13 @@ icon_state = "labcoat_paramedic" inhand_icon_state = null -//START SKYRAT EDIT - ADDITION -/obj/item/clothing/suit/toggle/labcoat/paramedic/Initialize() +//START SKYRAT EDIT ADDITION +/obj/item/clothing/suit/toggle/labcoat/paramedic/Initialize(mapload) . = ..() allowed += list( /obj/item/storage/medkit, ) -//END SKYRAT EDIT- ADDITION +//END SKYRAT EDIT /obj/item/clothing/suit/toggle/labcoat/mad name = "\proper The Mad's labcoat" @@ -111,4 +111,3 @@ name = "interdyne labcoat" desc = "More like an eccentric coat than a labcoat. Helps pass off bloodstains as part of the aesthetic. Comes with red shoulder pads." icon_state = "labcoat_robo" - diff --git a/code/modules/food_and_drinks/machinery/coffeemaker.dm b/code/modules/food_and_drinks/machinery/coffeemaker.dm index 59078a5d692..f9c673831a8 100644 --- a/code/modules/food_and_drinks/machinery/coffeemaker.dm +++ b/code/modules/food_and_drinks/machinery/coffeemaker.dm @@ -491,7 +491,7 @@ is_open = TRUE spawn_type = /obj/item/coffee_cartridge -/obj/item/storage/fancy/coffee_cart_rack/Initialize() +/obj/item/storage/fancy/coffee_cart_rack/Initialize(mapload) . = ..() atom_storage.max_slots = 4 atom_storage.set_holdable(list(/obj/item/coffee_cartridge)) diff --git a/code/modules/mob/living/basic/farm_animals/pig.dm b/code/modules/mob/living/basic/farm_animals/pig.dm index fee809e43eb..bf9831db0f7 100644 --- a/code/modules/mob/living/basic/farm_animals/pig.dm +++ b/code/modules/mob/living/basic/farm_animals/pig.dm @@ -29,7 +29,7 @@ blood_volume = BLOOD_VOLUME_NORMAL ai_controller = /datum/ai_controller/basic_controller/pig -/mob/living/basic/pig/Initialize() +/mob/living/basic/pig/Initialize(mapload) AddElement(/datum/element/pet_bonus, "oinks!") AddElement(/datum/element/ai_retaliate) AddElement(/datum/element/ai_flee_while_injured) diff --git a/code/modules/paperwork/filingcabinet.dm b/code/modules/paperwork/filingcabinet.dm index 3c99334a48b..52327092e03 100644 --- a/code/modules/paperwork/filingcabinet.dm +++ b/code/modules/paperwork/filingcabinet.dm @@ -189,7 +189,7 @@ GLOBAL_LIST_EMPTY(employmentCabinets) ///This var is so that its filled on crew interaction to be as accurate (including latejoins) as possible, true until first interact var/virgin = TRUE -/obj/structure/filingcabinet/employment/Initialize() +/obj/structure/filingcabinet/employment/Initialize(mapload) . = ..() GLOB.employmentCabinets += src diff --git a/code/modules/paperwork/paperwork.dm b/code/modules/paperwork/paperwork.dm index bf413e5c66d..cffa480e4a1 100644 --- a/code/modules/paperwork/paperwork.dm +++ b/code/modules/paperwork/paperwork.dm @@ -117,7 +117,7 @@ stamp_job = /datum/job/quartermaster stamp_icon = "paper_stamp-qm" -/obj/item/paperwork/cargo/Initialize() +/obj/item/paperwork/cargo/Initialize(mapload) . = ..() detailed_desc += span_info(" The papers are a mess of shipping order paperwork. There's no rhyme or reason to how these documents are sorted at all.") @@ -130,7 +130,7 @@ stamp_job = /datum/job/head_of_security stamp_icon = "paper_stamp-hos" -/obj/item/paperwork/security/Initialize() +/obj/item/paperwork/security/Initialize(mapload) . = ..() detailed_desc += span_info(" The stack of documents are related to a civil case being processed by a neighboring installation.") @@ -143,7 +143,7 @@ stamp_job = /datum/job/head_of_personnel stamp_icon = "paper_stamp-hop" -/obj/item/paperwork/service/Initialize() +/obj/item/paperwork/service/Initialize(mapload) . = ..() detailed_desc += span_info(" You begin scanning over the document. This is a standard Nanotrasen NT-435Z3 form used for requests to Central Command.") @@ -156,7 +156,7 @@ stamp_job = /datum/job/chief_medical_officer stamp_icon = "paper_stamp-cmo" -/obj/item/paperwork/medical/Initialize() +/obj/item/paperwork/medical/Initialize(mapload) . = ..() detailed_desc += span_info(" The stack of documents appear to be a medical report from a nearby station, detailing the autopsy of an unknown xenofauna.") @@ -170,7 +170,7 @@ stamp_job = /datum/job/chief_engineer stamp_icon = "paper_stamp-ce" -/obj/item/paperwork/engineering/Initialize() +/obj/item/paperwork/engineering/Initialize(mapload) . = ..() detailed_desc += span_info(" These papers are a power output report from a neighboring station. It details the power output and other engineering data regarding the station during a typical shift.") @@ -183,7 +183,7 @@ stamp_job = /datum/job/research_director stamp_icon = "paper_stamp-rd" -/obj/item/paperwork/research/Initialize() +/obj/item/paperwork/research/Initialize(mapload) . = ..() detailed_desc += span_info(" The documents detail the results of a standard ordnance test that occured on a nearby station.") @@ -196,7 +196,7 @@ stamp_job = /datum/job/captain stamp_icon = "paper_stamp-cap" -/obj/item/paperwork/captain/Initialize() +/obj/item/paperwork/captain/Initialize(mapload) . = ..() detailed_desc += span_info(" The documents are an unsigned correspondence from the captain's desk of a nearby station.") diff --git a/tools/ci/check_grep.sh b/tools/ci/check_grep.sh index f9db3a863b3..af2fd163ed9 100644 --- a/tools/ci/check_grep.sh +++ b/tools/ci/check_grep.sh @@ -117,14 +117,15 @@ section "common mistakes" part "global vars" if $grep '^/*var/' $code_files; then echo - echo -e "${RED}ERROR: Unmanaged global var use detected in code, please use the helpers.${NC}" - st=1 + echo -e "${RED}ERROR: Unmanaged global var use detected in code, please use the helpers.${NC}" + st=1 fi; + part "proc args with var/" if $grep '^/[\w/]\S+\(.*(var/|, ?var/.*).*\)' $code_files; then echo - echo -e "${RED}ERROR: Changed files contains a proc argument starting with 'var'.${NC}" - st=1 + echo -e "${RED}ERROR: Changed files contains a proc argument starting with 'var'.${NC}" + st=1 fi; part "can_perform_action argument check" @@ -228,6 +229,12 @@ if [ "$pcre2_support" -eq 1 ]; then echo -e "${RED}ERROR: Should be using datum/stock_part instead" st=1 fi; + part "improper atom initialize args" + if $grep -P '^/(obj|mob|turf|area|atom)/.+/Initialize\((?!mapload).*\)' $code_files; then + echo + echo -e "${RED}ERROR: Initialize override without 'mapload' argument.${NC}" + st=1 + fi; else echo -e "${RED}pcre2 not supported, skipping checks requiring pcre2" echo -e "if you want to run these checks install ripgrep with pcre2 support.${NC}"