From 8a412d798f34b6e75ec1c6c823b604c67f435f36 Mon Sep 17 00:00:00 2001 From: DeityLink Date: Thu, 9 Jan 2025 16:28:46 +0100 Subject: [PATCH] babyproofing (#37369) --- code/modules/admin/topic.dm | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 4adecb0ae63f..1de877d78dcd 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -652,15 +652,30 @@ if(!map.climate) return var/datum/climate/C = map.climate - var/nu = input(usr, "Select New Weather", "Adjust Weather", C.current_weather.type) as null|anything in typesof(/datum/weather) - if(!nu || nu == C.current_weather.type) + + var/list/valid_climates = list() + + for(var/subtype in subtypesof(/datum/weather)) + var/datum/weather/instance = subtype + var/weather_name = initial(instance.name) + if (weather_name != "weather") + valid_climates[weather_name] = subtype + + if (valid_climates.len <= 0) + alert(usr, "There are somehow no weather subtypes!", "Error", "Wtf?") + return + + var/nu = input(usr, "Select New Weather", "Adjust Weather", null) as null|anything in valid_climates + if(!nu) + to_chat(usr, "Weather change canceled.") return - if(!ispath(nu)) + if(nu == C.current_weather.name) + to_chat(usr, "That's already the current weather you dummy.") return - C.change_weather(nu) + C.change_weather(valid_climates[nu]) C.forecast() - log_admin("[key_name(usr)] adjusted weather type.") - message_admins("[key_name(usr)] adjusted weather type.", 1) + log_admin("[key_name(usr)] changed the weather to [nu].") + message_admins("[key_name(usr)] changed the weather to [nu].", 1) climate_panel() else if(href_list["delay_round_end"])