mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
decode Tournament handlers
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
package mhfpacket
|
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfAcquireTournament represents the MSG_MHF_ACQUIRE_TOURNAMENT
|
// MsgMhfAcquireTournament represents the MSG_MHF_ACQUIRE_TOURNAMENT
|
||||||
type MsgMhfAcquireTournament struct{}
|
type MsgMhfAcquireTournament struct {
|
||||||
|
AckHandle uint32
|
||||||
|
TournamentID uint32
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfAcquireTournament) Opcode() network.PacketID {
|
func (m *MsgMhfAcquireTournament) Opcode() network.PacketID {
|
||||||
@@ -18,7 +21,9 @@ func (m *MsgMhfAcquireTournament) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfAcquireTournament) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfAcquireTournament) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
m.TournamentID = bf.ReadUint32()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package mhfpacket
|
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfEntryTournament represents the MSG_MHF_ENTRY_TOURNAMENT
|
// MsgMhfEntryTournament represents the MSG_MHF_ENTRY_TOURNAMENT
|
||||||
type MsgMhfEntryTournament struct{}
|
type MsgMhfEntryTournament struct {
|
||||||
|
AckHandle uint32
|
||||||
|
TournamentID uint32
|
||||||
|
Unk0 uint8
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfEntryTournament) Opcode() network.PacketID {
|
func (m *MsgMhfEntryTournament) Opcode() network.PacketID {
|
||||||
@@ -18,7 +22,10 @@ func (m *MsgMhfEntryTournament) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfEntryTournament) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfEntryTournament) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
m.TournamentID = bf.ReadUint32()
|
||||||
|
m.Unk0 = bf.ReadUint8()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -7,54 +7,124 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TournamentInfo0 struct {
|
||||||
|
ID uint32
|
||||||
|
MaxPlayers uint32
|
||||||
|
CurrentPlayers uint32
|
||||||
|
Unk1 uint16
|
||||||
|
TextColor uint16
|
||||||
|
Unk2 uint32
|
||||||
|
Time1 time.Time
|
||||||
|
Time2 time.Time
|
||||||
|
Time3 time.Time
|
||||||
|
Time4 time.Time
|
||||||
|
Time5 time.Time
|
||||||
|
Time6 time.Time
|
||||||
|
Unk3 uint8
|
||||||
|
Unk4 uint8
|
||||||
|
MinHR uint32
|
||||||
|
MaxHR uint32
|
||||||
|
Unk5 string
|
||||||
|
Unk6 string
|
||||||
|
}
|
||||||
|
|
||||||
|
type TournamentInfo21 struct {
|
||||||
|
Unk0 uint32
|
||||||
|
Unk1 uint32
|
||||||
|
Unk2 uint32
|
||||||
|
Unk3 uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type TournamentInfo22 struct {
|
||||||
|
Unk0 uint32
|
||||||
|
Unk1 uint32
|
||||||
|
Unk2 uint32
|
||||||
|
Unk3 uint8
|
||||||
|
Unk4 string
|
||||||
|
}
|
||||||
|
|
||||||
func handleMsgMhfInfoTournament(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfInfoTournament(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfInfoTournament)
|
pkt := p.(*mhfpacket.MsgMhfInfoTournament)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
|
|
||||||
|
tournamentInfo0 := []TournamentInfo0{}
|
||||||
|
tournamentInfo21 := []TournamentInfo21{}
|
||||||
|
tournamentInfo22 := []TournamentInfo22{}
|
||||||
|
|
||||||
switch pkt.Unk0 {
|
switch pkt.Unk0 {
|
||||||
case 0:
|
case 0:
|
||||||
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
|
||||||
bf.WriteUint32(0) // Tied to schedule ID?
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
bf.WriteBytes(make([]byte, 21))
|
|
||||||
ps.Uint8(bf, "", false)
|
|
||||||
break
|
|
||||||
|
|
||||||
bf.WriteUint32(0xACEDCAFE)
|
|
||||||
|
|
||||||
bf.WriteUint32(5) // Active schedule?
|
|
||||||
|
|
||||||
bf.WriteUint32(1) // Schedule ID?
|
|
||||||
|
|
||||||
bf.WriteUint32(32) // Max players
|
|
||||||
bf.WriteUint32(0) // Registered players
|
|
||||||
|
|
||||||
bf.WriteUint16(0)
|
|
||||||
bf.WriteUint16(2) // Color code for schedule item
|
|
||||||
bf.WriteUint32(0)
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint32(uint32(len(tournamentInfo0)))
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * -10).Unix()))
|
for _, tinfo := range tournamentInfo0 {
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * 10).Unix()))
|
bf.WriteUint32(tinfo.ID)
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * 10).Unix()))
|
bf.WriteUint32(tinfo.MaxPlayers)
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * 10).Unix()))
|
bf.WriteUint32(tinfo.CurrentPlayers)
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * 10).Unix()))
|
bf.WriteUint16(tinfo.Unk1)
|
||||||
bf.WriteUint32(uint32(time.Now().Add(time.Hour * 10).Unix()))
|
bf.WriteUint16(tinfo.TextColor)
|
||||||
|
bf.WriteUint32(tinfo.Unk2)
|
||||||
bf.WriteBool(true) // Unk
|
bf.WriteUint32(uint32(tinfo.Time1.Unix()))
|
||||||
bf.WriteBool(false) // Cafe-only
|
bf.WriteUint32(uint32(tinfo.Time2.Unix()))
|
||||||
|
bf.WriteUint32(uint32(tinfo.Time3.Unix()))
|
||||||
bf.WriteUint32(0) // Min HR
|
bf.WriteUint32(uint32(tinfo.Time4.Unix()))
|
||||||
bf.WriteUint32(0) // Max HR
|
bf.WriteUint32(uint32(tinfo.Time5.Unix()))
|
||||||
|
bf.WriteUint32(uint32(tinfo.Time6.Unix()))
|
||||||
ps.Uint8(bf, "Test", false)
|
bf.WriteUint8(tinfo.Unk3)
|
||||||
|
bf.WriteUint8(tinfo.Unk4)
|
||||||
// ...
|
bf.WriteUint32(tinfo.MinHR)
|
||||||
|
bf.WriteUint32(tinfo.MaxHR)
|
||||||
|
ps.Uint8(bf, tinfo.Unk5, true)
|
||||||
|
ps.Uint16(bf, tinfo.Unk6, true)
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
||||||
|
bf.WriteUint32(0) // Registered ID
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint8(0)
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
ps.Uint8(bf, "", true)
|
||||||
|
case 2:
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint32(uint32(len(tournamentInfo21)))
|
||||||
|
for _, info := range tournamentInfo21 {
|
||||||
|
bf.WriteUint32(info.Unk0)
|
||||||
|
bf.WriteUint32(info.Unk1)
|
||||||
|
bf.WriteUint32(info.Unk2)
|
||||||
|
bf.WriteUint8(info.Unk3)
|
||||||
|
}
|
||||||
|
bf.WriteUint32(uint32(len(tournamentInfo22)))
|
||||||
|
for _, info := range tournamentInfo22 {
|
||||||
|
bf.WriteUint32(info.Unk0)
|
||||||
|
bf.WriteUint32(info.Unk1)
|
||||||
|
bf.WriteUint32(info.Unk2)
|
||||||
|
bf.WriteUint8(info.Unk3)
|
||||||
|
ps.Uint8(bf, info.Unk4, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfEntryTournament(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfEntryTournament(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfEntryTournament)
|
||||||
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
}
|
||||||
|
|
||||||
func handleMsgMhfAcquireTournament(s *Session, p mhfpacket.MHFPacket) {}
|
type TournamentReward struct {
|
||||||
|
Unk0 uint16
|
||||||
|
Unk1 uint16
|
||||||
|
Unk2 uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleMsgMhfAcquireTournament(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfAcquireTournament)
|
||||||
|
rewards := []TournamentReward{}
|
||||||
|
bf := byteframe.NewByteFrame()
|
||||||
|
bf.WriteUint8(uint8(len(rewards)))
|
||||||
|
for _, reward := range rewards {
|
||||||
|
bf.WriteUint16(reward.Unk0)
|
||||||
|
bf.WriteUint16(reward.Unk1)
|
||||||
|
bf.WriteUint16(reward.Unk2)
|
||||||
|
}
|
||||||
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user