From 30506e18952c578a101bbce46fc81f3e75eecbc5 Mon Sep 17 00:00:00 2001 From: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:51:51 +0530 Subject: [PATCH] Fixes photocopier charging for failed tasks (#94655) ## About The Pull Request - Fixes #94234 ## Changelog :cl: fix: photocopier does not charge for failed tasks /:cl: --- code/modules/paperwork/photocopier.dm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/code/modules/paperwork/photocopier.dm b/code/modules/paperwork/photocopier.dm index 418b297bcea..31262237d9e 100644 --- a/code/modules/paperwork/photocopier.dm +++ b/code/modules/paperwork/photocopier.dm @@ -423,9 +423,6 @@ GLOBAL_LIST_INIT(paper_blanks, init_paper_blanks()) if(get_paper_count(created_paper) < paper_use * copies_amount) copies_amount = FLOOR(get_paper_count(created_paper) / paper_use, 1) error_message = span_warning("An error message flashes across \the [src]'s screen: \"Not enough paper to perform [copies_amount >= 1 ? "full " : ""]operation.\"") - if(!(obj_flags & EMAGGED) && (copies_amount > 0) && (attempt_charge(src, user, (copies_amount - 1) * usage_cost) & COMPONENT_OBJ_CANCEL_CHARGE)) - copies_amount = 0 - error_message = span_warning("An error message flashes across \the [src]'s screen: \"Failed to charge bank account. Aborting.\"") copies_left = copies_amount @@ -438,6 +435,7 @@ GLOBAL_LIST_INIT(paper_blanks, init_paper_blanks()) to_chat(user, error_message) // if you managed to cancel the copy operation, tough luck. you aren't getting your money back. + var/list/copies_made = list() for(var/i in 1 to copies_amount) if(machine_stat & (BROKEN|NOPOWER)) break @@ -454,10 +452,22 @@ GLOBAL_LIST_INIT(paper_blanks, init_paper_blanks()) sleep(time_to_print) // reveal our copied item - copied_obj.forceMove(drop_location()) - give_pixel_offset(copied_obj) + if(!QDELETED(copied_obj)) + copied_obj.forceMove(drop_location()) + give_pixel_offset(copied_obj) + copies_made += copied_obj copies_left-- + if(copies_made.len) + if(!(obj_flags & EMAGGED) && attempt_charge(src, user, (copies_made.len - 1) * usage_cost) & COMPONENT_OBJ_CANCEL_CHARGE) + visible_message( + span_warning("An error message flashes across \the [src]'s screen."), \ + span_warning("Failed to charge bank account. Scrapping copies.") \ + ) + QDEL_LIST(copies_made) + else + to_chat(user, span_warning("Failed to copy object!")) + copies_left = 0 reset_busy()