New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix map linting crashing for not existing directories #14136
Conversation
7e011ab
to
66252c1
Compare
OpenRA.Game/Map/MapCache.cs
Outdated
{ | ||
var name = kv.Key; | ||
var classification = string.IsNullOrEmpty(kv.Value) | ||
? MapClassification.Unknown : Enum<MapClassification>.Parse(kv.Value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum.TryParse
and continue
upon failure or Unknown
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this I suppose. You're just moving code afterall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good opportunity to fix the original code (since this is pulling out a common helper).
@@ -78,42 +77,19 @@ void IUtilityCommand.Run(Utility utility, string[] args) | |||
// The map cache won't be valid if there was a map format upgrade, so walk the map packages manually | |||
// Only upgrade system maps - user maps must be updated manually using --upgrade-map | |||
Console.WriteLine("Processing Maps:"); | |||
foreach (var kv in modData.Manifest.MapFolders) | |||
var maps = modData.MapCache.EnumerateMapsWithoutCaching(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why store this in a local?
Updated. |
@@ -122,6 +122,48 @@ public void LoadMaps() | |||
} | |||
} | |||
|
|||
public IEnumerable<Map> EnumerateMapsWithoutCaching(MapClassification classification = MapClassification.System) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this to work properly you will need to change the MapClassification
definition to:
// Used for grouping maps in the UI and for filtering
[Flags]
public enum MapClassification
{
Unknown = 0,
System = 1,
User = 2,
Remote = 4
}
OpenRA.Game/Map/MapCache.cs
Outdated
if (!Enum.TryParse(kv.Value, out packageClassification)) | ||
continue; | ||
|
||
if (packageClassification != classification) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will then need to become
if (!classification.HasFlag(packageClassification))
} | ||
} | ||
// Use all system maps for lint checking | ||
maps = modData.MapCache.EnumerateMapsWithoutCaching().ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is silently changing the command behaviour.
Please do EnumerateMapsWithoutCaching(MapClassification.System | MapClassification.User)
and then remove the User
in its own commit to make the intention clear.
} | ||
} | ||
} | ||
Console.WriteLine(map.Package.Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over debugging code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. We also print out which yaml files are currently upgraded. It also takes quite a while to update all maps, and you're left without knowing if something even happens.
OpenRA.Game/Map/MapCache.cs
Outdated
{ | ||
// Assume that the path is a directory if there is not an existing file with the same name | ||
var resolved = Platform.ResolvePath(name); | ||
if (!File.Exists(resolved)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The support directory is not a file, so this always fails. This needs to also check Directory.Exists
. The comment also needs to be corrected or removed.
Updated. |
Upgrading the maps can take quite some time, and at the moment you are left without information if something is happening.
Fixes the regression that slipped in #13938 in (see #13938 (comment)).
For reference: https://logs.openra.net/?year=2017&month=08&day=30#15:42:38