feat(D.5.1): thread CreateObject IconId into ItemRepository via spawn event

Added uint IconId = 0 (defaulted, last positional param) to the EntitySpawn
record so existing call sites outside WorldSession compile unchanged. The
WorldSession invoke now passes parsed.Value.IconId as the final arg.
OnLiveEntitySpawned calls Items.EnrichItem unconditionally — it's a no-op
for non-item spawns (players/NPCs/furniture aren't in the repo), so the call
is safe for every incoming CreateObject.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-16 21:54:48 +02:00
parent 998a0bd408
commit 5382d0a9d2
2 changed files with 9 additions and 2 deletions

View file

@ -2495,6 +2495,10 @@ public sealed class GameWindow : IDisposable
/// </summary> /// </summary>
private void OnLiveEntitySpawned(AcDream.Core.Net.WorldSession.EntitySpawn spawn) private void OnLiveEntitySpawned(AcDream.Core.Net.WorldSession.EntitySpawn spawn)
{ {
// D.5.1: enrich a known inventory/equipped item (stubbed from PlayerDescription)
// with the icon/name/type its CreateObject carries, so the toolbar can render it.
Items.EnrichItem(spawn.Guid, spawn.IconId, spawn.Name ?? string.Empty, (AcDream.Core.Items.ItemType)(spawn.ItemType ?? 0));
// Phase A.1 hotfix: live CreateObject handler reads dats extensively // Phase A.1 hotfix: live CreateObject handler reads dats extensively
// (Setup, GfxObj, Surface, SurfaceTexture) to hydrate the spawned // (Setup, GfxObj, Surface, SurfaceTexture) to hydrate the spawned
// entity. All of it must run under the dat lock so it doesn't race // entity. All of it must run under the dat lock so it doesn't race

View file

@ -80,7 +80,9 @@ public sealed class WorldSession : IDisposable
// sizing hint for tall-scenery selection indicators when the // sizing hint for tall-scenery selection indicators when the
// server publishes it for non-useable display entities. // server publishes it for non-useable display entities.
uint? Useability = null, uint? Useability = null,
float? UseRadius = null); float? UseRadius = null,
// D.5.1: icon datId from CreateObject WeenieHeader, for toolbar rendering.
uint IconId = 0);
/// <summary>Fires when the session finishes parsing a CreateObject.</summary> /// <summary>Fires when the session finishes parsing a CreateObject.</summary>
public event Action<EntitySpawn>? EntitySpawned; public event Action<EntitySpawn>? EntitySpawned;
@ -716,7 +718,8 @@ public sealed class WorldSession : IDisposable
parsed.Value.Friction, parsed.Value.Friction,
parsed.Value.Elasticity, parsed.Value.Elasticity,
parsed.Value.Useability, parsed.Value.Useability,
parsed.Value.UseRadius)); parsed.Value.UseRadius,
parsed.Value.IconId));
} }
} }
else if (op == DeleteObject.Opcode) else if (op == DeleteObject.Opcode)