mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
initial hunting-tournament commit
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"MaxHexdumpLength": 256,
|
"MaxHexdumpLength": 256,
|
||||||
"DivaEvent": 0,
|
"DivaEvent": 0,
|
||||||
"FestaEvent": -1,
|
"FestaEvent": -1,
|
||||||
"TournamentEvent": 0,
|
"TournamentEvent": -1,
|
||||||
"MezFesEvent": true,
|
"MezFesEvent": true,
|
||||||
"MezFesAlt": false,
|
"MezFesAlt": false,
|
||||||
"DisableTokenCheck": false,
|
"DisableTokenCheck": false,
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfEnumerateOrder represents the MSG_MHF_ENUMERATE_ORDER
|
// MsgMhfEnumerateOrder represents the MSG_MHF_ENUMERATE_ORDER
|
||||||
type MsgMhfEnumerateOrder struct {
|
type MsgMhfEnumerateOrder struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk0 uint32
|
EventID uint32
|
||||||
Unk1 uint32
|
Unk1 uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ func (m *MsgMhfEnumerateOrder) Opcode() network.PacketID {
|
|||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfEnumerateOrder) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfEnumerateOrder) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint32()
|
m.EventID = bf.ReadUint32()
|
||||||
m.Unk1 = bf.ReadUint32()
|
m.Unk1 = bf.ReadUint32()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -635,11 +635,6 @@ func handleMsgMhfEnumeratePrice(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckBufSucceed(s, pkt.AckHandle, data)
|
doAckBufSucceed(s, pkt.AckHandle, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateOrder(s *Session, p mhfpacket.MHFPacket) {
|
|
||||||
pkt := p.(*mhfpacket.MsgMhfEnumerateOrder)
|
|
||||||
stubEnumerateNoResults(s, pkt.AckHandle)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleMsgMhfGetExtraInfo(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfGetExtraInfo(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateUnionItem(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfEnumerateUnionItem(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
|||||||
@@ -33,62 +33,166 @@ func handleMsgMhfLoadMezfesData(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generateTournamentTimestamps(start uint32, debug bool) []uint32 {
|
||||||
|
timestamps := make([]uint32, 4)
|
||||||
|
midnight := TimeMidnight()
|
||||||
|
if debug && start <= 3 {
|
||||||
|
midnight := uint32(midnight.Unix())
|
||||||
|
switch start {
|
||||||
|
case 1:
|
||||||
|
timestamps[0] = midnight
|
||||||
|
timestamps[1] = timestamps[0] + 259200
|
||||||
|
timestamps[2] = timestamps[1] + 766800
|
||||||
|
timestamps[3] = timestamps[2] + 604800
|
||||||
|
case 2:
|
||||||
|
timestamps[0] = midnight - 259200
|
||||||
|
timestamps[1] = midnight
|
||||||
|
timestamps[2] = timestamps[1] + 766800
|
||||||
|
timestamps[3] = timestamps[2] + 604800
|
||||||
|
case 3:
|
||||||
|
timestamps[0] = midnight - 1026000
|
||||||
|
timestamps[1] = midnight - 766800
|
||||||
|
timestamps[2] = midnight
|
||||||
|
timestamps[3] = timestamps[2] + 604800
|
||||||
|
}
|
||||||
|
return timestamps
|
||||||
|
}
|
||||||
|
timestamps[0] = start
|
||||||
|
timestamps[1] = timestamps[0] + 259200
|
||||||
|
timestamps[2] = timestamps[1] + 766800
|
||||||
|
timestamps[3] = timestamps[2] + 604800
|
||||||
|
return timestamps
|
||||||
|
}
|
||||||
|
|
||||||
|
type TournamentEvent struct {
|
||||||
|
ID uint32
|
||||||
|
CupGroup uint16
|
||||||
|
Limit int16
|
||||||
|
QuestFile uint32
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type TournamentCup struct {
|
||||||
|
ID uint32
|
||||||
|
CupGroup uint16
|
||||||
|
Type uint16
|
||||||
|
Unk2 uint16
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateRanking(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfEnumerateRanking(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfEnumerateRanking)
|
pkt := p.(*mhfpacket.MsgMhfEnumerateRanking)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
state := s.server.erupeConfig.DevModeOptions.TournamentEvent
|
|
||||||
// Unk
|
id, start := uint32(0xBEEFDEAD), uint32(0)
|
||||||
// Unk
|
rows, _ := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='festa'")
|
||||||
// Start?
|
for rows.Next() {
|
||||||
// End?
|
rows.Scan(&id, &start)
|
||||||
midnight := TimeMidnight()
|
}
|
||||||
switch state {
|
|
||||||
case 1:
|
var timestamps []uint32
|
||||||
bf.WriteUint32(uint32(midnight.Unix()))
|
if s.server.erupeConfig.DevMode && s.server.erupeConfig.DevModeOptions.TournamentEvent >= 0 {
|
||||||
bf.WriteUint32(uint32(midnight.Add(3 * 24 * time.Hour).Unix()))
|
if s.server.erupeConfig.DevModeOptions.TournamentEvent == 0 {
|
||||||
bf.WriteUint32(uint32(midnight.Add(13 * 24 * time.Hour).Unix()))
|
bf.WriteBytes(make([]byte, 16))
|
||||||
bf.WriteUint32(uint32(midnight.Add(20 * 24 * time.Hour).Unix()))
|
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
||||||
case 2:
|
bf.WriteUint8(0)
|
||||||
bf.WriteUint32(uint32(midnight.Add(-3 * 24 * time.Hour).Unix()))
|
ps.Uint8(bf, "", true)
|
||||||
bf.WriteUint32(uint32(midnight.Unix()))
|
bf.WriteUint16(0)
|
||||||
bf.WriteUint32(uint32(midnight.Add(10 * 24 * time.Hour).Unix()))
|
bf.WriteUint8(0)
|
||||||
bf.WriteUint32(uint32(midnight.Add(17 * 24 * time.Hour).Unix()))
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
case 3:
|
return
|
||||||
bf.WriteUint32(uint32(midnight.Add(-13 * 24 * time.Hour).Unix()))
|
}
|
||||||
bf.WriteUint32(uint32(midnight.Add(-10 * 24 * time.Hour).Unix()))
|
timestamps = generateTournamentTimestamps(uint32(s.server.erupeConfig.DevModeOptions.TournamentEvent), true)
|
||||||
bf.WriteUint32(uint32(midnight.Unix()))
|
} else {
|
||||||
bf.WriteUint32(uint32(midnight.Add(7 * 24 * time.Hour).Unix()))
|
timestamps = generateTournamentTimestamps(start, false)
|
||||||
default:
|
}
|
||||||
|
|
||||||
|
if timestamps[0] > uint32(TimeAdjusted().Unix()) {
|
||||||
bf.WriteBytes(make([]byte, 16))
|
bf.WriteBytes(make([]byte, 16))
|
||||||
bf.WriteUint32(uint32(TimeAdjusted().Unix())) // TS Current Time
|
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
||||||
bf.WriteUint8(3)
|
bf.WriteUint8(0)
|
||||||
bf.WriteBytes(make([]byte, 4))
|
ps.Uint8(bf, "", true)
|
||||||
|
bf.WriteUint16(0)
|
||||||
|
bf.WriteUint8(0)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bf.WriteUint32(uint32(TimeAdjusted().Unix())) // TS Current Time
|
|
||||||
bf.WriteUint8(3)
|
|
||||||
ps.Uint8(bf, "", false)
|
|
||||||
bf.WriteUint16(0) // numEvents
|
|
||||||
bf.WriteUint8(0) // numCups
|
|
||||||
|
|
||||||
/*
|
for _, timestamp := range timestamps {
|
||||||
struct event
|
bf.WriteUint32(timestamp)
|
||||||
uint32 eventID
|
}
|
||||||
uint16 unk
|
bf.WriteUint32(uint32(TimeAdjusted().Unix()))
|
||||||
uint16 unk
|
bf.WriteUint8(1) // TODO: Make this dynamic depending on timestamp
|
||||||
uint32 unk
|
ps.Uint8(bf, "", true)
|
||||||
psUint8 name
|
|
||||||
|
|
||||||
struct cup
|
// Temp direct port
|
||||||
uint32 cupID
|
tournamentEvents := []TournamentEvent{
|
||||||
uint16 unk
|
{2644, 16, 0, 62151, ""},
|
||||||
uint16 unk
|
{2645, 16, 1, 62151, ""},
|
||||||
uint16 unk
|
{2646, 16, 2, 62151, ""},
|
||||||
psUint8 name
|
{2647, 16, 3, 62151, ""},
|
||||||
psUint16 desc
|
{2648, 16, 4, 62151, ""},
|
||||||
*/
|
{2649, 16, 5, 62151, ""},
|
||||||
|
{2650, 16, 6, 62151, ""},
|
||||||
|
{2651, 16, 7, 62151, ""},
|
||||||
|
{2652, 16, 8, 62151, ""},
|
||||||
|
{2653, 16, 9, 62151, ""},
|
||||||
|
{2654, 16, 10, 62151, ""},
|
||||||
|
{2655, 16, 11, 62151, ""},
|
||||||
|
{2656, 16, 12, 62151, ""},
|
||||||
|
{2657, 16, 13, 62151, ""},
|
||||||
|
{2658, 17, -1, 62150, ""},
|
||||||
|
{2659, 6, 234, 0, ""},
|
||||||
|
{2660, 6, 237, 0, ""},
|
||||||
|
{2661, 6, 239, 0, ""},
|
||||||
|
}
|
||||||
|
tournamentCups := []TournamentCup{
|
||||||
|
{569, 6, 6, 0, "", ""},
|
||||||
|
{570, 17, 7, 0, "", ""},
|
||||||
|
{571, 16, 7, 0, "", ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
bf.WriteUint16(uint16(len(tournamentEvents)))
|
||||||
|
for _, event := range tournamentEvents {
|
||||||
|
bf.WriteUint32(event.ID)
|
||||||
|
bf.WriteUint16(event.CupGroup)
|
||||||
|
bf.WriteInt16(event.Limit)
|
||||||
|
bf.WriteUint32(event.QuestFile)
|
||||||
|
ps.Uint8(bf, event.Name, true)
|
||||||
|
}
|
||||||
|
bf.WriteUint8(uint8(len(tournamentCups)))
|
||||||
|
for _, cup := range tournamentCups {
|
||||||
|
bf.WriteUint32(cup.ID)
|
||||||
|
bf.WriteUint16(cup.CupGroup)
|
||||||
|
bf.WriteUint16(cup.Type)
|
||||||
|
bf.WriteUint16(cup.Unk2)
|
||||||
|
ps.Uint8(bf, cup.Name, true)
|
||||||
|
ps.Uint16(bf, cup.Description, true)
|
||||||
|
}
|
||||||
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
|
}
|
||||||
|
|
||||||
|
type TournamentRanking struct {
|
||||||
|
Unk0 uint32
|
||||||
|
Unk1 uint32
|
||||||
|
Unk2 uint16
|
||||||
|
Unk3 uint16 // Unused
|
||||||
|
Unk4 uint16
|
||||||
|
Unk5 uint16
|
||||||
|
Unk6 uint16
|
||||||
|
Unk7 uint8
|
||||||
|
Unk8 string
|
||||||
|
Unk9 string
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleMsgMhfEnumerateOrder(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfEnumerateOrder)
|
||||||
|
bf := byteframe.NewByteFrame()
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint32(0)
|
||||||
|
bf.WriteUint16(0)
|
||||||
|
bf.WriteUint16(0)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,10 +230,10 @@ func generateFestaTimestamps(s *Session, start uint32, debug bool) []uint32 {
|
|||||||
}
|
}
|
||||||
return timestamps
|
return timestamps
|
||||||
}
|
}
|
||||||
if start == 0 || TimeAdjusted().Unix() > int64(start)+2977200 {
|
if start == 0 || TimeAdjusted().Unix() > int64(start)+3024000 {
|
||||||
cleanupFesta(s)
|
cleanupFesta(s)
|
||||||
// Generate a new festa, starting midnight tomorrow
|
// Generate a new festa, starting 11am tomorrow
|
||||||
start = uint32(midnight.Add(24 * time.Hour).Unix())
|
start = uint32(midnight.Add(35 * time.Hour).Unix())
|
||||||
s.server.db.Exec("INSERT INTO events (event_type, start_time) VALUES ('festa', to_timestamp($1)::timestamp without time zone)", start)
|
s.server.db.Exec("INSERT INTO events (event_type, start_time) VALUES ('festa', to_timestamp($1)::timestamp without time zone)", start)
|
||||||
}
|
}
|
||||||
timestamps[0] = start
|
timestamps[0] = start
|
||||||
|
|||||||
Reference in New Issue
Block a user