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

@@ -1,7 +1,6 @@
package channelserver
import (
"erupe-ce/utils/broadcast"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
@@ -30,7 +29,7 @@ func handleMsgMhfAcquireCafeItem(s *Session, p mhfpacket.MHFPacket) {
}
resp := byteframe.NewByteFrame()
resp.WriteUint32(netcafePoints)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, resp.Data())
s.DoAckSimpleSucceed(pkt.AckHandle, resp.Data())
}
func handleMsgMhfUpdateCafepoint(s *Session, p mhfpacket.MHFPacket) {
@@ -46,7 +45,7 @@ func handleMsgMhfUpdateCafepoint(s *Session, p mhfpacket.MHFPacket) {
}
resp := byteframe.NewByteFrame()
resp.WriteUint32(netcafePoints)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, resp.Data())
s.DoAckSimpleSucceed(pkt.AckHandle, resp.Data())
}
func handleMsgMhfCheckDailyCafepoint(s *Session, p mhfpacket.MHFPacket) {
@@ -83,7 +82,7 @@ func handleMsgMhfCheckDailyCafepoint(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint32(bondBonus)
bf.WriteUint32(bonusQuests)
bf.WriteUint32(dailyQuests)
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) {
@@ -118,7 +117,7 @@ func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint16(0)
ps.Uint16(bf, fmt.Sprintf(s.Server.i18n.cafe.reset, int(cafeReset.Month()), cafeReset.Day()), true)
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type CafeBonus struct {
@@ -148,7 +147,7 @@ func handleMsgMhfGetCafeDurationBonusInfo(s *Session, p mhfpacket.MHFPacket) {
FROM cafebonus cb ORDER BY id ASC;`, s.CharID)
if err != nil {
s.Logger.Error("Error getting cafebonus", zap.Error(err))
broadcast.DoAckBufSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 4))
} else {
for rows.Next() {
count++
@@ -168,7 +167,7 @@ func handleMsgMhfGetCafeDurationBonusInfo(s *Session, p mhfpacket.MHFPacket) {
resp.WriteUint32(uint32(gametime.TimeAdjusted().Unix()))
resp.WriteUint32(count)
resp.WriteBytes(bf.Data())
broadcast.DoAckBufSucceed(s, pkt.AckHandle, resp.Data())
s.DoAckBufSucceed(pkt.AckHandle, resp.Data())
}
}
@@ -194,7 +193,7 @@ func handleMsgMhfReceiveCafeDurationBonus(s *Session, p mhfpacket.MHFPacket) {
WHERE ch.id = $1
) >= time_req`, s.CharID, gametime.TimeAdjusted().Unix()-s.sessionStart)
if err != nil {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
} else {
for rows.Next() {
cafeBonus := &CafeBonus{}
@@ -210,7 +209,7 @@ func handleMsgMhfReceiveCafeDurationBonus(s *Session, p mhfpacket.MHFPacket) {
}
bf.Seek(0, io.SeekStart)
bf.WriteUint32(count)
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
}
@@ -232,7 +231,7 @@ func handleMsgMhfPostCafeDurationBonusReceived(s *Session, p mhfpacket.MHFPacket
}
database.Exec("INSERT INTO public.cafe_accepted VALUES ($1, $2)", cbID, s.CharID)
}
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
func addPointNetcafe(s *Session, p int) error {
@@ -264,17 +263,17 @@ func handleMsgMhfStartBoostTime(s *Session, p mhfpacket.MHFPacket) {
boostLimit := gametime.TimeAdjusted().Add(time.Duration(config.GetConfig().GameplayOptions.BoostTimeDuration) * time.Second)
if config.GetConfig().GameplayOptions.DisableBoostTime {
bf.WriteUint32(0)
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
return
}
database.Exec("UPDATE characters SET boost_time=$1 WHERE id=$2", boostLimit, s.CharID)
bf.WriteUint32(uint32(boostLimit.Unix()))
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func handleMsgMhfGetBoostTime(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetBoostTime)
broadcast.DoAckBufSucceed(s, pkt.AckHandle, []byte{})
s.DoAckBufSucceed(pkt.AckHandle, []byte{})
}
func handleMsgMhfGetBoostTimeLimit(s *Session, p mhfpacket.MHFPacket) {
@@ -291,8 +290,8 @@ func handleMsgMhfGetBoostTimeLimit(s *Session, p mhfpacket.MHFPacket) {
} else {
bf.WriteUint32(uint32(boostLimit.Unix()))
}
broadcast.DoAckBufSucceed(s, pkt.AckHandle, bf.Data())
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
func handleMsgMhfGetBoostRight(s *Session, p mhfpacket.MHFPacket) {
@@ -304,27 +303,27 @@ func handleMsgMhfGetBoostRight(s *Session, p mhfpacket.MHFPacket) {
}
err = database.QueryRow("SELECT boost_time FROM characters WHERE id=$1", s.CharID).Scan(&boostLimit)
if err != nil {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckBufSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
if boostLimit.After(gametime.TimeAdjusted()) {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x01})
s.DoAckBufSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x01})
} else {
broadcast.DoAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x02})
s.DoAckBufSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x02})
}
}
func handleMsgMhfPostBoostTimeQuestReturn(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPostBoostTimeQuestReturn)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
s.DoAckSimpleSucceed(pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
}
func handleMsgMhfPostBoostTime(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPostBoostTime)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
func handleMsgMhfPostBoostTimeLimit(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPostBoostTimeLimit)
broadcast.DoAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}