Skip to content

Commit

Permalink
Fix an error in OnNewAppearance() (#2182)
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit authored Jan 24, 2025
1 parent b90c210 commit 114e76e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion OpenDreamClient/Interface/Html/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static class HtmlParser {
private const string TagNotClosedError = "HTML tag was not closed";

private static readonly ISawmill Sawmill;
private static readonly HashSet<string> WarnedAttributes = new();

static HtmlParser() {
Sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("opendream.html_parser");
Expand Down Expand Up @@ -169,7 +170,8 @@ private static Dictionary<string, MarkupParameter> ParseAttributes(string[] attr
parameter = new(color);
break;
default:
Sawmill.Debug($"Unimplemented HTML attribute \"{attributeName}\"");
if (WarnedAttributes.Add(attributeName))
Sawmill.Debug($"Unimplemented HTML attribute \"{attributeName}\"");
continue;
}

Expand Down
15 changes: 12 additions & 3 deletions OpenDreamClient/Rendering/ClientAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal sealed class ClientAppearanceSystem : SharedAppearanceSystem {
private readonly Dictionary<uint, List<Action<ImmutableAppearance>>> _appearanceLoadCallbacks = new();
private readonly Dictionary<uint, DreamIcon> _turfIcons = new();
private readonly Dictionary<DreamFilter, ShaderInstance> _filterShaders = new();
private bool _receivedAllAppearancesMsg;

[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IDreamResourceManager _dreamResourceManager = default!;
Expand All @@ -30,13 +31,17 @@ public override void Initialize() {
}

public override void Shutdown() {
_receivedAllAppearancesMsg = false;
_appearances.Clear();
_appearanceLoadCallbacks.Clear();
_turfIcons.Clear();
_filterShaders.Clear();
}

public void SetAllAppearances(Dictionary<uint, ImmutableAppearance> appearances) {
_appearances = appearances;
_receivedAllAppearancesMsg = true;

//need to do this because all overlays can't be resolved until the whole appearance table is populated
foreach(KeyValuePair<uint, ImmutableAppearance> pair in _appearances) {
pair.Value.ResolveOverlays(this);
Expand Down Expand Up @@ -73,10 +78,14 @@ public DreamIcon GetTurfIcon(uint turfId) {
public void OnNewAppearance(MsgNewAppearance e) {
uint appearanceId = e.Appearance.MustGetId();
_appearances[appearanceId] = e.Appearance;
_appearances[appearanceId].ResolveOverlays(this);

if (_appearanceLoadCallbacks.TryGetValue(appearanceId, out var callbacks)) {
foreach (var callback in callbacks) callback(_appearances[appearanceId]);
// If we haven't received the MsgAllAppearances yet, leave this initialization for later
if (_receivedAllAppearancesMsg) {
_appearances[appearanceId].ResolveOverlays(this);

if (_appearanceLoadCallbacks.TryGetValue(appearanceId, out var callbacks)) {
foreach (var callback in callbacks) callback(_appearances[appearanceId]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion OpenDreamClient/Rendering/DreamViewOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private DreamPlane GetPlane(int planeIndex, Vector2i viewportSize) {

plane = new(renderTarget);
_planes.Add(planeIndex, plane);
_sawmill.Info($"Created plane {planeIndex}");
_sawmill.Verbose($"Created plane {planeIndex}");
return plane;
}

Expand Down

0 comments on commit 114e76e

Please sign in to comment.