mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
fix Enumerate/UpdateGuacot
This commit is contained in:
@@ -9,8 +9,7 @@ import (
|
|||||||
|
|
||||||
type Goocoo struct {
|
type Goocoo struct {
|
||||||
Index uint32
|
Index uint32
|
||||||
Data1 []uint16
|
Data []byte
|
||||||
Data2 []uint32
|
|
||||||
Name []byte
|
Name []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,12 +33,7 @@ func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clien
|
|||||||
var temp Goocoo
|
var temp Goocoo
|
||||||
for i := 0; i < int(m.EntryCount); i++ {
|
for i := 0; i < int(m.EntryCount); i++ {
|
||||||
temp.Index = bf.ReadUint32()
|
temp.Index = bf.ReadUint32()
|
||||||
for j := 0; j < 22; j++ {
|
temp.Data = bf.ReadBytes(52)
|
||||||
temp.Data1 = append(temp.Data1, bf.ReadUint16())
|
|
||||||
}
|
|
||||||
for j := 0; j < 2; j++ {
|
|
||||||
temp.Data2 = append(temp.Data2, bf.ReadUint32())
|
|
||||||
}
|
|
||||||
temp.Name = bf.ReadBytes(uint(bf.ReadUint8()))
|
temp.Name = bf.ReadBytes(uint(bf.ReadUint8()))
|
||||||
m.Goocoos = append(m.Goocoos, temp)
|
m.Goocoos = append(m.Goocoos, temp)
|
||||||
}
|
}
|
||||||
|
|||||||
5
patch-schema/15-reset-goocoos.sql
Normal file
5
patch-schema/15-reset-goocoos.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
UPDATE goocoo SET goocoo0=NULL, goocoo1=NULL, goocoo2=NULL, goocoo3=NULL, goocoo4=NULL;
|
||||||
|
|
||||||
|
END;
|
||||||
@@ -959,56 +959,44 @@ func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGookData(s *Session, cid uint32) (uint16, []byte) {
|
func getGoocooData(s *Session, cid uint32) [][]byte {
|
||||||
var data []byte
|
var goocoo []byte
|
||||||
var count uint16
|
var goocoos [][]byte
|
||||||
bf := byteframe.NewByteFrame()
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
err := s.server.db.QueryRow(fmt.Sprintf("SELECT goocoo%d FROM goocoo WHERE id=$1", i), cid).Scan(&data)
|
err := s.server.db.QueryRow(fmt.Sprintf("SELECT goocoo%d FROM goocoo WHERE id=$1", i), cid).Scan(&goocoo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.server.db.Exec("INSERT INTO goocoo (id) VALUES ($1)", s.charID)
|
s.server.db.Exec("INSERT INTO goocoo (id) VALUES ($1)", s.charID)
|
||||||
return 0, bf.Data()
|
return goocoos
|
||||||
}
|
}
|
||||||
if err == nil && data != nil {
|
if err == nil && goocoo != nil {
|
||||||
count++
|
goocoos = append(goocoos, goocoo)
|
||||||
if s.charID == cid && count == 1 {
|
|
||||||
goocoo := byteframe.NewByteFrameFromBytes(data)
|
|
||||||
bf.WriteBytes(goocoo.ReadBytes(4))
|
|
||||||
d := goocoo.ReadBytes(2)
|
|
||||||
bf.WriteBytes(d)
|
|
||||||
bf.WriteBytes(d)
|
|
||||||
bf.WriteBytes(goocoo.DataFromCurrent())
|
|
||||||
} else {
|
|
||||||
bf.WriteBytes(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count, bf.Data()
|
return goocoos
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot)
|
pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
count, data := getGookData(s, s.charID)
|
goocoos := getGoocooData(s, s.charID)
|
||||||
bf.WriteUint16(count)
|
bf.WriteUint16(uint16(len(goocoos)))
|
||||||
bf.WriteBytes(data)
|
bf.WriteUint16(0)
|
||||||
|
for _, goocoo := range goocoos {
|
||||||
|
bf.WriteBytes(goocoo)
|
||||||
|
}
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfUpdateGuacot)
|
pkt := p.(*mhfpacket.MsgMhfUpdateGuacot)
|
||||||
for _, goocoo := range pkt.Goocoos {
|
for _, goocoo := range pkt.Goocoos {
|
||||||
if goocoo.Data1[0] == 0 {
|
// TODO: This doesn't seem to indicate deletion?
|
||||||
|
if goocoo.Data[0] == 0 && goocoo.Data[1] == 0 {
|
||||||
s.server.db.Exec(fmt.Sprintf("UPDATE goocoo SET goocoo%d=NULL WHERE id=$1", goocoo.Index), s.charID)
|
s.server.db.Exec(fmt.Sprintf("UPDATE goocoo SET goocoo%d=NULL WHERE id=$1", goocoo.Index), s.charID)
|
||||||
} else {
|
} else {
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteUint32(goocoo.Index)
|
bf.WriteUint32(goocoo.Index)
|
||||||
for i := range goocoo.Data1 {
|
bf.WriteBytes(goocoo.Data)
|
||||||
bf.WriteUint16(goocoo.Data1[i])
|
|
||||||
}
|
|
||||||
for i := range goocoo.Data2 {
|
|
||||||
bf.WriteUint32(goocoo.Data2[i])
|
|
||||||
}
|
|
||||||
bf.WriteUint8(uint8(len(goocoo.Name)))
|
bf.WriteUint8(uint8(len(goocoo.Name)))
|
||||||
bf.WriteBytes(goocoo.Name)
|
bf.WriteBytes(goocoo.Name)
|
||||||
s.server.db.Exec(fmt.Sprintf("UPDATE goocoo SET goocoo%d=$1 WHERE id=$2", goocoo.Index), bf.Data(), s.charID)
|
s.server.db.Exec(fmt.Sprintf("UPDATE goocoo SET goocoo%d=$1 WHERE id=$2", goocoo.Index), bf.Data(), s.charID)
|
||||||
|
|||||||
@@ -215,10 +215,12 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteBytes(houseFurniture)
|
bf.WriteBytes(houseFurniture)
|
||||||
case 10: // Garden
|
case 10: // Garden
|
||||||
bf.WriteBytes(garden)
|
bf.WriteBytes(garden)
|
||||||
c, d := getGookData(s, pkt.CharID)
|
goocoos := getGoocooData(s, pkt.CharID)
|
||||||
bf.WriteUint16(c)
|
bf.WriteUint16(uint16(len(goocoos)))
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
bf.WriteBytes(d)
|
for _, goocoo := range goocoos {
|
||||||
|
bf.WriteBytes(goocoo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(bf.Data()) == 0 {
|
if len(bf.Data()) == 0 {
|
||||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
|||||||
Reference in New Issue
Block a user