Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
841 changes: 773 additions & 68 deletions .editorconfig

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ on:
push:
pull_request:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
linux:
name: Linux (.NET 6.0)
runs-on: ubuntu-22.04

steps:
- name: Remove System .NET
run: sudo apt-get remove -y dotnet*

- name: Clone Repository
uses: actions/checkout@v3

Expand All @@ -32,7 +38,7 @@ jobs:
run: |
sudo apt-get install lua5.1
make check-scripts
make test
make TREAT_WARNINGS_AS_ERRORS=true test

linux-mono:
name: Linux (mono)
Expand All @@ -56,7 +62,7 @@ jobs:
- name: Check Mod
run: |
# check-scripts does not depend on .net/mono, so is not needed here
make RUNTIME=mono test
make RUNTIME=mono TREAT_WARNINGS_AS_ERRORS=true test

windows:
name: Windows (.NET 6.0)
Expand All @@ -80,7 +86,8 @@ jobs:

- name: Check Mods
run: |
chocolatey install lua --version 5.1.5.52
choco install lua --version 5.1.5.52 --no-progress
$ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\"
$ENV:TREAT_WARNINGS_AS_ERRORS = "true"
.\make.ps1 check-scripts
.\make.ps1 test
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# to compile, run:
# make
#
# to compile using Mono (version 6.4 or greater) instead of .NET 6, run:
# to compile using Mono (version 6.12 or greater) instead of .NET 6, run:
# make RUNTIME=mono
#
# to compile using system libraries for native dependencies, run:
Expand All @@ -22,7 +22,7 @@
# make [RUNTIME=net6] check
#
# to check your mod yaml for errors, run:
# make [RUNTIME=net6] test
# make [RUNTIME=net6] [TREAT_WARNINGS_AS_ERRORS=false] test
#
# the following are internal sdk helpers that are not intended to be run directly:
# make check-variables
Expand Down Expand Up @@ -145,7 +145,7 @@ engine: check-variables check-sdk-scripts

all: engine
ifeq ($(RUNTIME), mono)
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.4."; exit 1)
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.12."; exit 1)
ifneq ("$(MOD_SOLUTION_FILES)","")
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true \;
endif
Expand Down Expand Up @@ -181,11 +181,10 @@ check: engine
ifneq ("$(MOD_SOLUTION_FILES)","")
@echo "Compiling in Debug mode..."
ifeq ($(RUNTIME), mono)
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(MSBUILD) -t:build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
@$(MSBUILD) -t:clean\;build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM)
else
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
@$(DOTNET) clean -c Debug --nologo --verbosity minimal
@$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM)
endif
endif
@echo "Checking for explicit interface violations..."
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA2/Activities/EnterCarrierParent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace OpenRA.Mods.RA2.Activities
{
class EnterCarrierParent : Enter
sealed class EnterCarrierParent : Enter
{
readonly Actor parent;
readonly CarrierParent spawnerParent;
Expand Down
11 changes: 4 additions & 7 deletions OpenRA.Mods.RA2/FileSystem/BagFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ public BagFile(Stream s, List<IdxEntry> entries, string filename)
Name = filename;
this.s = s;

index = entries.ToDictionaryWithConflictLog(x => x.Filename,
"{0} (bag format)".F(filename),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length));
index = entries.ToDictionaryWithConflictLog(x => x.Filename, $"{filename} (bag format)", null, x => $"(offs={x.Offset}, len={x.Length})");
}

