Inventory: stamp an appraisal when it arrives
The original's appraisal time was the wall clock at the moment the appraisal came in. The reader stamped it when it first built the record, which for a coalesced update can be minutes later; the appraisal event now stamps it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7a6b0a7f9d
commit
c1e8a2cf18
3 changed files with 31 additions and 0 deletions
|
|
@ -424,7 +424,10 @@ internal sealed class InventoryFeature : IMmFeature
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (change.Kind == PluginObjectChangeKind.IdentReceived)
|
if (change.Kind == PluginObjectChangeKind.IdentReceived)
|
||||||
|
{
|
||||||
|
_reader.NoteAppraisal(change.ObjectId);
|
||||||
_identify.OnIdentReceived(change.ObjectId);
|
_identify.OnIdentReceived(change.ObjectId);
|
||||||
|
}
|
||||||
|
|
||||||
PluginWorldObject? current = change.Current;
|
PluginWorldObject? current = change.Current;
|
||||||
if (change.Kind == PluginObjectChangeKind.Released
|
if (change.Kind == PluginObjectChangeKind.Released
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,16 @@ internal sealed class InventoryReader
|
||||||
&& world.HasAppraisalData
|
&& world.HasAppraisalData
|
||||||
&& world.LastIdTime != 0;
|
&& world.LastIdTime != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stamps an appraisal as it arrives, so the record carries the time it
|
||||||
|
/// came in rather than the time the record was first built.
|
||||||
|
/// </summary>
|
||||||
|
public void NoteAppraisal(uint objectId)
|
||||||
|
{
|
||||||
|
if (_context.Automation.Objects.TryGet(objectId, out PluginWorldObject world) && world.LastIdTime != 0)
|
||||||
|
Stamp(objectId, world.LastIdTime);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>The item record for one owned item, as it stands now.</summary>
|
/// <summary>The item record for one owned item, as it stands now.</summary>
|
||||||
public MyWorldObject Build(in PluginInventoryItem item)
|
public MyWorldObject Build(in PluginInventoryItem item)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -252,4 +252,22 @@ public sealed class InventoryFeatureTests
|
||||||
|
|
||||||
Assert.Empty(harness.FramesOfTypeRaw("full_inventory"));
|
Assert.Empty(harness.FramesOfTypeRaw("full_inventory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void The_appraisal_time_is_the_wall_clock_when_the_appraisal_arrived()
|
||||||
|
{
|
||||||
|
using var harness = new PluginHarness("Mossy");
|
||||||
|
InventoryFeature feature = LoginAndSettle(harness);
|
||||||
|
Own(harness.Host, Tachi(appraised: false));
|
||||||
|
Raise(harness.Host, 0x80000202u, PluginObjectChangeKind.Created);
|
||||||
|
|
||||||
|
Own(harness.Host, Tachi(appraised: true), TachiProps(), hostIdTime: 5000);
|
||||||
|
Raise(harness.Host, 0x80000202u, PluginObjectChangeKind.IdentReceived);
|
||||||
|
harness.Clock.Advance(TimeSpan.FromMinutes(3));
|
||||||
|
harness.Frames.Clear();
|
||||||
|
feature.FlushDirtyItems();
|
||||||
|
|
||||||
|
JObject update = JObject.Parse(harness.FramesOfTypeRaw("inventory_delta").Single());
|
||||||
|
Assert.Equal(1790325015, (int)update["item"]!["LastIdTime"]!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue