From ca19d4d7b0e785a9a6354ef758ffcc9610a84ca2 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 15 Jun 2024 18:35:32 +0200 Subject: [PATCH] [MIRROR] Fixes station trait based event weight modifiers being added for events that aren't valid on the current map (#28159) * Fixes station trait based event weight modifiers being added for events that aren't valid on the current map (#83897) ``` [2024-06-12 02:12:22.135] RUNTIME: runtime error: Cannot execute /datum/round_event_control/met... (/datum/round_event_control/meteor_wave/dust_storm).valid for map(). - proc name: New (/datum/station_trait/random_event_weight_modifier/New) - source file: code/datums/station_traits/negative_traits.dm,296 - usr: null - src: Dust Stormfront (/datum/station_trait/random_event_weight_modifier/dust_storms) - call stack: - Dust Stormfront (/datum/station_trait/random_event_weight_modifier/dust_storms): New() - Station (/datum/controller/subsystem/processing/station): setup trait(/datum/station_trait/random_ev... (/datum/station_trait/random_event_weight_modifier/dust_storms)) - Station (/datum/controller/subsystem/processing/station): SetupTraits() - Station (/datum/controller/subsystem/processing/station): Initialize() - Master (/datum/controller/master): init subsystem(Station (/datum/controller/subsystem/processing/station)) - Master (/datum/controller/master): Initialize(10, 0, 1) - ``` :cl: ShizCalev fix: Fixed a bug with station traits being added to modify weights for events that couldn't actually occur on the current map! /:cl: * Fixes station trait based event weight modifiers being added for events that aren't valid on the current map --------- Co-authored-by: Afevis --- code/controllers/subsystem/processing/station.dm | 11 +++++++++-- code/datums/station_traits/negative_traits.dm | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/processing/station.dm b/code/controllers/subsystem/processing/station.dm index 5ea6cc5463d..064f1446bf9 100644 --- a/code/controllers/subsystem/processing/station.dm +++ b/code/controllers/subsystem/processing/station.dm @@ -95,8 +95,7 @@ PROCESSING_SUBSYSTEM_DEF(station) return - for(var/i in subtypesof(/datum/station_trait)) - var/datum/station_trait/trait_typepath = i + for(var/datum/station_trait/trait_typepath as anything in subtypesof(/datum/station_trait)) // If forced, (probably debugging), just set it up now, keep it out of the pool. if(initial(trait_typepath.force)) @@ -115,6 +114,14 @@ PROCESSING_SUBSYSTEM_DEF(station) if(!(initial(trait_typepath.trait_flags) & STATION_TRAIT_REQUIRES_AI) && !CONFIG_GET(flag/allow_ai)) //can't have AI traits without AI continue + if(ispath(trait_typepath, /datum/station_trait/random_event_weight_modifier)) //Don't add event modifiers for events that can't occur on our map. + var/datum/station_trait/random_event_weight_modifier/random_trait_typepath = trait_typepath + var/datum/round_event_control/event_to_check = initial(random_trait_typepath.event_control_path) + if(event_to_check) + event_to_check = new event_to_check() + if(!event_to_check.valid_for_map()) + continue + selectable_traits_by_types[initial(trait_typepath.trait_type)][trait_typepath] = initial(trait_typepath.weight) var/positive_trait_budget = text2num(pick_weight(CONFIG_GET(keyed_list/positive_station_traits))) diff --git a/code/datums/station_traits/negative_traits.dm b/code/datums/station_traits/negative_traits.dm index 89c34565e57..4d3c30feb93 100644 --- a/code/datums/station_traits/negative_traits.dm +++ b/code/datums/station_traits/negative_traits.dm @@ -285,7 +285,7 @@ weight = 0 /// The path to the round_event_control that we modify. - var/event_control_path + var/datum/round_event_control/event_control_path /// Multiplier applied to the weight of the event. var/weight_multiplier = 1 /// Flat modifier added to the amount of max occurances the random event can have.