Skip to content

Commit c303658

Browse files
committed
test: cover gold reward owner identity pickup
1 parent 6a5bcb9 commit c303658

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

internal/minimal/shared_world_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,39 @@ func TestSharedWorldRegistryGroundRewardPickupWithholdsOwnerDeliveryAfterOwnerId
681681
}
682682
}
683683

684+
func TestSharedWorldRegistryGroundGoldRewardPickupWithholdsOwnerDeliveryAfterOwnerIdentityChanges(t *testing.T) {
685+
registry := newSharedWorldRegistry()
686+
owner := peerVisibilityCharacter("IdentityGoldPickupOwner", 0x010301ad, 0x020401ad, 1200, 2200, 0, 101, 201)
687+
collector := peerVisibilityCharacter("OwnerIdentityGoldCollector", 0x010301ae, 0x020401ae, 1220, 2220, 0, 102, 202)
688+
ownerID, _ := registry.Join(owner, newPendingServerFrames(), nil)
689+
collectorID, _ := registry.Join(collector, newPendingServerFrames(), nil)
690+
if ownerID == 0 || collectorID == 0 {
691+
t.Fatal("expected owner and collector joins to allocate shared-world entity ids")
692+
}
693+
const groundVID uint32 = 0x07000029
694+
if !registry.RegisterGroundGold(ownerID, "identity-gold-pickup-owner", owner, groundVID, 250) {
695+
t.Fatal("expected owner ground-gold registration to succeed")
696+
}
697+
updatedOwner := owner
698+
updatedOwner.Name = "FreshIdentityGoldPickupOwner"
699+
updatedOwner.VID = 0x020401af
700+
registry.UpdateCharacter(ownerID, updatedOwner)
701+
702+
pickup, ok := registry.GroundItemPickupFor(collectorID, collector, groundVID)
703+
if !ok {
704+
t.Fatal("expected collector gold pickup resolution to remain available")
705+
}
706+
if pickup.GoldAmount != 250 {
707+
t.Fatalf("expected original gold amount to remain available, got %+v", pickup)
708+
}
709+
if pickup.Owner.ID != 0 || pickup.Owner.Name != "" {
710+
t.Fatalf("expected gold owner delivery to be withheld after owner identity changes, got %+v", pickup.Owner)
711+
}
712+
if pickup.OwnerName != owner.Name {
713+
t.Fatalf("expected display ownership name to remain %q, got %q", owner.Name, pickup.OwnerName)
714+
}
715+
}
716+
684717
func TestSharedWorldRegistryGroundRewardPickupRejectsStaleCollectorIdentitySnapshot(t *testing.T) {
685718
registry := newSharedWorldRegistry()
686719
owner := peerVisibilityCharacter("IdentityPickupOwner", 0x0103019d, 0x0204019d, 1200, 2200, 0, 101, 201)

spec/protocol/non-player-reward-bootstrap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ Ground pickup also skips party-style delivery back into an owner that has since
125125
Ground pickup also withholds party-style owner delivery if the registered owner entity no longer matches the identity and exact runtime location captured when the ground reward was created; this preserves the display ownership label while preventing stale handles from mutating a rebound or relocated owner snapshot.
126126
Ground reward registration re-checks the registered owner snapshot before trusting the caller-supplied character copy, so a stale owner snapshot cannot create item-shaped or gold-shaped reward ground entries after the registered owner has already changed selected-character identity (`id`, `vid`, or name) or moved to a different runtime location.
127127
Lookup, pickup-resolution, and removal also re-check the registered collector snapshot before trusting the caller-supplied character copy, so a stale collector snapshot cannot see, resolve, or remove item-shaped or gold-shaped reward ground entries after that collector has already reached the bootstrap `0`-HP floor, changed selected-character identity (`id`, `vid`, or name), or moved out of the exact runtime location represented by the supplied pickup attempt.
128-
Dedicated coverage now freezes the gold-shaped reward half of both stale collector-identity and stale collector-location cases, not just ordinary item-shaped drops, because both reward families share the same ground-entry visibility/pickup seam.
128+
Dedicated coverage now freezes the gold-shaped reward half of stale collector-identity, stale collector-location, and stale owner-identity owner-delivery cases, not just ordinary item-shaped drops, because both reward families share the same ground-entry visibility/pickup seam.
129129
This guard applies in both directions for item-shaped and gold-shaped rewards: a stale near snapshot cannot pick up after the registered collector has moved away or rebound to a different selected-character identity, and a stale far snapshot cannot become valid merely because the registered collector later moved near the ground reward.
130-
When that living, identity-current, and currently reachable collector succeeds, the collector receives the ordinary self pickup shape (`ITEM_GROUND_DEL`, inventory `ITEM_SET`, and normal `ITEM_GET` feedback) and the dead owner receives no queued party-style pickup feedback.
130+
When that living, identity-current, and currently reachable collector succeeds, the collector receives the ordinary self pickup shape (`ITEM_GROUND_DEL`, inventory `ITEM_SET`, and normal `ITEM_GET` feedback) and the dead, rebound, or relocated owner receives no queued party-style pickup feedback.
131131

132132
This keeps death/restart cleanup and concurrent movement from leaking new pickup surfaces, stale delete noise, debug/runtime-visible pickup affordances, stale collector pickup affordances, stale owner-location ground registration, transfer-entry ground visibility, or late owner-delivery mutations for players that are already dead or no longer at the supplied reward location.
133133

0 commit comments

Comments
 (0)