Skip to content

Commit 13f26c5

Browse files
committed
Refactor: Replace direct filename handling with NormalizeFileName for consistency and re-enable particle name mismatch validation
1 parent 5f87709 commit 13f26c5

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

src/ModVerify/Verifiers/Commons/SingleModelVerifier.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Runtime.InteropServices;
34
using System.Threading;
45
using AET.ModVerify.Reporting;
56
using AET.ModVerify.Settings;
@@ -240,31 +241,30 @@ private void VerifyParticle(IAloParticleFile file, IReadOnlyCollection<string> c
240241
VerifierErrorCodes.InvalidFilePath,
241242
$"Invalid texture file name '{texture}' in particle '{file.FileName}'",
242243
VerificationSeverity.Error,
243-
[file.FileName.ToUpperInvariant()],
244+
[NormalizeFileName(file.FileName)],
244245
texture));
245246
});
246247
}
247248

248-
var fileName = FileSystem.Path.GetFileNameWithoutExtension(file.FilePath.AsSpan());
249+
var fileName = GameEngine.GameRepository.PGFileSystem.GetFileNameWithoutExtension(file.FilePath.AsSpan());
249250
var name = file.Content.Name.AsSpan();
250251

251252
if (!fileName.Equals(name, StringComparison.OrdinalIgnoreCase))
252253
{
253-
// TODO: Re-enable
254-
// AddError(VerificationError.Create(
255-
// this,
256-
// VerifierErrorCodes.InvalidParticleName,
257-
// $"The particle name '{file.Content.Name}' does not match file name '{file.FileName}'",
258-
// VerificationSeverity.Error,
259-
// [file.FileName.ToUpperInvariant()],
260-
// file.Content.Name));
254+
AddError(VerificationError.Create(
255+
this,
256+
VerifierErrorCodes.InvalidParticleName,
257+
$"The particle name '{file.Content.Name}' does not match file name '{file.FileName}'",
258+
VerificationSeverity.Error,
259+
[NormalizeFileName(file.FileName)],
260+
file.Content.Name));
261261
}
262262

263263
}
264264

265265
private void VerifyModel(IAloModelFile file, AnimationCollection animations, IReadOnlyCollection<string> contextInfo, CancellationToken token)
266266
{
267-
IReadOnlyList<string> modelContext = [.. contextInfo, file.FileName.ToUpperInvariant()];
267+
IReadOnlyList<string> modelContext = [.. contextInfo, NormalizeFileName(file.FileName)];
268268

269269
foreach (var texture in file.Content.Textures)
270270
{
@@ -334,7 +334,7 @@ private void VerifyTextureExists(IPetroglyphFileHolder model, string texture, IR
334334
{
335335
if (texture == "None")
336336
return;
337-
_textureVerifier.Verify(texture, [..contextInfo, model.FileName.ToUpperInvariant()], CancellationToken.None);
337+
_textureVerifier.Verify(texture, [..contextInfo, NormalizeFileName(model.FileName)], CancellationToken.None);
338338
}
339339

340340
private void VerifyProxyExists(IPetroglyphFileHolder model, string proxy, IReadOnlyCollection<string> contextInfo, CancellationToken token)
@@ -368,12 +368,17 @@ private void VerifyShaderExists(IPetroglyphFileHolder model, string shader, IRea
368368
VerifierErrorCodes.FileNotFound,
369369
message,
370370
VerificationSeverity.Error,
371-
[..contextInfo, model.FileName.ToUpperInvariant()],
371+
[..contextInfo, NormalizeFileName(model.FileName)],
372372
shader);
373373
AddError(error);
374374
}
375375
}
376376

377+
private string NormalizeFileName(string fileName)
378+
{
379+
return GameEngine.GameRepository.PGFileSystem.GetFileName(fileName).ToUpperInvariant();
380+
}
381+
377382
private void AddNotExistError(string fileName, IReadOnlyCollection<string> contextInfo)
378383
{
379384
AddError(VerificationError.Create(

0 commit comments

Comments
 (0)