Merge pull request #10300 from PsiOmegaDelta/150726-ChemicalRuntime

More #10285 fixes.
This commit is contained in:
Zuhayr
2015-07-27 11:28:09 +09:30

View File

@@ -7,14 +7,14 @@
/datum/reagents/New(var/max = 100, atom/A = null)
maximum_volume = max
my_atom = A
//I dislike having these here but map-objects are initialised before world/New() is called. >_>
if(!chemical_reagents_list)
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
var/paths = typesof(/datum/reagent) - /datum/reagent
chemical_reagents_list = list()
for(var/path in paths)
var/datum/reagent/D = new path()
var/datum/reagent/D = new path()
if(!D.name)
continue
chemical_reagents_list[D.id] = D
@@ -41,16 +41,16 @@
for(var/id in reaction_ids)
if(!chemical_reactions_list[id])
chemical_reactions_list[id] = list()
chemical_reactions_list[id] += D
break // Don't bother adding ourselves to other reagent ids, it is redundant.
/datum/reagents/Destroy()
..()
for(var/datum/reagent/R in reagent_list)
qdel(R)
reagent_list.Cut()
reagent_list = null
if(my_atom && my_atom.reagents == src)
chemical_reactions_list[id] += D
break // Don't bother adding ourselves to other reagent ids, it is redundant.
/datum/reagents/Destroy()
..()
for(var/datum/reagent/R in reagent_list)
qdel(R)
reagent_list.Cut()
reagent_list = null
if(my_atom && my_atom.reagents == src)
my_atom.reagents = null
/* Internal procs */
@@ -170,7 +170,7 @@
if(!isnull(data)) // For all we know, it could be zero or empty string and meaningful
current.mix_data(data, amount)
update_total()
if(!safety)
if(!safety)
handle_reactions()
if(my_atom)
my_atom.on_reagent_change()
@@ -184,7 +184,7 @@
R.initialize_data(data)
update_total()
if(!safety)
handle_reactions()
handle_reactions()
if(my_atom)
my_atom.on_reagent_change()
return 1
@@ -219,7 +219,7 @@
/datum/reagents/proc/has_reagent(var/id, var/amount = 0)
for(var/datum/reagent/current in reagent_list)
if(current.id == id)
if(current.volume >= amount)
if(current.volume >= amount)
return 1
else
return 0
@@ -235,12 +235,12 @@
if(current.id == id)
return current.volume
return 0
/datum/reagents/proc/get_data(var/id)
for(var/datum/reagent/current in reagent_list)
if(current.id == id)
return current.get_data()
return 0
return 0
/datum/reagents/proc/get_reagents()
. = list()
@@ -254,14 +254,14 @@
amount = min(amount, total_volume)
if(!amount)
return
return
var/part = amount / total_volume
for(var/datum/reagent/current in reagent_list)
var/amount_to_remove = current.volume * part
remove_reagent(current.id, amount_to_remove, 1)
update_total()
handle_reactions()
return amount
@@ -270,7 +270,7 @@
if(!target || !istype(target))
return
amount = min(amount, total_volume, target.get_free_space() / multiplier)
amount = max(0, min(amount, total_volume, target.get_free_space() / multiplier))
if(!amount)
return
@@ -290,9 +290,9 @@
/* Holder-to-atom and similar procs */
//The general proc for applying reagents to things. This proc assumes the reagents are being applied externally,
//The general proc for applying reagents to things. This proc assumes the reagents are being applied externally,
//not directly injected into the contents. It first calls touch, then the appropriate trans_to_*() or splash_mob().
//If for some reason touch effects are bypassed (e.g. injecting stuff directly into a reagent container or person),
//If for some reason touch effects are bypassed (e.g. injecting stuff directly into a reagent container or person),
//call the appropriate trans_to_*() proc.
/datum/reagents/proc/trans_to(var/atom/target, var/amount = 1, var/multiplier = 1, var/copy = 0)
touch(target) //First, handle mere touch effects
@@ -418,5 +418,5 @@
/* Atom reagent creation - use it all the time */
/atom/proc/create_reagents(var/max_vol)
reagents = new/datum/reagents(max_vol, src)
/atom/proc/create_reagents(var/max_vol)
reagents = new/datum/reagents(max_vol, src)