-
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.
Merge pull request #3 from AlamoEngine-Tools/develop
Support SFX Events, Logging and reporting
- Loading branch information
Showing
161 changed files
with
5,857 additions
and
1,507 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
Submodule PetroglyphTools
updated
124 files
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<Costura /> | ||
</Weavers> | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"/> |
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO.Abstractions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using PG.StarWarsGame.Infrastructure.Clients.Steam; | ||
using PG.StarWarsGame.Infrastructure.Games; | ||
using PG.StarWarsGame.Infrastructure.Mods; | ||
using PG.StarWarsGame.Infrastructure.Services; | ||
using PG.StarWarsGame.Infrastructure.Services.Dependencies; | ||
using PG.StarWarsGame.Infrastructure.Services.Detection; | ||
|
||
namespace ModVerify.CliApp; | ||
|
||
internal class GameFinderService | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly IFileSystem _fileSystem; | ||
private readonly ILogger? _logger; | ||
private readonly IGameFactory _gameFactory; | ||
private readonly IModFactory _modFactory; | ||
|
||
public GameFinderService(IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); | ||
_fileSystem = _serviceProvider.GetRequiredService<IFileSystem>(); | ||
_gameFactory = _serviceProvider.GetRequiredService<IGameFactory>(); | ||
_modFactory = _serviceProvider.GetRequiredService<IModFactory>(); | ||
_logger = _serviceProvider.GetService<ILoggerFactory>()?.CreateLogger(GetType()); | ||
} | ||
|
||
public GameFinderResult FindGames() | ||
{ | ||
var detectors = new List<IGameDetector> | ||
{ | ||
new DirectoryGameDetector(_fileSystem.DirectoryInfo.New(Environment.CurrentDirectory), _serviceProvider), | ||
new SteamPetroglyphStarWarsGameDetector(_serviceProvider), | ||
}; | ||
|
||
return FindGames(detectors); | ||
} | ||
|
||
public GameFinderResult FindGamesFromPath(string path) | ||
{ | ||
// There are three common situations: | ||
// 1. path points to the actual game directory | ||
// 2. path points to a local mod in game/Mods/ModDir | ||
// 3. path points to a workshop mod | ||
var givenDirectory = _fileSystem.DirectoryInfo.New(path); | ||
var possibleGameDir = givenDirectory.Parent?.Parent; | ||
var possibleSteamAppsFolder = givenDirectory.Parent?.Parent?.Parent?.Parent?.Parent; | ||
|
||
var detectors = new List<IGameDetector> | ||
{ | ||
new DirectoryGameDetector(givenDirectory, _serviceProvider) | ||
}; | ||
|
||
if (possibleGameDir is not null) | ||
detectors.Add(new DirectoryGameDetector(possibleGameDir, _serviceProvider)); | ||
|
||
if (possibleSteamAppsFolder is not null && possibleSteamAppsFolder.Name == "steamapps" && uint.TryParse(givenDirectory.Name, out _)) | ||
detectors.Add(new SteamPetroglyphStarWarsGameDetector(_serviceProvider)); | ||
|
||
return FindGames(detectors); | ||
} | ||
|
||
private bool TryDetectGame(GameType gameType, IList<IGameDetector> detectors, out GameDetectionResult result) | ||
{ | ||
var gd = new CompositeGameDetector(detectors, _serviceProvider, true); | ||
result = gd.Detect(new GameDetectorOptions(gameType)); | ||
|
||
if (result.Error is not null) | ||
{ | ||
_logger?.LogTrace($"Unable to find game installation: {result.Error.Message}", result.Error); | ||
return false; | ||
} | ||
if (result.GameLocation is null) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
|
||
private void SetupMods(IGame game) | ||
{ | ||
var modFinder = _serviceProvider.GetRequiredService<IModReferenceFinder>(); | ||
var modRefs = modFinder.FindMods(game); | ||
|
||
var mods = new List<IMod>(); | ||
|
||
foreach (var modReference in modRefs) | ||
{ | ||
var mod = _modFactory.FromReference(game, modReference); | ||
mods.AddRange(mod); | ||
} | ||
|
||
foreach (var mod in mods) | ||
game.AddMod(mod); | ||
|
||
// Mods need to be added to the game first, before resolving their dependencies. | ||
foreach (var mod in mods) | ||
{ | ||
var resolver = _serviceProvider.GetRequiredService<IDependencyResolver>(); | ||
mod.ResolveDependencies(resolver, | ||
new DependencyResolverOptions { CheckForCycle = true, ResolveCompleteChain = true }); | ||
} | ||
} | ||
|
||
private GameFinderResult FindGames(IList<IGameDetector> detectors) | ||
{ | ||
// FoC needs to be tried first | ||
if (!TryDetectGame(GameType.Foc, detectors, out var result)) | ||
{ | ||
_logger?.LogTrace("Unable to find FoC installation. Trying again with EaW..."); | ||
if (!TryDetectGame(GameType.EaW, detectors, out result)) | ||
throw new GameException("Unable to find game installation: Wrong install path?"); | ||
} | ||
|
||
if (result.GameLocation is null) | ||
throw new GameException("Unable to find game installation: Wrong install path?"); | ||
|
||
_logger?.LogTrace($"Found game installation: {result.GameIdentity} at {result.GameLocation.FullName}"); | ||
|
||
var game = _gameFactory.CreateGame(result); | ||
|
||
SetupMods(game); | ||
|
||
|
||
IGame? fallbackGame = null; | ||
// If the game is Foc we want to set up Eaw as well as the fallbackGame | ||
if (game.Type == GameType.Foc) | ||
{ | ||
var fallbackDetectors = new List<IGameDetector>(); | ||
|
||
if (game.Platform == GamePlatform.SteamGold) | ||
fallbackDetectors.Add(new SteamPetroglyphStarWarsGameDetector(_serviceProvider)); | ||
else | ||
throw new NotImplementedException("Searching fallback game for non-Steam games is currently is not yet implemented."); | ||
|
||
if (!TryDetectGame(GameType.EaW, fallbackDetectors, out var fallbackResult) || fallbackResult.GameLocation is null) | ||
throw new GameException("Unable to find fallback game installation: Wrong install path?"); | ||
|
||
_logger?.LogTrace($"Found fallback game installation: {fallbackResult.GameIdentity} at {fallbackResult.GameLocation.FullName}"); | ||
|
||
fallbackGame = _gameFactory.CreateGame(fallbackResult); | ||
|
||
SetupMods(fallbackGame); | ||
} | ||
|
||
return new GameFinderResult(game, fallbackGame); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.