mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-15 08:25:09 +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 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 data []byte
|
||||||
var count uint16
|
var count uint16
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
@@ -597,15 +597,16 @@ func getGookData(s *Session, cid uint32) []byte {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp := byteframe.NewByteFrame()
|
return count, bf.Data()
|
||||||
resp.WriteUint16(count)
|
|
||||||
resp.WriteBytes(bf.Data())
|
|
||||||
return resp.Data()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot)
|
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) {
|
func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
ps "erupe-ce/common/pascalstring"
|
ps "erupe-ce/common/pascalstring"
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"fmt"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -173,20 +172,10 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
for _, session := range s.server.sessions {
|
for _, session := range s.server.sessions {
|
||||||
if session.charID == pkt.CharID {
|
if session.charID == pkt.CharID {
|
||||||
bf.WriteBytes(session.myseries.gardenData)
|
bf.WriteBytes(session.myseries.gardenData)
|
||||||
// TODO: Convert EnumerateGuacot to function this can also call
|
c, d := getGookData(s, pkt.CharID)
|
||||||
var data []byte
|
bf.WriteUint16(c)
|
||||||
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)
|
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
bf.WriteBytes(gooks.Data())
|
bf.WriteBytes(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user