course enumeration concept

This commit is contained in:
wish
2022-10-30 11:44:22 +11:00
parent da1a48ee2c
commit bac4e70be4
3 changed files with 53 additions and 22 deletions

View File

@@ -2,6 +2,7 @@ package mhfpacket
import (
"errors"
ps "erupe-ce/common/pascalstring"
"erupe-ce/common/byteframe"
"erupe-ce/network"
@@ -34,6 +35,12 @@ type ClientRight struct {
Timestamp uint32
}
type Course struct {
Name 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.
@@ -63,9 +70,32 @@ func (m *MsgSysUpdateRight) Build(bf *byteframe.ByteFrame, ctx *clientctx.Client
bf.WriteUint16(v.Unk0)
bf.WriteUint32(v.Timestamp)
}
bf.WriteUint16(m.UnkSize) // String of upto 0x800 bytes, update client login token / password in the game's launcherstate struct.
//bf.WriteBytes(m.UpdatedClientLoginToken)
ps.Uint16(bf, "", false) // update client login token / password in the game's launcherstate struct
return nil
}
// GetCourseStruct returns a slice of Course(s) from a rights integer
func GetCourseStruct(rights uint32) []Course {
var courses = []Course{
{"Trial", 1, 0x00000002},
{"HunterLife", 2, 0x00000004},
{"ExtraA", 3, 0x00000008},
{"ExtraB", 4, 0x00000010},
{"Mobile", 5, 0x00000020},
{"Premium", 6, 0x00000040},
{"Pallone", 7, 0x00000080},
{"Assist", 8, 0x00000100}, // Legend
{"Netcafe", 9, 0x00000200},
{"Hiden", 10, 0x00000400}, // Secret
{"HunterSupport", 11, 0x00000800}, // Royal
{"NetcafeBoost", 12, 0x00001000},
}
var resp []Course
for _, course := range courses {
if rights-course.Value < 0x80000000 {
resp = append(resp, course)
rights -= course.Value
}
}
return resp
}