diff --git a/network/mhfpacket/msg_mhf_add_ud_point.go b/network/mhfpacket/msg_mhf_add_ud_point.go index 3ccefa9ec..9b3998239 100644 --- a/network/mhfpacket/msg_mhf_add_ud_point.go +++ b/network/mhfpacket/msg_mhf_add_ud_point.go @@ -1,18 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfAddUdPoint represents the MSG_MHF_ADD_UD_POINT type MsgMhfAddUdPoint struct { AckHandle uint32 - Unk1 uint32 - Unk2 uint32 + Points uint32 } // Opcode returns the ID associated with this packet type. @@ -23,11 +22,10 @@ func (m *MsgMhfAddUdPoint) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfAddUdPoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.Unk1 = bf.ReadUint32() - m.Unk2 = bf.ReadUint32() - + m.Points += bf.ReadUint32() + // Premium Course bonus + m.Points += bf.ReadUint32() return nil - //panic("Not implemented") } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_set_kiju.go b/network/mhfpacket/msg_mhf_set_kiju.go index 24cc82101..c0d202776 100644 --- a/network/mhfpacket/msg_mhf_set_kiju.go +++ b/network/mhfpacket/msg_mhf_set_kiju.go @@ -1,17 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfSetKiju represents the MSG_MHF_SET_KIJU type MsgMhfSetKiju struct { AckHandle uint32 - Unk1 uint16 + BeadIndex uint8 } // Opcode returns the ID associated with this packet type. @@ -22,9 +22,8 @@ func (m *MsgMhfSetKiju) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfSetKiju) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.Unk1 = bf.ReadUint16() + m.BeadIndex = bf.ReadUint8() return nil - //panic("Not implemented") } // Build builds a binary packet from the current data. diff --git a/patch-schema/diva.sql b/patch-schema/diva.sql index caf0f6598..ae939a2d0 100644 --- a/patch-schema/diva.sql +++ b/patch-schema/diva.sql @@ -21,4 +21,14 @@ CREATE TABLE IF NOT EXISTS public.diva_beads ( type INTEGER ); +ALTER TABLE IF EXISTS public.characters + ADD COLUMN IF NOT EXISTS diva_bead INTEGER; + +CREATE TABLE IF NOT EXISTS public.diva_beads_points ( + character_id INTEGER, + points INTEGER, + timestamp TIMESTAMP WITH TIME ZONE, + bead_index INTEGER +); + END; \ No newline at end of file diff --git a/server/channelserver/handlers_diva.go b/server/channelserver/handlers_diva.go index 6451489a9..90c330722 100644 --- a/server/channelserver/handlers_diva.go +++ b/server/channelserver/handlers_diva.go @@ -82,10 +82,7 @@ func handleMsgMhfGetUdSchedule(s *Session, p mhfpacket.MHFPacket) { bf := byteframe.NewByteFrame() id, start := uint32(0xCAFEBEEF), uint32(0) - rows, _ := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'") - for rows.Next() { - rows.Scan(&id, &start) - } + _ = s.server.db.QueryRow("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'").Scan(&id, &start) var timestamps []uint32 if s.server.erupeConfig.DevMode && s.server.erupeConfig.DevModeOptions.DivaEvent >= 0 { @@ -141,7 +138,7 @@ func handleMsgMhfGetUdInfo(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetKijuInfo(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfGetKijuInfo) beads := []uint8{1, 3, 4, 8} - rows, err := s.server.db.Queryx(`SELECT * FROM diva_beads`) + rows, err := s.server.db.Query(`SELECT * FROM diva_beads`) if err == nil { var i int for rows.Next() { @@ -173,11 +170,13 @@ func handleMsgMhfGetKijuInfo(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfSetKiju(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfSetKiju) + s.server.db.Exec(`UPDATE characters SET diva_bead=$1 WHERE id=$2`, pkt.BeadIndex, s.charID) doAckBufSucceed(s, pkt.AckHandle, []byte{0}) } func handleMsgMhfAddUdPoint(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfAddUdPoint) + s.server.db.Exec(`INSERT INTO diva_beads_points VALUES ($1, $2, now(), (SELECT diva_bead FROM characters WHERE id=$1))`, s.charID, pkt.Points) doAckBufSucceed(s, pkt.AckHandle, []byte{0}) }