From 8f445d44fa59a2991b1da84112e52c76dd9a64c7 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Fri, 5 Aug 2022 11:19:31 +1200 Subject: [PATCH] Fix stuck lathe queue (#10311) --- Content.Server/Lathe/LatheSystem.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 6ca7b5855a..3df6c82bee 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -187,12 +187,16 @@ namespace Content.Server.Lathe component.Queue.RemoveAt(0); return TryStartProducing(uid, prodComp, component); } - + if (!component.CanProduce(recipe) || !TryComp(uid, out MaterialStorageComponent? storage)) + { + component.Queue.RemoveAt(0); return false; + } prodComp ??= EnsureComp(uid); + // Do nothing if the lathe is already producing something. if (prodComp.Recipe != null) return false; @@ -203,6 +207,7 @@ namespace Content.Server.Lathe foreach (var (material, amount) in recipe.RequiredMaterials) { // This should always return true, otherwise CanProduce fucked up. + // TODO just remove materials when first queuing, to avoid queuing more items than can actually be produced. storage.RemoveMaterial(material, amount); } @@ -278,6 +283,7 @@ namespace Content.Server.Lathe { for (var i = 0; i < args.Quantity; i++) { + // TODO check required materials exist and make materials unavailable. component.Queue.Add(recipe.ID); }