fix(inventory): await final wield confirmation
Keep the retail inventory transaction busy until authoritative WieldObject confirms the requested weapon. This prevents rapid weapon changes from overlapping on ACE and rejecting otherwise valid items such as spears. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
815ce0dec4
commit
ea5cf5b842
8 changed files with 115 additions and 9 deletions
|
|
@ -66,6 +66,8 @@ internal sealed class AutoWieldController : IDisposable
|
|||
private PendingSwitch? _pendingSwitch;
|
||||
private bool _disposed;
|
||||
|
||||
public bool IsBusy => _pendingSwitch is not null;
|
||||
|
||||
public AutoWieldController(
|
||||
ClientObjectTable objects,
|
||||
Func<uint> playerGuid,
|
||||
|
|
@ -82,6 +84,7 @@ internal sealed class AutoWieldController : IDisposable
|
|||
_objects.ObjectMoved += OnObjectMoved;
|
||||
_objects.ObjectRemoved += OnObjectRemoved;
|
||||
_objects.MoveRequestFailed += OnMoveRequestFailed;
|
||||
_objects.MoveRequestConfirmed += OnMoveRequestConfirmed;
|
||||
_objects.Cleared += OnObjectsCleared;
|
||||
}
|
||||
|
||||
|
|
@ -160,8 +163,12 @@ internal sealed class AutoWieldController : IDisposable
|
|||
{
|
||||
if (_sendWield is null)
|
||||
return false;
|
||||
_pendingSwitch = new PendingSwitch(item.ObjectId, BlockingItemId: 0);
|
||||
if (!_objects.WieldItemOptimistic(item.ObjectId, _playerGuid(), mask))
|
||||
{
|
||||
_pendingSwitch = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Retail ACCWeenieObject::UIAttemptWield @ 0x0058D590.
|
||||
_sendWield(item.ObjectId, (uint)mask);
|
||||
|
|
@ -171,6 +178,7 @@ internal sealed class AutoWieldController : IDisposable
|
|||
private void OnObjectMoved(ClientObject item, uint _, uint newContainerId)
|
||||
{
|
||||
if (_pendingSwitch is not { } pending
|
||||
|| pending.BlockingItemId == 0
|
||||
|| item.ObjectId != pending.BlockingItemId
|
||||
|| newContainerId != _playerGuid()
|
||||
|| item.CurrentlyEquippedLocation != EquipMask.None)
|
||||
|
|
@ -183,6 +191,13 @@ internal sealed class AutoWieldController : IDisposable
|
|||
TryWield(requested);
|
||||
}
|
||||
|
||||
private void OnMoveRequestConfirmed(ClientObject item)
|
||||
{
|
||||
if (_pendingSwitch is { BlockingItemId: 0 } pending
|
||||
&& item.ObjectId == pending.RequestedItemId)
|
||||
_pendingSwitch = null;
|
||||
}
|
||||
|
||||
private void OnMoveRequestFailed(MoveRequestFailure failure)
|
||||
{
|
||||
if (_pendingSwitch is { } pending
|
||||
|
|
@ -304,6 +319,7 @@ internal sealed class AutoWieldController : IDisposable
|
|||
_objects.ObjectMoved -= OnObjectMoved;
|
||||
_objects.ObjectRemoved -= OnObjectRemoved;
|
||||
_objects.MoveRequestFailed -= OnMoveRequestFailed;
|
||||
_objects.MoveRequestConfirmed -= OnMoveRequestConfirmed;
|
||||
_objects.Cleared -= OnObjectsCleared;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue