mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 08:55:31 +01:00
decode UD packets & preliminary handling & schema
This commit is contained in:
@@ -3,16 +3,15 @@ package mhfpacket
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
|
||||||
"erupe-ce/network"
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
"erupe-ce/network"
|
||||||
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfAddUdPoint represents the MSG_MHF_ADD_UD_POINT
|
// MsgMhfAddUdPoint represents the MSG_MHF_ADD_UD_POINT
|
||||||
type MsgMhfAddUdPoint struct {
|
type MsgMhfAddUdPoint struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk1 uint32
|
Points uint32
|
||||||
Unk2 uint32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// 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
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfAddUdPoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfAddUdPoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk1 = bf.ReadUint32()
|
m.Points += bf.ReadUint32()
|
||||||
m.Unk2 = bf.ReadUint32()
|
// Premium Course bonus
|
||||||
|
m.Points += bf.ReadUint32()
|
||||||
return nil
|
return nil
|
||||||
//panic("Not implemented")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ package mhfpacket
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
|
||||||
"erupe-ce/network"
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
"erupe-ce/network"
|
||||||
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfSetKiju represents the MSG_MHF_SET_KIJU
|
// MsgMhfSetKiju represents the MSG_MHF_SET_KIJU
|
||||||
type MsgMhfSetKiju struct {
|
type MsgMhfSetKiju struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk1 uint16
|
BeadIndex uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// 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
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfSetKiju) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfSetKiju) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk1 = bf.ReadUint16()
|
m.BeadIndex = bf.ReadUint8()
|
||||||
return nil
|
return nil
|
||||||
//panic("Not implemented")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -21,4 +21,14 @@ CREATE TABLE IF NOT EXISTS public.diva_beads (
|
|||||||
type INTEGER
|
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;
|
END;
|
||||||
@@ -82,10 +82,7 @@ func handleMsgMhfGetUdSchedule(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
|
|
||||||
id, start := uint32(0xCAFEBEEF), uint32(0)
|
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'")
|
_ = s.server.db.QueryRow("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'").Scan(&id, &start)
|
||||||
for rows.Next() {
|
|
||||||
rows.Scan(&id, &start)
|
|
||||||
}
|
|
||||||
|
|
||||||
var timestamps []uint32
|
var timestamps []uint32
|
||||||
if s.server.erupeConfig.DevMode && s.server.erupeConfig.DevModeOptions.DivaEvent >= 0 {
|
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) {
|
func handleMsgMhfGetKijuInfo(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfGetKijuInfo)
|
pkt := p.(*mhfpacket.MsgMhfGetKijuInfo)
|
||||||
beads := []uint8{1, 3, 4, 8}
|
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 {
|
if err == nil {
|
||||||
var i int
|
var i int
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
@@ -173,11 +170,13 @@ func handleMsgMhfGetKijuInfo(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func handleMsgMhfSetKiju(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfSetKiju(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfSetKiju)
|
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})
|
doAckBufSucceed(s, pkt.AckHandle, []byte{0})
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfAddUdPoint(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfAddUdPoint(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfAddUdPoint)
|
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})
|
doAckBufSucceed(s, pkt.AckHandle, []byte{0})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user