diff --git a/network/mhfpacket/msg_mhf_enumerate_guacot.go b/network/mhfpacket/msg_mhf_enumerate_guacot.go index 4fcdba523..2f970f938 100644 --- a/network/mhfpacket/msg_mhf_enumerate_guacot.go +++ b/network/mhfpacket/msg_mhf_enumerate_guacot.go @@ -2,7 +2,6 @@ package mhfpacket import ( "errors" - "erupe-ce/common/byteframe" "erupe-ce/network" "erupe-ce/network/clientctx" @@ -11,9 +10,8 @@ import ( // MsgMhfEnumerateGuacot represents the MSG_MHF_ENUMERATE_GUACOT type MsgMhfEnumerateGuacot struct { AckHandle uint32 - Unk0 uint16 // Hardcoded 0 in binary + Unk0 uint32 // Hardcoded 0 in binary Unk1 uint16 // Hardcoded 0 in binary - Unk2 uint16 // Hardcoded 0 in binary } // Opcode returns the ID associated with this packet type. @@ -24,9 +22,8 @@ func (m *MsgMhfEnumerateGuacot) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfEnumerateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.Unk0 = bf.ReadUint16() + m.Unk0 = bf.ReadUint32() m.Unk1 = bf.ReadUint16() - m.Unk2 = bf.ReadUint16() return nil } diff --git a/network/mhfpacket/msg_mhf_update_guacot.go b/network/mhfpacket/msg_mhf_update_guacot.go index 99aa215e2..433854ae3 100644 --- a/network/mhfpacket/msg_mhf_update_guacot.go +++ b/network/mhfpacket/msg_mhf_update_guacot.go @@ -2,27 +2,23 @@ package mhfpacket import ( "errors" - "erupe-ce/common/byteframe" "erupe-ce/network" "erupe-ce/network/clientctx" ) -type Gook struct { - Exists bool - Index uint32 - Type uint16 - Data []byte - NameLen uint8 - Name []byte +type Goocoo struct { + Index uint32 + Data1 []uint16 + Data2 []uint32 + Name []byte } // MsgMhfUpdateGuacot represents the MSG_MHF_UPDATE_GUACOT type MsgMhfUpdateGuacot struct { AckHandle uint32 EntryCount uint16 - Unk0 uint16 // Hardcoded 0 in binary - Gooks []Gook + Goocoos []Goocoo } // Opcode returns the ID associated with this packet type. @@ -34,20 +30,18 @@ func (m *MsgMhfUpdateGuacot) Opcode() network.PacketID { func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() m.EntryCount = bf.ReadUint16() - m.Unk0 = bf.ReadUint16() + _ = bf.ReadUint16() // Zero + var temp Goocoo for i := 0; i < int(m.EntryCount); i++ { - e := Gook{} - e.Index = bf.ReadUint32() - e.Type = bf.ReadUint16() - e.Data = bf.ReadBytes(50) - e.NameLen = bf.ReadUint8() - e.Name = bf.ReadBytes(uint(e.NameLen)) - if e.Type > 0 { - e.Exists = true - } else { - e.Exists = false + temp.Index = bf.ReadUint32() + for j := 0; j < 22; j++ { + temp.Data1 = append(temp.Data1, bf.ReadUint16()) } - m.Gooks = append(m.Gooks, e) + for j := 0; j < 2; j++ { + temp.Data2 = append(temp.Data2, bf.ReadUint32()) + } + temp.Name = bf.ReadBytes(uint(bf.ReadUint8())) + m.Goocoos = append(m.Goocoos, temp) } return nil } diff --git a/patch-schema/06-goocoo-rename.sql b/patch-schema/06-goocoo-rename.sql new file mode 100644 index 000000000..e72585ab3 --- /dev/null +++ b/patch-schema/06-goocoo-rename.sql @@ -0,0 +1,11 @@ +BEGIN; + +ALTER TABLE gook RENAME TO goocoo; + +ALTER TABLE goocoo RENAME COLUMN gook0 TO goocoo0; +ALTER TABLE goocoo RENAME COLUMN gook1 TO goocoo1; +ALTER TABLE goocoo RENAME COLUMN gook2 TO goocoo2; +ALTER TABLE goocoo RENAME COLUMN gook3 TO goocoo3; +ALTER TABLE goocoo RENAME COLUMN gook4 TO goocoo4; + +END; \ No newline at end of file diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index abc554d06..517da6e6d 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -822,21 +822,25 @@ func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfUpdateGuacot) - for _, gook := range pkt.Gooks { - if !gook.Exists { - s.server.db.Exec(fmt.Sprintf("UPDATE gook SET gook%d=NULL WHERE id=$1", gook.Index), s.charID) + for _, goocoo := range pkt.Goocoos { + if goocoo.Data1[0] == 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(gook.Index) - bf.WriteUint16(gook.Type) - bf.WriteBytes(gook.Data) - bf.WriteUint8(gook.NameLen) - bf.WriteBytes(gook.Name) - s.server.db.Exec(fmt.Sprintf("UPDATE gook SET gook%d=$1 WHERE id=$2", gook.Index), bf.Data(), s.charID) - dumpSaveData(s, bf.Data(), fmt.Sprintf("goocoo-%d", gook.Index)) + 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.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) + dumpSaveData(s, bf.Data(), fmt.Sprintf("goocoo-%d", goocoo.Index)) } } - doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00}) + doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) } func handleMsgMhfInfoScenarioCounter(s *Session, p mhfpacket.MHFPacket) {