Skip to content

Commit

Permalink
Prevent deep mod exploration in folders starting with @
Browse files Browse the repository at this point in the history
  • Loading branch information
RhenaudTheLukark committed Sep 11, 2024
1 parent cf49e22 commit 8d36b73
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Assets/Scripts/PregamePlaceholder/SelectOMatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ private void Start() {
// If that's the case, we want to open the encounter list so the user only has to click once to re enter
if (StaticInits.ENCOUNTER != "") {
// Check to see if there is more than one encounter in the mod just exited from
DirectoryInfo di2 = new DirectoryInfo(Path.Combine(FileLoader.ModDataPath, "Lua/Encounters"));
string[] encounters = di2.GetFiles("*.lua").Select(f => Path.GetFileNameWithoutExtension(f.Name)).Where(f => !f.StartsWith("@")).ToArray();
// Note: Encounters starting with @ are ignored
DirectoryInfo encounterFiles = new DirectoryInfo(Path.Combine(FileLoader.ModDataPath, "Lua/Encounters"));
string[] encounterNames = encounterFiles.GetFiles("*.lua").Select(f => Path.GetFileNameWithoutExtension(f.Name)).Where(f => !f.StartsWith("@")).ToArray();

// Highlight the chosen encounter whenever the user exits the mod menu
if (encounters.Length > 1) {
if (encounterNames.Length > 1) {
int temp = selectedItem;
encounterSelection();
selectedItem = temp;
Expand Down Expand Up @@ -203,7 +204,11 @@ private List<DirectoryInfo>[] DeepModSearch(DirectoryInfo dir, int currentDepth
DirectoryInfo modsDirectory = new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods"));

foreach (DirectoryInfo encountersFolder in dir.GetDirectories()) {
// Do not explore symlinks/junctions!
// Ignore folders whose name start with @
if (encountersFolder.Name.StartsWith("@"))
continue;

// Do not explore junctions!
if ((encountersFolder.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
continue;

Expand All @@ -227,9 +232,6 @@ private List<DirectoryInfo>[] DeepModSearch(DirectoryInfo dir, int currentDepth
// The root of the mod should not be the CYF Mods folder.
if (modRootFolder == null || modRootFolder.FullName == Path.Combine(FileLoader.DataRoot, "Mods"))
continue;
// The root of the mod should not start with the symbol @.
if (modRootFolder.Name.StartsWith("@"))
continue;
// The root of the mod should not be hidden.
if ((modRootFolder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
continue;
Expand Down

0 comments on commit 8d36b73

Please sign in to comment.