From 948e9e42c3cea859906213187167bd39e17c31c4 Mon Sep 17 00:00:00 2001 From: vontell Date: Wed, 9 Oct 2024 15:54:09 -0400 Subject: [PATCH 1/4] Allow absolute paths to be used in segment and sequence loading --- .../StateRecorder/BotSegments/Models/BotSequence.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs index 1d3db1be..9a78cea1 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/BotSegments/Models/BotSequence.cs @@ -46,11 +46,6 @@ public static (string, string, BotSequence) LoadSequenceJsonFromPath(string path return (null, null, null); } - if (path.StartsWith('/') || path.StartsWith('\\')) - { - throw new Exception("Invalid path. Path must be relative, not absolute in order to support editor vs production runtimes interchangeably."); - } - path = path.Replace('\\', '/'); (string, string, string) sequenceJson; @@ -144,10 +139,6 @@ private static object ParseSegmentOrListJson(string resourcePath, string fileDat */ public static (string, string, object) LoadBotSegmentOrBotSegmentListFromPath(string path) { - if (path.StartsWith('/') || path.StartsWith('\\')) - { - throw new Exception("Invalid path. Path must be relative, not absolute, in order to support editor vs production runtimes interchangeably."); - } path = path.Replace('\\', '/'); From a038e257abb8153255aaaf8bf846d087edab1d85 Mon Sep 17 00:00:00 2001 From: vontell Date: Wed, 16 Oct 2024 12:49:54 -0400 Subject: [PATCH 2/4] Catch absolute paths when using the CLI args --- .../Runtime/Scripts/RGHeadlessSequenceRunner.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs index efef3919..7529f4cf 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.IO; using System.Linq; using System.Reflection; using RegressionGames.StateRecorder.BotSegments; @@ -124,6 +125,18 @@ internal static string ParsePathArgument() { if (i + 1 < argsLength) { + + var path = args[i + 1]; + + // Sequences that are run via -rgsequencepath must be relative, as we only allows sequences + // included in the Resource or persistent path directories. + if (Path.IsPathRooted(path)) + { + RGDebug.LogError($"{SequencePathArgument} command line argument requires a relative path"); + Application.Quit(Rc_SequencePathMissing); + return null; + } + return args[i + 1]; } // else From 864f982b5ad4992cbfdef82e7adc7ffbc68cfdb3 Mon Sep 17 00:00:00 2001 From: vontell Date: Wed, 16 Oct 2024 12:52:16 -0400 Subject: [PATCH 3/4] Oops --- .../Runtime/Scripts/RGHeadlessSequenceRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs index 7529f4cf..acfde04f 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs @@ -137,7 +137,7 @@ internal static string ParsePathArgument() return null; } - return args[i + 1]; + return path; } // else RGDebug.LogError($"{SequencePathArgument} command line argument requires a path value to be passed after it"); From 63e2416d633b174659d08390aea4a9efba15287c Mon Sep 17 00:00:00 2001 From: vontell Date: Wed, 16 Oct 2024 13:01:19 -0400 Subject: [PATCH 4/4] Introduce new quit error code --- .../Runtime/Scripts/RGHeadlessSequenceRunner.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs index acfde04f..1b1e7301 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/RGHeadlessSequenceRunner.cs @@ -24,6 +24,7 @@ public static class RGHeadlessSequenceRunner internal static readonly int Rc_SequenceTimeoutNeedsPath = 5; internal static readonly int Rc_SequenceTimeoutMissing = 6; internal static readonly int Rc_SequenceTimeoutNotInt = 7; + internal static readonly int Rc_SequencePathNotRelative = 8; internal static readonly string SequencePathArgument = "-rgsequencepath"; internal static readonly string SequenceTimeoutArgument = "-rgsequencetimeout"; @@ -133,7 +134,7 @@ internal static string ParsePathArgument() if (Path.IsPathRooted(path)) { RGDebug.LogError($"{SequencePathArgument} command line argument requires a relative path"); - Application.Quit(Rc_SequencePathMissing); + Application.Quit(Rc_SequencePathNotRelative); return null; }