mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
fix: follow .fiz includes and check vehicle files whatever their case
An include in a .fiz is looked up in the vehicle's folder through CaseInsensitivePaths, so its physics are read on Linux when the include names the file in other letter case. The missing-asset scan finds skins and models the same way, with extensions in any case, instead of reporting files that are there.
This commit is contained in:
@@ -23,6 +23,7 @@ public sealed class FizPhysicsRepository : IPhysicsRepository
|
||||
};
|
||||
|
||||
private readonly IFileSystem _files;
|
||||
private readonly CaseInsensitivePaths _names;
|
||||
private readonly IGamePaths _paths;
|
||||
private readonly IDiagnosticsLog _log;
|
||||
|
||||
@@ -38,6 +39,7 @@ public sealed class FizPhysicsRepository : IPhysicsRepository
|
||||
public FizPhysicsRepository(IFileSystem files, IGamePaths paths, IDiagnosticsLog log)
|
||||
{
|
||||
_files = files;
|
||||
_names = new CaseInsensitivePaths(files);
|
||||
_paths = paths;
|
||||
_log = log;
|
||||
}
|
||||
@@ -165,8 +167,9 @@ public sealed class FizPhysicsRepository : IPhysicsRepository
|
||||
while (i < tokens.Count && !tokens[i].Equals("end", StringComparison.OrdinalIgnoreCase))
|
||||
includeParameters.Add(Resolve(tokens[i++], parameters));
|
||||
|
||||
Parse(physics, Path.Combine(directory, includeFile), directory, includeParameters.ToArray(),
|
||||
depth + 1);
|
||||
// Named in the letter case of whoever wrote the include, not always that of the file.
|
||||
string included = _names.Find(directory, includeFile) ?? Path.Combine(directory, includeFile);
|
||||
Parse(physics, included, directory, includeParameters.ToArray(), depth + 1);
|
||||
pendingKey = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -10,44 +10,53 @@ public sealed class MissingAssetScanner
|
||||
private static readonly string[] TextureExtensions = { ".mat", ".bmp" };
|
||||
private static readonly string[] ModelExtensions = { ".t3d", ".e3d" };
|
||||
|
||||
private readonly IFileSystem _files;
|
||||
private readonly IGamePaths _paths;
|
||||
private readonly CaseInsensitivePaths _names;
|
||||
|
||||
public MissingAssetScanner(IFileSystem files, IGamePaths paths)
|
||||
{
|
||||
_files = files;
|
||||
_paths = paths;
|
||||
_names = new CaseInsensitivePaths(files, keepListings: true);
|
||||
}
|
||||
|
||||
public List<string> Scan(VehicleCatalog catalog)
|
||||
{
|
||||
var lines = new List<string>();
|
||||
|
||||
foreach (var texture in catalog.Textures)
|
||||
try
|
||||
{
|
||||
string directory = Path.Combine(
|
||||
_paths.Dynamic,
|
||||
texture.Directory.Replace('/', Path.DirectorySeparatorChar).TrimEnd('\\', '/'));
|
||||
foreach (var texture in catalog.Textures)
|
||||
{
|
||||
string directory = texture.Directory.Replace('\\', '/').TrimEnd('/');
|
||||
|
||||
if (!string.IsNullOrEmpty(texture.Skinfile) &&
|
||||
!ExistsWithAnyExtension(Path.Combine(directory, texture.Skinfile), TextureExtensions))
|
||||
lines.Add($"# no file: {texture.Directory}{texture.Skinfile}");
|
||||
if (!string.IsNullOrEmpty(texture.Skinfile) &&
|
||||
!ExistsWithAnyExtension(Under(directory, texture.Skinfile), TextureExtensions))
|
||||
lines.Add($"# no file: {texture.Directory}{texture.Skinfile}");
|
||||
|
||||
if (!string.IsNullOrEmpty(texture.Model) &&
|
||||
!ExistsWithAnyExtension(Path.Combine(directory, texture.Model), ModelExtensions))
|
||||
lines.Add($"# no model: {texture.Directory}{texture.Model}");
|
||||
if (!string.IsNullOrEmpty(texture.Model) &&
|
||||
!ExistsWithAnyExtension(Under(directory, texture.Model), ModelExtensions))
|
||||
lines.Add($"# no model: {texture.Directory}{texture.Model}");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// The folders are listed once for the whole catalog, and not kept past it.
|
||||
_names.Forget();
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private bool ExistsWithAnyExtension(string path, string[] extensions)
|
||||
private static string Under(string directory, string name) =>
|
||||
directory.Length == 0 ? name : directory + "/" + name;
|
||||
|
||||
/// <summary>Whether the file is under dynamic as named, or with one of the extensions, in any letter case.</summary>
|
||||
private bool ExistsWithAnyExtension(string name, string[] extensions)
|
||||
{
|
||||
if (_files.FileExists(path))
|
||||
if (_names.Resolve(_paths.Dynamic, name) is not null)
|
||||
return true;
|
||||
|
||||
foreach (string extension in extensions)
|
||||
if (_files.FileExists(Path.ChangeExtension(path, extension)))
|
||||
if (_names.Resolve(_paths.Dynamic, Path.ChangeExtension(name, extension)) is not null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user