diff --git a/Erupe/gook.sql b/Erupe/gook.sql index af70efd86..d9b2f1f05 100644 --- a/Erupe/gook.sql +++ b/Erupe/gook.sql @@ -21,4 +21,6 @@ ALTER TABLE IF EXISTS public.gook ALTER TABLE IF EXISTS public.gook DROP COLUMN IF EXISTS gook5; +UPDATE public.gook SET gook1=NULL, gook2=NULL, gook3=NULL, gook4=NULL; + END; \ No newline at end of file diff --git a/Erupe/network/mhfpacket/msg_mhf_update_guacot.go b/Erupe/network/mhfpacket/msg_mhf_update_guacot.go index c5a73944e..99aa215e2 100644 --- a/Erupe/network/mhfpacket/msg_mhf_update_guacot.go +++ b/Erupe/network/mhfpacket/msg_mhf_update_guacot.go @@ -9,14 +9,12 @@ import ( ) type Gook struct { - Exists bool - Index uint32 - Type uint16 - Data []byte - Birthday1 uint32 - Birthday2 uint32 - NameLen uint8 - Name []byte + Exists bool + Index uint32 + Type uint16 + Data []byte + NameLen uint8 + Name []byte } // MsgMhfUpdateGuacot represents the MSG_MHF_UPDATE_GUACOT @@ -41,9 +39,7 @@ func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clien e := Gook{} e.Index = bf.ReadUint32() e.Type = bf.ReadUint16() - e.Data = bf.ReadBytes(42) - e.Birthday1 = bf.ReadUint32() - e.Birthday2 = bf.ReadUint32() + e.Data = bf.ReadBytes(50) e.NameLen = bf.ReadUint8() e.Name = bf.ReadBytes(uint(e.NameLen)) if e.Type > 0 { diff --git a/Erupe/server/channelserver/handlers.go b/Erupe/server/channelserver/handlers.go index 4381d8ca2..3adab427f 100644 --- a/Erupe/server/channelserver/handlers.go +++ b/Erupe/server/channelserver/handlers.go @@ -577,22 +577,35 @@ func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {} -func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) { - pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot) +func getGookData(s *Session, cid uint32) []byte { var data []byte var count uint16 bf := byteframe.NewByteFrame() for i := 0; i < 5; i++ { - err := s.server.db.QueryRow(fmt.Sprintf("SELECT gook%d FROM gook WHERE id=$1", i), s.charID).Scan(&data) + err := s.server.db.QueryRow(fmt.Sprintf("SELECT gook%d FROM gook WHERE id=$1", i), cid).Scan(&data) if err == nil && data != nil { count++ - bf.WriteBytes(data) + if s.charID == cid && count == 1 { + gook := byteframe.NewByteFrameFromBytes(data) + bf.WriteBytes(gook.ReadBytes(4)) + d := gook.ReadBytes(2) + bf.WriteBytes(d) + bf.WriteBytes(d) + bf.WriteBytes(gook.DataFromCurrent()) + } else { + bf.WriteBytes(data) + } } } resp := byteframe.NewByteFrame() resp.WriteUint16(count) resp.WriteBytes(bf.Data()) - doAckBufSucceed(s, pkt.AckHandle, resp.Data()) + return resp.Data() +} + +func handleMsgMhfEnumerateGuacot(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfEnumerateGuacot) + doAckBufSucceed(s, pkt.AckHandle, getGookData(s, s.charID)) } func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) { @@ -601,23 +614,10 @@ func handleMsgMhfUpdateGuacot(s *Session, p mhfpacket.MHFPacket) { if !gook.Exists { s.server.db.Exec(fmt.Sprintf("UPDATE gook SET gook%d=NULL WHERE id=$1", gook.Index), s.charID) } else { - // TODO: Birthdays are still 7 years in the past - //var data []byte - //err := s.server.db.QueryRow(fmt.Sprintf("SELECT gook%d FROM gook WHERE id=$1", gook.Index), s.charID).Scan(&data) - //if err != nil && data == nil { // If index doesn't exist - // // Give gook a birthday not 7 years ago - // gook.Birthday1 = uint32(time.Now().Unix()) - // gook.Birthday2 = uint32(time.Now().Unix()) - //} bf := byteframe.NewByteFrame() bf.WriteUint32(gook.Index) - if gook.Index == 0 { - bf.WriteUint16(gook.Type) - } bf.WriteUint16(gook.Type) bf.WriteBytes(gook.Data) - bf.WriteUint32(gook.Birthday1) - bf.WriteUint32(gook.Birthday2) 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)