From 287db94b72e649a8f3193f28a63925deda70f36b Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 5 Feb 2020 23:44:08 -0700 Subject: [PATCH] Merge pull request #10900 from Putnam3145/port-atmos-fix Ports atmos priority reaction mix from TG --- .../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 ea5ff2cb..da1323c8 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -338,8 +338,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 b8905a36..e83bc0e5 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"