diff --git a/network/mhfpacket/msg_mhf_update_guacot.go b/network/mhfpacket/msg_mhf_update_guacot.go index 685f66f1b..3295d1251 100644 --- a/network/mhfpacket/msg_mhf_update_guacot.go +++ b/network/mhfpacket/msg_mhf_update_guacot.go @@ -9,8 +9,7 @@ import ( type Goocoo struct { Index uint32 - Data1 []uint16 - Data2 []uint32 + Data []byte Name []byte } @@ -34,12 +33,7 @@ func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clien var temp Goocoo for i := 0; i < int(m.EntryCount); i++ { temp.Index = bf.ReadUint32() - for j := 0; j < 22; j++ { - temp.Data1 = append(temp.Data1, bf.ReadUint16()) - } - for j := 0; j < 2; j++ { - temp.Data2 = append(temp.Data2, bf.ReadUint32()) - } + temp.Data = bf.ReadBytes(52) temp.Name = bf.ReadBytes(uint(bf.ReadUint8())) m.Goocoos = append(m.Goocoos, temp) } diff --git a/patch-schema/15-reset-goocoos.sql b/patch-schema/15-reset-goocoos.sql new file mode 100644 index 000000000..ca4d3fa11 --- /dev/null +++ b/patch-schema/15-reset-goocoos.sql @@ -0,0 +1,5 @@ +BEGIN; + +UPDATE goocoo SET goocoo0=NULL, goocoo1=NULL, goocoo2=NULL, goocoo3=NULL, goocoo4=NULL; + +END; \ No newline at end of file diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 193ccdd9f..fe26d0d6b 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -959,56 +959,44 @@ func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) { doAckBufSucceed(s, pkt.AckHandle, bf.Data()) } -func getGookData(s *Session, cid uint32) (uint16, []byte) { - var data []byte - var count uint16 - bf := byteframe.NewByteFrame() +func getGoocooData(s *Session, cid uint32) [][]byte { + var goocoo []byte + var goocoos [][]byte 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 { s.server.db.Exec("INSERT INTO goocoo (id) VALUES ($1)", s.charID) - return 0, bf.Data() + return goocoos } - if err == nil && data != nil { - count++ - 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) - } + if err == nil && goocoo != nil { + goocoos = append(goocoos, goocoo) } } - return count, bf.Data() + return goocoos } func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot) bf := byteframe.NewByteFrame() - count, data := getGookData(s, s.charID) - bf.WriteUint16(count) - bf.WriteBytes(data) + goocoos := getGoocooData(s, s.charID) + bf.WriteUint16(uint16(len(goocoos))) + bf.WriteUint16(0) + for _, goocoo := range goocoos { + bf.WriteBytes(goocoo) + } doAckBufSucceed(s, pkt.AckHandle, bf.Data()) } func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfUpdateGuacot) 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) } else { bf := byteframe.NewByteFrame() bf.WriteUint32(goocoo.Index) - for i := range goocoo.Data1 { - bf.WriteUint16(goocoo.Data1[i]) - } - for i := range goocoo.Data2 { - bf.WriteUint32(goocoo.Data2[i]) - } + bf.WriteBytes(goocoo.Data) bf.WriteUint8(uint8(len(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) diff --git a/server/channelserver/handlers_house.go b/server/channelserver/handlers_house.go index 62561c96d..3f6188750 100644 --- a/server/channelserver/handlers_house.go +++ b/server/channelserver/handlers_house.go @@ -215,10 +215,12 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) { bf.WriteBytes(houseFurniture) case 10: // Garden bf.WriteBytes(garden) - c, d := getGookData(s, pkt.CharID) - bf.WriteUint16(c) + goocoos := getGoocooData(s, pkt.CharID) + bf.WriteUint16(uint16(len(goocoos))) bf.WriteUint16(0) - bf.WriteBytes(d) + for _, goocoo := range goocoos { + bf.WriteBytes(goocoo) + } } if len(bf.Data()) == 0 { doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))