diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index ee1b6f11..2fc346dd 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -598,9 +598,25 @@ func (this *player) CMChooseBattleItem(hdr *f5.MsgHdr, msg *cs.CMChooseBattleIte q5.DuckToSimple(rspObj.ItemNum, &itemNum) q5.DuckToSimple(rspObj.ItemType, &itemType) q5.DuckToSimple(rspObj.ItemSubType, &itemSubType) - for _, p := range(this.battleItems) { - if p.itemType == itemType && p.itemSubType == itemSubType { - + if itemNum > 0 { + found := false + for _, p := range(this.battleItems) { + if p.itemType == itemType && p.itemSubType == itemSubType { + p.itemId = itemId + p.itemNum = itemNum + p.itemType = itemType + p.itemSubType = itemSubType + found = true + break + } + } + if !found { + p := new(battleItem) + p.itemId = itemId + p.itemNum = itemNum + p.itemType = itemType + p.itemSubType = itemSubType + q5.AppendSlice(&this.battleItems, p) } } this.SendMsg(rspMsg)