Fix map renderer error when painting decals with paths that start with /Textures (#16822)

This commit is contained in:
DrSmugleaf
2023-05-25 18:46:27 -07:00
committed by GitHub
parent 9f3f3b4998
commit ca8adf10aa
3 changed files with 12 additions and 18 deletions

View File

@@ -2,17 +2,4 @@
namespace Content.MapRenderer.Painters;
public sealed class DecalData
{
public DecalData(Decal decal, float x, float y)
{
Decal = decal;
X = x;
Y = y;
}
public Decal Decal;
public float X;
public float Y;
}
public readonly record struct DecalData(Decal Decal, float X, float Y);

View File

@@ -28,7 +28,7 @@ public sealed class DecalPainter
_sPrototypeManager = server.ResolveDependency<IPrototypeManager>();
}
public void Run(Image canvas, List<DecalData> decals)
public void Run(Image canvas, Span<DecalData> decals)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
@@ -48,7 +48,7 @@ public sealed class DecalPainter
Run(canvas, decal);
}
Console.WriteLine($"{nameof(DecalPainter)} painted {decals.Count} decals in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
Console.WriteLine($"{nameof(DecalPainter)} painted {decals.Length} decals in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
}
private void Run(Image canvas, DecalData data)
@@ -67,7 +67,13 @@ public sealed class DecalPainter
}
else if (sprite is SpriteSpecifier.Rsi rsi)
{
stream = _cResourceCache.ContentFileRead($"/Textures/{rsi.RsiPath}/{rsi.RsiState}.png");
var path = $"{rsi.RsiPath}/{rsi.RsiState}.png";
if (!path.StartsWith("/Textures"))
{
path = $"/Textures/{path}";
}
stream = _cResourceCache.ContentFileRead(path);
}
else
{

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Content.Shared.Decals;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
@@ -57,7 +58,7 @@ namespace Content.MapRenderer.Painters
// Decals are always painted before entities, and are also optional.
if (_decals.TryGetValue(grid.Owner, out var decals))
_decalPainter.Run(gridCanvas, decals);
_decalPainter.Run(gridCanvas, CollectionsMarshal.AsSpan(decals));
_entityPainter.Run(gridCanvas, entities);