Skip to content

Commit

Permalink
Merge branch 'bleed' into rv-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Apr 6, 2024
2 parents ec3c406 + 7859b91 commit 825b259
Show file tree
Hide file tree
Showing 37 changed files with 230 additions and 102 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

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

- name: Install .NET 6.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand All @@ -39,7 +39,7 @@ jobs:

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

- name: Check Code
run: |
Expand All @@ -57,10 +57,10 @@ jobs:

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

- name: Install .NET 6.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ jobs:
echo ${{ needs.prepare.outputs.version_type }}
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.git_tag }}

- name: Install .NET 6
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand All @@ -66,7 +66,7 @@ jobs:
make all
- name: Clone Wiki
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: openra/openra.wiki
token: ${{ secrets.DOCS_TOKEN }}
Expand Down Expand Up @@ -107,12 +107,12 @@ jobs:
echo ${{ needs.prepare.outputs.version_type }}
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.git_tag }}

- name: Install .NET 6
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand All @@ -122,7 +122,7 @@ jobs:
# version_type is release/playtest/bleed - the name of the target branch.
- name: Clone docs.openra.net
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: openra/docs
token: ${{ secrets.DOCS_TOKEN }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Prepare Environment
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
Expand All @@ -40,10 +40,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install .NET 6.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand All @@ -70,10 +70,10 @@ jobs:
runs-on: macos-11
steps:
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install .NET 6.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand Down Expand Up @@ -105,10 +105,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Clone Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install .NET 6.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/FileFormats/Png.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public Png(Stream s)

case "PLTE":
{
Palette = new Color[256];
for (var i = 0; i < length / 3; i++)
Palette = new Color[length / 3];
for (var i = 0; i < Palette.Length; i++)
{
var r = ms.ReadUInt8(); var g = ms.ReadUInt8(); var b = ms.ReadUInt8();
Palette[i] = Color.FromArgb(r, g, b);
Expand Down
6 changes: 6 additions & 0 deletions OpenRA.Game/FileSystem/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ public void LoadFromManifest(Manifest manifest)
UnmountAll();
foreach (var kv in manifest.Packages)
Mount(kv.Key, kv.Value);

mountedPackages.TrimExcess();
explicitMounts.TrimExcess();
modPackages.TrimExcess();
foreach (var packages in fileIndex.Values)
packages.TrimExcess();
}

Stream GetFromCache(string filename)
Expand Down
15 changes: 10 additions & 5 deletions OpenRA.Game/Graphics/SpriteCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public void LoadReservations(ModData modData)
}
}

spriteReservations.Clear();
spriteReservations.TrimExcess();
reservationsByFilename.Clear();
reservationsByFilename.TrimExcess();

// When the sheet builder is adding sprites, it reserves height for the tallest sprite seen along the row.
// We can achieve better sheet packing by keeping sprites with similar heights together.
var orderedPendingResolve = pendingResolve.OrderBy(x => x.Frame.Size.Height);
Expand All @@ -137,17 +142,17 @@ public void LoadReservations(ModData modData)
modData.LoadScreen?.Display();
}

spriteReservations.Clear();
reservationsByFilename.Clear();

foreach (var sb in SheetBuilders.Values)
sb.Current.ReleaseBuffer();
}

