revert broadcast package refactor in prep for session interface refactor

This commit is contained in:
stratic-dev
2024-10-15 04:11:58 +01:00
parent f6efbb39a6
commit 0fa7f37743
39 changed files with 475 additions and 523 deletions

View File

@@ -4,7 +4,6 @@ import (
"erupe-ce/network/mhfpacket"
"erupe-ce/server/channelserver/compression/deltacomp"
"erupe-ce/server/channelserver/compression/nullcomp"
"erupe-ce/utils/broadcast"
"erupe-ce/utils/db"
"fmt"
@@ -22,7 +21,7 @@ func handleMsgMhfLoadPlateData(s *Session, p mhfpacket.MHFPacket) {
if err != nil {
s.Logger.Error("Failed to load platedata", zap.Error(err))
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
}
func handleMsgMhfSavePlateData(s *Session, p mhfpacket.MHFPacket) {
@@ -38,7 +37,7 @@ func handleMsgMhfSavePlateData(s *Session, p mhfpacket.MHFPacket) {
err := database.QueryRow("SELECT platedata FROM characters WHERE id = $1", s.CharID).Scan(&data)
if err != nil {
s.Logger.Error("Failed to load platedata", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
@@ -48,7 +47,7 @@ func handleMsgMhfSavePlateData(s *Session, p mhfpacket.MHFPacket) {
data, err = nullcomp.Decompress(data)
if err != nil {
s.Logger.Error("Failed to decompress platedata", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
} else {
@@ -61,14 +60,14 @@ func handleMsgMhfSavePlateData(s *Session, p mhfpacket.MHFPacket) {
saveOutput, err := nullcomp.Compress(deltacomp.ApplyDataDiff(pkt.RawDataPayload, data))
if err != nil {
s.Logger.Error("Failed to diff and compress platedata", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
_, err = database.Exec("UPDATE characters SET platedata=$1 WHERE id=$2", saveOutput, s.CharID)
if err != nil {
s.Logger.Error("Failed to save platedata", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
@@ -82,7 +81,7 @@ func handleMsgMhfSavePlateData(s *Session, p mhfpacket.MHFPacket) {
}
}
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
}
func handleMsgMhfLoadPlateBox(s *Session, p mhfpacket.MHFPacket) {
@@ -96,7 +95,7 @@ func handleMsgMhfLoadPlateBox(s *Session, p mhfpacket.MHFPacket) {
if err != nil {
s.Logger.Error("Failed to load platebox", zap.Error(err))
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
}
func handleMsgMhfSavePlateBox(s *Session, p mhfpacket.MHFPacket) {
@@ -112,7 +111,7 @@ func handleMsgMhfSavePlateBox(s *Session, p mhfpacket.MHFPacket) {
err := database.QueryRow("SELECT platebox FROM characters WHERE id = $1", s.CharID).Scan(&data)
if err != nil {
s.Logger.Error("Failed to load platebox", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
@@ -123,7 +122,7 @@ func handleMsgMhfSavePlateBox(s *Session, p mhfpacket.MHFPacket) {
data, err = nullcomp.Decompress(data)
if err != nil {
s.Logger.Error("Failed to decompress platebox", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
} else {
@@ -136,14 +135,14 @@ func handleMsgMhfSavePlateBox(s *Session, p mhfpacket.MHFPacket) {
saveOutput, err := nullcomp.Compress(deltacomp.ApplyDataDiff(pkt.RawDataPayload, data))
if err != nil {
s.Logger.Error("Failed to diff and compress platebox", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
_, err = database.Exec("UPDATE characters SET platebox=$1 WHERE id=$2", saveOutput, s.CharID)
if err != nil {
s.Logger.Error("Failed to save platebox", zap.Error(err))
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
@@ -156,7 +155,7 @@ func handleMsgMhfSavePlateBox(s *Session, p mhfpacket.MHFPacket) {
s.Logger.Error("Failed to save platebox", zap.Error(err))
}
}
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
}
func handleMsgMhfLoadPlateMyset(s *Session, p mhfpacket.MHFPacket) {
@@ -171,7 +170,7 @@ func handleMsgMhfLoadPlateMyset(s *Session, p mhfpacket.MHFPacket) {
s.Logger.Error("Failed to load platemyset", zap.Error(err))
data = make([]byte, 1920)
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
}
func handleMsgMhfSavePlateMyset(s *Session, p mhfpacket.MHFPacket) {
@@ -186,5 +185,5 @@ func handleMsgMhfSavePlateMyset(s *Session, p mhfpacket.MHFPacket) {
if err != nil {
s.Logger.Error("Failed to save platemyset", zap.Error(err))
}
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
}