From b66b656601dd6d27bdcb9fb7b1b94c84ab69b5a8 Mon Sep 17 00:00:00 2001 From: harryob <55142896+harryob@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:31:52 +0100 Subject: [PATCH] make it work --- code/__HELPERS/cmp.dm | 2 +- code/_compile_options.dm | 2 ++ code/modules/autowiki/pages/guns.dm | 18 ++++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index 5b7fc2c03ead..e27add2c9601 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -57,7 +57,7 @@ GLOBAL_LIST_INIT(cmp_field, "name") /proc/cmp_typepaths_asc(A, B) return sorttext("[B]","[A]") -/proc/cmp_typepaths_name_asc(A, B) +/proc/cmp_typepaths_name_asc(atom/A, atom/B) return sorttext(initial(A.name), initial(B.name)) /// Compares mobs based on their timeofdeath value in ascending order diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 20aa2081318c..6d3791085cff 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -41,3 +41,5 @@ // #define TESTING // #define REFERENCE_TRACKING // #define GC_FAILURE_HARD_LOOKUP + +#define AUTOWIKI diff --git a/code/modules/autowiki/pages/guns.dm b/code/modules/autowiki/pages/guns.dm index 8a8ec08bed49..2de4d5c23598 100644 --- a/code/modules/autowiki/pages/guns.dm +++ b/code/modules/autowiki/pages/guns.dm @@ -4,7 +4,7 @@ /datum/autowiki/guns/generate_multiple() - var/output = "" + var/output = list() var/list/gun_to_ammo = list() @@ -14,18 +14,19 @@ LAZYADD(gun_to_ammo[initial(typepath.gun_type)], typepath) var/list/unique_typepaths = list() - for(var/typepath in sort_list(subtypesof(/obj/item/weapon/gun), GLOBAL_PROC_REF(cmp_typepaths_name_asc))) + for(var/obj/item/weapon/gun/typepath as anything in sort_list(subtypesof(/obj/item/weapon/gun), GLOBAL_PROC_REF(cmp_typepaths_name_asc))) if(initial(typepath.name) in unique_typepaths) continue - unique_typepaths[typepath.name] = typepath + unique_typepaths[initial(typepath.name)] = typepath + + for(var/name in unique_typepaths) + var/typepath = unique_typepaths[name] - for(var/typepath in unique_typepaths) var/obj/item/weapon/gun/generating_gun = typepath if(isnull(initial(generating_gun.icon_state))) continue // Skip guns with no icon_state (e.g. base types) - - generating_gun = new typepath() + generating_gun = new typepath var/filename = SANITIZE_FILENAME(escape_value(format_text(generating_gun.name))) var/list/gun_data = generating_gun.ui_data() @@ -116,8 +117,9 @@ upload_icon(generated_icon, filename) gun_data["icon"] = filename - var/page_name = replacetext(strip_improper(generating_gun.name), " ", "_") - output += list(title = "Autowiki/Gun/[page_name]", text = include_template("Autowiki/Gun", gun_data)) + var/page_name = SANITIZE_FILENAME(replacetext(strip_improper(generating_gun.name), " ", "_")) + var/to_add = list(title = "Autowiki/Content/Gun/[page_name]", text = include_template("Autowiki/Gun", gun_data)) + output += list(to_add) qdel(generating_gun)