public Sprite[] ResolveSprites(int token)
{
var resolved = resolvedSprites[token];
resolvedSprites.Remove(token);
if (!resolvedSprites.Remove(token, out var resolved))
throw new InvalidOperationException($"{nameof(token)} {token} has either already been resolved, or was never reserved via {nameof(ReserveSprites)}");

resolvedSprites.TrimExcess();

if (missingFiles.TryGetValue(token, out var r))
throw new FileNotFoundException($"{r.Location}: {r.Filename} not found", r.Filename);

Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Cnc/FileSystem/BigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sealed class BigFile : IReadOnlyPackage
public string Name { get; }
public IEnumerable<string> Contents => index.Keys;

readonly Dictionary<string, Entry> index = new();
readonly Dictionary<string, Entry> index;
readonly Stream s;

public BigFile(Stream s, string filename)
Expand All @@ -48,6 +48,7 @@ public BigFile(Stream s, string filename)
// and we don't have to try seeking there since the entries typically start next in EA's .big files.
s.ReadUInt32();

index = new Dictionary<string, Entry>((int)entryCount);
for (var i = 0; i < entryCount; i++)
{
var entry = new Entry(s);
Expand Down
5 changes: 4 additions & 1 deletion OpenRA.Mods.Cnc/FileSystem/MegFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public sealed class MegFile : IReadOnlyPackage
{
readonly Stream s;

readonly Dictionary<string, (uint Offset, int Length)> contents = new();
readonly Dictionary<string, (uint Offset, int Length)> contents;

public MegFile(Stream s, string filename)
{
Expand Down Expand Up @@ -84,6 +84,7 @@ public MegFile(Stream s, string filename)
throw new Exception("File name table in .meg file inconsistent");

// Now we load each file entry and associated info
contents = new Dictionary<string, (uint Offset, int Length)>((int)numFiles);
for (var i = 0; i < numFiles; i++)
{
// Ignore flags, crc, index
Expand All @@ -94,6 +95,8 @@ public MegFile(Stream s, string filename)
contents[filenames[nameIndex]] = (offset, (int)size);
}

contents.TrimExcess();

if (s.Position != headerSize)
throw new Exception("Expected to be at data start offset");
}
Expand Down
6 changes: 4 additions & 2 deletions OpenRA.Mods.Cnc/FileSystem/MixFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public MixFile(Stream s, string filename, string[] globalFilenames)

Dictionary<string, PackageEntry> ParseIndex(Dictionary<uint, PackageEntry> entries, string[] globalFilenames)
{
var classicIndex = new Dictionary<string, PackageEntry>();
var crcIndex = new Dictionary<string, PackageEntry>();
var allPossibleFilenames = new HashSet<string>(globalFilenames);

// Try and find a local mix database
Expand All @@ -88,6 +86,9 @@ Dictionary<string, PackageEntry> ParseIndex(Dictionary<uint, PackageEntry> entri
}
}

var classicIndex = new Dictionary<string, PackageEntry>(entries.Count);
var crcIndex = new Dictionary<string, PackageEntry>(entries.Count);

foreach (var filename in allPossibleFilenames)
{
var classicHash = PackageEntry.HashFilename(filename, PackageHashType.Classic);
Expand All @@ -106,6 +107,7 @@ Dictionary<string, PackageEntry> ParseIndex(Dictionary<uint, PackageEntry> entri
if (unknown > 0)
Log.Write("debug", $"{Name}: failed to resolve filenames for {unknown} unknown hashes");

bestIndex.TrimExcess();
return bestIndex;
}

Expand Down
9 changes: 4 additions & 5 deletions OpenRA.Mods.Cnc/FileSystem/Pak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ public PakFile(Stream stream, string filename)
var length = (next == 0 ? (uint)stream.Length : next) - offset;

// Ignore duplicate files
if (index.ContainsKey(file))
continue;

index.Add(file, new Entry { Offset = offset, Length = length, Filename = file });
offset = next;
if (index.TryAdd(file, new Entry { Offset = offset, Length = length, Filename = file }))
offset = next;
}

index.TrimExcess();
}
catch
{
Expand Down
9 changes: 7 additions & 2 deletions OpenRA.Mods.Common/FileSystem/InstallShieldPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Entry(uint offset, uint length)
public string Name { get; }
public IEnumerable<string> Contents => index.Keys;

readonly Dictionary<string, Entry> index = new();
readonly Dictionary<string, Entry> index;
readonly Stream s;
readonly long dataStart = 255;

Expand All @@ -63,7 +63,8 @@ public InstallShieldPackage(Stream s, string filename)
s.Position = tocAddress;

// Parse directories
var directories = new Dictionary<string, uint>();
var directories = new Dictionary<string, uint>(dirCount);
var totalFileCount = 0;
for (var i = 0; i < dirCount; i++)
{
// Parse directory header
Expand All @@ -75,12 +76,16 @@ public InstallShieldPackage(Stream s, string filename)
// Skip to the end of the chunk
s.Position += chunkSize - nameLength - 6;
directories.Add(dirName, fileCount);
totalFileCount += fileCount;
}

// Parse files
index = new Dictionary<string, Entry>(totalFileCount);
foreach (var dir in directories)
for (var i = 0; i < dir.Value; i++)
ParseFile(dir.Key);

index.TrimExcess();
}
catch
{
Expand Down
3 changes: 3 additions & 0 deletions OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public abstract class SupportPowerInfo : PausableConditionalTraitInfo
[Desc("Palette used for the icon.")]
public readonly string IconPalette = "chrome";

[TranslationReference(optional: true)]
public readonly Dictionary<int, string> Names = new();

[TranslationReference(optional: true)]
public readonly Dictionary<int, string> Descriptions = new();

[Desc("Allow multiple instances of the same support power.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipCon
var costSize = costFont.Measure(costString);
var level = sp.GetLevel();
var nameText = sp.Info.Names.First(ld => ld.Key == level).Value;
var nameText = TranslationProvider.GetString(sp.Info.Names.First(ld => ld.Key == level).Value);
nameLabel.GetText = () => nameText;
var nameSize = nameFont.Measure(nameText);
var descText = sp.Info.Descriptions.First(ld => ld.Key == level).Value.Replace("\\n", "\n");
var descText = TranslationProvider.GetString(sp.Info.Descriptions.First(ld => ld.Key == level).Value);
descLabel.GetText = () => descText;
var descSize = descFont.Measure(descText);
Expand Down
8 changes: 6 additions & 2 deletions OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ namespace OpenRA.Mods.Common.Widgets
{
public class SupportPowerTimerWidget : Widget
{
[TranslationReference("player", "support-power", "time")]
const string Format = "support-power-timer";

public readonly string Font = "Bold";
public readonly string Format = "{0}'s {1}: {2}";
public readonly TextAlign Align = TextAlign.Left;
public readonly TimerOrder Order = TimerOrder.Descending;

Expand Down Expand Up @@ -58,7 +60,9 @@ public override void Tick()
var level = p.GetLevel();
var self = p.Instances[0].Self;
var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep);
var text = Format.FormatCurrent(self.Owner.PlayerName, p.Info.Names.First(ld => ld.Key == level).Value, time);
var supportPowerName = TranslationProvider.GetString(p.Info.Names.First(ld => ld.Key == level).Value);
var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.PlayerName, "support-power", supportPowerName, "time", time));
var playerColor = self.Owner.Color;
if (Game.Settings.Game.UsePlayerStanceColors)
Expand Down
2 changes: 2 additions & 0 deletions OpenRA.Mods.D2k/PackageLoaders/D2kSoundResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public D2kSoundResources(Stream s, string filename)
var length = s.ReadUInt32();
index.Add(name, new Entry(offset, length));
}

index.TrimExcess();
}
catch
{
Expand Down
9 changes: 9 additions & 0 deletions mods/cnc/languages/rules/en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ actor-hq =
.description = Provides radar and Air Strike support power.
Unlocks higher-tech units and buildings.
Requires power to operate.
.airstrikepower-name = Air Strike
.airstrikepower-description = Deploy an aerial napalm strike.
Burns buildings and infantry along a line.
actor-fix =
.name = Repair Facility
Expand All @@ -343,12 +346,18 @@ actor-eye =
.description = Provides radar and Orbital Ion Cannon support power.
Unlocks Mammoth Tank and Commando.
Requires power to operate.
.ioncannonpower-name = Ion Cannon
.ioncannonpower-description = Initiate an Ion Cannon strike.
Applies instant damage to a small area.
actor-tmpl =
.name = Temple of Nod
.description = Provides Nuclear Strike support power.
Unlocks Stealth Tank, Chem. Warrior and Obelisk of Light.
Requires power to operate.
.nukepower-name = Nuclear Strike
.nukepower-description = Launch a tactical nuclear warhead.
Applies heavy damage over a large area.
actor-gun =
.name = Turret
Expand Down
Loading

0 comments on commit 825b259

Please sign in to comment.