public Stream GetStream(string filename)
{
IdxEntry entry;
if (!index.TryGetValue(filename, out entry))
if (!index.TryGetValue(filename, out var entry))
return null;

var waveHeaderMemoryStream = new MemoryStream();
Expand Down Expand Up @@ -71,8 +68,8 @@ public Stream GetStream(string filename)
if ((entry.Flags & 8) > 0)
{
// IMA ADPCM
var samplesPerChunk = (2 * (entry.ChunkSize - 4)) + 1;
var bytesPerSec = (int)Math.Floor(((double)(2 * entry.ChunkSize) / samplesPerChunk) * ((double)entry.SampleRate / 2));
var samplesPerChunk = 2 * (entry.ChunkSize - 4) + 1;
var bytesPerSec = (int)Math.Floor((double)(2 * entry.ChunkSize) / samplesPerChunk * ((double)entry.SampleRate / 2));
var chunkSize = entry.ChunkSize > entry.Length ? entry.Length : entry.ChunkSize;

waveHeaderMemoryStream.WriteArray(Encoding.ASCII.GetBytes("RIFF"));
Expand Down
23 changes: 11 additions & 12 deletions OpenRA.Mods.RA2/Graphics/ArcRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,31 @@

namespace OpenRA.Mods.RA2.Graphics
{
public struct ArcRenderable : IRenderable, IFinalizedRenderable
public readonly struct ArcRenderable : IRenderable, IFinalizedRenderable
{
readonly Color color;
readonly WPos a, b;
readonly WPos end;
readonly WAngle angle;
readonly int zOffset;
readonly WDist width;
readonly int segments;

public ArcRenderable(WPos a, WPos b, int zOffset, WAngle angle, Color color, WDist width, int segments)
public ArcRenderable(WPos start, WPos end, int zOffset, WAngle angle, Color color, WDist width, int segments)
{
this.a = a;
this.b = b;
Pos = start;
ZOffset = zOffset;
this.end = end;
this.angle = angle;
this.color = color;
this.zOffset = zOffset;
this.width = width;
this.segments = segments;
}

public WPos Pos => a;
public int ZOffset => zOffset;
public WPos Pos { get; }
public int ZOffset { get; }
public bool IsDecoration => true;

public IRenderable WithZOffset(int newOffset) { return new ArcRenderable(a, b, zOffset, angle, color, width, segments); }
public IRenderable OffsetBy(in WVec vec) { return new ArcRenderable(a + vec, b + vec, zOffset, angle, color, width, segments); }
public IRenderable WithZOffset(int newOffset) { return new ArcRenderable(Pos, end, ZOffset, angle, color, width, segments); }
public IRenderable OffsetBy(in WVec vec) { return new ArcRenderable(Pos + vec, end + vec, ZOffset, angle, color, width, segments); }
public IRenderable AsDecoration() { return this; }

public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
Expand All @@ -50,7 +49,7 @@ void IFinalizedRenderable.Render(WorldRenderer wr)

var points = new float3[segments + 1];
for (var i = 0; i <= segments; i++)
points[i] = wr.Screen3DPosition(WPos.LerpQuadratic(a, b, angle, i, segments));
points[i] = wr.Screen3DPosition(WPos.LerpQuadratic(Pos, end, angle, i, segments));

Game.Renderer.WorldRgbaColorRenderer.DrawLine(points, screenWidth, color, false);
}
Expand Down
11 changes: 5 additions & 6 deletions OpenRA.Mods.RA2/Graphics/ElectricBoltRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@

namespace OpenRA.Mods.RA2.Graphics
{
public struct ElectricBoltRenderable : IRenderable, IFinalizedRenderable
public readonly struct ElectricBoltRenderable : IRenderable, IFinalizedRenderable
{
readonly WPos[] offsets;
readonly int zOffset;
readonly WDist width;
readonly Color color;

public ElectricBoltRenderable(WPos[] offsets, int zOffset, WDist width, Color color)
{
this.offsets = offsets;
this.zOffset = zOffset;
ZOffset = zOffset;
this.width = width;
this.color = color;
}

public WPos Pos => new WPos(offsets[0].X, offsets[0].Y, 0);
public int ZOffset => zOffset;
public WPos Pos => new(offsets[0].X, offsets[0].Y, 0);
public int ZOffset { get; }
public bool IsDecoration => true;

public IRenderable WithZOffset(int newOffset) { return new ElectricBoltRenderable(offsets, newOffset, width, color); }

public IRenderable OffsetBy(in WVec vec)
{
var vec2 = vec;
return new ElectricBoltRenderable(offsets.Select(offset => offset + vec2).ToArray(), zOffset, width, color);
return new ElectricBoltRenderable(offsets.Select(offset => offset + vec2).ToArray(), ZOffset, width, color);
}

public IRenderable AsDecoration() { return this; }
Expand Down

This file was deleted.

27 changes: 13 additions & 14 deletions OpenRA.Mods.RA2/Graphics/RadBeamRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

namespace OpenRA.Mods.RA2.Graphics
{
public struct RadBeamRenderable : IRenderable, IFinalizedRenderable
public readonly struct RadBeamRenderable : IRenderable, IFinalizedRenderable
{
readonly WPos pos;
readonly int zOffset;
readonly WVec sourceToTarget;
readonly WDist width;
readonly Color color;
Expand All @@ -27,8 +25,8 @@ public struct RadBeamRenderable : IRenderable, IFinalizedRenderable

public RadBeamRenderable(WPos pos, int zOffset, WVec sourceToTarget, WDist width, Color color, WDist amplitude, WDist wavelength, int quantizationCount)
{
this.pos = pos;
this.zOffset = zOffset;
Pos = pos;
ZOffset = zOffset;
this.sourceToTarget = sourceToTarget;
this.width = width;
this.color = color;
Expand All @@ -37,18 +35,19 @@ public RadBeamRenderable(WPos pos, int zOffset, WVec sourceToTarget, WDist width
this.quantizationCount = quantizationCount;
}

public WPos Pos => pos;
public WPos Pos { get; }
public PaletteReference Palette => null;
public int ZOffset => zOffset;
public int ZOffset { get; }
public bool IsDecoration => true;

public IRenderable WithZOffset(int newOffset) { return new RadBeamRenderable(pos, zOffset, sourceToTarget, width, color, amplitude, wavelength, quantizationCount); }
public IRenderable WithZOffset(int newOffset) => new RadBeamRenderable(Pos, ZOffset, sourceToTarget, width, color, amplitude, wavelength, quantizationCount);

public IRenderable OffsetBy(in WVec vec) { return new RadBeamRenderable(pos + vec, zOffset, sourceToTarget, width, color, amplitude, wavelength, quantizationCount); }
public IRenderable OffsetBy(in WVec vec) => new RadBeamRenderable(Pos + vec, ZOffset, sourceToTarget, width, color, amplitude, wavelength, quantizationCount);

public IRenderable AsDecoration() { return this; }
public IRenderable AsDecoration() => this;

public IFinalizedRenderable PrepareRender(WorldRenderer wr) => this;

public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
public void Render(WorldRenderer wr)
{
if (sourceToTarget == WVec.Zero)
Expand All @@ -58,7 +57,7 @@ public void Render(WorldRenderer wr)

// forward step, pointing from src to target.
// QuantizationCont * forwardStep == One cycle of beam in src2target direction.
var forwardStep = (wavelength.Length * sourceToTarget) / (quantizationCount * sourceToTarget.Length);
var forwardStep = wavelength.Length * sourceToTarget / (quantizationCount * sourceToTarget.Length);

var cycleCount = sourceToTarget.Length / wavelength.Length;
if (sourceToTarget.Length % wavelength.Length != 0)
Expand All @@ -70,7 +69,7 @@ public void Render(WorldRenderer wr)
var angleStep = new WAngle(1024 / quantizationCount);

// last point the rad beam "reached"
var pos = this.pos; // where we are
var pos = Pos; // where we are
var last = wr.Screen3DPosition(pos); // we start from the shooter
for (var i = 0; i < cycleCount * quantizationCount; i++)
{
Expand All @@ -86,6 +85,6 @@ public void Render(WorldRenderer wr)

public void RenderDebugGeometry(WorldRenderer wr) { }

public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; }
public Rectangle ScreenBounds(WorldRenderer wr) => Rectangle.Empty;
}
}
Loading
Loading