From d2f106976470efb34551d2ccf35934a60df84f36 Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 4 Feb 2020 14:32:39 -0800 Subject: [PATCH] Ported atmos reaction priority fix --- .../atmospherics/gasmixtures/gas_mixture.dm | 5 +++-- .../atmospherics/gasmixtures/reactions.dm | 22 +++++-------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 12efa01a38..5ff8586c34 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -337,8 +337,9 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list()) if(!length(cached_gases)) return var/list/reactions = list() - for(var/I in cached_gases) - reactions += SSair.gas_reactions[I] + for(var/datum/gas_reaction/G in SSair.gas_reactions) + if(cached_gases[G.major_gas]) + reactions += G if(!length(reactions)) return reaction_results = new diff --git a/code/modules/atmospherics/gasmixtures/reactions.dm b/code/modules/atmospherics/gasmixtures/reactions.dm index f9c831a65a..ebe894138d 100644 --- a/code/modules/atmospherics/gasmixtures/reactions.dm +++ b/code/modules/atmospherics/gasmixtures/reactions.dm @@ -2,8 +2,6 @@ /proc/init_gas_reactions() . = list() - for(var/type in subtypesof(/datum/gas)) - .[type] = list() for(var/r in subtypesof(/datum/gas_reaction)) var/datum/gas_reaction/reaction = r @@ -16,27 +14,19 @@ var/datum/gas/req_gas = req if (!reaction_key || initial(reaction_key.rarity) > initial(req_gas.rarity)) reaction_key = req_gas - .[reaction_key] += list(reaction) - sortTim(., /proc/cmp_gas_reactions, TRUE) + reaction.major_gas = reaction_key + . += reaction + sortTim(., /proc/cmp_gas_reaction) -/proc/cmp_gas_reactions(list/datum/gas_reaction/a, list/datum/gas_reaction/b) // compares lists of reactions by the maximum priority contained within the list - if (!length(a) || !length(b)) - return length(b) - length(a) - var/maxa - var/maxb - for (var/datum/gas_reaction/R in a) - if (R.priority > maxa) - maxa = R.priority - for (var/datum/gas_reaction/R in b) - if (R.priority > maxb) - maxb = R.priority - return maxb - maxa +/proc/cmp_gas_reaction(datum/gas_reaction/a, datum/gas_reaction/b) // compares lists of reactions by the maximum priority contained within the list + return b.priority - a.priority /datum/gas_reaction //regarding the requirements lists: the minimum or maximum requirements must be non-zero. //when in doubt, use MINIMUM_MOLE_COUNT. var/list/min_requirements var/list/max_requirements + var/major_gas //the highest rarity gas used in the reaction. var/exclude = FALSE //do it this way to allow for addition/removal of reactions midmatch in the future var/priority = 100 //lower numbers are checked/react later than higher numbers. if two reactions have the same priority they may happen in either order var/name = "reaction"