fix(inventory): complete switches on wield response
Clear retail AutoWield on the matching authoritative WieldObject instead of waiting for unrelated rollback bookkeeping to drain. This prevents a completed switch from consuming the next weapon activation locally, including crossbows. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
ea5cf5b842
commit
3e84027885
9 changed files with 47 additions and 21 deletions
|
|
@ -523,9 +523,15 @@ public sealed class ItemInteractionControllerTests
|
|||
Assert.Single(h.Puts);
|
||||
Assert.Single(h.Wields);
|
||||
|
||||
// Authoritative WieldObject + ConfirmMove completes the transaction.
|
||||
// A separate reconciliation record for the same item must not delay
|
||||
// retail's exact IR_WIELD completion boundary.
|
||||
Assert.True(h.Objects.WieldItemOptimistic(
|
||||
bow, Player, EquipMask.MissileWeapon));
|
||||
|
||||
// Authoritative WieldObject + ConfirmWield completes AutoWield even
|
||||
// though the object table still has another rollback record.
|
||||
h.Objects.MoveItem(bow, Player, -1, EquipMask.MissileWeapon);
|
||||
h.Objects.ConfirmMove(bow);
|
||||
h.Objects.ConfirmWield(bow);
|
||||
h.Now += 200;
|
||||
Assert.True(h.Controller.ActivateItem(sword));
|
||||
Assert.Equal(
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ public sealed class GameEventWiringTests
|
|||
items.AddOrUpdate(new ClientObject { ObjectId = 0x1500, WeenieClassId = 1 });
|
||||
items.MoveItem(0x1500, 0x9999u, newSlot: 0); // start in a pack
|
||||
items.WieldItemOptimistic(0x1500, player, EquipMask.MeleeWeapon); // optimistic wield → snapshot pending
|
||||
var wieldConfirmed = new List<uint>();
|
||||
items.WieldConfirmed += item => wieldConfirmed.Add(item.ObjectId);
|
||||
|
||||
byte[] payload = new byte[8];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(payload, 0x1500);
|
||||
|
|
@ -137,6 +139,7 @@ public sealed class GameEventWiringTests
|
|||
|
||||
Assert.False(items.RollbackMove(0x1500)); // pending snapshot was cleared by ConfirmMove
|
||||
Assert.Equal(player, items.Get(0x1500)!.ContainerId);
|
||||
Assert.Equal(new[] { 0x1500u }, wieldConfirmed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ public sealed class ClientObjectTableTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void ConfirmMove_publishesOnlyAfterFinalOutstandingRequest()
|
||||
public void ConfirmWield_publishesIndependentlyOfRollbackOutstandingCount()
|
||||
{
|
||||
var table = new ClientObjectTable();
|
||||
const uint item = 0x944u, player = 0x50000001u, pack = 0x40000005u;
|
||||
|
|
@ -753,13 +753,12 @@ public sealed class ClientObjectTableTests
|
|||
table.WieldItemOptimistic(item, player, EquipMask.MeleeWeapon);
|
||||
table.MoveItemOptimistic(item, pack, 0);
|
||||
var confirmed = new List<uint>();
|
||||
table.MoveRequestConfirmed += moved => confirmed.Add(moved.ObjectId);
|
||||
table.WieldConfirmed += moved => confirmed.Add(moved.ObjectId);
|
||||
|
||||
table.ConfirmMove(item);
|
||||
Assert.Empty(confirmed);
|
||||
table.ConfirmWield(item);
|
||||
|
||||
table.ConfirmMove(item);
|
||||
Assert.Equal(new[] { item }, confirmed);
|
||||
Assert.True(table.RollbackMove(item));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue