Cigarette Fixes (#5597)

There was an issue with one of the travis checks that caused reagents with incorrect specific heat values to sneak into the game and cause havok. This fixes that.

Fixes #5594
Fixes #5593
This commit is contained in:
BurgerLUA
2018-11-12 09:39:28 +02:00
committed by Erki
parent 6d778d035c
commit c35ce60a50
11 changed files with 96 additions and 24 deletions
+17 -10
View File
@@ -11,24 +11,29 @@ var/datum/controller/subsystem/chemistry/SSchemistry
var/list/chemical_reagents
var/tmp/list/processing_holders = list()
/datum/controller/subsystem/chemistry/proc/has_valid_specific_heat(var/datum/reagent/R) //Used for unit tests
/datum/controller/subsystem/chemistry/proc/has_valid_specific_heat(var/datum/reagent/R) //Used for unit tests. Same as check_specific_heat but returns a boolean instead.
if(R.specific_heat > 0)
return TRUE
return TRUE
if(chemical_reagents[R.id].specific_heat > 0) //Don't think this will happen but you never know.
return TRUE
var/datum/chemical_reaction/recipe = find_recipe_by_result(R.id)
if(recipe)
for(var/chem in recipe.required_reagents)
if(!has_valid_specific_heat(chemical_reagents[chem]))
return FALSE
log_ss("chemistry", "ERROR: [recipe.type] has an improper recipe!")
return R.fallback_specific_heat > 0
if(R.fallback_specific_heat)
return TRUE
return FALSE
else
if(R.fallback_specific_heat > 0)
return TRUE
else
log_ss("chemistry", "ERROR: [R.type] does not have a valid specific heat ([R.specific_heat]) or a valid fallback specific heat ([R.fallback_specific_heat]) assigned!")
return FALSE
/datum/controller/subsystem/chemistry/proc/check_specific_heat(var/datum/reagent/R)
@@ -44,15 +49,17 @@ var/datum/controller/subsystem/chemistry/SSchemistry
var/result_amount = recipe.result_amount
for(var/chem in recipe.required_reagents)
var/chem_specific_heat = check_specific_heat(chemical_reagents[chem])
if(!chem_specific_heat)
if(chem_specific_heat <= 0)
log_ss("chemistry", "ERROR: [R.type] does not have a specific heat value set, and there is no associated recipe for it! Please fix this by giving it a specific_heat value!")
final_heat = 0
break
final_heat += chem_specific_heat * (recipe.required_reagents[chem]/result_amount)
if(final_heat > 0)
chemical_reagents[R.id].specific_heat = final_heat
return final_heat
if(R.fallback_specific_heat)
if(R.fallback_specific_heat > 0)
chemical_reagents[R.id].specific_heat = R.fallback_specific_heat
return R.fallback_specific_heat