mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
rights v3.1
This commit is contained in:
@@ -66,10 +66,14 @@
|
|||||||
{"Name": "Extra", "Enabled": true},
|
{"Name": "Extra", "Enabled": true},
|
||||||
{"Name": "Premium", "Enabled": true},
|
{"Name": "Premium", "Enabled": true},
|
||||||
{"Name": "Assist", "Enabled": false},
|
{"Name": "Assist", "Enabled": false},
|
||||||
{"Name": "Netcafe", "Enabled": false},
|
{"Name": "N", "Enabled": false},
|
||||||
{"Name": "Hiden", "Enabled": false},
|
{"Name": "Hiden", "Enabled": false},
|
||||||
{"Name": "HunterSupport", "Enabled": false},
|
{"Name": "HunterSupport", "Enabled": false},
|
||||||
{"Name": "NetcafeBoost", "Enabled": false}
|
{"Name": "NBoost", "Enabled": false},
|
||||||
|
{"Name": "NetCafe", "Enabled": true},
|
||||||
|
{"Name": "HLContinue", "Enabled": true},
|
||||||
|
{"Name": "EXContinue", "Enabled": true},
|
||||||
|
{"Name": "Free", "Enabled": true}
|
||||||
],
|
],
|
||||||
"Database": {
|
"Database": {
|
||||||
"Host": "localhost",
|
"Host": "localhost",
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package mhfpacket
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
ps "erupe-ce/common/pascalstring"
|
|
||||||
"golang.org/x/exp/slices"
|
|
||||||
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
ps "erupe-ce/common/pascalstring"
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
"erupe-ce/network/clientctx"
|
"erupe-ce/network/clientctx"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -77,19 +77,27 @@ func (m *MsgSysUpdateRight) Build(bf *byteframe.ByteFrame, ctx *clientctx.Client
|
|||||||
|
|
||||||
func Courses() []Course {
|
func Courses() []Course {
|
||||||
var courses = []Course{
|
var courses = []Course{
|
||||||
{[]string{"Trial", "TL"}, 1, 0x00000002},
|
{Aliases: []string{"Trial", "TL"}, ID: 1},
|
||||||
{[]string{"HunterLife", "HL"}, 2, 0x00000004},
|
{Aliases: []string{"HunterLife", "HL"}, ID: 2},
|
||||||
{[]string{"Extra", "ExtraA", "EX"}, 3, 0x00000008},
|
{Aliases: []string{"Extra", "ExtraA", "EX"}, ID: 3},
|
||||||
{[]string{"ExtraB"}, 4, 0x00000010},
|
{Aliases: []string{"ExtraB"}, ID: 4},
|
||||||
{[]string{"Mobile"}, 5, 0x00000020},
|
{Aliases: []string{"Mobile"}, ID: 5},
|
||||||
{[]string{"Premium"}, 6, 0x00000040},
|
{Aliases: []string{"Premium"}, ID: 6},
|
||||||
{[]string{"Pallone"}, 7, 0x00000080},
|
{Aliases: []string{"Pallone", "ExtraC"}, ID: 7},
|
||||||
{[]string{"Assist", "Legend", "Rasta"}, 8, 0x00000100}, // Legend
|
{Aliases: []string{"Assist", "Legend", "Rasta"}, ID: 8}, // Legend
|
||||||
{[]string{"Netcafe", "N", "Cafe"}, 9, 0x40000200},
|
{Aliases: []string{"N"}, ID: 9},
|
||||||
{[]string{"Hiden", "Secret"}, 10, 0x00000400}, // Secret
|
{Aliases: []string{"Hiden", "Secret"}, ID: 10}, // Secret
|
||||||
{[]string{"HunterSupport", "HunterAid", "Support", "Royal", "Aid"}, 11, 0x00000800}, // Royal
|
{Aliases: []string{"HunterSupport", "HunterAid", "Support", "Aid", "Royal"}, ID: 11}, // Royal
|
||||||
{[]string{"NetcafeBoost", "NBoost", "Boost"}, 12, 0x00001000},
|
{Aliases: []string{"NBoost", "NetCafeBoost", "Boost"}, ID: 12},
|
||||||
{[]string{"ExtraC"}, 13, 0x00002000},
|
// 13-25 do nothing
|
||||||
|
{Aliases: []string{"NetCafe", "Cafe", "InternetCafe"}, ID: 26},
|
||||||
|
{Aliases: []string{"HLContinue", "HLC"}, ID: 27},
|
||||||
|
{Aliases: []string{"EXContinue", "EXC"}, 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
|
return courses
|
||||||
}
|
}
|
||||||
@@ -99,7 +107,7 @@ func GetCourseStruct(rights uint32) []Course {
|
|||||||
var resp []Course
|
var resp []Course
|
||||||
s := Courses()
|
s := Courses()
|
||||||
slices.SortStableFunc(s, func(i, j Course) bool {
|
slices.SortStableFunc(s, func(i, j Course) bool {
|
||||||
return i.Value > j.Value
|
return i.ID > j.ID
|
||||||
})
|
})
|
||||||
for _, course := range s {
|
for _, course := range s {
|
||||||
if rights-course.Value < 0x80000000 {
|
if rights-course.Value < 0x80000000 {
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ func updateRights(s *Session) {
|
|||||||
s.courses = mhfpacket.GetCourseStruct(rightsInt)
|
s.courses = mhfpacket.GetCourseStruct(rightsInt)
|
||||||
rights := []mhfpacket.ClientRight{{1, 0, 0}}
|
rights := []mhfpacket.ClientRight{{1, 0, 0}}
|
||||||
for _, course := range s.courses {
|
for _, course := range s.courses {
|
||||||
|
if course.ID == 9 || course.ID == 26 {
|
||||||
|
rightsInt += 0x40000000 // set netcafe bit
|
||||||
|
rights = append(rights, mhfpacket.ClientRight{ID: 30})
|
||||||
|
}
|
||||||
rights = append(rights, mhfpacket.ClientRight{ID: course.ID, Timestamp: 0x70DB59F0})
|
rights = append(rights, mhfpacket.ClientRight{ID: course.ID, Timestamp: 0x70DB59F0})
|
||||||
}
|
}
|
||||||
update := &mhfpacket.MsgSysUpdateRight{
|
update := &mhfpacket.MsgSysUpdateRight{
|
||||||
@@ -213,7 +217,7 @@ func logoutPlayer(s *Session) {
|
|||||||
timePlayed += sessionTime
|
timePlayed += sessionTime
|
||||||
|
|
||||||
var rpGained int
|
var rpGained int
|
||||||
if s.FindCourse("Netcafe").ID != 0 {
|
if s.FindCourse("NetCafe").ID != 0 || s.FindCourse("N").ID != 0 {
|
||||||
rpGained = timePlayed / 900
|
rpGained = timePlayed / 900
|
||||||
timePlayed = timePlayed % 900
|
timePlayed = timePlayed % 900
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
for _, alias := range course.Aliases {
|
for _, alias := range course.Aliases {
|
||||||
if strings.ToLower(name) == strings.ToLower(alias) {
|
if strings.ToLower(name) == strings.ToLower(alias) {
|
||||||
if slices.Contains(s.server.erupeConfig.Courses, config.Course{Name: course.Aliases[0], Enabled: true}) {
|
if slices.Contains(s.server.erupeConfig.Courses, config.Course{Name: course.Aliases[0], Enabled: true}) {
|
||||||
if s.FindCourse(name).Value != 0 {
|
if s.FindCourse(name).ID != 0 {
|
||||||
ei := slices.IndexFunc(s.courses, func(c mhfpacket.Course) bool {
|
ei := slices.IndexFunc(s.courses, func(c mhfpacket.Course) bool {
|
||||||
for _, alias := range c.Aliases {
|
for _, alias := range c.Aliases {
|
||||||
if strings.ToLower(name) == strings.ToLower(alias) {
|
if strings.ToLower(name) == strings.ToLower(alias) {
|
||||||
@@ -335,20 +335,20 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
})
|
})
|
||||||
if ei != -1 {
|
if ei != -1 {
|
||||||
s.courses = append(s.courses[:ei], s.courses[ei+1:]...)
|
s.courses = append(s.courses[:ei], s.courses[ei+1:]...)
|
||||||
sendServerChatMessage(s, fmt.Sprintf(`%s Course disabled.`, course.Aliases[0]))
|
sendServerChatMessage(s, fmt.Sprintf(`%s Course disabled`, course.Aliases[0]))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.courses = append(s.courses, course)
|
s.courses = append(s.courses, course)
|
||||||
sendServerChatMessage(s, fmt.Sprintf(`%s Course enabled.`, course.Aliases[0]))
|
sendServerChatMessage(s, fmt.Sprintf(`%s Course enabled`, course.Aliases[0]))
|
||||||
}
|
}
|
||||||
var newInt uint32
|
var newInt uint32
|
||||||
for _, course := range s.courses {
|
for _, course := range s.courses {
|
||||||
newInt += course.Value
|
newInt += uint32(math.Pow(2, float64(course.ID)))
|
||||||
}
|
}
|
||||||
s.server.db.Exec("UPDATE users u SET rights=$1 WHERE u.id=(SELECT c.user_id FROM characters c WHERE c.id=$2)", newInt, s.charID)
|
s.server.db.Exec("UPDATE users u SET rights=$1 WHERE u.id=(SELECT c.user_id FROM characters c WHERE c.id=$2)", newInt, s.charID)
|
||||||
updateRights(s)
|
updateRights(s)
|
||||||
} else {
|
} else {
|
||||||
sendServerChatMessage(s, fmt.Sprintf(`%s Course is locked.`, course.Aliases[0]))
|
sendServerChatMessage(s, fmt.Sprintf(`%s Course is locked`, course.Aliases[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user