From 1f1f58a1820d41294f260461fb046140c9d382a6 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 7 Feb 2023 22:25:34 +0100 Subject: [PATCH] Revert .yaml file extension changes. This reverts commit d8d2993d7f3dea3d92e529fa642c88754b4d30d2. This reverts commit a7d79eed2d4b338a4d7f5f22bc1903c2c7ccfa70. This reverts commit 58c79b2c7bfe2cc54ceca3dcf81cf0754fcf7998. See https://github.com/space-wizards/space-station-14/pull/13971 --- .editorconfig | 2 +- RELEASE-NOTES.md | 3 ++- .../Prototypes/ClientPrototypeManager.cs | 23 +++++-------------- .../Passes/AssetPassNormalizeText.cs | 1 - .../Prototypes/PrototypeManager.YamlLoad.cs | 4 ++-- Robust.Shared/Utility/ResourcePath.cs | 6 ----- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/.editorconfig b/.editorconfig index 716ad5e998b..9f2e43c8690 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ indent_size = 4 trim_trailing_whitespace = true charset = utf-8 -[*.{csproj,xml,yml,yaml,dll.config,targets,props}] +[*.{csproj,xml,yml,dll.config,targets,props}] indent_size = 2 [*.gdsl] diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 06f2f4687a0..05e52859c30 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -35,7 +35,7 @@ END TEMPLATE--> ### Breaking changes -*None yet* +* Undid `*.yaml` prototype loading change from previous version. ### New features @@ -78,6 +78,7 @@ END TEMPLATE--> * UI content scale is now listed in the F3 coordinates panel. * SDL2 backend is now wired up to update key names dynamically on keyboard mode change. * The prototype reload event is no longer wrapped under #if !FULL_RELEASE. +* The engine now loads `*.yaml` files (previously loading only `*.yml`) for prototypes. ### Internal diff --git a/Robust.Client/Prototypes/ClientPrototypeManager.cs b/Robust.Client/Prototypes/ClientPrototypeManager.cs index 9473403754d..74fd04bdd3b 100644 --- a/Robust.Client/Prototypes/ClientPrototypeManager.cs +++ b/Robust.Client/Prototypes/ClientPrototypeManager.cs @@ -8,6 +8,7 @@ using Robust.Client.Timing; using Robust.Shared; using Robust.Shared.Configuration; +using Robust.Shared.ContentPack; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Network; @@ -86,20 +87,13 @@ private void WatchResources() foreach (var path in Resources.GetContentRoots().Select(r => r.ToString()) .Where(r => Directory.Exists(r + "/Prototypes")).Select(p => p + "/Prototypes")) { - var watcherYml = new FileSystemWatcher(path, "*.yml") + var watcher = new FileSystemWatcher(path, "*.yml") { IncludeSubdirectories = true, NotifyFilter = NotifyFilters.LastWrite }; - //filesystemwatcher doesnt support multiple filters, so we gotta do this. its a debug feature, so i dont think its that critical - var watcherYaml = new FileSystemWatcher(path, "*.yaml") - { - IncludeSubdirectories = true, - NotifyFilter = NotifyFilters.LastWrite - }; - - void OnWatcherOnChanged(object _, FileSystemEventArgs args) + watcher.Changed += (_, args) => { switch (args.ChangeType) { @@ -129,17 +123,12 @@ void OnWatcherOnChanged(object _, FileSystemEventArgs args) _reloadQueue.Add(relative); } }); - } - - watcherYml.Changed += OnWatcherOnChanged; - watcherYaml.Changed += OnWatcherOnChanged; + }; try { - watcherYml.EnableRaisingEvents = true; - watcherYaml.EnableRaisingEvents = true; - _watchers.Add(watcherYml); - _watchers.Add(watcherYaml); + watcher.EnableRaisingEvents = true; + _watchers.Add(watcher); } catch (IOException ex) { diff --git a/Robust.Packaging/AssetProcessing/Passes/AssetPassNormalizeText.cs b/Robust.Packaging/AssetProcessing/Passes/AssetPassNormalizeText.cs index 31a7dd7f756..d923e7b29df 100644 --- a/Robust.Packaging/AssetProcessing/Passes/AssetPassNormalizeText.cs +++ b/Robust.Packaging/AssetProcessing/Passes/AssetPassNormalizeText.cs @@ -12,7 +12,6 @@ public sealed class AssetPassNormalizeText : AssetPass "txt", "json", "yml", - "yaml", "html", "css", "js", diff --git a/Robust.Shared/Prototypes/PrototypeManager.YamlLoad.cs b/Robust.Shared/Prototypes/PrototypeManager.YamlLoad.cs index 6a5138f8633..32ff5a7ca01 100644 --- a/Robust.Shared/Prototypes/PrototypeManager.YamlLoad.cs +++ b/Robust.Shared/Prototypes/PrototypeManager.YamlLoad.cs @@ -24,7 +24,7 @@ public void LoadDirectory(ResourcePath path, bool overwrite = false, { _hasEverBeenReloaded = true; var streams = Resources.ContentFindFiles(path) - .Where(ResourcePath.IsYamlResourceFile) + .Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".")) .ToArray(); // Shuffle to avoid input data patterns causing uneven thread workloads. @@ -84,7 +84,7 @@ public void LoadDirectory(ResourcePath path, bool overwrite = false, public Dictionary> ValidateDirectory(ResourcePath path) { var streams = Resources.ContentFindFiles(path).ToList().AsParallel() - .Where(ResourcePath.IsYamlResourceFile); + .Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".")); var dict = new Dictionary>(); foreach (var resourcePath in streams) diff --git a/Robust.Shared/Utility/ResourcePath.cs b/Robust.Shared/Utility/ResourcePath.cs index c5dc707dd67..eba9941b7c8 100644 --- a/Robust.Shared/Utility/ResourcePath.cs +++ b/Robust.Shared/Utility/ResourcePath.cs @@ -717,11 +717,5 @@ private static void ValidateSeparate(string separator) throw new ArgumentException("Separator may not be . or .."); } } - - public static bool IsYamlResourceFile(ResourcePath filePath) - { - return filePath.Extension is "yml" or "yaml" && - !filePath.Filename.StartsWith(".", StringComparison.Ordinal); - } } }