-
Notifications
You must be signed in to change notification settings - Fork 5
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 #825 from TheEadie/process-replays
Process replays
- Loading branch information
Showing
54 changed files
with
675 additions
and
124 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
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
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,79 @@ | ||
#### Build #### | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0.303@sha256:7d0ba26469267b563120456557e38eccef9972cb6b9cfbbd47a50d1218fa7b30 AS build | ||
WORKDIR /app | ||
|
||
COPY src/Directory.Build.props . | ||
COPY .editorconfig . | ||
COPY src/Worms.Armageddon.Game/Worms.Armageddon.Game.csproj ./src/Worms.Armageddon.Game/Worms.Armageddon.Game.csproj | ||
COPY src/Worms.Hub.Storage/Worms.Hub.Storage.csproj ./src/Worms.Hub.Storage/Worms.Hub.Storage.csproj | ||
COPY src/Worms.Hub.ReplayProcessor/Worms.Hub.ReplayProcessor.csproj ./src/Worms.Hub.ReplayProcessor/Worms.Hub.ReplayProcessor.csproj | ||
RUN dotnet restore src/Worms.Hub.ReplayProcessor/Worms.Hub.ReplayProcessor.csproj | ||
|
||
COPY src/Worms.Armageddon.Game ./src/Worms.Armageddon.Game | ||
COPY src/Worms.Hub.Storage ./src/Worms.Hub.Storage | ||
COPY src/Worms.Hub.ReplayProcessor ./src/Worms.Hub.ReplayProcessor | ||
ARG VERSION=0.0.1 | ||
RUN dotnet publish \ | ||
src/Worms.Hub.ReplayProcessor/Worms.Hub.ReplayProcessor.csproj \ | ||
-c Release \ | ||
-o out \ | ||
--no-restore \ | ||
-p:AssemblyVersion=${VERSION} \ | ||
-p:Version=${VERSION} | ||
|
||
#### Test #### | ||
FROM build AS test | ||
RUN dotnet test --no-restore --no-build --verbosity normal | ||
|
||
#### Runtime #### | ||
FROM ubuntu:22.04@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221 as runtime | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
wget \ | ||
gnupg \ | ||
dotnet-runtime-8.0 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Get key to Wine repo | ||
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key -O /tmp/winehq.key | ||
|
||
# Add Wine repo | ||
RUN apt-get update \ | ||
&& apt-get install -y software-properties-common \ | ||
&& apt-key add /tmp/winehq.key \ | ||
&& add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ jammy main' \ | ||
&& rm /tmp/winehq.key \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# AMD 32-bit deps for Wine | ||
RUN dpkg --add-architecture i386 \ | ||
&& apt-get update \ | ||
&& apt-get install -y --install-recommends winehq-stable wine32 xvfb \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create WINEPREFIX | ||
RUN WINEDLLOVERRIDES="mscoree,mshtml=" xvfb-run wineboot -i \ | ||
&& wineserver -k | ||
|
||
# Copy game installation directory | ||
|
||
# Some settings for WA | ||
RUN wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v WineCompatibilitySuggested /d 0x7FFFFFFF /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v WindowedMode /d 0x00000001 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v DetailLevel /d 0x00000005 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v WindowedMode /d 0x00000001 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v PinnedChatLines /d 0x00000007 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v InfoTransparency /d 0x00000001 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v InfoSpy /d 0x00000001 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v DisableSmoothBackgroundGradient /d 0x00000000 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v HardwareRendering /d 0x00000001 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v LargerFonts /d 0x00000000 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v AssistedVsync /d 0x00000000 /f \ | ||
&& wine reg add 'HKEY_CURRENT_USER\Software\Team17SoftwareLTD\WormsArmageddon\Options' /t REG_DWORD /v Vsync /d 0x00000000 /f \ | ||
&& wineserver -k | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/out . | ||
ENTRYPOINT ["./Worms.Hub.ReplayProcessor"] |
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,10 @@ | ||
# Ignore everything | ||
** | ||
|
||
# Except for these files | ||
!/src | ||
!/scripts | ||
!.editorconfig | ||
|
||
**/bin | ||
**/obj |
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,3 @@ | ||
replay-processor_IMAGE_NAME := theeadie/worms-hub-replay-processor | ||
replay-processor_NEXT_VERSION := 0.1 | ||
replay-processor_TAG_PREFIX := replay-processor/v |
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
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,33 +1,70 @@ | ||
using System.Diagnostics; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Worms.Armageddon.Game.Linux; | ||
|
||
internal sealed class WormsRunner(IWormsLocator wormsLocator) : IWormsRunner | ||
internal sealed class WormsRunner(IWormsLocator wormsLocator, ILogger<WormsRunner> logger) : IWormsRunner | ||
{ | ||
public Task RunWorms(params string[] wormsArgs) | ||
{ | ||
// Replace " with ' in the args | ||
// Wine doesn't like using "s around arguments | ||
// Windows doesn't like using 's around arguments | ||
for (var i = 0; i < wormsArgs.Length; i++) | ||
{ | ||
wormsArgs[i] = wormsArgs[i].Replace("\"", "'", StringComparison.InvariantCulture); | ||
} | ||
|
||
return Task.Run( | ||
async () => | ||
{ | ||
var gameInfo = wormsLocator.Find(); | ||
var args = string.Join(" ", wormsArgs); | ||
logger.Log(LogLevel.Debug, "Running Worms Armageddon: {Path}", gameInfo.ExeLocation); | ||
logger.Log(LogLevel.Debug, "Args: {Arguments}", args); | ||
var processStartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "wine", | ||
Arguments = gameInfo.ExeLocation + " " + args, | ||
FileName = "/bin/bash", | ||
Arguments = $""" | ||
-c "xvfb-run wine "{gameInfo.ExeLocation}" {args}" | ||
""", | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true | ||
RedirectStandardError = true, | ||
WorkingDirectory = $"{gameInfo.ReplayFolder}", | ||
}; | ||
using var process = Process.Start(processStartInfo); | ||
if (process is not null) | ||
{ | ||
await process.WaitForExitAsync().ConfigureAwait(false); | ||
var processTask = Task.Run(() => process.WaitForExitAsync()); | ||
var output = Task.Run(() => PrintStdOut(process)); | ||
var errors = Task.Run(() => PrintStdErr(process)); | ||
await Task.WhenAll(processTask, errors, output).ConfigureAwait(false); | ||
await Console.Error.WriteLineAsync("Exit code:" + process.ExitCode).ConfigureAwait(false); | ||
} | ||
return Task.CompletedTask; | ||
}); | ||
} | ||
|
||
private async Task PrintStdOut(Process process) | ||
{ | ||
while (!process.StandardOutput.EndOfStream) | ||
{ | ||
var line = await process.StandardOutput.ReadLineAsync().ConfigureAwait(false); | ||
logger.Log(LogLevel.Debug, "StdOut: {Message}", line); | ||
} | ||
} | ||
|
||
private async Task PrintStdErr(Process process) | ||
{ | ||
while (!process.StandardError.EndOfStream) | ||
{ | ||
var line = await process.StandardError.ReadLineAsync().ConfigureAwait(false); | ||
logger.Log(LogLevel.Debug, "StdErr: {Message}", line); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.