From 33faee17d150c02bd0905f76eb4bcd9d25029d99 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Sun, 25 Feb 2024 23:05:55 +0100
Subject: [PATCH] [MIRROR] Fix runtime when food processor handles items
without reagents (#26632)
* Fix runtime when food processor handles items without reagents (#81646)
## About The Pull Request
### Alternate title: "Stop the popsicle stick maximizer."
The popsicle stick maximizer in question

So when using the food processor to produce popsicle sticks from logs,
it seemed to never actually delete the log, letting you create more and
more and more and more and more and etc popsicle sticks.
This seemed to be caused by the popsicles not actually having reagents
to clear nor copy to, and thus it caused a runtime before it got the
opportunity to delete the log.
Runtime

Adding a check to make sure neither of these are null before proceeding
to use them resolves this issue.
## Why It's Good For The Game
Less runtimes, less popsicle stick maximizing.
Fixes #81644.
## Changelog
:cl:
fix: Disabled the popsicle stick maximizer. (Producing popsicle sticks
actually deletes the input logs.)
/:cl:
* Fix runtime when food processor handles items without reagents
---------
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
---
code/modules/food_and_drinks/machinery/processor.dm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/code/modules/food_and_drinks/machinery/processor.dm b/code/modules/food_and_drinks/machinery/processor.dm
index 4641da596da..27444c537ba 100644
--- a/code/modules/food_and_drinks/machinery/processor.dm
+++ b/code/modules/food_and_drinks/machinery/processor.dm
@@ -69,8 +69,9 @@
var/cached_multiplier = (recipe.food_multiplier * rating_amount)
for(var/i in 1 to cached_multiplier)
var/atom/processed_food = new recipe.output(drop_location())
- processed_food.reagents.clear_reagents()
- what.reagents.copy_to(processed_food, what.reagents.total_volume, multiplier = 1 / cached_multiplier)
+ if(processed_food.reagents && what.reagents)
+ processed_food.reagents.clear_reagents()
+ what.reagents.copy_to(processed_food, what.reagents.total_volume, multiplier = 1 / cached_multiplier)
if(cached_mats)
processed_food.set_custom_materials(cached_mats, 1 / cached_multiplier)