mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-16 21:14:10 +01:00
The simulator now also comes built without AVX2, its file name ending in _noavx2 (eu07-x64_<date>_<hash>_noavx2.exe, eu07_noavx2 on Linux), and both builds can lie side by side in the game folder. The automatic choice took eu07.exe or the shortest name and never that one, so a processor without AVX2 got a simulator that stops at its first instruction and a notice telling it to build its own. Without AVX2 the automatic choice now takes the newest _noavx2 build, even one through Wine before a native build that would not run. With AVX2 the build made for it stays first and a _noavx2 one is used only when it is all there is. The notice comes only when what would start still needs AVX2. With a _noavx2 build in the folder but another chosen by hand it names both and offers to go back to the automatic choice; with none it says what such a build is called and that the starter picks it up from the game folder.
68 lines
3.2 KiB
C#
68 lines
3.2 KiB
C#
using StarterNG.Application;
|
|
using StarterNG.Infrastructure.Adapters;
|
|
using StarterNG.Infrastructure.Sceneries;
|
|
using StarterNG.Infrastructure.Settings;
|
|
using StarterNG.Infrastructure.Vehicles;
|
|
|
|
namespace StarterNG.Tests.Fakes;
|
|
|
|
/// <summary>
|
|
/// The production object graph wired over an in-memory installation: the same
|
|
/// composition as <c>AppServices</c>, with disk, clock and randomness replaced.
|
|
/// </summary>
|
|
public sealed class TestInstallation
|
|
{
|
|
public const string Root = "game";
|
|
|
|
public TestInstallation(InMemoryFileSystem? files = null, DateTime? now = null, bool lacksAvx2 = false)
|
|
{
|
|
Files = files ?? new InMemoryFileSystem();
|
|
Paths = new GamePaths(Root);
|
|
Clock = new FixedClock(now ?? new DateTime(2026, 1, 1, 12, 0, 0));
|
|
Random = new StubRandom();
|
|
Log = new FileDiagnosticsLog(Files, Clock, Paths);
|
|
Strings = new FakeStrings();
|
|
|
|
MiniTextures = new MiniTextureIndex(Files, Paths);
|
|
Physics = new FizPhysicsRepository(Files, Paths, Log);
|
|
Vehicles = new TexturesTxtVehicleRepository(Files, Paths, Log, new TexturesTxtParser());
|
|
VehicleJson = new VehicleJsonSerializer();
|
|
Sceneries = new SceneryRepository(Files, Paths, Log, new SceneryParser(Clock, Random));
|
|
MissingAssets = new MissingAssetScanner(Files, Paths);
|
|
Environment = new FakeEnvironment();
|
|
SettingsPaths = new SettingsPaths(Environment, Paths);
|
|
VehicleCache = new VehicleCacheRepository(Files, Paths, Log, Vehicles, VehicleJson,
|
|
SettingsPaths.VehicleCacheDirectory());
|
|
Library = new GameLibrary(VehicleCache, Sceneries, MiniTextures, Physics, Log);
|
|
|
|
// The processor of the machine running the tests is not the one tested.
|
|
Executables = new ExecutableLocator(Files, Paths, Environment, Log, lacksAvx2);
|
|
SettingsStore = new SettingsStore(Files, Clock, Log, SettingsPaths, new SettingsSerializer(), Executables);
|
|
Tapes = new HaslerTapes(Files, Paths, Log, Clock, new TimetableLocator(Files), () => SimulatorRunning);
|
|
}
|
|
|
|
public InMemoryFileSystem Files { get; }
|
|
public GamePaths Paths { get; }
|
|
public FixedClock Clock { get; }
|
|
public StubRandom Random { get; }
|
|
public FileDiagnosticsLog Log { get; }
|
|
public FakeStrings Strings { get; }
|
|
public MiniTextureIndex MiniTextures { get; }
|
|
public FizPhysicsRepository Physics { get; }
|
|
public TexturesTxtVehicleRepository Vehicles { get; }
|
|
public VehicleJsonSerializer VehicleJson { get; }
|
|
public VehicleCacheRepository VehicleCache { get; }
|
|
public SceneryRepository Sceneries { get; }
|
|
public MissingAssetScanner MissingAssets { get; }
|
|
public GameLibrary Library { get; }
|
|
public FakeEnvironment Environment { get; }
|
|
public SettingsPaths SettingsPaths { get; }
|
|
public ExecutableLocator Executables { get; }
|
|
public SettingsStore SettingsStore { get; }
|
|
public HaslerTapes Tapes { get; }
|
|
public bool SimulatorRunning { get; set; }
|
|
|
|
/// <summary>Path of a file inside the fake installation.</summary>
|
|
public static string At(params string[] segments) => Path.Combine(new[] { Root }.Concat(segments).ToArray());
|
|
}
|