From f922a3dda5b2b05d7cafd6d637e22bdaec874a85 Mon Sep 17 00:00:00 2001 From: Fermi <> Date: Sat, 12 Oct 2019 07:18:39 +0100 Subject: [PATCH 1/6] Fast!! --- code/modules/reagents/chemistry/holder.dm | 6 ++++-- code/modules/reagents/chemistry/recipes/medicine.dm | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 957a2a1a52..7f363575ca 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -503,6 +503,8 @@ for(var/B in cached_required_reagents) // multiplier = min(multiplier, round((get_reagent_amount(B) / cached_required_reagents[B]), CHEMICAL_QUANTISATION_LEVEL)) + if(multiplier < 1) + return 0 for(var/B in cached_required_reagents) remove_reagent(B, (multiplier * cached_required_reagents[B]), safety = 1, ignore_pH = TRUE) @@ -545,11 +547,11 @@ var/list/cached_required_reagents = C.required_reagents//update reagents list var/list/cached_results = C.results//resultant chemical list - var/multiplier = INFINITY + var/multiplier = 0 for(var/B in cached_required_reagents) // multiplier = min(multiplier, round((get_reagent_amount(B) / cached_required_reagents[B]), 0.0001)) - if (multiplier == 0)//clarity + if (multiplier <= 0)//clarity fermiEnd() return diff --git a/code/modules/reagents/chemistry/recipes/medicine.dm b/code/modules/reagents/chemistry/recipes/medicine.dm index d49e7a2d3d..15959d96ec 100644 --- a/code/modules/reagents/chemistry/recipes/medicine.dm +++ b/code/modules/reagents/chemistry/recipes/medicine.dm @@ -101,7 +101,8 @@ if(St.purity < 1) St.volume *= St.purity St.purity = 1 - N.volume -= 0.002 + var/amount = CLAMP(0.002, 0, N.volume) + N.volume -= amount St.data["grown_volume"] = St.data["grown_volume"] + added_volume /datum/chemical_reaction/styptic_powder From 2e0398569620dadebcb28d4ddca30440e2d93387 Mon Sep 17 00:00:00 2001 From: Fermi <> Date: Sat, 12 Oct 2019 07:55:19 +0100 Subject: [PATCH 2/6] aaaa --- code/modules/reagents/chemistry/holder.dm | 14 +++++--------- .../modules/reagents/chemistry/recipes/fermi.dm | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 7f363575ca..356ae3c645 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -128,14 +128,12 @@ /datum/reagents/proc/remove_all(amount = 1) var/list/cached_reagents = reagent_list - if((total_volume - amount) <= 0)//Because this can result in 0, I don't want it to crash. - pH = 7 if(total_volume > 0) var/part = amount / total_volume for(var/reagent in cached_reagents) var/datum/reagent/R = reagent remove_reagent(R.id, R.volume * part, ignore_pH = TRUE) - + pH = REAGENT_NORMAL_PH update_total() handle_reactions() return amount @@ -502,9 +500,8 @@ return 0 for(var/B in cached_required_reagents) // - multiplier = min(multiplier, round((get_reagent_amount(B) / cached_required_reagents[B]), CHEMICAL_QUANTISATION_LEVEL)) - if(multiplier < 1) - return 0 + multiplier = min(multiplier, round(get_reagent_amount(B) / cached_required_reagents[B])) + for(var/B in cached_required_reagents) remove_reagent(B, (multiplier * cached_required_reagents[B]), safety = 1, ignore_pH = TRUE) @@ -771,7 +768,7 @@ del_reagent(R.id) else total_volume += R.volume - if(!reagent_list || !total_volume) + if(!total_volume) pH = REAGENT_NORMAL_PH return 0 @@ -871,7 +868,6 @@ var/new_total = cached_total + amount var/cached_temp = chem_temp var/list/cached_reagents = reagent_list - var/cached_pH = pH @@ -965,7 +961,7 @@ var/datum/reagent/R = A if (R.id == reagent) if((total_volume - amount) <= 0)//Because this can result in 0, I don't want it to crash. - pH = 7 + pH = REAGENT_NORMAL_PH //In practice this is really confusing and players feel like it randomly melts their beakers, but I'm not sure how else to handle it. We'll see how it goes and I can remove this if it confuses people. else if (!ignore_pH) //if (((pH > R.pH) && (pH <= 7)) || ((pH < R.pH) && (pH >= 7))) diff --git a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm index de56b4be68..47f71d1acf 100644 --- a/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm +++ b/modular_citadel/code/modules/reagents/chemistry/recipes/fermi.dm @@ -28,7 +28,7 @@ return //Called when temperature is above a certain threshold, or if purity is too low. -/datum/chemical_reaction/proc/FermiExplode(datum/reagents, var/atom/my_atom, volume, temp, pH, Exploding = FALSE) +/datum/chemical_reaction/proc/FermiExplode(datum/reagents/R0, var/atom/my_atom, volume, temp, pH, Exploding = FALSE) if (Exploding == TRUE) return @@ -76,7 +76,7 @@ var/datum/effect_system/smoke_spread/chem/s = new() R.my_atom = my_atom //Give the gas a fingerprint - for (var/datum/reagent/reagent in my_atom.reagents.reagent_list) //make gas for reagents, has to be done this way, otherwise it never stops Exploding + for (var/datum/reagent/reagent in R0.reagent_list) //make gas for reagents, has to be done this way, otherwise it never stops Exploding R.add_reagent(reagent.id, reagent.volume/3) //Seems fine? I think I fixed the infinite explosion bug. if (reagent.purity < 0.6) From 2a6b84151e9195b9ad9659c21a197532a1caf248 Mon Sep 17 00:00:00 2001 From: Fermi <> Date: Sat, 12 Oct 2019 07:59:44 +0100 Subject: [PATCH 3/6] Removed something I didn't mean to --- code/modules/reagents/chemistry/holder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 356ae3c645..e680ba58e0 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -768,7 +768,7 @@ del_reagent(R.id) else total_volume += R.volume - if(!total_volume) + if(!reagent_list || !total_volume) pH = REAGENT_NORMAL_PH return 0 From d94f796ffbc6a07d1e3fbfab9ca18dc0dc790b3c Mon Sep 17 00:00:00 2001 From: Thalpy <48600475+ThalpySci@users.noreply.github.com> Date: Sat, 12 Oct 2019 12:42:51 +0100 Subject: [PATCH 4/6] aaaa --- code/modules/reagents/chemistry/holder.dm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index e680ba58e0..cd6f86c9a6 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -544,18 +544,18 @@ var/list/cached_required_reagents = C.required_reagents//update reagents list var/list/cached_results = C.results//resultant chemical list - var/multiplier = 0 - + var/multiplier = INFINITY for(var/B in cached_required_reagents) // multiplier = min(multiplier, round((get_reagent_amount(B) / cached_required_reagents[B]), 0.0001)) if (multiplier <= 0)//clarity fermiEnd() return - for(var/P in C.required_catalysts) - if(!has_reagent(P)) - fermiEnd() - return + if(C.required_catalysts) + for(var/P in C.required_catalysts) + if(!has_reagent(P)) + fermiEnd() + return if (!fermiIsReacting) CRASH("Fermi has refused to stop reacting even though we asked her nicely.") From 82446681bfc850dd12e275c13fae6213091d58ea Mon Sep 17 00:00:00 2001 From: Thalpy <48600475+ThalpySci@users.noreply.github.com> Date: Sat, 12 Oct 2019 13:22:05 +0100 Subject: [PATCH 5/6] Everything is pain --- code/modules/reagents/chemistry/holder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index cd6f86c9a6..01555bf5ed 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -402,7 +402,7 @@ for(var/B in cached_required_reagents) - if(!has_reagent(B, cached_required_reagents[B]*CHEMICAL_QUANTISATION_LEVEL))//Allows vols at less than 1 to react. + if(!has_reagent(B, cached_required_reagents[B]))//Allows vols at less than 1 to react. break total_matching_reagents++ for(var/B in cached_required_catalysts) From 3f16c287a94bbcab8574d7e128f03c32fa6bb2f4 Mon Sep 17 00:00:00 2001 From: Thalpy <48600475+ThalpySci@users.noreply.github.com> Date: Sat, 12 Oct 2019 13:40:40 +0100 Subject: [PATCH 6/6] I'm big silly --- code/modules/reagents/chemistry/holder.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 01555bf5ed..fb064b6146 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -500,7 +500,7 @@ return 0 for(var/B in cached_required_reagents) // - multiplier = min(multiplier, round(get_reagent_amount(B) / cached_required_reagents[B])) + multiplier = min(multiplier, round((get_reagent_amount(B) / cached_required_reagents[B]), CHEMICAL_QUANTISATION_LEVEL)) for(var/B in cached_required_reagents)