From 159ca02294eb862b65dba7c9949980dec2567f8d Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Sat, 6 Feb 2016 03:00:20 -0600 Subject: [PATCH] Find and replace strikes again --- code/controllers/subsystem/air.dm | 1 - .../atmospherics/gasmixtures/gas_mixture.dm | 29 ++++++++++--------- .../atmospherics/gasmixtures/gas_types.dm | 16 +++++----- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm index 6e9becdeb87..0cef0b59919 100644 --- a/code/controllers/subsystem/air.dm +++ b/code/controllers/subsystem/air.dm @@ -24,7 +24,6 @@ var/datum/subsystem/air/SSair var/list/networks = list() var/list/obj/machinery/atmos_machinery = list() - //Special functions lists var/list/turf/simulated/active_super_conductivity = list() var/list/turf/simulated/high_pressure_delta = list() diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 1f957352891..dea173e1ac0 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -11,19 +11,22 @@ var/list/meta_gas_info = meta_gas_list() //see ATMOSPHERICS/gas_types.dm var/list/gaslist_cache = null /proc/gaslist(id) + var/list/cached_gas + if(!gaslist_cache) gaslist_cache = new(meta_gas_info.len) + if(!gaslist_cache[id]) if(!meta_gas_info[id]) CRASH("Gas [id] does not exist!") + cached_gas = new(3) + gaslist_cache[id] = cached_gas - var/list/gas = new(3) - gas[MOLES] = 0 - gas[ARCHIVE] = 0 - gas[meta_gas_info] = meta_gas_info[id] - gaslist_cache[id] = gas - - var/list/cached_gas = gaslist_cache[id] + cached_gas[MOLES] = 0 + cached_gas[ARCHIVE] = 0 + cached_gas[GAS_META] = meta_gas_info[id] + else + cached_gas = gaslist_cache[id] return cached_gas.Copy() /datum/gas_mixture @@ -34,12 +37,12 @@ var/list/gaslist_cache = null var/last_share var/tmp/fuel_burnt -/datum/gas_mixture/New(vol = CELL_VOLUME) +/datum/gas_mixture/New(volume = CELL_VOLUME) ..() gases = new temperature = 0 temperature_archived = 0 - volume = 0 + src.volume = volume last_share = 0 fuel_burnt = 0 @@ -99,9 +102,9 @@ var/list/gaslist_cache = null . += cached_gases[id][MOLES] /datum/gas_mixture/proc/return_pressure() - . = 0 - if(volume > 0) - . = total_moles() * R_IDEAL_GAS_EQUATION * temperature / volume + if(volume > 0) // to prevent division by zero + return total_moles() * R_IDEAL_GAS_EQUATION * temperature / volume + return 0 /datum/gas_mixture/proc/return_temperature() return temperature @@ -379,9 +382,9 @@ var/list/gaslist_cache = null /datum/gas_mixture/copy_from_turf(turf/model) var/list/cached_gases = gases - assert_gases(arglist(hardcoded_gases)) temperature = model.temperature + assert_gases(arglist(hardcoded_gases)) cached_gases["o2"][MOLES] = model.oxygen cached_gases["n2"][MOLES] = model.nitrogen cached_gases["plasma"][MOLES] = model.toxins diff --git a/code/modules/atmospherics/gasmixtures/gas_types.dm b/code/modules/atmospherics/gasmixtures/gas_types.dm index 850dd0f483b..5a3871292d6 100644 --- a/code/modules/atmospherics/gasmixtures/gas_types.dm +++ b/code/modules/atmospherics/gasmixtures/gas_types.dm @@ -1,17 +1,17 @@ var/list/hardcoded_gases = list("o2","n2","co2","plasma") //the main four gases, which were at one time hardcoded /proc/meta_gas_list() - . = list() + . = new /list for(var/gas_path in subtypesof(/datum/gas)) var/list/gas_info = new(4) - var/datum/gas/g = gas_path + var/datum/gas/gas = gas_path - gas_info[META_GAS_SPECIFIC_HEAT] = initial(g.specific_heat) - gas_info[META_GAS_NAME] = initial(g.name) - gas_info[META_GAS_MOLES_VISIBLE] = initial(g.moles_visible) - if(gas_info[META_GAS_MOLES_VISIBLE] != null) - gas_info[META_GAS_OVERLAY] = new /obj/effect/overlay/gas(initial(g.gas_overlay)) - .[initial(g.id)] = gas_info + gas_info[META_GAS_SPECIFIC_HEAT] = initial(gas.specific_heat) + gas_info[META_GAS_NAME] = initial(gas.name) + gas_info[META_GAS_MOLES_VISIBLE] = initial(gas.moles_visible) + if(initial(gas.moles_visible) != null) + gas_info[META_GAS_OVERLAY] = new /obj/effect/overlay/gas(initial(gas.gas_overlay)) + .[initial(gas.id)] = gas_info /*||||||||||||||/----------\||||||||||||||*\ ||||||||||||||||[GAS DATUMS]||||||||||||||||