mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-20 10:54:51 +01:00
Merge branch 'main' into feature/diva
# Conflicts: # bundled-schema/DivaShops.sql # bundled-schema/OtherShops.sql # patch-schema/shop-db.sql # server/channelserver/handlers_guild.go # server/channelserver/handlers_tactics.go
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
package mhfpacket
|
||||
|
||||
import (
|
||||
"errors"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"erupe-ce/network/clientctx"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
)
|
||||
|
||||
// MsgMhfGetRyoudama represents the MSG_MHF_GET_RYOUDAMA
|
||||
type MsgMhfGetRyoudama struct{
|
||||
AckHandle uint32
|
||||
Unk0 uint16
|
||||
Unk1 uint32
|
||||
Unk2 uint8
|
||||
type MsgMhfGetRyoudama struct {
|
||||
AckHandle uint32
|
||||
Unk0 uint8
|
||||
Unk1 uint8
|
||||
GuildID uint32
|
||||
Unk3 uint8
|
||||
}
|
||||
|
||||
// Opcode returns the ID associated with this packet type.
|
||||
@@ -24,9 +25,10 @@ func (m *MsgMhfGetRyoudama) Opcode() network.PacketID {
|
||||
// Parse parses the packet from binary
|
||||
func (m *MsgMhfGetRyoudama) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.Unk0 = bf.ReadUint16()
|
||||
m.Unk1 = bf.ReadUint32()
|
||||
m.Unk2 = bf.ReadUint8()
|
||||
m.Unk0 = bf.ReadUint8()
|
||||
m.Unk1 = bf.ReadUint8()
|
||||
m.GuildID = bf.ReadUint32()
|
||||
m.Unk3 = bf.ReadUint8()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ import (
|
||||
// MsgMhfPostTinyBin represents the MSG_MHF_POST_TINY_BIN
|
||||
type MsgMhfPostTinyBin struct {
|
||||
AckHandle uint32
|
||||
Unk []byte
|
||||
Unk0 uint16
|
||||
Unk1 uint8
|
||||
Unk2 uint8
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// Opcode returns the ID associated with this packet type.
|
||||
@@ -22,7 +25,10 @@ func (m *MsgMhfPostTinyBin) Opcode() network.PacketID {
|
||||
// Parse parses the packet from binary
|
||||
func (m *MsgMhfPostTinyBin) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.Unk = bf.ReadBytes(14)
|
||||
m.Unk0 = bf.ReadUint16()
|
||||
m.Unk1 = bf.ReadUint8()
|
||||
m.Unk2 = bf.ReadUint8()
|
||||
m.Data = bf.ReadBytes(uint(bf.ReadUint16()))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package mhfpacket
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"erupe-ce/common/stringsupport"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network"
|
||||
@@ -10,9 +11,16 @@ import (
|
||||
|
||||
// MsgMhfUpdateGuildMessageBoard represents the MSG_MHF_UPDATE_GUILD_MESSAGE_BOARD
|
||||
type MsgMhfUpdateGuildMessageBoard struct {
|
||||
AckHandle uint32
|
||||
MessageOp uint32
|
||||
Request []byte
|
||||
AckHandle uint32
|
||||
MessageOp uint32
|
||||
PostType uint32
|
||||
StampID uint32
|
||||
TitleLength uint32
|
||||
BodyLength uint32
|
||||
Title string
|
||||
Body string
|
||||
PostID uint32
|
||||
LikeState bool
|
||||
}
|
||||
|
||||
// Opcode returns the ID associated with this packet type.
|
||||
@@ -24,9 +32,31 @@ func (m *MsgMhfUpdateGuildMessageBoard) Opcode() network.PacketID {
|
||||
func (m *MsgMhfUpdateGuildMessageBoard) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.MessageOp = bf.ReadUint32()
|
||||
if m.MessageOp != 5 {
|
||||
m.Request = bf.DataFromCurrent()
|
||||
bf.Seek(int64(len(bf.Data())-2), 0)
|
||||
switch m.MessageOp {
|
||||
case 0:
|
||||
m.PostType = bf.ReadUint32()
|
||||
m.StampID = bf.ReadUint32()
|
||||
m.TitleLength = bf.ReadUint32()
|
||||
m.BodyLength = bf.ReadUint32()
|
||||
m.Title = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.BodyLength)))
|
||||
case 1:
|
||||
m.PostID = bf.ReadUint32()
|
||||
case 2:
|
||||
m.PostID = bf.ReadUint32()
|
||||
bf.ReadBytes(8)
|
||||
m.TitleLength = bf.ReadUint32()
|
||||
m.BodyLength = bf.ReadUint32()
|
||||
m.Title = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.TitleLength)))
|
||||
m.Body = stringsupport.SJISToUTF8(bf.ReadBytes(uint(m.BodyLength)))
|
||||
case 3:
|
||||
m.PostID = bf.ReadUint32()
|
||||
bf.ReadBytes(8)
|
||||
m.StampID = bf.ReadUint32()
|
||||
case 4:
|
||||
m.PostID = bf.ReadUint32()
|
||||
bf.ReadBytes(8)
|
||||
m.LikeState = bf.ReadBool()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,50 +3,17 @@ package mhfpacket
|
||||
import (
|
||||
"errors"
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/common/mhfcourse"
|
||||
ps "erupe-ce/common/pascalstring"
|
||||
"erupe-ce/network"
|
||||
"erupe-ce/network/clientctx"
|
||||
"golang.org/x/exp/slices"
|
||||
"math"
|
||||
)
|
||||
|
||||
/*
|
||||
00 58 // Opcode
|
||||
|
||||
00 00 00 00
|
||||
00 00 00 4e
|
||||
|
||||
00 04 // Count
|
||||
00 00 // Skipped(padding?)
|
||||
|
||||
00 01 00 00 00 00 00 00
|
||||
00 02 00 00 5d fa 14 c0
|
||||
00 03 00 00 5d fa 14 c0
|
||||
00 06 00 00 5d e7 05 10
|
||||
|
||||
00 00 // Count of some buf up to 0x800 bytes following it.
|
||||
|
||||
00 10 // Trailer
|
||||
*/
|
||||
|
||||
// ClientRight represents a right that the client has.
|
||||
type ClientRight struct {
|
||||
ID uint16
|
||||
Unk0 uint16
|
||||
Timestamp uint32
|
||||
}
|
||||
|
||||
type Course struct {
|
||||
Aliases []string
|
||||
ID uint16
|
||||
Value uint32
|
||||
}
|
||||
|
||||
// MsgSysUpdateRight represents the MSG_SYS_UPDATE_RIGHT
|
||||
type MsgSysUpdateRight struct {
|
||||
ClientRespAckHandle uint32 // If non-0, requests the client to send back a MSG_SYS_ACK packet with this value.
|
||||
Bitfield uint32
|
||||
Rights []ClientRight
|
||||
Rights []mhfcourse.Course
|
||||
UnkSize uint16 // Count of some buf up to 0x800 bytes following it.
|
||||
}
|
||||
|
||||
@@ -68,54 +35,13 @@ func (m *MsgSysUpdateRight) Build(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
||||
bf.WriteUint16(0)
|
||||
for _, v := range m.Rights {
|
||||
bf.WriteUint16(v.ID)
|
||||
bf.WriteUint16(v.Unk0)
|
||||
bf.WriteUint32(v.Timestamp)
|
||||
bf.WriteUint16(0)
|
||||
if v.Expiry.IsZero() {
|
||||
bf.WriteUint32(0)
|
||||
} else {
|
||||
bf.WriteUint32(uint32(v.Expiry.Unix()))
|
||||
}
|
||||
}
|
||||
ps.Uint16(bf, "", false) // update client login token / password in the game's launcherstate struct
|
||||
return nil
|
||||
}
|
||||
|
||||
func Courses() []Course {
|
||||
var courses = []Course{
|
||||
{Aliases: []string{"Trial", "TL"}, ID: 1},
|
||||
{Aliases: []string{"HunterLife", "HL"}, ID: 2},
|
||||
{Aliases: []string{"Extra", "ExtraA", "EX"}, ID: 3},
|
||||
{Aliases: []string{"ExtraB"}, ID: 4},
|
||||
{Aliases: []string{"Mobile"}, ID: 5},
|
||||
{Aliases: []string{"Premium"}, ID: 6},
|
||||
{Aliases: []string{"Pallone", "ExtraC"}, ID: 7},
|
||||
{Aliases: []string{"Assist", "Legend", "Rasta"}, ID: 8}, // Legend
|
||||
{Aliases: []string{"N"}, ID: 9},
|
||||
{Aliases: []string{"Hiden", "Secret"}, ID: 10}, // Secret
|
||||
{Aliases: []string{"HunterSupport", "HunterAid", "Support", "Aid", "Royal"}, ID: 11}, // Royal
|
||||
{Aliases: []string{"NBoost", "NetCafeBoost", "Boost"}, ID: 12},
|
||||
// 13-19 = (unknown), 20 = DEBUG, 21 = COG_LINK_EXPIRED, 22 = 360_GOLD, 23 = PS3_TROP
|
||||
{Aliases: []string{"COG"}, ID: 24},
|
||||
{Aliases: []string{"NetCafe", "Cafe", "InternetCafe"}, ID: 25},
|
||||
{Aliases: []string{"OfficialCafe", "Official"}, ID: 26},
|
||||
{Aliases: []string{"HLRenewing", "HLR", "HLRenewal", "HLRenew"}, ID: 27},
|
||||
{Aliases: []string{"EXRenewing", "EXR", "EXRenewal", "EXRenew"}, ID: 28},
|
||||
{Aliases: []string{"Free"}, ID: 29},
|
||||
// 30 = real netcafe bit
|
||||
}
|
||||
for i := range courses {
|
||||
courses[i].Value = uint32(math.Pow(2, float64(courses[i].ID)))
|
||||
}
|
||||
return courses
|
||||
}
|
||||
|
||||
// GetCourseStruct returns a slice of Course(s) from a rights integer
|
||||
func GetCourseStruct(rights uint32) []Course {
|
||||
var resp []Course
|
||||
s := Courses()
|
||||
slices.SortStableFunc(s, func(i, j Course) bool {
|
||||
return i.ID > j.ID
|
||||
})
|
||||
for _, course := range s {
|
||||
if rights-course.Value < 0x80000000 {
|
||||
resp = append(resp, course)
|
||||
rights -= course.Value
|
||||
}
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user