diff --git a/Content.Server/Weather/WeatherSystem.cs b/Content.Server/Weather/WeatherSystem.cs index c3af49944d..dbee62a72f 100644 --- a/Content.Server/Weather/WeatherSystem.cs +++ b/Content.Server/Weather/WeatherSystem.cs @@ -33,58 +33,50 @@ public sealed class WeatherSystem : SharedWeatherSystem { if (args.Length < 2) { - shell.WriteError($"A"); + shell.WriteError(Loc.GetString("cmd-weather-error-no-arguments")); return; } if (!int.TryParse(args[0], out var mapInt)) - { return; - } var mapId = new MapId(mapInt); if (!MapManager.MapExists(mapId)) - { return; - } - TimeSpan? endTime = null; + if (!_mapSystem.TryGetMap(mapId, out var mapUid)) + return; - if (args.Length == 3) + var weatherComp = EnsureComp(mapUid.Value); + + //Weather Proto parsing + WeatherPrototype? weather = null; + if (!args[1].Equals("null")) { - if (int.TryParse(args[2], out var durationInt)) + if (!ProtoMan.TryIndex(args[1], out weather)) { - var curTime = Timing.CurTime; - var maxTime = TimeSpan.MaxValue; - - // If it's already running then just fade out with how much time we're into the weather. - if (_mapSystem.TryGetMap(mapId, out var mapUid) && - TryComp(mapUid, out var weatherComp) && - weatherComp.Weather.TryGetValue(args[1], out var existing)) - { - maxTime = curTime - existing.StartTime; - } - - endTime = curTime + TimeSpan.FromSeconds(durationInt); - - if (endTime > maxTime) - endTime = maxTime; + shell.WriteError(Loc.GetString("cmd-weather-error-unknown-proto")); + return; } } - if (args[1].Equals("null")) + //Time parsing + TimeSpan? endTime = null; + if (args.Length == 3) { - SetWeather(mapId, null, endTime); - } - else if (ProtoMan.TryIndex(args[1], out var weatherProto)) - { - SetWeather(mapId, weatherProto, endTime); - } - else - { - shell.WriteError($"Unable to parse weather prototype"); + var curTime = Timing.CurTime; + if (int.TryParse(args[2], out var durationInt)) + { + endTime = curTime + TimeSpan.FromSeconds(durationInt); + } + else + { + shell.WriteError(Loc.GetString("cmd-weather-error-wrong-time")); + } } + + SetWeather(mapId, weather, endTime); } private CompletionResult WeatherCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Shared/Weather/SharedWeatherSystem.cs b/Content.Shared/Weather/SharedWeatherSystem.cs index 6141902124..acd4305538 100644 --- a/Content.Shared/Weather/SharedWeatherSystem.cs +++ b/Content.Shared/Weather/SharedWeatherSystem.cs @@ -156,11 +156,14 @@ public abstract class SharedWeatherSystem : EntitySystem foreach (var (eProto, weather) in weatherComp.Weather) { + // if we turn off the weather, we don't want endTime = null + if (proto == null) + endTime ??= Timing.CurTime + WeatherComponent.ShutdownTime; + // Reset cooldown if it's an existing one. - if (proto == null || eProto == proto.ID) + if (proto is not null && eProto == proto.ID) { weather.EndTime = endTime; - if (weather.State == WeatherState.Ending) weather.State = WeatherState.Running; diff --git a/Resources/Locale/en-US/weather/weather.ftl b/Resources/Locale/en-US/weather/weather.ftl index de5dbd8890..67e6eec35f 100644 --- a/Resources/Locale/en-US/weather/weather.ftl +++ b/Resources/Locale/en-US/weather/weather.ftl @@ -1,3 +1,7 @@ cmd-weather-desc = Sets the weather for the current map. cmd-weather-help = weather cmd-weather-hint = Weather prototype + +cmd-weather-error-no-arguments = Not enough arguments! +cmd-weather-error-unknown-proto = Unknown Weather prototype! +cmd-weather-error-wrong-time = Time is in the wrong format! \ No newline at end of file