feat(net): port retail physics spawn and event timestamps
Parse the complete PhysicsDesc plus F754/F755 packets, correct every PhysicsState bit, and gate all nine retail update channels with generation-safe immutable snapshots. Preserve ForcePosition, teleport, placement, velocity, parent, pickup, delete, and same-generation CreateObject ordering from the named client. Separate accepted logical lifecycle notifications from retained UI qualities, make GUID replacement and session reset clear every projection exactly once, and add packet, wraparound, malformed-input, parent FIFO, canonical-position, reconnect, and GUID-reuse conformance coverage. Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
parent
d53fe30ffe
commit
8a5d77f7f4
50 changed files with 3809 additions and 649 deletions
|
|
@ -12,9 +12,8 @@ namespace AcDream.Core.Net.Tests;
|
|||
/// ctor opens a UDP socket), so the subscription wiring is tested via the guard
|
||||
/// logic extracted as a local handler — this is the same lambda body that
|
||||
/// ObjectTableWiring.Wire wires to session.EntityDeleted. The retail two-table
|
||||
/// semantics are: PickupEvent (0xF74A) removes from the 3-D object_table but
|
||||
/// KEEPS the weenie in ClientObjectTable; DeleteObject (0xF747) evicts the
|
||||
/// weenie from both. FromPickup = true guards the eviction.
|
||||
/// semantics are: PickupEvent (0xF74A) is routed separately and keeps the
|
||||
/// weenie; DeleteObject (0xF747) evicts it from both projections.
|
||||
/// </summary>
|
||||
public sealed class ObjectTableWiringTests
|
||||
{
|
||||
|
|
@ -148,13 +147,6 @@ public sealed class ObjectTableWiringTests
|
|||
Assert.Equal(1, playerChanges);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The handler that ObjectTableWiring.Wire subscribes to session.EntityDeleted.
|
||||
// Testing it directly avoids needing a live WorldSession (UDP socket).
|
||||
// -------------------------------------------------------------------------
|
||||
private static Action<DeleteObject.Parsed> MakeEntityDeletedHandler(ClientObjectTable table)
|
||||
=> d => { if (!d.FromPickup) table.Remove(d.Guid); };
|
||||
|
||||
private static WeenieData MinimalWeenie(uint guid) => new(
|
||||
Guid: guid,
|
||||
Name: "Test Item",
|
||||
|
|
@ -180,47 +172,90 @@ public sealed class ObjectTableWiringTests
|
|||
Workmanship: null);
|
||||
|
||||
/// <summary>
|
||||
/// PickupEvent path: FromPickup = true → weenie is RETAINED in ClientObjectTable.
|
||||
/// The 3-D render entity is removed (EntityDeleted still fires), but the weenie
|
||||
/// data persists so the follow-up InventoryPutObjInContainer can find it.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void EntityDeleted_FromPickupTrue_RetainsWeenieInTable()
|
||||
{
|
||||
var table = new ClientObjectTable();
|
||||
var handler = MakeEntityDeletedHandler(table);
|
||||
|
||||
const uint guid = 0x80000100u;
|
||||
table.Ingest(MinimalWeenie(guid));
|
||||
Assert.NotNull(table.Get(guid)); // pre-condition: item is in the table
|
||||
|
||||
// Fire EntityDeleted as WorldSession does for PickupEvent (0xF74A).
|
||||
// The handler itself represents the EntityDeleted subscription — firing it IS the event.
|
||||
handler(new DeleteObject.Parsed(guid, 0, FromPickup: true));
|
||||
|
||||
// Post-condition: weenie still in table (it moved into a container, was NOT destroyed).
|
||||
// EntityDeleted still fires (the handler ran), so the 3-D render layer would remove the WorldEntity.
|
||||
Assert.NotNull(table.Get(guid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DeleteObject path: FromPickup = false → weenie IS evicted from ClientObjectTable.
|
||||
/// DeleteObject is a true destroy and evicts the weenie from ClientObjectTable.
|
||||
/// Regression guard — true destroys (0xF747) must still clean up the table.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void EntityDeleted_FromPickupFalse_EvictsWeenieFromTable()
|
||||
public void EntityDeleted_EvictsWeenieFromTable()
|
||||
{
|
||||
var table = new ClientObjectTable();
|
||||
var handler = MakeEntityDeletedHandler(table);
|
||||
|
||||
const uint guid = 0x80000200u;
|
||||
table.Ingest(MinimalWeenie(guid));
|
||||
Assert.NotNull(table.Get(guid)); // pre-condition: item is in the table
|
||||
|
||||
// Fire EntityDeleted as WorldSession does for DeleteObject (0xF747).
|
||||
handler(new DeleteObject.Parsed(guid, 0, FromPickup: false));
|
||||
ObjectTableWiring.ApplyEntityDelete(
|
||||
table, new DeleteObject.Parsed(guid, 0));
|
||||
|
||||
// Post-condition: weenie evicted (truly destroyed).
|
||||
Assert.Null(table.Get(guid));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NewGenerationCreateObject_ReplacesPriorQualities()
|
||||
{
|
||||
const uint guid = 0x80000300u;
|
||||
var table = new ClientObjectTable();
|
||||
ClientObject old = table.Ingest(MinimalWeenie(guid));
|
||||
old.Properties.Ints[123u] = 456;
|
||||
|
||||
var stale = new WorldSession.EntitySpawn(
|
||||
Guid: guid,
|
||||
Position: null,
|
||||
SetupTableId: null,
|
||||
AnimPartChanges: [],
|
||||
TextureChanges: [],
|
||||
SubPalettes: [],
|
||||
BasePaletteId: null,
|
||||
ObjScale: null,
|
||||
Name: "Stale Name",
|
||||
ItemType: null,
|
||||
MotionState: null,
|
||||
MotionTableId: null);
|
||||
|
||||
int removed = 0;
|
||||
int generationRemoved = 0;
|
||||
table.ObjectRemoved += _ => removed++;
|
||||
table.ObjectRemovalClassified += removal =>
|
||||
{
|
||||
if (removal.Reason == ClientObjectRemovalReason.GenerationReplacement)
|
||||
generationRemoved++;
|
||||
};
|
||||
|
||||
ObjectTableWiring.ApplyEntitySpawn(table, stale, replaceGeneration: true);
|
||||
|
||||
Assert.Equal("Stale Name", table.Get(guid)!.Name);
|
||||
Assert.False(table.Get(guid)!.Properties.Ints.ContainsKey(123u));
|
||||
Assert.Equal(1, removed);
|
||||
Assert.Equal(1, generationRemoved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameGenerationCreateObject_MergesPriorQualities()
|
||||
{
|
||||
const uint guid = 0x80000400u;
|
||||
var table = new ClientObjectTable();
|
||||
ClientObject old = table.Ingest(MinimalWeenie(guid));
|
||||
old.Properties.Ints[123u] = 456;
|
||||
|
||||
var refresh = new WorldSession.EntitySpawn(
|
||||
Guid: guid,
|
||||
Position: null,
|
||||
SetupTableId: null,
|
||||
AnimPartChanges: [],
|
||||
TextureChanges: [],
|
||||
SubPalettes: [],
|
||||
BasePaletteId: null,
|
||||
ObjScale: null,
|
||||
Name: "Refreshed Name",
|
||||
ItemType: null,
|
||||
MotionState: null,
|
||||
MotionTableId: null);
|
||||
|
||||
ObjectTableWiring.ApplyEntitySpawn(table, refresh);
|
||||
|
||||
Assert.NotNull(table.Get(guid));
|
||||
Assert.Equal("Refreshed Name", table.Get(guid)!.Name);
|
||||
Assert.Equal(456, table.Get(guid)!.Properties.Ints[123u]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue