feat(core): D.2b-B B-Wire — ClientObjectTable.UpdateStackSize
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b56087b498
commit
3f190811be
2 changed files with 34 additions and 0 deletions
|
|
@ -205,6 +205,20 @@ public sealed class ClientObjectTable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply a SetStackSize (0x0197) update: set the object's StackSize + Value and
|
||||||
|
/// fire ObjectUpdated so bound widgets refresh the quantity overlay. False if the
|
||||||
|
/// object is unknown. Retail: ACCWeenieObject::ServerSaysSetStackSize (0x0058...).
|
||||||
|
/// </summary>
|
||||||
|
public bool UpdateStackSize(uint guid, int stackSize, int value)
|
||||||
|
{
|
||||||
|
if (!_objects.TryGetValue(guid, out var item)) return false;
|
||||||
|
item.StackSize = stackSize;
|
||||||
|
item.Value = value;
|
||||||
|
ObjectUpdated?.Invoke(item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Canonical CreateObject ingestion: create-if-absent, else patch the
|
/// Canonical CreateObject ingestion: create-if-absent, else patch the
|
||||||
/// wire-carried fields in place (retail SetWeenieDesc). Preserves the
|
/// wire-carried fields in place (retail SetWeenieDesc). Preserves the
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,24 @@ public sealed class ClientObjectTableUpdateTests
|
||||||
Assert.Equal(99, t.Get(0x50000001u)!.Properties.Ints[5]);
|
Assert.Equal(99, t.Get(0x50000001u)!.Properties.Ints[5]);
|
||||||
Assert.True(updated);
|
Assert.True(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UpdateStackSize_knownObject_setsFieldsAndFiresUpdated()
|
||||||
|
{
|
||||||
|
var t = new ClientObjectTable();
|
||||||
|
t.AddOrUpdate(new ClientObject { ObjectId = 0x600u, StackSize = 1, Value = 5 });
|
||||||
|
bool updated = false;
|
||||||
|
t.ObjectUpdated += _ => updated = true;
|
||||||
|
|
||||||
|
bool ok = t.UpdateStackSize(0x600u, stackSize: 25, value: 125);
|
||||||
|
|
||||||
|
Assert.True(ok);
|
||||||
|
Assert.Equal(25, t.Get(0x600u)!.StackSize);
|
||||||
|
Assert.Equal(125, t.Get(0x600u)!.Value);
|
||||||
|
Assert.True(updated);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UpdateStackSize_unknownObject_returnsFalse()
|
||||||
|
=> Assert.False(new ClientObjectTable().UpdateStackSize(0xDEADu, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue