From eb5403ce1cca021aa015bb80092ce3ee8274a9ed Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 6 Dec 2025 05:01:04 +0000 Subject: [PATCH 1/2] Fix special characters in map seeds breaking file/folder creation Use Path.GetInvalidFileNameChars() instead of Path.GetInvalidPathChars() when escaping the seed string for subdirectory names. GetInvalidPathChars only returns control characters, missing characters like : < > " * ? | which are invalid in file/folder names on Windows. This fixes maps with seeds like "MountainPeople:3<3!!!!. failing to create output directories. --- Source/MapComponents/MapComponent_RenderManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MapComponents/MapComponent_RenderManager.cs b/Source/MapComponents/MapComponent_RenderManager.cs index a288ac9..0fa4684 100644 --- a/Source/MapComponents/MapComponent_RenderManager.cs +++ b/Source/MapComponents/MapComponent_RenderManager.cs @@ -809,7 +809,7 @@ private string CreateFilePath(FileNamePattern fileNamePattern, bool addTmpSubdir var path = PrModSettings.ExportPath; if (PrModSettings.CreateSubdirs) { - var subDir = Escape(Find.World.info.seedString, Path.GetInvalidPathChars()); + var subDir = Escape(Find.World.info.seedString, Path.GetInvalidFileNameChars()); path = Path.Combine(path, subDir); if (!manuallyTriggered & GameComponentProgressManager.TileFoldersEnabled) // start using tile folders when a new game is created to avoid confusion in existing games { From 737391b02c1f817a71d4c4578c490f2720102d1b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 6 Dec 2025 05:05:14 +0000 Subject: [PATCH 2/2] Escape seed and map name in image filename functions Apply Path.GetInvalidFileNameChars() escaping directly in CreateImageNameDateTime() and CreateImageNameNumbered() for the seed string and map name. This ensures special characters are stripped at the source, making the escaping explicit and consistent with the subdirectory escaping. --- Source/MapComponents/MapComponent_RenderManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/MapComponents/MapComponent_RenderManager.cs b/Source/MapComponents/MapComponent_RenderManager.cs index 0fa4684..55aec8f 100644 --- a/Source/MapComponents/MapComponent_RenderManager.cs +++ b/Source/MapComponents/MapComponent_RenderManager.cs @@ -876,15 +876,17 @@ private string CreateImageNameDateTime() var quadrum = MoreGenDate.QuadrumInteger(tick, longitude); var day = GenDate.DayOfQuadrum(tick, longitude) + 1; var hour = GenDate.HourInteger(tick, longitude); - string mapName = PrModSettings.UseMapNameInstead ? map.ToString() : map.Tile.ToString(); - return "rimworld-" + Find.World.info.seedString + "-" + year + "-" + quadrum + "-" + + string seedName = Escape(Find.World.info.seedString, Path.GetInvalidFileNameChars()); + string mapName = Escape(PrModSettings.UseMapNameInstead ? map.ToString() : map.Tile.ToString(), Path.GetInvalidFileNameChars()); + return "rimworld-" + seedName + "-" + year + "-" + quadrum + "-" + ((day < 10) ? "0" : "") + day + "-" + ((hour < 10) ? "0" : "") + hour + "-" + mapName; } private string CreateImageNameNumbered() { - string mapName = PrModSettings.UseMapNameInstead ? map.ToString() : map.Tile.ToString(); - return "rimworld-" + Find.World.info.seedString + "-" + + string seedName = Escape(Find.World.info.seedString, Path.GetInvalidFileNameChars()); + string mapName = Escape(PrModSettings.UseMapNameInstead ? map.ToString() : map.Tile.ToString(), Path.GetInvalidFileNameChars()); + return "rimworld-" + seedName + "-" + lastRenderedCounter.ToString("000000") + "-" + mapName; } }