Skip to content

Commit d771e34

Browse files
committed
feat: reject blank-name reward drops
1 parent 7ac39a9 commit d771e34

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

internal/minimal/shared_world.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ func (r *sharedWorldRegistry) RegisterGroundGold(ownerID uint64, ownerLogin stri
931931
}
932932

933933
func (r *sharedWorldRegistry) registerGroundItem(ownerID uint64, ownerLogin string, character loginticket.Character, vid uint32, item inventory.ItemInstance, goldAmount uint32) bool {
934-
if r == nil || ownerID == 0 || strings.TrimSpace(ownerLogin) == "" || vid == 0 || item.Vnum == 0 {
934+
if r == nil || ownerID == 0 || strings.TrimSpace(ownerLogin) == "" || strings.TrimSpace(character.Name) == "" || vid == 0 || item.Vnum == 0 {
935935
return false
936936
}
937937

internal/minimal/shared_world_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,26 @@ func TestSharedWorldRegistryRegisterGroundRewardsRejectsBlankOwnerLogin(t *testi
491491
}
492492
}
493493

494+
func TestSharedWorldRegistryRegisterGroundRewardsRejectsBlankOwnerName(t *testing.T) {
495+
registry := newSharedWorldRegistry()
496+
owner := peerVisibilityCharacter("BlankNameRewardOwner", 0x010301a1, 0x020401a1, 1200, 2200, 0, 101, 201)
497+
owner.Name = "\t"
498+
ownerID, _ := registry.Join(owner, newPendingServerFrames(), nil)
499+
if ownerID == 0 {
500+
t.Fatal("expected blank-name reward owner join to allocate a shared-world entity id")
501+
}
502+
503+
if registry.RegisterGroundItem(ownerID, "blank-name-reward-owner", owner, 0x07000021, inventory.ItemInstance{Vnum: 3001, Count: 1}) {
504+
t.Fatal("expected blank-name ground-item reward registration to fail closed")
505+
}
506+
if registry.RegisterGroundGold(ownerID, "blank-name-reward-owner", owner, 0x07000022, 250) {
507+
t.Fatal("expected blank-name ground-gold reward registration to fail closed")
508+
}
509+
if registry.GroundItemExists(0x07000021) || registry.GroundItemExists(0x07000022) {
510+
t.Fatal("expected rejected blank-name reward ground entries to stay absent")
511+
}
512+
}
513+
494514
func TestSharedWorldRegistryRegisterGroundRewardsRejectsStaleLiveOwnerSnapshotAfterOwnerDeath(t *testing.T) {
495515
registry := newSharedWorldRegistry()
496516
owner := peerVisibilityCharacter("StaleLiveRewardOwner", 0x01030193, 0x02040193, 1200, 2200, 0, 101, 201)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Reward descriptors fail closed when:
5757
- any `reward_drop_vnums` entry is duplicated in the same descriptor
5858
- a runtime-generated ground-entry VID for a configured item-shaped or gold-shaped drop would be `0`
5959
- the reward owner login is empty or blank after trimming whitespace when registering a configured item-shaped or gold-shaped drop
60+
- the reward owner character name is empty or blank after trimming whitespace when registering a configured item-shaped or gold-shaped drop
6061
- a runtime-generated ground-item instance for a configured item-shaped drop would have `vnum = 0`
6162
- a runtime-generated ground-item instance for a configured item-shaped drop would have zero count
6263
- a runtime-generated ground-item instance for a configured item-shaped drop would exceed the current `GC ITEM_GET` count carrier (`255`)

0 commit comments

Comments
 (0)