From 12b1f601ed1a8efbf2d257d9a7f315f7c3db0d3e Mon Sep 17 00:00:00 2001
From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Wed, 7 Jun 2023 19:44:42 +0000
Subject: [PATCH] microwave tweaks (#17107)
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
.../Kitchen/Components/MicrowaveComponent.cs | 9 ++++++++-
.../Kitchen/EntitySystems/MicrowaveSystem.cs | 16 ++++++++++------
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs
index cb5e031004..11b2568050 100644
--- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs
+++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs
@@ -43,7 +43,14 @@ namespace Content.Server.Kitchen.Components
/// For right now, I don't think any recipe cook time should be greater than 60 seconds.
///
[DataField("currentCookTimerTime"), ViewVariables(VVAccess.ReadWrite)]
- public uint CurrentCookTimerTime = 5;
+ public uint CurrentCookTimerTime = 0;
+
+ ///
+ /// The maximum number of seconds a microwave can be set to.
+ /// This is currently only used for validation and the client does not check this.
+ ///
+ [DataField("maxCookTime"), ViewVariables(VVAccess.ReadWrite)]
+ public uint MaxCookTime = 30;
///
/// The max temperature that this microwave can heat objects to.
diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
index 86935163bb..ecf6fa58a8 100644
--- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
+++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
@@ -479,15 +479,19 @@ namespace Content.Server.Kitchen.EntitySystems
UpdateUserInterfaceState(uid, component);
}
- private void OnSelectTime(EntityUid uid, MicrowaveComponent component, MicrowaveSelectCookTimeMessage args)
+ private void OnSelectTime(EntityUid uid, MicrowaveComponent comp, MicrowaveSelectCookTimeMessage args)
{
- if (!HasContents(component) || HasComp(uid) || !(TryComp(uid, out var apc) && apc.Powered))
+ if (!HasContents(comp) || HasComp(uid) || !(TryComp(uid, out var apc) && apc.Powered))
return;
- component.CurrentCookTimeButtonIndex = args.ButtonIndex;
- component.CurrentCookTimerTime = args.NewCookTime;
- _audio.PlayPvs(component.ClickSound, uid, AudioParams.Default.WithVolume(-2));
- UpdateUserInterfaceState(uid, component);
+ // some validation to prevent trollage
+ if (args.NewCookTime % 5 != 0 || args.NewCookTime > comp.MaxCookTime)
+ return;
+
+ comp.CurrentCookTimeButtonIndex = args.ButtonIndex;
+ comp.CurrentCookTimerTime = args.NewCookTime;
+ _audio.PlayPvs(comp.ClickSound, uid, AudioParams.Default.WithVolume(-2));
+ UpdateUserInterfaceState(uid, comp);
}
#endregion
}