update rights integer via struct

This commit is contained in:
wish
2022-10-30 23:18:53 +11:00
parent 676bb736bf
commit 4390617ccf
3 changed files with 20 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package mhfpacket
import (
"errors"
ps "erupe-ce/common/pascalstring"
"golang.org/x/exp/slices"
"erupe-ce/common/byteframe"
"erupe-ce/network"
@@ -95,7 +96,11 @@ func Courses() []Course {
// GetCourseStruct returns a slice of Course(s) from a rights integer
func GetCourseStruct(rights uint32) []Course {
var resp []Course
for _, course := range Courses() {
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