Merge pull request #86 from ZeruLight/chore/rename-goocoo

rename instances of gook to goocoo
This commit is contained in:
wish
2023-09-25 20:11:13 +10:00
committed by GitHub
4 changed files with 44 additions and 38 deletions

View File

@@ -2,7 +2,6 @@ package mhfpacket
import ( import (
"errors" "errors"
"erupe-ce/common/byteframe" "erupe-ce/common/byteframe"
"erupe-ce/network" "erupe-ce/network"
"erupe-ce/network/clientctx" "erupe-ce/network/clientctx"
@@ -11,9 +10,8 @@ import (
// MsgMhfEnumerateGuacot represents the MSG_MHF_ENUMERATE_GUACOT // MsgMhfEnumerateGuacot represents the MSG_MHF_ENUMERATE_GUACOT
type MsgMhfEnumerateGuacot struct { type MsgMhfEnumerateGuacot struct {
AckHandle uint32 AckHandle uint32
Unk0 uint16 // Hardcoded 0 in binary Unk0 uint32 // Hardcoded 0 in binary
Unk1 uint16 // 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. // 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 // Parse parses the packet from binary
func (m *MsgMhfEnumerateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { func (m *MsgMhfEnumerateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32() m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16() m.Unk0 = bf.ReadUint32()
m.Unk1 = bf.ReadUint16() m.Unk1 = bf.ReadUint16()
m.Unk2 = bf.ReadUint16()
return nil return nil
} }

View File

@@ -2,27 +2,23 @@ package mhfpacket
import ( import (
"errors" "errors"
"erupe-ce/common/byteframe" "erupe-ce/common/byteframe"
"erupe-ce/network" "erupe-ce/network"
"erupe-ce/network/clientctx" "erupe-ce/network/clientctx"
) )
type Gook struct { type Goocoo struct {
Exists bool Index uint32
Index uint32 Data1 []uint16
Type uint16 Data2 []uint32
Data []byte Name []byte
NameLen uint8
Name []byte
} }
// MsgMhfUpdateGuacot represents the MSG_MHF_UPDATE_GUACOT // MsgMhfUpdateGuacot represents the MSG_MHF_UPDATE_GUACOT
type MsgMhfUpdateGuacot struct { type MsgMhfUpdateGuacot struct {
AckHandle uint32 AckHandle uint32
EntryCount uint16 EntryCount uint16
Unk0 uint16 // Hardcoded 0 in binary Goocoos []Goocoo
Gooks []Gook
} }
// Opcode returns the ID associated with this packet type. // 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 { func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32() m.AckHandle = bf.ReadUint32()
m.EntryCount = bf.ReadUint16() m.EntryCount = bf.ReadUint16()
m.Unk0 = bf.ReadUint16() _ = bf.ReadUint16() // Zero
var temp Goocoo
for i := 0; i < int(m.EntryCount); i++ { for i := 0; i < int(m.EntryCount); i++ {
e := Gook{} temp.Index = bf.ReadUint32()
e.Index = bf.ReadUint32() for j := 0; j < 22; j++ {
e.Type = bf.ReadUint16() temp.Data1 = append(temp.Data1, 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
} }
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 return nil
} }

View File

@@ -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;

View File

@@ -822,21 +822,25 @@ func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfUpdateGuacot) pkt := p.(*mhfpacket.MsgMhfUpdateGuacot)
for _, gook := range pkt.Gooks { for _, goocoo := range pkt.Goocoos {
if !gook.Exists { if goocoo.Data1[0] == 0 {
s.server.db.Exec(fmt.Sprintf("UPDATE gook SET gook%d=NULL WHERE id=$1", gook.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(gook.Index) bf.WriteUint32(goocoo.Index)
bf.WriteUint16(gook.Type) for i := range goocoo.Data1 {
bf.WriteBytes(gook.Data) bf.WriteUint16(goocoo.Data1[i])
bf.WriteUint8(gook.NameLen) }
bf.WriteBytes(gook.Name) for i := range goocoo.Data2 {
s.server.db.Exec(fmt.Sprintf("UPDATE gook SET gook%d=$1 WHERE id=$2", gook.Index), bf.Data(), s.charID) bf.WriteUint32(goocoo.Data2[i])
dumpSaveData(s, bf.Data(), fmt.Sprintf("goocoo-%d", gook.Index)) }
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) { func handleMsgMhfInfoScenarioCounter(s *Session, p mhfpacket.MHFPacket) {