fix(interaction): port retail's wielded-item pickup rejection (Slice 4 F1)
Slice 4 made a remote character's wielded weapon selectable, which made the
pickup chain reachable end to end for the first time: SelectionPickUp on
another player's weapon captured identity, passed ValidatePickupTarget (which
checked only the Stuck flag and the small-item mask, and a MeleeWeapon clears
both), installed a real non-autonomous approach through
PlayerInteractionMovementSink, and then sent a pickup request the server
rejects. Retail does none of that.
ItemHolder::AttemptToPlaceInContainer @ 0x00588140 runs
AttemptToPlaceInContainer_IsItemLegal @ 0x005870C0 first, at 0x00588173 --
ahead of container legality, auto-merge, the container walk, and the only
CM_Inventory::Event_PutItemInContainer emitter
(ACCWeenieObject::UIAttemptPutInContainer @ 0x0058D680). IsItemLegal's arm at
0x005872B7 rejects `!ACCWeenieObject::IsOwnedByPlayer(item) &&
item->pwd._location != 0` with one local
ECM_UI::SendNotice_DisplayStringInfo(0x1a, ...), and
CPlayerSystem::PlaceInBackpack @ 0x0055D8C0 then withdraws the waiting slot it
had published (SetWaitingState(obj, 0) + SendNotice_EndPendingInPlayer at
0x0055D918). No request, no movement. acdream had never ported that arm; it
was harmless while wielded children were unpickable and stopped being harmless
at f6db964f.
The notice is data_7e2228, "The %s is being wielded by someone else!" -- WITH
the exclamation mark. IsItemLegal's six strings occupy one contiguous literal
block, 0x007e21f0 through 0x007e234c, one per arm in reverse code order, and
the two neighbours already ported here (0x007e227c "The %s cannot be picked
up!" at 0x00587264, 0x007e22b4 "You cannot pick up creatures!" at 0x005871f4)
pin it. The punctuation-free 0x007cd350 variant belongs to the wield/wear
block and is emitted from a different function at 0x00560aef.
pwd._location is the PublicWeenieDesc CurrentWieldedLocation field
(acclient.h:37175), which acdream projects as
ClientObject.CurrentlyEquippedLocation, and ACCWeenieObject::IsOwnedByPlayer
@ 0x0058D160 is IsOwnedByObject(this, player_id) -- already ported as
ClientObjectTable.IsOwnedByObject @ 0x0058CEB0 and reached here through the
existing ItemInteractionController.IsOwnedByPlayer. The arm reads pwd._location
verbatim rather than adding a WielderId belt-and-braces test, because retail's
predicate is the thing being ported.
The player's OWN wielded item is IsOwnedByPlayer, so retail passes it and takes
a different route. ACCWeenieObject::DeterminePositionState @ 0x0058BE70 gives
it PositionState.WIELDED (acclient.h:6802) rather than IN_3D_VIEW, and
UIAttemptPutInContainer records IR_PICK_UP only for IN_3D_VIEW, treating
WIELDED and IN_CONTAINER alike as a plain IR_PUT_IN_CONTAINER transfer. So an
own-wielded item is unwielded in place: the request goes out immediately with
no approach, joining the existing current-ground-object shortcut. The shortcut
carries an ownership conjunct so it can never outrun the 0x005872B7 gate.
TryGetApproach now refuses attached children outright, for the same
IN_3D_VIEW reason. An Attached projection's bookkeeping WorldEntity.Position
carries the PARENT's composed root (EquippedChildRenderController
.ApplyParentWorldPose), not the child frame CPhysicsObj::UpdateChild @
0x00512D50 composes, so an approach built from it walked toward the wielder.
Slice 4 de-parented the marker anchor but left this one parent-derived; no
approach can anchor on a wielder now.
The pick predicates are deliberately untouched. Picking, selecting, examining,
lighting-pulse identity, and the vivid-marker anchor on a remote's wielded
weapon all behave exactly as Slice 4 shipped them -- retail's sr_Select and
sr_Examine branches of RecvNotice_SmartBoxObjectFound @ 0x004E5AD0 never
consult IsItemLegal. The gate is the transaction, not the pick.
f6db964f's message asserted the slice introduced no deviation and owed no
retail-divergence-register row. That was wrong: the unported 0x005872B7 arm
was a deviation it made reachable. This commit ports the arm in full, matches
retail on the own-wielded path, and removes the parent-derived approach
anchor, so the record is corrected here and no register row is owed.
Gates: dotnet build green; AcDream.App.Tests 3,960 passed / 3 skipped;
complete Release solution 9,792 passed / 5 skipped;
tools\run-connected-world-lifecycle-gate.ps1 -SkipBuild RESULT=PASS.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f6db964fd5
commit
0ccbb4e52c
8 changed files with 442 additions and 5 deletions
|
|
@ -18,6 +18,10 @@ public sealed class SelectionInteractionControllerTests
|
|||
private const uint Player = 0x5000_0001u;
|
||||
private const uint Target = 0x7000_0001u;
|
||||
private const uint GroundContainer = 0x7000_0010u;
|
||||
private const uint Wielder = 0x7000_0100u;
|
||||
private const uint RemoteWeapon = 0x7000_0101u;
|
||||
private const uint OwnWeapon = 0x7000_0102u;
|
||||
private const uint GroundWeapon = 0x7000_0103u;
|
||||
|
||||
private sealed class Query : IWorldSelectionQuery
|
||||
{
|
||||
|
|
@ -29,6 +33,13 @@ public sealed class SelectionInteractionControllerTests
|
|||
public bool Useable { get; set; } = true;
|
||||
public bool Pickupable { get; set; } = true;
|
||||
public bool WieldedByPlayer { get; set; }
|
||||
/// <summary>
|
||||
/// Guids whose <c>ACCWeenieObject::DeterminePositionState @
|
||||
/// 0x0058BE70</c> result is <c>PositionState.WIELDED</c>. Ownership is
|
||||
/// NOT faked — the controller resolves it through the real
|
||||
/// <see cref="ClientObjectTable"/>.
|
||||
/// </summary>
|
||||
public HashSet<uint> WieldedPositionStates { get; } = new();
|
||||
public bool CaptureIdentity { get; set; } = true;
|
||||
public uint LocalEntityId { get; set; } = 101u;
|
||||
public ClosestCombatTarget? Closest { get; set; }
|
||||
|
|
@ -59,6 +70,8 @@ public sealed class SelectionInteractionControllerTests
|
|||
public bool IsUseable(uint serverGuid) => Useable;
|
||||
public bool IsPickupable(uint serverGuid) => Pickupable;
|
||||
public bool IsWieldedByPlayer(uint serverGuid) => WieldedByPlayer;
|
||||
public bool IsWieldedPositionState(uint serverGuid)
|
||||
=> WieldedPositionStates.Contains(serverGuid);
|
||||
public Vector3? GetCombatCameraTargetPoint(uint serverGuid) => null;
|
||||
|
||||
public bool TryGetApproach(uint serverGuid, out InteractionApproach approach)
|
||||
|
|
@ -194,19 +207,22 @@ public sealed class SelectionInteractionControllerTests
|
|||
Items.PendingBackpackPlacementCancelled += CancelledPlacements.Add;
|
||||
}
|
||||
|
||||
public void SetApproach(bool closeRange, uint localEntityId = 101u)
|
||||
public void SetApproach(
|
||||
bool closeRange,
|
||||
uint localEntityId = 101u,
|
||||
uint serverGuid = Target)
|
||||
{
|
||||
var entity = new WorldEntity
|
||||
{
|
||||
Id = localEntityId,
|
||||
ServerGuid = Target,
|
||||
ServerGuid = serverGuid,
|
||||
SourceGfxObjOrSetupId = 0x0200_0001u,
|
||||
Position = new Vector3(5f, 0f, 0f),
|
||||
Rotation = Quaternion.Identity,
|
||||
MeshRefs = [],
|
||||
};
|
||||
Query.Approach = new InteractionApproach(
|
||||
new WorldInteractionTarget(Target, localEntityId, entity),
|
||||
new WorldInteractionTarget(serverGuid, localEntityId, entity),
|
||||
new PlayerInteractionPose(0x0101_0001u, Vector3.Zero),
|
||||
0.6f,
|
||||
closeRange,
|
||||
|
|
@ -746,6 +762,181 @@ public sealed class SelectionInteractionControllerTests
|
|||
Assert.Empty(h.Transport.Uses);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a wielded weapon exactly as <c>ClientObjectTable.Ingest</c>
|
||||
/// projects a CreateObject PublicWeenieDesc that carries Wielder plus
|
||||
/// CurrentWieldedLocation. Ownership is resolved by the real
|
||||
/// <c>ACCWeenieObject::IsOwnedByObject @ 0x0058CEB0</c> port, not a fake.
|
||||
/// </summary>
|
||||
private static void AddWieldedWeapon(Harness h, uint guid, uint wielderId)
|
||||
{
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = guid,
|
||||
Name = $"Weapon {guid:X8}",
|
||||
Type = ItemType.MeleeWeapon,
|
||||
WielderId = wielderId,
|
||||
CurrentlyEquippedLocation = EquipMask.MeleeWeapon,
|
||||
});
|
||||
h.Query.WieldedPositionStates.Add(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>ItemHolder::AttemptToPlaceInContainer_IsItemLegal @ 0x005870C0</c>
|
||||
/// rejects <c>!IsOwnedByPlayer(item) && item->pwd._location != 0</c>
|
||||
/// at <c>0x005872B7</c> with the notice at <c>0x005872DB</c>, and it runs
|
||||
/// at <c>0x00588173</c> before every other stage of
|
||||
/// <c>AttemptToPlaceInContainer @ 0x00588140</c>. So: one local message,
|
||||
/// no approach, no wire request, no waiting slot.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void PickupOfARemotesWieldedItemIsRejectedLocallyWithNoMovementOrRequest()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = Wielder,
|
||||
Name = "Remote",
|
||||
Type = ItemType.Creature,
|
||||
});
|
||||
AddWieldedWeapon(h, RemoteWeapon, wielderId: Wielder);
|
||||
h.SetApproach(closeRange: false, serverGuid: RemoteWeapon);
|
||||
h.Selection.Select(RemoteWeapon, SelectionChangeSource.World);
|
||||
|
||||
Assert.True(h.Controller.HandleInputAction(InputAction.SelectionPickUp));
|
||||
h.Controller.DrainOutbound();
|
||||
|
||||
Assert.Contains(
|
||||
// Query.Describe is the fake's ACCWeenieObject::GetObjectNameWide.
|
||||
$"The Target {RemoteWeapon:X8} is being wielded by someone else!",
|
||||
h.Toasts);
|
||||
Assert.Empty(h.Transport.Pickups);
|
||||
Assert.Empty(h.Transport.Uses);
|
||||
Assert.Empty(h.Movement.Approaches);
|
||||
Assert.Empty(h.PendingPlacements);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The same gate must hold on the direct
|
||||
/// <c>CPlayerSystem::PlaceInBackpack @ 0x0055D8C0</c> entry point, whose
|
||||
/// published waiting slot retail withdraws at <c>0x0055D918</c>
|
||||
/// (<c>SetWaitingState(obj, 0)</c> + <c>SendNotice_EndPendingInPlayer</c>).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DirectBackpackPlacementOfARemotesWieldedItemWithdrawsItsWaitingSlot()
|
||||
{
|
||||
var h = new Harness();
|
||||
AddWieldedWeapon(h, RemoteWeapon, wielderId: Wielder);
|
||||
h.SetApproach(closeRange: true, serverGuid: RemoteWeapon);
|
||||
|
||||
Assert.True(h.Items.PlaceWorldItemInBackpack(RemoteWeapon));
|
||||
|
||||
Assert.Contains(
|
||||
// Query.Describe is the fake's ACCWeenieObject::GetObjectNameWide.
|
||||
$"The Target {RemoteWeapon:X8} is being wielded by someone else!",
|
||||
h.Toasts);
|
||||
Assert.Empty(h.Transport.Pickups);
|
||||
Assert.Empty(h.Movement.Approaches);
|
||||
Assert.Single(h.PendingPlacements);
|
||||
Assert.Equal(
|
||||
new[] { RemoteWeapon },
|
||||
h.CancelledPlacements.Select(p => p.ItemId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Slice 4 non-regression: the rejected item stays fully selectable and
|
||||
/// examinable. Retail's <c>sr_Select</c>/<c>sr_Examine</c> branches of
|
||||
/// <c>RecvNotice_SmartBoxObjectFound @ 0x004E5AD0</c> never consult
|
||||
/// <c>IsItemLegal</c>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ARemotesWieldedItemStaysSelectableAndExaminable()
|
||||
{
|
||||
var h = new Harness();
|
||||
AddWieldedWeapon(h, RemoteWeapon, wielderId: Wielder);
|
||||
h.Query.Picked = RemoteWeapon;
|
||||
|
||||
Assert.True(h.Controller.HandleInputAction(InputAction.SelectRight));
|
||||
|
||||
Assert.Equal(RemoteWeapon, h.Selection.SelectedObjectId);
|
||||
Assert.Equal(new[] { "pick", "pulse", "examine" }, h.Query.Events);
|
||||
Assert.Equal(new[] { RemoteWeapon }, h.Examines);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Positive control: the identical ItemType lying in the world is not in
|
||||
/// <c>PositionState.WIELDED</c> (<c>DeterminePositionState @ 0x0058BE70</c>
|
||||
/// needs a nonzero <c>pwd._location</c>) and picks up normally.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void AGroundItemOfTheSameTypeStillPicksUpNormally()
|
||||
{
|
||||
var h = new Harness();
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = GroundWeapon,
|
||||
Name = "Ground weapon",
|
||||
Type = ItemType.MeleeWeapon,
|
||||
});
|
||||
h.SetApproach(closeRange: false, serverGuid: GroundWeapon);
|
||||
h.Selection.Select(GroundWeapon, SelectionChangeSource.World);
|
||||
|
||||
Assert.True(h.Controller.HandleInputAction(InputAction.SelectionPickUp));
|
||||
h.Controller.DrainOutbound();
|
||||
|
||||
Assert.Equal(new[] { (GroundWeapon, Player, 0) }, h.Transport.Pickups);
|
||||
Assert.Single(h.Movement.Approaches);
|
||||
Assert.Empty(h.CancelledPlacements);
|
||||
Assert.DoesNotContain(h.Toasts, text => text.Contains("wielded"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The player's OWN wielded item is <c>IsOwnedByPlayer</c>, so
|
||||
/// <c>IsItemLegal</c>'s 0x005872B7 arm passes it. Its
|
||||
/// <c>PositionState</c> is WIELDED rather than IN_3D_VIEW, so
|
||||
/// <c>ACCWeenieObject::UIAttemptPutInContainer @ 0x0058D680</c> records
|
||||
/// <c>IR_PUT_IN_CONTAINER</c> instead of <c>IR_PICK_UP</c>: the transfer
|
||||
/// goes out immediately, with no world approach.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void PickupOfThePlayersOwnWieldedItemTransfersImmediatelyWithoutApproach()
|
||||
{
|
||||
var h = new Harness();
|
||||
AddWieldedWeapon(h, OwnWeapon, wielderId: Player);
|
||||
h.SetApproach(closeRange: true, serverGuid: OwnWeapon);
|
||||
h.Selection.Select(OwnWeapon, SelectionChangeSource.World);
|
||||
|
||||
Assert.True(h.Controller.HandleInputAction(InputAction.SelectionPickUp));
|
||||
h.Controller.DrainOutbound();
|
||||
|
||||
Assert.Equal(new[] { (OwnWeapon, Player, 0) }, h.Transport.Pickups);
|
||||
Assert.Empty(h.Movement.Approaches);
|
||||
Assert.Empty(h.CancelledPlacements);
|
||||
Assert.DoesNotContain(h.Toasts, text => text.Contains("wielded"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The WIELDED no-approach shortcut must never outrun the legality gate:
|
||||
/// ownership alone decides which of the two wielded items may transfer.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TheWieldedShortcutIsGatedOnOwnershipNotOnWieldedStateAlone()
|
||||
{
|
||||
var h = new Harness();
|
||||
AddWieldedWeapon(h, RemoteWeapon, wielderId: Wielder);
|
||||
AddWieldedWeapon(h, OwnWeapon, wielderId: Player);
|
||||
|
||||
h.SetApproach(closeRange: true, serverGuid: RemoteWeapon);
|
||||
Assert.True(h.Items.PlaceWorldItemInBackpack(RemoteWeapon));
|
||||
Assert.Empty(h.Transport.Pickups);
|
||||
|
||||
h.SetApproach(closeRange: true, serverGuid: OwnWeapon);
|
||||
Assert.True(h.Items.PlaceWorldItemInBackpack(OwnWeapon));
|
||||
|
||||
Assert.Equal(new[] { (OwnWeapon, Player, 0) }, h.Transport.Pickups);
|
||||
Assert.Empty(h.Movement.Approaches);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DragReleasePulsesTheDropTargetWithoutChangingSelection()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue