mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
fix Warehouse Item functions
This commit is contained in:
@@ -433,17 +433,8 @@ func handleMsgMhfOperateWarehouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func addWarehouseItem(s *Session, item mhfitem.MHFItemStack) {
|
func addWarehouseItem(s *Session, item mhfitem.MHFItemStack) {
|
||||||
giftBox := warehouseGetItems(s, 10)
|
giftBox := warehouseGetItems(s, 10)
|
||||||
exists := false
|
item.WarehouseID = token.RNG().Uint32()
|
||||||
for i, stack := range giftBox {
|
giftBox = append(giftBox, item)
|
||||||
if stack.Item.ItemID == item.Item.ItemID {
|
|
||||||
exists = true
|
|
||||||
giftBox[i].Quantity += item.Quantity
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
giftBox = append(giftBox, item)
|
|
||||||
}
|
|
||||||
s.server.db.Exec("UPDATE warehouse SET item10=$1 WHERE character_id=$2", mhfitem.SerializeWarehouseItems(giftBox), s.charID)
|
s.server.db.Exec("UPDATE warehouse SET item10=$1 WHERE character_id=$2", mhfitem.SerializeWarehouseItems(giftBox), s.charID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,13 +502,10 @@ func handleMsgMhfUpdateWarehouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
oItems := warehouseGetItems(s, pkt.BoxIndex)
|
oItems := warehouseGetItems(s, pkt.BoxIndex)
|
||||||
for _, uItem := range pkt.UpdatedItems {
|
for _, uItem := range pkt.UpdatedItems {
|
||||||
exists := false
|
exists := false
|
||||||
for _, oItem := range oItems {
|
for i := range oItems {
|
||||||
if uItem.Item.ItemID == oItem.Item.ItemID {
|
if oItems[i].WarehouseID == uItem.WarehouseID {
|
||||||
if uItem.Quantity > 0 {
|
|
||||||
fItems = append(fItems, uItem)
|
|
||||||
}
|
|
||||||
exists = true
|
exists = true
|
||||||
break
|
oItems[i].Quantity = uItem.Quantity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !exists {
|
if !exists {
|
||||||
@@ -525,6 +513,11 @@ func handleMsgMhfUpdateWarehouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
fItems = append(fItems, uItem)
|
fItems = append(fItems, uItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, oItem := range oItems {
|
||||||
|
if oItem.Quantity > 0 {
|
||||||
|
fItems = append(fItems, oItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
s.server.db.Exec(fmt.Sprintf(`UPDATE warehouse SET item%d=$1 WHERE character_id=$2`, pkt.BoxIndex), mhfitem.SerializeWarehouseItems(fItems), s.charID)
|
s.server.db.Exec(fmt.Sprintf(`UPDATE warehouse SET item%d=$1 WHERE character_id=$2`, pkt.BoxIndex), mhfitem.SerializeWarehouseItems(fItems), s.charID)
|
||||||
case 1:
|
case 1:
|
||||||
oEquips := warehouseGetEquipment(s, pkt.BoxIndex)
|
oEquips := warehouseGetEquipment(s, pkt.BoxIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user