mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
merge gook simplification
This commit is contained in:
@@ -577,7 +577,7 @@ func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {}
|
||||
|
||||
func getGookData(s *Session, cid uint32) []byte {
|
||||
func getGookData(s *Session, cid uint32) (uint16, []byte) {
|
||||
var data []byte
|
||||
var count uint16
|
||||
bf := byteframe.NewByteFrame()
|
||||
@@ -597,15 +597,16 @@ func getGookData(s *Session, cid uint32) []byte {
|
||||
}
|
||||
}
|
||||
}
|
||||
resp := byteframe.NewByteFrame()
|
||||
resp.WriteUint16(count)
|
||||
resp.WriteBytes(bf.Data())
|
||||
return resp.Data()
|
||||
return count, bf.Data()
|
||||
}
|
||||
|
||||
func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot)
|
||||
doAckBufSucceed(s, pkt.AckHandle, getGookData(s, s.charID))
|
||||
bf := byteframe.NewByteFrame()
|
||||
count, data := getGookData(s, s.charID)
|
||||
bf.WriteUint16(count)
|
||||
bf.WriteBytes(data)
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
ps "erupe-ce/common/pascalstring"
|
||||
"erupe-ce/common/stringsupport"
|
||||
"erupe-ce/network/mhfpacket"
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -173,20 +172,10 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
for _, session := range s.server.sessions {
|
||||
if session.charID == pkt.CharID {
|
||||
bf.WriteBytes(session.myseries.gardenData)
|
||||
// TODO: Convert EnumerateGuacot to function this can also call
|
||||
var data []byte
|
||||
var count uint16
|
||||
gooks := byteframe.NewByteFrame()
|
||||
for i := 0; i < 5; i++ {
|
||||
err := s.server.db.QueryRow(fmt.Sprintf("SELECT gook%d FROM gook WHERE id=$1", i), pkt.CharID).Scan(&data)
|
||||
if err == nil && data != nil {
|
||||
count++
|
||||
gooks.WriteBytes(data)
|
||||
}
|
||||
}
|
||||
bf.WriteUint16(count)
|
||||
c, d := getGookData(s, pkt.CharID)
|
||||
bf.WriteUint16(c)
|
||||
bf.WriteUint16(0)
|
||||
bf.WriteBytes(gooks.Data())
|
||||
bf.WriteBytes(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user