From d8e4e7430b55fb04941f1f65bfacb246a6963f35 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 9 Feb 2026 09:14:08 -0500 Subject: [PATCH] Standardize mob payloads and refresh pending client requirements - Include isAlive in dungeon state and join mob payloads for consistent render lifecycle - Add mobCatalog to dungeon enter responses so clients can bootstrap mob art deterministically - Filter DUNGEON_STATE visible mobs to alive mobs to avoid stale/dead entity feed - Rewrite pending-clientChanges.md to reflect no mandatory remaining client work --- Game/Dungeon/DungeonHandler.Dungeons.cs | 10 ++++++ Game/Dungeon/DungeonHandler.cs | 12 ++++++- pending-clientChanges.md | 42 +++++-------------------- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/Game/Dungeon/DungeonHandler.Dungeons.cs b/Game/Dungeon/DungeonHandler.Dungeons.cs index f14fb2d..f8e0b22 100644 --- a/Game/Dungeon/DungeonHandler.Dungeons.cs +++ b/Game/Dungeon/DungeonHandler.Dungeons.cs @@ -422,11 +422,21 @@ public sealed partial class DungeonHandler rotation = m.Rotation, health = m.Health, maxHealth = m.MaxHealth, + isAlive = m.IsAlive, state = m.State.ToString().ToLower(), spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), tintColor = m.TintColor, scale = m.Scale }), + mobCatalog = instance.Simulation.Mobs.Values.Select(m => new + { + id = m.Id, + definitionId = m.DefinitionId, + name = m.Name, + spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), + tintColor = m.TintColor, + scale = m.Scale + }), chests = instance.Simulation.Chests.Values.Select(c => new { id = c.Id, diff --git a/Game/Dungeon/DungeonHandler.cs b/Game/Dungeon/DungeonHandler.cs index ba0194b..91d3b72 100644 --- a/Game/Dungeon/DungeonHandler.cs +++ b/Game/Dungeon/DungeonHandler.cs @@ -852,6 +852,15 @@ public sealed partial class DungeonHandler : IClientMessageHandler tintColor = m.TintColor, scale = m.Scale }), + mobCatalog = instance.Simulation.Mobs.Values.Select(m => new + { + id = m.Id, + definitionId = m.DefinitionId, + name = m.Name, + spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), + tintColor = m.TintColor, + scale = m.Scale + }), chests = instance.Simulation.Chests.Values.Select(c => new { id = c.Id, @@ -2810,7 +2819,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler var visiblePlayerIds = visiblePlayers.Select(p => p.CharacterId).ToHashSet(); var nearbyOrRelevantMobs = sim.Mobs.Values - .Where(m => !spatialFiltering || IsNearby(m.X, m.Y) || m.TargetId == session.CharacterId) + .Where(m => m.IsAlive && (!spatialFiltering || IsNearby(m.X, m.Y) || m.TargetId == session.CharacterId)) .ToList(); var visibleMobs = sendSpatialThisTick ? nearbyOrRelevantMobs @@ -2868,6 +2877,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler rotation = m.Rotation, health = m.Health, maxHealth = m.MaxHealth, + isAlive = m.IsAlive, state = m.State.ToString().ToLower(), spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson), tintColor = m.TintColor, diff --git a/pending-clientChanges.md b/pending-clientChanges.md index c751108..ed121c0 100644 --- a/pending-clientChanges.md +++ b/pending-clientChanges.md @@ -1,38 +1,10 @@ # Pending Client Changes -## Context -Server-side dungeon state payloads now support spatial filtering and one-time mob metadata delivery per dungeon session. +## Status +No mandatory client changes are currently required for the latest server fixes. -## Required Client Updates -1. Support `mobCatalog` on `DUNGEON_STATE` packets. -- `mobCatalog` is sent once per dungeon join and contains static mob render metadata: - - `id` - - `definitionId` - - `name` - - `spriteConfig` - - `tintColor` - - `scale` -- Client should cache this per-runtime mob `id` and use it to preload/resolve art. - -2. Do not assume all mobs are present every tick. -- With spatial filtering enabled, `mobs` in `DUNGEON_STATE` only includes nearby/relevant mobs. -- Client entity lifecycle should be "visibility-scoped", not "full authoritative list each tick". -- Recommended behavior: - - Keep existing mob entities when omitted for a tick (out of range), do not hard-delete immediately. - - Remove only when confirmed dead/despawned via explicit state/event signal or timeout policy. - -3. Use `definitionId` when available. -- `definitionId` is now included in enter/state mob payloads. -- Client can use this for fallback art resolution or future dictionary-based rendering. - -4. Portal rendering should treat payload as authoritative for active portals. -- Server now sends active portals each state packet regardless of spatial throttling. -- If client currently clears portals aggressively between packets, keep the most recent active set. - -## Optional Hardening -1. Handle missing/invalid `spriteConfig` gracefully. -- Server now nulls bad JSON instead of throwing. -- Client should apply safe defaults (placeholder sprite, default tint/scale) when `spriteConfig` is null. - -2. Add debug overlay for spatial tuning validation. -- Show current nearby mob count vs total known on minimap for live tuning checks. +## Notes +1. Server now includes `isAlive` consistently in mob payloads and sends `mobCatalog` on dungeon-enter responses and one-time in dungeon state. +2. If invisible mobs still occur, keep a fallback render path when `spriteConfig` is null: +- Use `definitionId` -> local/default sprite mapping. +- Apply default tint `#ffffff` and scale `1.0`.