aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_get.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-16 02:56:56 -0400
committerhistoria <[not public]>2026-09-16 02:56:56 -0400
commitf2d44f10f52d3fe68fdb19b518a330f7af9e1ed2 (patch)
tree9db54e8d4fd2f9bd30c651700f7cf246eef1b017 /internal/game/cmd_get.go
parentad60843fbf577eda80105e3916822d663aaefcb3 (diff)
downloadthehouseoficarus-f2d44f10f52d3fe68fdb19b518a330f7af9e1ed2.tar.gz
fix: disconnect race, rename ownership, reserved pickup, economy recovery retry/refund semantics
Diffstat (limited to 'internal/game/cmd_get.go')
-rw-r--r--internal/game/cmd_get.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/internal/game/cmd_get.go b/internal/game/cmd_get.go
index afd9ae6..d538afc 100644
--- a/internal/game/cmd_get.go
+++ b/internal/game/cmd_get.go
@@ -11,7 +11,10 @@ import (
func (g *Game) doGet(sess *net.Session, input string) {
p := sess.Player
g.cancelAction(p)
- ground := g.World.GroundItems(p.RoomID)
+ // Only stock this player may actually take counts: entries reserved
+ // for another player are invisible to the pickup, so a blocked pickup
+ // can never half-remove the ground stack.
+ ground := g.World.AccessibleGround(p.RoomID, p.Name)
if len(ground) == 0 {
sess.WriteLine("There's nothing on the ground to pick up.")
return
@@ -75,11 +78,12 @@ func (g *Game) doGet(sess *net.Session, input string) {
for i := 0; i < 28; i++ {
slot := p.InvSlot(i)
if slot != nil && slot.ItemID == itemID {
- if _, ok := g.World.RemoveReservedItem(p.RoomID, itemID, qty, p.Name); !ok {
+ removed, ok := g.World.RemoveReservedItem(p.RoomID, itemID, qty, p.Name)
+ if !ok {
sess.WriteLine("That's not yours!")
return
}
- slot.Quantity += qty
+ slot.Quantity += removed
g.AccountStore.SaveCharacter(p)
sess.WriteLine(fmt.Sprintf("You pick up %d x %s. (now %d)", qty, g.itemColorize(sess, def, def.Name), slot.Quantity))
return
@@ -130,7 +134,8 @@ func (g *Game) doGet(sess *net.Session, input string) {
func (g *Game) doGetAllNamed(sess *net.Session, input string) {
p := sess.Player
g.cancelAction(p)
- ground := g.World.GroundItems(p.RoomID)
+ // Only takeable stock counts (see doGet).
+ ground := g.World.AccessibleGround(p.RoomID, p.Name)
if len(ground) == 0 {
sess.WriteLine("There's nothing on the ground to pick up.")
return
@@ -252,7 +257,9 @@ func (g *Game) doGetAllNamed(sess *net.Session, input string) {
func (g *Game) doGetAll(sess *net.Session) {
p := sess.Player
g.cancelAction(p)
- ground := g.World.GroundItems(p.RoomID)
+ // Only takeable stock counts (see doGet); the all-or-nothing
+ // RemoveReservedItem then never aborts a partial pickup.
+ ground := g.World.AccessibleGround(p.RoomID, p.Name)
if len(ground) == 0 {
sess.WriteLine("There's nothing on the ground to pick up.")
return