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

@@ -3,7 +3,6 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/broadcast"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
@@ -29,7 +28,7 @@ func HandleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateGuildTresure)
guild, err := GetGuildInfoByCharacterId(s, s.CharID)
if err != nil || guild == nil {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 4))
return
}
var hunts []TreasureHunt
@@ -57,7 +56,7 @@ func HandleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) {
`, s.CharID, guild.ID)
if err != nil {
rows.Close()
broadcast.DoAckBufSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 4))
return
} else {
for rows.Next() {
@@ -84,7 +83,7 @@ func HandleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) {
bf.WriteBool(h.Claimed)
bf.WriteBytes(h.HuntData)
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func HandleMsgMhfRegistGuildTresure(s *Session, p mhfpacket.MHFPacket) {
@@ -93,7 +92,7 @@ func HandleMsgMhfRegistGuildTresure(s *Session, p mhfpacket.MHFPacket) {
huntData := byteframe.NewByteFrame()
guild, err := GetGuildInfoByCharacterId(s, s.CharID)
if err != nil || guild == nil {
broadcast.DoAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleFail(pkt.AckHandle, make([]byte, 4))
return
}
guildCats := getGuildAirouList(s)
@@ -122,7 +121,7 @@ func HandleMsgMhfRegistGuildTresure(s *Session, p mhfpacket.MHFPacket) {
}
database.Exec(`INSERT INTO guild_hunts (guild_id, host_id, destination, level, hunt_data, cats_used) VALUES ($1, $2, $3, $4, $5, $6)
`, guild.ID, s.CharID, destination, level, huntData.Data(), catsUsed)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
func HandleMsgMhfAcquireGuildTresure(s *Session, p mhfpacket.MHFPacket) {
@@ -132,7 +131,7 @@ func HandleMsgMhfAcquireGuildTresure(s *Session, p mhfpacket.MHFPacket) {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
database.Exec(`UPDATE guild_hunts SET acquired=true WHERE id=$1`, pkt.HuntID)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
func HandleMsgMhfOperateGuildTresureReport(s *Session, p mhfpacket.MHFPacket) {
@@ -150,7 +149,7 @@ func HandleMsgMhfOperateGuildTresureReport(s *Session, p mhfpacket.MHFPacket) {
case 2: // Claim treasure
database.Exec(`INSERT INTO guild_hunts_claimed VALUES ($1, $2)`, pkt.HuntID, s.CharID)
}
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type TreasureSouvenir struct {
@@ -168,10 +167,10 @@ func HandleMsgMhfGetGuildTresureSouvenir(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint32(souvenir.Destination)
bf.WriteUint32(souvenir.Quantity)
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func HandleMsgMhfAcquireGuildTresureSouvenir(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfAcquireGuildTresureSouvenir)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}