mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
course enumeration concept
This commit is contained in:
@@ -2,6 +2,7 @@ package mhfpacket
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
ps "erupe-ce/common/pascalstring"
|
||||||
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
@@ -34,6 +35,12 @@ type ClientRight struct {
|
|||||||
Timestamp uint32
|
Timestamp uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Course struct {
|
||||||
|
Name string
|
||||||
|
ID uint16
|
||||||
|
Value uint32
|
||||||
|
}
|
||||||
|
|
||||||
// MsgSysUpdateRight represents the MSG_SYS_UPDATE_RIGHT
|
// MsgSysUpdateRight represents the MSG_SYS_UPDATE_RIGHT
|
||||||
type MsgSysUpdateRight struct {
|
type MsgSysUpdateRight struct {
|
||||||
ClientRespAckHandle uint32 // If non-0, requests the client to send back a MSG_SYS_ACK packet with this value.
|
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.WriteUint16(v.Unk0)
|
||||||
bf.WriteUint32(v.Timestamp)
|
bf.WriteUint32(v.Timestamp)
|
||||||
}
|
}
|
||||||
|
ps.Uint16(bf, "", false) // update client login token / password in the game's launcherstate struct
|
||||||
bf.WriteUint16(m.UnkSize) // String of upto 0x800 bytes, update client login token / password in the game's launcherstate struct.
|
|
||||||
//bf.WriteBytes(m.UpdatedClientLoginToken)
|
|
||||||
|
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -74,26 +73,18 @@ func doAckSimpleFail(s *Session, ackHandle uint32, data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateRights(s *Session) {
|
func updateRights(s *Session) {
|
||||||
s.rights = uint32(0x0E)
|
rightsInt := uint32(0x0E)
|
||||||
s.server.db.QueryRow("SELECT rights FROM users u INNER JOIN characters c ON u.id = c.user_id WHERE c.id = $1", s.charID).Scan(&s.rights)
|
s.server.db.QueryRow("SELECT rights FROM users u INNER JOIN characters c ON u.id = c.user_id WHERE c.id = $1", s.charID).Scan(&rightsInt)
|
||||||
|
|
||||||
rights := make([]mhfpacket.ClientRight, 0)
|
courses := mhfpacket.GetCourseStruct(rightsInt)
|
||||||
tempRights := s.rights
|
rights := []mhfpacket.ClientRight{{1, 0, 0}}
|
||||||
for i := 30; i > 0; i-- {
|
for _, course := range courses {
|
||||||
right := uint32(math.Pow(2, float64(i)))
|
rights = append(rights, mhfpacket.ClientRight{ID: course.ID, Timestamp: 0x70DB59F0})
|
||||||
if tempRights-right < 0x80000000 {
|
|
||||||
if i == 1 {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
rights = append(rights, mhfpacket.ClientRight{ID: uint16(i), Timestamp: 0x70DB59F0})
|
|
||||||
tempRights -= right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rights = append(rights, mhfpacket.ClientRight{ID: 1, Timestamp: 0})
|
|
||||||
|
|
||||||
update := &mhfpacket.MsgSysUpdateRight{
|
update := &mhfpacket.MsgSysUpdateRight{
|
||||||
ClientRespAckHandle: 0,
|
ClientRespAckHandle: 0,
|
||||||
Bitfield: s.rights,
|
Bitfield: rightsInt,
|
||||||
Rights: rights,
|
Rights: rights,
|
||||||
UnkSize: 0,
|
UnkSize: 0,
|
||||||
}
|
}
|
||||||
@@ -224,7 +215,7 @@ func logoutPlayer(s *Session) {
|
|||||||
timePlayed += sessionTime
|
timePlayed += sessionTime
|
||||||
|
|
||||||
var rpGained int
|
var rpGained int
|
||||||
if s.rights >= 0x40000000 { // N Course
|
if s.CourseExists("Netcafe") {
|
||||||
rpGained = timePlayed / 900
|
rpGained = timePlayed / 900
|
||||||
timePlayed = timePlayed % 900
|
timePlayed = timePlayed % 900
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ type Session struct {
|
|||||||
charID uint32
|
charID uint32
|
||||||
logKey []byte
|
logKey []byte
|
||||||
sessionStart int64
|
sessionStart int64
|
||||||
rights uint32
|
courses []mhfpacket.Course
|
||||||
token string
|
token string
|
||||||
kqf []byte
|
kqf []byte
|
||||||
kqfOverride bool
|
kqfOverride bool
|
||||||
@@ -268,3 +269,12 @@ func (s *Session) logMessage(opcode uint16, data []byte, sender string, recipien
|
|||||||
fmt.Printf("Data [%d bytes]:\n(Too long!)\n\n", len(data))
|
fmt.Printf("Data [%d bytes]:\n(Too long!)\n\n", len(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) CourseExists(name string) bool {
|
||||||
|
for _, course := range s.courses {
|
||||||
|
if strings.ToLower(name) == strings.ToLower(course.Name) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user