diff --git a/config.json b/config.json index 31ecd8416..69b54862f 100644 --- a/config.json +++ b/config.json @@ -63,13 +63,17 @@ ], "Courses": [ {"Name": "HunterLife", "Enabled": true}, - {"Name": "ExtraA", "Enabled": true}, + {"Name": "Extra", "Enabled": true}, {"Name": "Premium", "Enabled": true}, {"Name": "Assist", "Enabled": false}, - {"Name": "Netcafe", "Enabled": false}, + {"Name": "N", "Enabled": false}, {"Name": "Hiden", "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": { "Host": "localhost", diff --git a/network/mhfpacket/msg_mhf_check_monthly_item.go b/network/mhfpacket/msg_mhf_check_monthly_item.go index d79c65240..860725aa4 100644 --- a/network/mhfpacket/msg_mhf_check_monthly_item.go +++ b/network/mhfpacket/msg_mhf_check_monthly_item.go @@ -11,7 +11,8 @@ import ( // MsgMhfCheckMonthlyItem represents the MSG_MHF_CHECK_MONTHLY_ITEM type MsgMhfCheckMonthlyItem struct { AckHandle uint32 - Unk uint32 + Type uint8 + Unk []byte } // Opcode returns the ID associated with this packet type. @@ -22,7 +23,8 @@ func (m *MsgMhfCheckMonthlyItem) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfCheckMonthlyItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.Unk = bf.ReadUint32() + m.Type = bf.ReadUint8() + m.Unk = bf.ReadBytes(3) return nil } diff --git a/network/mhfpacket/msg_sys_update_right.go b/network/mhfpacket/msg_sys_update_right.go index 0702a5b3e..c27dc1f55 100644 --- a/network/mhfpacket/msg_sys_update_right.go +++ b/network/mhfpacket/msg_sys_update_right.go @@ -2,12 +2,12 @@ package mhfpacket import ( "errors" - ps "erupe-ce/common/pascalstring" - "golang.org/x/exp/slices" - "erupe-ce/common/byteframe" + ps "erupe-ce/common/pascalstring" "erupe-ce/network" "erupe-ce/network/clientctx" + "golang.org/x/exp/slices" + "math" ) /* @@ -77,18 +77,27 @@ func (m *MsgSysUpdateRight) Build(bf *byteframe.ByteFrame, ctx *clientctx.Client func Courses() []Course { var courses = []Course{ - {[]string{"Trial", "TL"}, 1, 0x00000002}, - {[]string{"HunterLife", "HL"}, 2, 0x00000004}, - {[]string{"ExtraA", "Extra", "EX"}, 3, 0x00000008}, - {[]string{"ExtraB"}, 4, 0x00000010}, - {[]string{"Mobile"}, 5, 0x00000020}, - {[]string{"Premium"}, 6, 0x00000040}, - {[]string{"Pallone"}, 7, 0x00000080}, - {[]string{"Assist", "Legend", "Rasta"}, 8, 0x00000100}, // Legend - {[]string{"Netcafe", "N", "Cafe"}, 9, 0x00000200}, - {[]string{"Hiden", "Secret"}, 10, 0x00000400}, // Secret - {[]string{"HunterSupport", "HunterAid", "Support", "Royal", "Aid"}, 11, 0x00000800}, // Royal - {[]string{"NetcafeBoost", "NBoost", "Boost"}, 12, 0x00001000}, + {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-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 } diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index edd2dc33c..47d3d6b4c 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -77,7 +77,13 @@ func updateRights(s *Session) { 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) s.courses = mhfpacket.GetCourseStruct(rightsInt) rights := []mhfpacket.ClientRight{{1, 0, 0}} + var netcafeBitSet bool for _, course := range s.courses { + if (course.ID == 9 || course.ID == 26) && !netcafeBitSet { + netcafeBitSet = true + rightsInt += 0x40000000 // set netcafe bit + rights = append(rights, mhfpacket.ClientRight{ID: 30}) + } rights = append(rights, mhfpacket.ClientRight{ID: course.ID, Timestamp: 0x70DB59F0}) } update := &mhfpacket.MsgSysUpdateRight{ @@ -213,16 +219,16 @@ func logoutPlayer(s *Session) { timePlayed += sessionTime var rpGained int - if s.FindCourse("Netcafe").ID != 0 { + if s.FindCourse("NetCafe").ID != 0 || s.FindCourse("N").ID != 0 { rpGained = timePlayed / 900 timePlayed = timePlayed % 900 + s.server.db.Exec("UPDATE characters SET cafe_time=cafe_time+$1 WHERE id=$2", sessionTime, s.charID) } else { rpGained = timePlayed / 1800 timePlayed = timePlayed % 1800 } s.server.db.Exec("UPDATE characters SET time_played = $1 WHERE id = $2", timePlayed, s.charID) - s.server.db.Exec("UPDATE characters SET cafe_time=cafe_time+$1 WHERE id=$2", sessionTime, s.charID) treasureHuntUnregister(s) diff --git a/server/channelserver/handlers_cafe.go b/server/channelserver/handlers_cafe.go index 15b01f510..d91806a93 100644 --- a/server/channelserver/handlers_cafe.go +++ b/server/channelserver/handlers_cafe.go @@ -84,7 +84,9 @@ func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) { if err != nil { panic(err) } - cafeTime = uint32(Time_Current_Adjusted().Unix()) - uint32(s.sessionStart) + cafeTime + if s.FindCourse("NetCafe").ID != 0 || s.FindCourse("N").ID != 0 { + cafeTime = uint32(Time_Current_Adjusted().Unix()) - uint32(s.sessionStart) + cafeTime + } bf.WriteUint32(cafeTime) // Total cafe time bf.WriteUint16(0) ps.Uint16(bf, fmt.Sprintf("Resets on %s %d", cafeReset.Month().String(), cafeReset.Day()), true) diff --git a/server/channelserver/handlers_cast_binary.go b/server/channelserver/handlers_cast_binary.go index 64666d9af..17a1d7858 100644 --- a/server/channelserver/handlers_cast_binary.go +++ b/server/channelserver/handlers_cast_binary.go @@ -324,7 +324,7 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) { for _, alias := range course.Aliases { if strings.ToLower(name) == strings.ToLower(alias) { 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 { for _, alias := range c.Aliases { if strings.ToLower(name) == strings.ToLower(alias) { @@ -335,20 +335,20 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) { }) if 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 { 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 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) updateRights(s) } else { - sendServerChatMessage(s, fmt.Sprintf(`%s Course is locked.`, course.Aliases[0])) + sendServerChatMessage(s, fmt.Sprintf(`%s Course is locked`, course.Aliases[0])) } } } diff --git a/server/channelserver/handlers_guild.go b/server/channelserver/handlers_guild.go index 3f0df48b3..ca1ddf973 100644 --- a/server/channelserver/handlers_guild.go +++ b/server/channelserver/handlers_guild.go @@ -2002,6 +2002,7 @@ func handleMsgMhfCheckMonthlyItem(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfCheckMonthlyItem) doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x01}) // TODO: Implement month-by-month tracker, 0 = Not claimed, 1 = Claimed + // Also handles HLC and EXC items, IDs = 064D, 076B } func handleMsgMhfAcquireMonthlyItem(s *Session, p mhfpacket.MHFPacket) {