-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
955 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,8 @@ jobs: | |
# Change into the artifacts directory to avoid including the directory itself in the zip archive | ||
working-directory: ./releases/net8.0 | ||
run: zip -r ../ModVerify-Net8.zip . | ||
- name: Rename .NET Framework executable | ||
run: mv ./releases/net48/ModVerify.CliApp.exe ./releases/net48/ModVerify.exe | ||
- uses: dotnet/[email protected] | ||
id: nbgv | ||
- name: Create GitHub release | ||
|
@@ -65,5 +67,5 @@ jobs: | |
token: ${{ secrets.GITHUB_TOKEN }} | ||
generate_release_notes: true | ||
files: | | ||
./releases/net48/ModVerify.CliApp.exe | ||
./releases/net48/ModVerify.exe | ||
./releases/ModVerify-Net8.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,77 @@ | ||
# ModVerify | ||
# ModVerify: A Mod Verification Tool | ||
|
||
ModVerify is a command-line tool designed to verify mods for the game Star Wars: Empire at War and its expansion Forces of Corruption. | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Options](#options) | ||
- [Available Checks](#available-checks) | ||
|
||
## Installation | ||
|
||
Download the latest release from the [releases page](https://github.com/AlamoEngine-Tools/ModVerify/releases). There are two versions of the application available. | ||
|
||
1. `ModVerify.exe` is the default version. Use this if you simply want to verify your mods. This version only works on Windows. | ||
2. `ModVerify-NetX.zip` is the cross-platform app. It works on Windows and Linux and is most likely the version you want to use to include it in some CI/CD scenarios. | ||
|
||
You can place the files anywhere on your system, eg. your Desktop. There is no need to place it inside a mod's directory. | ||
|
||
*Note: Both versions have the exact same feature set. They just target a different .NET runtime. Linux and CI/CD support is not fully tested yet. Current priority is on the Windows-only version.* | ||
|
||
## Usage | ||
|
||
Simply run the executable file `ModVerify.exe`. | ||
|
||
When given no specific argument through the command line, the app will ask you which game or mod you want to verify. When the tool is done, it will write the verification results into new files next to the executable. | ||
|
||
A `.JSON` file lists all found issues. Into seperate `.txt` files the same errors get grouped by a category of the finding. The text files may be easier to read, while the json file is more useful for 3rd party tool processing. | ||
|
||
## Options | ||
|
||
You can also run the tool with command line arguments to adjust the tool to your needs. | ||
|
||
To see all available options, open the command line and type: | ||
|
||
```bash | ||
ModVerify.exe --help | ||
``` | ||
|
||
Here is a list of the most relevant options: | ||
|
||
### `--path` | ||
Specifies a path that shall be analyzed. **There will be no user input required when using this option** | ||
|
||
### `--output` | ||
Specified the output path where analysis result shall be written to. | ||
|
||
### `--baseline` | ||
Specifies a baseline file that shall be used to filter out known errors. You can download the [FoC baseline](focBaseline.json) which includes all errors produced by the vanilla game. | ||
|
||
### `--createBaseline` | ||
If you want to create your own baseline, add this option with a file path such as `myModBaseline.json`. | ||
|
||
### Example | ||
This is an example run configuration that analyzes a specific mod, uses a the FoC basline and writes the output into a dedicated directory: | ||
|
||
```bash | ||
ModVerify.exe --path "C:\My Games\FoC\Mods\MyMod" --output "C:\My Games\FoC\Mods\MyMod\verifyResults" --baseline focBaseline.json | ||
``` | ||
|
||
|
||
## Available Checks | ||
|
||
The following verifiers are currently implemented: | ||
|
||
### For SFX Events: | ||
- Checks whether coded preset exists | ||
- Checks the referenced samples for validity (bit rate, sample size, channels, etc.) | ||
- Duplicates | ||
|
||
|
||
### For GameObjects | ||
- Checks the referenced models for validity (textures, particles and shaders) | ||
- Duplicates | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Abstractions; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AET.ModVerify; | ||
using AET.ModVerify.Reporting; | ||
using AET.ModVerify.Settings; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using PG.StarWarsGame.Engine; | ||
using PG.StarWarsGame.Infrastructure.Mods; | ||
using PG.StarWarsGame.Infrastructure.Services.Dependencies; | ||
|
||
namespace ModVerify.CliApp; | ||
|
||
internal class ModVerifyApp(GameVerifySettings settings, IServiceProvider services) | ||
internal class ModVerifyApp(ModVerifyAppSettings settings, IServiceProvider services) | ||
{ | ||
private readonly ILogger? _logger = services.GetService<ILoggerFactory>()?.CreateLogger(typeof(ModVerifyApp)); | ||
private readonly IFileSystem _fileSystem = services.GetRequiredService<IFileSystem>(); | ||
|
||
private IReadOnlyCollection<VerificationError> Errors { get; set; } = Array.Empty<VerificationError>(); | ||
|
||
public async Task RunVerification(VerifyGameSetupData gameSetupData) | ||
public async Task<int> RunApplication() | ||
{ | ||
var verifyPipeline = BuildPipeline(gameSetupData); | ||
_logger?.LogInformation($"Verifying {gameSetupData.VerifyObject.Name}..."); | ||
await verifyPipeline.RunAsync(); | ||
_logger?.LogInformation("Finished Verifying"); | ||
var returnCode = 0; | ||
|
||
var gameSetupData = CreateGameSetupData(settings, services); | ||
var verifyPipeline = new ModVerifyPipeline(gameSetupData.EngineType, gameSetupData.GameLocations, settings.GameVerifySettigns, services); | ||
|
||
try | ||
{ | ||
_logger?.LogInformation($"Verifying {gameSetupData.VerifyObject.Name}..."); | ||
await verifyPipeline.RunAsync().ConfigureAwait(false); | ||
_logger?.LogInformation("Finished Verifying"); | ||
} | ||
catch (GameVerificationException e) | ||
{ | ||
returnCode = e.HResult; | ||
} | ||
|
||
if (settings.CreateNewBaseline) | ||
await WriteBaseline(verifyPipeline.Errors, settings.NewBaselinePath).ConfigureAwait(false); | ||
|
||
return returnCode; | ||
} | ||
|
||
private VerifyGamePipeline BuildPipeline(VerifyGameSetupData setupData) | ||
private async Task WriteBaseline(IEnumerable<VerificationError> errors, string baselineFile) | ||
{ | ||
return new ModVerifyPipeline(setupData.EngineType, setupData.GameLocations, settings, services); | ||
var fullPath = _fileSystem.Path.GetFullPath(baselineFile); | ||
#if NET | ||
await | ||
#endif | ||
using var fs = _fileSystem.FileStream.New(fullPath, FileMode.Create, FileAccess.Write, FileShare.None); | ||
var baseline = new VerificationBaseline(errors); | ||
await baseline.ToJsonAsync(fs); | ||
} | ||
|
||
public async Task WriteBaseline(string baselineFile) | ||
private static VerifyGameSetupData CreateGameSetupData(ModVerifyAppSettings options, IServiceProvider services) | ||
{ | ||
var selectionResult = new ModOrGameSelector(services).SelectModOrGame(options.PathToVerify); | ||
|
||
IList<string> mods = Array.Empty<string>(); | ||
if (selectionResult.ModOrGame is IMod mod) | ||
{ | ||
var traverser = services.GetRequiredService<IModDependencyTraverser>(); | ||
mods = traverser.Traverse(mod) | ||
.Select(x => x.Mod) | ||
.OfType<IPhysicalMod>().Select(x => x.Directory.FullName) | ||
.ToList(); | ||
} | ||
|
||
var fallbackPaths = new List<string>(); | ||
if (selectionResult.FallbackGame is not null) | ||
fallbackPaths.Add(selectionResult.FallbackGame.Directory.FullName); | ||
|
||
if (!string.IsNullOrEmpty(options.AdditionalFallbackPath)) | ||
fallbackPaths.Add(options.AdditionalFallbackPath); | ||
|
||
var gameLocations = new GameLocations( | ||
mods, | ||
selectionResult.ModOrGame.Game.Directory.FullName, | ||
fallbackPaths); | ||
|
||
return new VerifyGameSetupData | ||
{ | ||
EngineType = GameEngineType.Foc, | ||
GameLocations = gameLocations, | ||
VerifyObject = selectionResult.ModOrGame, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using AET.ModVerify.Settings; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace ModVerify.CliApp; | ||
|
||
public record ModVerifyAppSettings | ||
{ | ||
public GameVerifySettings GameVerifySettigns { get; init; } | ||
|
||
public string? PathToVerify { get; init; } = null; | ||
|
||
public string Output { get; init; } = Environment.CurrentDirectory; | ||
|
||
public string? AdditionalFallbackPath { get; init; } = null; | ||
|
||
[MemberNotNullWhen(true, nameof(NewBaselinePath))] | ||
public bool CreateNewBaseline => !string.IsNullOrEmpty(NewBaselinePath); | ||
|
||
public string? NewBaselinePath { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.