道具空指针异常

This commit is contained in:
sk 2024-07-25 14:58:53 +08:00
parent 857f052728
commit 25c7f68dac
3 changed files with 5 additions and 4 deletions

View File

@ -172,7 +172,8 @@ func init() {
if items != nil { if items != nil {
for _, dbItem := range dbItemArr { for _, dbItem := range dbItemArr {
//todo 临时修复,正常应该道具需要使用事务同步 //todo 临时修复,正常应该道具需要使用事务同步
if dbItem.GetId() == common.ItemIDPermit { switch dbItem.GetId() {
case common.ItemIDPermit, common.ItemIDWeekScore:
continue continue
} }
if itemNum, exist := items[dbItem.Id]; exist { if itemNum, exist := items[dbItem.Id]; exist {

View File

@ -217,7 +217,7 @@ func (this *CSVCPayShopHandler) Process(s *netlib.Session, packetid int, data in
} }
case ShopConsumeDiamondScore: case ShopConsumeDiamondScore:
item := BagMgrSingleton.GetItem(p.SnId, common.ItemDiamondScore) item := BagMgrSingleton.GetItem(p.SnId, common.ItemDiamondScore)
if costNum > item.ItemNum { if item == nil || costNum > item.ItemNum {
SendClient(shop.OpResultCode_OPRC_Error) SendClient(shop.OpResultCode_OPRC_Error)
return nil return nil
} }

View File

@ -341,7 +341,7 @@ func (this *PetMgr) CheckSkinRed(p *Player) {
ok := true ok := true
for _, v := range info.GetCost() { for _, v := range info.GetCost() {
item := BagMgrSingleton.GetItem(p.SnId, v.GetId()) item := BagMgrSingleton.GetItem(p.SnId, v.GetId())
if item.ItemNum < v.GetN() { if item == nil || item.ItemNum < v.GetN() {
ok = false ok = false
break break
} }
@ -356,7 +356,7 @@ func (this *PetMgr) CheckSkinRed(p *Player) {
ok := true ok := true
for _, v := range info.GetCost() { for _, v := range info.GetCost() {
item := BagMgrSingleton.GetItem(p.SnId, v.GetId()) item := BagMgrSingleton.GetItem(p.SnId, v.GetId())
if item.ItemNum < v.GetN() { if item == nil || item.ItemNum < v.GetN() {
ok = false ok = false
break break
} }