Fix issue with plumbing reaction chambers getting stuck filling

This commit is contained in:
Belaya
2025-07-29 15:32:20 -05:00
parent ad7c3f2be6
commit 0caef258d6
3 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -66,9 +66,14 @@
var/datum/component/plumbing/supplier = A
if(supplier.can_give(amount, reagent, net))
valid_suppliers += supplier
// Need to ask for each in turn very carefully, making sure we get the total volume. This is to avoid a division that would always round down and become 0
var/targetVolume = reagents.total_volume = amount
var/suppliersLeft = valid_suppliers.len
for(var/A in valid_suppliers)
var/datum/component/plumbing/give = A
give.transfer_to(src, amount / valid_suppliers.len, reagent, net)
var/currentRequest = (targetVolume - reagents.total_volume) / suppliersLeft
give.transfer_to(src, currentRequest, reagent, net)
suppliersLeft--
///returns TRUE when they can give the specified amount and reagent. called by process request
/datum/component/plumbing/proc/can_give(amount, reagent, datum/ductnet/net)
if(amount <= 0)
@@ -23,7 +23,7 @@
var/datum/reagent/RD = A
if(RT == RD.type)
has_reagent = TRUE
if(RD.volume < RC.required_reagents[RT])
if(RD.volume + CHEMICAL_QUANTISATION_LEVEL < RC.required_reagents[RT]) // Allow the chamber to exit filling mode when it feels it has enough even if short by a tiny fraction
process_request(min(RC.required_reagents[RT] - RD.volume, MACHINE_REAGENT_TRANSFER) , RT, dir)
return
if(!has_reagent)