Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an error in OnNewAppearance() #2182

Merged
merged 1 commit into from
Jan 24, 2025
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
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
Loading