diff --git a/code/datums/components/plumbing/reaction_chamber.dm b/code/datums/components/plumbing/reaction_chamber.dm index 42b7abeb2e8..e76fb69ec1f 100644 --- a/code/datums/components/plumbing/reaction_chamber.dm +++ b/code/datums/components/plumbing/reaction_chamber.dm @@ -30,7 +30,7 @@ //compute how much more is needed and round it diff = chamber.required_reagents[required_reagent] - present_amount - if(diff >= CHEMICAL_QUANTISATION_LEVEL * 10) //should be safe even after rounding + if(diff >= 0.01) process_request(min(diff, MACHINE_REAGENT_TRANSFER), required_reagent, dir) return diff --git a/code/modules/plumbing/plumbers/bottler.dm b/code/modules/plumbing/plumbers/bottler.dm index d0a33aebf4a..fe56282746f 100644 --- a/code/modules/plumbing/plumbers/bottler.dm +++ b/code/modules/plumbing/plumbers/bottler.dm @@ -79,7 +79,7 @@ return PROCESS_KILL ///see if machine has enough to fill, is anchored down and has any inputspot objects to pick from - if(reagents.total_volume + (CHEMICAL_QUANTISATION_LEVEL * 10) >= wanted_amount && anchored && length(inputspot.contents)) + if(reagents.total_volume + 0.01 >= wanted_amount && anchored && length(inputspot.contents)) use_power(active_power_usage * seconds_per_tick) var/obj/AM = pick(inputspot.contents)///pick a reagent_container that could be used if((is_reagent_container(AM) && !istype(AM, /obj/item/reagent_containers/hypospray/medipen)) || istype(AM, /obj/item/ammo_casing/shotgun/dart)) diff --git a/code/modules/plumbing/plumbers/pill_press.dm b/code/modules/plumbing/plumbers/pill_press.dm index 6218151cc04..5061723acc7 100644 --- a/code/modules/plumbing/plumbers/pill_press.dm +++ b/code/modules/plumbing/plumbers/pill_press.dm @@ -84,7 +84,7 @@ return //shift & check to account for floating point inaccuracies - if(reagents.total_volume + (CHEMICAL_QUANTISATION_LEVEL * 10) >= current_volume) + if(reagents.total_volume + 0.01 >= current_volume) var/obj/item/reagent_containers/container = locate(packaging_type) container = new container(src) var/suffix diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index b210bde63a2..0d0b62a6686 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -112,7 +112,7 @@ if(!ignore_splitting && (flags & REAGENT_HOLDER_ALIVE)) //Stomachs are a pain - they will constantly call on_mob_add unless we split on addition to stomachs, but we also want to make sure we don't double split var/adjusted_vol = FLOOR(process_mob_reagent_purity(glob_reagent, amount, added_purity), CHEMICAL_QUANTISATION_LEVEL) if(adjusted_vol <= 0) //If we're inverse or FALSE cancel addition - return TRUE + return amount /* We return true here because of #63301 The only cases where this will be false or 0 if its an inverse chem, an impure chem of 0 purity (highly unlikely if even possible), or if glob_reagent is null (which shouldn't happen at all as there's a check for that a few lines up), In the first two cases, we would want to return TRUE so trans_to and other similar methods actually delete the corresponding chemical from the original reagent holder. @@ -158,7 +158,7 @@ SEND_SIGNAL(src, COMSIG_REAGENTS_ADD_REAGENT, iter_reagent, amount, reagtemp, data, no_react) if(!no_react && !is_reacting) //To reduce the amount of calculations for a reaction the reaction list is only updated on a reagents addition. handle_reactions() - return TRUE + return amount //otherwise make a new one var/datum/reagent/new_reagent = new reagent_type(data) @@ -187,7 +187,7 @@ SEND_SIGNAL(src, COMSIG_REAGENTS_NEW_REAGENT, new_reagent, amount, reagtemp, data, no_react) if(!no_react) handle_reactions() - return TRUE + return amount /** * Like add_reagent but you can enter a list. @@ -227,7 +227,7 @@ var/list/cached_reagents = reagent_list for(var/datum/reagent/cached_reagent as anything in cached_reagents) if(cached_reagent.type == reagent_type) - cached_reagent.volume = FLOOR(max(cached_reagent.volume - amount, 0), CHEMICAL_QUANTISATION_LEVEL) + cached_reagent.volume = FLOOR(max(cached_reagent.volume - amount, 0), CHEMICAL_QUANTISATION_LEVEL) update_total() if(!safety)//So it does not handle reactions when it need not to handle_reactions() @@ -491,7 +491,7 @@ * Arguments: * * obj/target - Target to attempt transfer to * * amount - amount of reagent volume to transfer - * * multiplier - multiplies amount of each reagent by this number + * * multiplier - multiplies each reagent amount by this number well byond their available volume before transfering. used to create reagents from thin air if you ever need to * * preserve_data - if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred. * * no_react - passed through to [/datum/reagents/proc/add_reagent] * * mob/transferred_by - used for logging @@ -546,7 +546,7 @@ var/cached_amount = amount // Prevents small amount problems, as well as zero and below zero amounts. - amount = FLOOR(min(amount * multiplier, total_volume, target_holder.maximum_volume - target_holder.total_volume), CHEMICAL_QUANTISATION_LEVEL) + amount = FLOOR(min(amount, total_volume, target_holder.maximum_volume - target_holder.total_volume), CHEMICAL_QUANTISATION_LEVEL) if(amount <= 0) return FALSE @@ -561,7 +561,8 @@ var/part = amount / total_volume var/transfer_amount - var/transfered_amount = 0 + var/transfered_amount + var/total_transfered_amount = 0 //first add reagents to target for(var/datum/reagent/reagent as anything in cached_reagents) @@ -571,13 +572,14 @@ trans_data = copy_data(reagent) if(reagent.intercept_reagents_transfer(target_holder, cached_amount)) continue - transfer_amount = FLOOR(reagent.volume * part, CHEMICAL_QUANTISATION_LEVEL) - if(!target_holder.add_reagent(reagent.type, transfer_amount, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT)) //we only handle reaction after every reagent has been transferred. + transfer_amount = reagent.volume * part + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount * multiplier, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) //we only handle reaction after every reagent has been transferred. + if(!transfered_amount) continue if(methods) r_to_send += reagent reagents_to_remove += list(list("R" = reagent, "T" = transfer_amount)) - transfered_amount += transfer_amount + total_transfered_amount += transfered_amount //expose target to reagent changes target_holder.expose_multiple(r_to_send, isorgan(target_atom) ? target : target_atom, methods, part, show_message) @@ -600,7 +602,7 @@ if(!no_react) target_holder.handle_reactions() src.handle_reactions() - return transfered_amount + return FLOOR(total_transfered_amount, CHEMICAL_QUANTISATION_LEVEL) /** * Transfer a specific reagent id to the target object @@ -665,7 +667,7 @@ * Arguments * * * [target][obj] - the target to transfer reagents to - * * multiplier - the multiplier applied on all reagent volumes before transfering + * * multiplier - multiplies each reagent amount by this number well byond their available volume before transfering. used to create reagents from thin air if you ever need to * * preserve_data - preserve user data of all reagents after transfering * * no_react - if TRUE will not handle reactions */ @@ -692,7 +694,7 @@ target_holder = target.reagents // Prevents small amount problems, as well as zero and below zero amounts. - amount = FLOOR(min(amount * multiplier, total_volume, target_holder.maximum_volume - target_holder.total_volume), CHEMICAL_QUANTISATION_LEVEL) + amount = FLOOR(min(amount, total_volume, target_holder.maximum_volume - target_holder.total_volume), CHEMICAL_QUANTISATION_LEVEL) if(amount <= 0) return @@ -700,15 +702,17 @@ var/part = amount / total_volume var/transfer_amount var/transfered_amount = 0 + var/total_transfered_amount = 0 var/trans_data = null for(var/datum/reagent/reagent as anything in cached_reagents) - transfer_amount = FLOOR(reagent.volume * part, CHEMICAL_QUANTISATION_LEVEL) + transfer_amount = reagent.volume * part * multiplier if(preserve_data) trans_data = reagent.data - if(!target_holder.add_reagent(reagent.type, transfer_amount, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT)) + transfered_amount = target_holder.add_reagent(reagent.type, transfer_amount, trans_data, chem_temp, reagent.purity, reagent.ph, no_react = TRUE, ignore_splitting = reagent.chemical_flags & REAGENT_DONOTSPLIT) + if(!transfered_amount) continue - transfered_amount += transfer_amount + total_transfered_amount += transfered_amount if(!no_react) // pass over previous ongoing reactions before handle_reactions is called @@ -717,7 +721,7 @@ target_holder.update_total() target_holder.handle_reactions() - return transfered_amount + return FLOOR(total_transfered_amount, CHEMICAL_QUANTISATION_LEVEL) /** * Multiplies the reagents inside this holder by a specific amount @@ -1410,7 +1414,7 @@ /// Is this holder full or not /datum/reagents/proc/holder_full() - return total_volume >= maximum_volume + return total_volume + 0.01 >= maximum_volume /** * Get the amount of this reagent or the sum of all its subtypes if specified