Abracted away broadcast utils

This commit is contained in:
stratic-dev
2024-10-13 18:23:04 +01:00
parent 5f975c97b5
commit 0af565a766
38 changed files with 479 additions and 434 deletions

View File

@@ -3,6 +3,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/broadcast"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
ps "erupe-ce/utils/pascalstring"
@@ -122,7 +123,7 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) {
}
}
}
DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
}
type DistributionItem struct {
@@ -166,7 +167,7 @@ func handleMsgMhfApplyDistItem(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint32(item.ID)
}
}
DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
}
func handleMsgMhfAcquireDistItem(s *Session, p mhfpacket.MHFPacket) {
@@ -199,7 +200,7 @@ func handleMsgMhfAcquireDistItem(s *Session, p mhfpacket.MHFPacket) {
}
}
}
DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
}
func handleMsgMhfGetDistDescription(s *Session, p mhfpacket.MHFPacket) {
@@ -212,11 +213,11 @@ func handleMsgMhfGetDistDescription(s *Session, p mhfpacket.MHFPacket) {
err = database.QueryRow("SELECT description FROM distribution WHERE id = $1", pkt.DistributionID).Scan(&desc)
if err != nil {
s.Logger.Error("Error parsing item distribution description", zap.Error(err))
DoAckBufSucceed(s, pkt.AckHandle, make([]byte, 4))
broadcast.DoAckBufSucceed(s, pkt.AckHandle, make([]byte, 4))
return
}
bf := byteframe.NewByteFrame()
ps.Uint16(bf, desc, true)
ps.Uint16(bf, "", false)
DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
}