From e9c29f144242a83a97e11b61d978c0a6088da28a Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Mon, 20 May 2024 10:36:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E5=8C=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/bagmgr.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/worldsrv/bagmgr.go b/worldsrv/bagmgr.go index ed64942..3320f0e 100644 --- a/worldsrv/bagmgr.go +++ b/worldsrv/bagmgr.go @@ -216,9 +216,11 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int code = bag.OpResultCode_OPRC_IdErr return newBagInfo, code, false } - if v.ItemNum < 0 && item.Num < int64(math.Abs(float64(v.ItemNum))) { - code = bag.OpResultCode_OPRC_UseUp - return newBagInfo, code, false + if itm, exist := newBagInfo.BagItem[v.ItemId]; exist { + if v.ItemNum < 0 && itm.ItemNum < int64(math.Abs(float64(v.ItemNum))) { + code = bag.OpResultCode_OPRC_UseUp + return newBagInfo, code, false + } } }