From 2f2bf9cebf23d021367f4c0980bda872ac82b7a6 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:37:20 +0100 Subject: [PATCH 1/5] autowiki improvements (again) --- code/__DEFINES/autowiki.dm | 7 +++ code/datums/agents/tools/decoy.dm | 2 + code/datums/datum.dm | 4 ++ .../items/explosives/grenades/marines.dm | 4 ++ code/game/world.dm | 2 +- code/modules/autowiki/pages/_page.dm | 1 + code/modules/autowiki/pages/guns.dm | 52 ++++++++++++++++++- code/modules/projectiles/ammunition.dm | 2 + .../specialist/launcher/grenade_launcher.dm | 8 ++- code/modules/projectiles/magazines/misc.dm | 4 ++ colonialmarines.dme | 1 + 11 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 code/__DEFINES/autowiki.dm diff --git a/code/__DEFINES/autowiki.dm b/code/__DEFINES/autowiki.dm new file mode 100644 index 000000000000..a6a745ca7910 --- /dev/null +++ b/code/__DEFINES/autowiki.dm @@ -0,0 +1,7 @@ +#ifdef AUTOWIKI + #define AUTOWIKI_SKIP(skip) autowiki_skip = skip + #define IS_AUTOWIKI_SKIP(datum) datum.autowiki_skip +#else + #define AUTOWIKI_SKIP(skip) + #define IS_AUTOWIKI_SKIP(datum) FALSE +#endif diff --git a/code/datums/agents/tools/decoy.dm b/code/datums/agents/tools/decoy.dm index 57c8e5130fee..57eef25a446d 100644 --- a/code/datums/agents/tools/decoy.dm +++ b/code/datums/agents/tools/decoy.dm @@ -1,4 +1,6 @@ /obj/item/explosive/grenade/decoy + AUTOWIKI_SKIP(TRUE) + name = "decoy grenade" desc = "A grenade typically used to distract the enemy. Emits a loud bang. Detonates in 5 seconds. Has 3 uses" diff --git a/code/datums/datum.dm b/code/datums/datum.dm index e926dfd022ca..2370987b4cfc 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -70,6 +70,10 @@ var/list/cached_vars #endif +#ifdef AUTOWIKI + var/autowiki_skip = FALSE +#endif + /** * Default implementation of clean-up code. * diff --git a/code/game/objects/items/explosives/grenades/marines.dm b/code/game/objects/items/explosives/grenades/marines.dm index 09c0197cda7f..fef62ab6a835 100644 --- a/code/game/objects/items/explosives/grenades/marines.dm +++ b/code/game/objects/items/explosives/grenades/marines.dm @@ -97,6 +97,8 @@ falloff_mode = EXPLOSION_FALLOFF_SHAPE_LINEAR /obj/item/explosive/grenade/high_explosive/frag/toy + AUTOWIKI_SKIP(TRUE) + name = "toy HEFA grenade" desc = "High-Explosive Fragmenting-Antipersonnel. A small, but deceptively strong fragmentation grenade that has been phasing out the M15 fragmentation grenades alongside the M40 HEDP. Capable of being loaded in the M92 Launcher, or thrown by hand. Wait, the labeling on the side indicates this is a toy, what the hell?" explosion_power = 0 @@ -865,6 +867,8 @@ return /obj/item/explosive/grenade/high_explosive/holy_hand_grenade + AUTOWIKI_SKIP(TRUE) + name = "\improper Holy Hand Grenade of Antioch" desc = "And Saint Attila raised the hand grenade up on high, saying, \"O LORD, bless this Thy hand grenade that with it Thou mayest blow Thine enemies to tiny bits, in Thy mercy.\" And the LORD did grin and the people did feast upon the lambs and sloths and carp and anchovies... And the LORD spake, saying, \"First shalt thou take out the Holy Pin, then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in My sight, shall snuff it.\"" icon_state = "grenade_antioch" diff --git a/code/game/world.dm b/code/game/world.dm index bf9534e5f926..515fabc5f705 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -114,7 +114,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt")) GLOB.log_directory += "[replacetext(time_stamp(), ":", ".")]" runtime_logging_ready = TRUE // Setting up logging now, so disabling early logging - #ifndef UNIT_TESTS + #if defined(UNIT_TESTS) || defined(AUTOWIKI) world.log = file("[GLOB.log_directory]/dd.log") #endif backfill_runtime_log() diff --git a/code/modules/autowiki/pages/_page.dm b/code/modules/autowiki/pages/_page.dm index 0e4091d0ccc5..7bd7b6dcf42c 100644 --- a/code/modules/autowiki/pages/_page.dm +++ b/code/modules/autowiki/pages/_page.dm @@ -27,6 +27,7 @@ /// something that looks like `{{ Autowiki_Circuit|name=Combiner|description=This combines }}` /// Lists, which must be array-like (no keys), will be turned into a flat list with their key and a number, /// such that list("food" = list("fruit", "candy")) -> food1=fruit|food2=candy +/// Your page should respect AUTOWIKI_SKIP, and check for this using IS_AUTOWIKI_SKIP /datum/autowiki/proc/include_template(name, parameters) var/template_text = "{{[name]" diff --git a/code/modules/autowiki/pages/guns.dm b/code/modules/autowiki/pages/guns.dm index 017c2535a5e1..4c276fb91b53 100644 --- a/code/modules/autowiki/pages/guns.dm +++ b/code/modules/autowiki/pages/guns.dm @@ -42,6 +42,9 @@ for(var/ammo_typepath in valid_mag_types) var/obj/item/ammo_magazine/generating_mag = new ammo_typepath() + if(IS_AUTOWIKI_SKIP(generating_mag)) + continue + var/ammo_filename = SANITIZE_FILENAME(escape_value(format_text(generating_mag.name))) if(!fexists("data/autowiki_files/[ammo_filename].png")) @@ -61,6 +64,8 @@ )) generating_gun.current_mag = generating_mag + generating_gun.ammo = current_ammo + generating_gun.in_chamber = null var/list/gun_ammo_data = generating_gun.ui_data() var/list/armor_data = list() @@ -68,18 +73,63 @@ var/iterator = 1 for(var/header in gun_ammo_data["damage_armor_profile_headers"]) var/damage = gun_ammo_data["damage_armor_profile_marine"][iterator] + if(!damage) + break armor_data["armor-[header]"] = damage iterator++ var/list/damage = list("ammo_name" = escape_value(generating_mag.name)) - damage += armor_data + if(length(armor_data)) + damage += armor_data damage_table += include_template("Autowiki/DamageVersusArmorRow", damage) qdel(generating_mag) + var/grenades = "" + if(istype(generating_gun, /obj/item/weapon/gun/launcher/grenade)) + var/obj/item/weapon/gun/launcher/grenade/generating_launcher = generating_gun + + var/list/permitted_grenades = list() + for(var/obj/item/explosive/grenade/type as anything in generating_launcher.valid_munitions) + permitted_grenades |= subtypesof(type) + + var/list/unique_grenades = list() + var/list/unique_grenade_names = list() + for(var/obj/item/explosive/grenade/grenade_type as anything in permitted_grenades) + if(initial(grenade_type.name) in unique_grenade_names) + continue + unique_grenade_names += initial(grenade_type.name) + unique_grenades += grenade_type + + var/list/denied_grenades = list() + for(var/type in generating_launcher.disallowed_grenade_types) + denied_grenades |= typesof(type) + + var/valid_grenades = unique_grenades.Copy() - denied_grenades.Copy() + + for(var/grenade_path in valid_grenades) + var/obj/item/explosive/grenade/generating_grenade = new grenade_path() + + if(IS_AUTOWIKI_SKIP(generating_grenade)) + continue + + var/grenade_filename = SANITIZE_FILENAME(escape_value(format_text(generating_grenade.name))) + + if(!fexists("data/autowiki_files/[grenade_filename].png")) + upload_icon(getFlatIcon(generating_grenade, no_anim = TRUE), grenade_filename) + + grenades += include_template("Autowiki/Grenade", list( + "icon" = escape_value(grenade_filename), + "name" = escape_value(generating_grenade.name), + "description" = escape_value(generating_grenade.desc) + )) + + qdel(generating_grenade) + gun_data["ammo_types"] = ammo gun_data["damage_table"] = damage_table + gun_data["grenades"] = grenades var/list/attachments_by_slot = list() for(var/obj/item/attachable/attachment_typepath as anything in generating_gun.attachable_allowed) diff --git a/code/modules/projectiles/ammunition.dm b/code/modules/projectiles/ammunition.dm index 5db904869973..e032d3ebbe55 100644 --- a/code/modules/projectiles/ammunition.dm +++ b/code/modules/projectiles/ammunition.dm @@ -233,6 +233,8 @@ bullets/shells. ~N */ /obj/item/ammo_magazine/handful + AUTOWIKI_SKIP(TRUE) + name = "generic handful" desc = "A handful of rounds to reload on the go." icon = 'icons/obj/items/weapons/guns/handful.dmi' diff --git a/code/modules/projectiles/guns/specialist/launcher/grenade_launcher.dm b/code/modules/projectiles/guns/specialist/launcher/grenade_launcher.dm index 06ac5428bfc6..40a145e1f77c 100644 --- a/code/modules/projectiles/guns/specialist/launcher/grenade_launcher.dm +++ b/code/modules/projectiles/guns/specialist/launcher/grenade_launcher.dm @@ -25,7 +25,13 @@ ///Does it launch its grenades in a low arc or a high? Do they strike people in their path, or fly beyond? var/is_lobbing = FALSE ///Verboten munitions. This is a blacklist. Anything in this list isn't loadable. - var/disallowed_grenade_types = list(/obj/item/explosive/grenade/spawnergrenade, /obj/item/explosive/grenade/alien, /obj/item/explosive/grenade/incendiary/molotov, /obj/item/explosive/grenade/flashbang) + var/disallowed_grenade_types = list(/obj/item/explosive/grenade/spawnergrenade, + /obj/item/explosive/grenade/alien, + /obj/item/explosive/grenade/nerve_gas, + /obj/item/explosive/grenade/incendiary/bursting_pipe, + /obj/item/explosive/grenade/xeno_acid_grenade, + /obj/item/explosive/grenade/incendiary/molotov, + /obj/item/explosive/grenade/flashbang) ///What is this weapon permitted to fire? This is a whitelist. Anything in this list can be fired. Anything. var/valid_munitions = list(/obj/item/explosive/grenade) diff --git a/code/modules/projectiles/magazines/misc.dm b/code/modules/projectiles/magazines/misc.dm index 87568c953211..251b863535e7 100644 --- a/code/modules/projectiles/magazines/misc.dm +++ b/code/modules/projectiles/magazines/misc.dm @@ -47,12 +47,16 @@ //rocket launchers /obj/item/ammo_magazine/rifle/grenadespawner + AUTOWIKI_SKIP(TRUE) + name = "\improper GRENADE SPAWNER AMMO" desc = "OH GOD OH FUCK" default_ammo = /datum/ammo/grenade_container/rifle ammo_band_color = AMMO_BAND_COLOR_LIGHT_EXPLOSIVE /obj/item/ammo_magazine/rifle/huggerspawner + AUTOWIKI_SKIP(TRUE) + name = "\improper HUGGER SPAWNER AMMO" desc = "OH GOD OH FUCK" default_ammo = /datum/ammo/hugger_container diff --git a/colonialmarines.dme b/colonialmarines.dme index d4c8bf6ce6e3..86ec739fa71f 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -37,6 +37,7 @@ #include "code\__DEFINES\atmospherics.dm" #include "code\__DEFINES\autofire.dm" #include "code\__DEFINES\autolathe.dm" +#include "code\__DEFINES\autowiki.dm" #include "code\__DEFINES\blood.dm" #include "code\__DEFINES\bsql.config.dm" #include "code\__DEFINES\bullet_traits.dm" From 522760ad6ac5f1089c00dc004e9864fdd4cc9617 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:54:05 +0100 Subject: [PATCH 2/5] i love linters --- code/__DEFINES/autowiki.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/__DEFINES/autowiki.dm b/code/__DEFINES/autowiki.dm index a6a745ca7910..b3dceefdff34 100644 --- a/code/__DEFINES/autowiki.dm +++ b/code/__DEFINES/autowiki.dm @@ -1,6 +1,9 @@ #ifdef AUTOWIKI #define AUTOWIKI_SKIP(skip) autowiki_skip = skip #define IS_AUTOWIKI_SKIP(datum) datum.autowiki_skip +#elif SPACEMAN_DMM + #define AUTOWIKI_SKIP(skip) + #define IS_AUTOWIKI_SKIP(datum) pick(FALSE) // this is to bypass the static control flow linter #else #define AUTOWIKI_SKIP(skip) #define IS_AUTOWIKI_SKIP(datum) FALSE From 24b4dc847027f24d3dcf9b96a282039866ca7242 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:54:32 +0100 Subject: [PATCH 3/5] does it better --- code/__DEFINES/autowiki.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/autowiki.dm b/code/__DEFINES/autowiki.dm index b3dceefdff34..caa98dc60f38 100644 --- a/code/__DEFINES/autowiki.dm +++ b/code/__DEFINES/autowiki.dm @@ -3,7 +3,7 @@ #define IS_AUTOWIKI_SKIP(datum) datum.autowiki_skip #elif SPACEMAN_DMM #define AUTOWIKI_SKIP(skip) - #define IS_AUTOWIKI_SKIP(datum) pick(FALSE) // this is to bypass the static control flow linter + #define IS_AUTOWIKI_SKIP(datum) UNLINT(FALSE) // this is to bypass the static control flow linter #else #define AUTOWIKI_SKIP(skip) #define IS_AUTOWIKI_SKIP(datum) FALSE From bead1a4021ee9495ddb55c93ca9a8c87c3726a9e Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:55:02 +0100 Subject: [PATCH 4/5] does it even better --- code/__DEFINES/autowiki.dm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/__DEFINES/autowiki.dm b/code/__DEFINES/autowiki.dm index caa98dc60f38..4edf385bcc82 100644 --- a/code/__DEFINES/autowiki.dm +++ b/code/__DEFINES/autowiki.dm @@ -1,10 +1,7 @@ #ifdef AUTOWIKI #define AUTOWIKI_SKIP(skip) autowiki_skip = skip #define IS_AUTOWIKI_SKIP(datum) datum.autowiki_skip -#elif SPACEMAN_DMM - #define AUTOWIKI_SKIP(skip) - #define IS_AUTOWIKI_SKIP(datum) UNLINT(FALSE) // this is to bypass the static control flow linter #else #define AUTOWIKI_SKIP(skip) - #define IS_AUTOWIKI_SKIP(datum) FALSE + #define IS_AUTOWIKI_SKIP(datum) UNLINT(FALSE) #endif From 010daa83a07503b1bbbbdb5305c42780a146769d Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Mon, 5 Aug 2024 08:28:12 +0100 Subject: [PATCH 5/5] Update code/game/world.dm --- code/game/world.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/world.dm b/code/game/world.dm index 515fabc5f705..101066c21cdb 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -114,7 +114,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt")) GLOB.log_directory += "[replacetext(time_stamp(), ":", ".")]" runtime_logging_ready = TRUE // Setting up logging now, so disabling early logging - #if defined(UNIT_TESTS) || defined(AUTOWIKI) + #if !defined(UNIT_TESTS) && !defined(AUTOWIKI) world.log = file("[GLOB.log_directory]/dd.log") #endif backfill_runtime_log()