Fix dungeon state visibility regression and document client follow-ups

- Add safe sprite-config deserialization to prevent DUNGEON_STATE tick failures when mob sprite JSON is invalid

- Include definitionId consistently in mob payloads and preserve one-time mob catalog flow for client art preload

- Send active portals on every state update to avoid portal disappearance under spatial throttling

- Add root pending-clientChanges.md documenting required client handling for spatially filtered mobs, mobCatalog, and portal state
This commit is contained in:
dingo
2026-02-09 08:44:47 -05:00
parent 40a000be92
commit f8f8b45ecb
3 changed files with 60 additions and 11 deletions
+21 -9
View File
@@ -104,6 +104,22 @@ public sealed partial class DungeonHandler : IClientMessageHandler
}
}
private static object? DeserializeSpriteConfigSafe(string? spriteConfigJson)
{
if (string.IsNullOrWhiteSpace(spriteConfigJson))
return null;
try
{
// Keep JSON structure intact for client-side consumers.
return JsonSerializer.Deserialize<JsonElement>(spriteConfigJson);
}
catch
{
return null;
}
}
public IReadOnlyCollection<int> SupportedOpCodes => new[]
{
DungeonOpCodes.HUB_STATE,
@@ -829,8 +845,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
y = m.Y,
health = m.Health,
maxHealth = m.MaxHealth,
spriteConfig = string.IsNullOrEmpty(m.SpriteConfigJson) ? null :
System.Text.Json.JsonSerializer.Deserialize<object>(m.SpriteConfigJson),
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
tintColor = m.TintColor,
scale = m.Scale
}),
@@ -2851,8 +2866,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
health = m.Health,
maxHealth = m.MaxHealth,
state = m.State.ToString().ToLower(),
spriteConfig = string.IsNullOrEmpty(m.SpriteConfigJson) ? null :
System.Text.Json.JsonSerializer.Deserialize<object>(m.SpriteConfigJson),
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
tintColor = m.TintColor,
scale = m.Scale
}),
@@ -2861,8 +2875,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
id = m.Id,
definitionId = m.DefinitionId,
name = m.Name,
spriteConfig = string.IsNullOrEmpty(m.SpriteConfigJson) ? null :
System.Text.Json.JsonSerializer.Deserialize<object>(m.SpriteConfigJson),
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
tintColor = m.TintColor,
scale = m.Scale
}) : null,
@@ -2886,9 +2899,8 @@ public sealed partial class DungeonHandler : IClientMessageHandler
y = i.Y
}),
portals = (sendSpatialThisTick
? sim.Portals.Values.Where(p => p.IsActive && (!spatialFiltering || IsNearby(p.X, p.Y)))
: sim.Portals.Values.Where(p => p.IsActive && p.Type == PortalType.Exit))
portals = sim.Portals.Values
.Where(p => p.IsActive)
.Select(p => new
{
id = p.Id,