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 (
"database/sql"
"encoding/binary"
"erupe-ce/utils/broadcast"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/decryption"
@@ -111,10 +110,10 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) {
if err != nil {
s.Logger.Error(fmt.Sprintf("Failed to open file: %s/scenarios/%s.bin", config.GetConfig().BinPath, filename))
// This will crash the game.
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
return
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
} else {
if config.GetConfig().DebugOptions.QuestTools {
s.Logger.Debug(
@@ -131,13 +130,13 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) {
if err != nil {
s.Logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", config.GetConfig().BinPath, pkt.Filename))
// This will crash the game.
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
return
}
if config.GetConfig().ClientID <= config.Z1 && config.GetConfig().DebugOptions.AutoQuestBackport {
data = BackportQuest(decryption.UnpackSimple(data))
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
}
}
@@ -177,9 +176,9 @@ func handleMsgMhfLoadFavoriteQuest(s *Session, p mhfpacket.MHFPacket) {
}
err = database.QueryRow("SELECT savefavoritequest FROM characters WHERE id = $1", s.CharID).Scan(&data)
if err == nil && len(data) > 0 {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, data)
s.DoAckBufSucceed(pkt.AckHandle, data)
} else {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, []byte{0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
s.DoAckBufSucceed(pkt.AckHandle, []byte{0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
}
}
@@ -191,7 +190,7 @@ func handleMsgMhfSaveFavoriteQuest(s *Session, p mhfpacket.MHFPacket) {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
database.Exec("UPDATE characters SET savefavoritequest=$1 WHERE id=$2", pkt.Data, s.CharID)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
}
func loadQuestFile(s *Session, questId int) []byte {
@@ -657,7 +656,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) {
bf.Seek(0, io.SeekStart)
bf.WriteUint16(returnedCount)
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func getTuneValueRange(start uint16, value uint16) []tuneValue {
@@ -695,5 +694,5 @@ func handleMsgMhfGetUdBonusQuestInfo(s *Session, p mhfpacket.MHFPacket) {
resp.WriteUint8(q.Unk6)
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, resp.Data())
s.DoAckBufSucceed(pkt.AckHandle, resp.Data())
}