mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-23 08:31:57 +00:00
Metabolism Precision Runtime Errors (#5701)
Because of precision issues with floating point values, metabolism would sometimes runtime and cause performance issues. This PR fixes this. Fixes #5698 as well.
This commit is contained in:
@@ -98,7 +98,6 @@
|
||||
//returns 1 if the holder should continue reactiong, 0 otherwise.
|
||||
/datum/reagents/proc/process_reactions()
|
||||
if(!my_atom || !my_atom.loc || my_atom.flags & NOREACT)
|
||||
equalize_temperature()
|
||||
return 0
|
||||
|
||||
var/reaction_occured
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
/datum/reagent/proc/initialize_data(var/newdata) // Called when the reagent is created.
|
||||
if(!isnull(newdata))
|
||||
data = newdata
|
||||
metabolism = round(metabolism,0.001)
|
||||
|
||||
/datum/reagent/proc/remove_self(var/amount) // Shortcut
|
||||
if (!holder)
|
||||
|
||||
@@ -66,9 +66,8 @@
|
||||
|
||||
var/total_thermal_energy = 0
|
||||
var/total_heat_capacity = 0
|
||||
|
||||
var/was_changed = FALSE
|
||||
|
||||
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
total_thermal_energy += R.get_thermal_energy()
|
||||
total_heat_capacity += R.get_heat_capacity()
|
||||
@@ -76,11 +75,10 @@
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
var/old_thermal_energy = R.get_thermal_energy()
|
||||
var/new_thermal_energy = total_thermal_energy * (R.get_heat_capacity()/total_heat_capacity)
|
||||
|
||||
if(old_thermal_energy != new_thermal_energy)
|
||||
if(round(old_thermal_energy,1) != round(new_thermal_energy,1))
|
||||
R.set_thermal_energy( new_thermal_energy )
|
||||
was_changed = TRUE
|
||||
|
||||
|
||||
return was_changed
|
||||
|
||||
/datum/reagents/proc/add_thermal_energy(var/thermal_energy_to_add)
|
||||
|
||||
Reference in New Issue
Block a user