various changes

This commit is contained in:
wish
2024-07-14 23:10:32 +10:00
parent 6cf7c1a4b7
commit 757c98a9a8
5 changed files with 69 additions and 101 deletions

View File

@@ -20,10 +20,9 @@
"ClientMode": "G9.1", "ClientMode": "G9.1",
"QuestCacheExpiry": 300, "QuestCacheExpiry": 300,
"CommandPrefix": "!", "CommandPrefix": "!",
"AutoCreateAccount": true, "AutoCreateAccount": true,
"DefaultCourses": [1, 23, 24], "DefaultCourses": [1, 23, 24],
"EarthDebug":true, "EarthDebug": false,
"EarthMonsters": [116, 107, 2, 36], "EarthMonsters": [116, 107, 2, 36],
"SaveDumps": { "SaveDumps": {
"Enabled": true, "Enabled": true,

View File

@@ -12,7 +12,7 @@ import (
type MsgMhfReadBeatLevelAllRanking struct { type MsgMhfReadBeatLevelAllRanking struct {
AckHandle uint32 AckHandle uint32
Unk0 uint32 Unk0 uint32
GuildID int32 MonsterID int32
Unk2 int32 Unk2 int32
} }
@@ -25,7 +25,7 @@ func (m *MsgMhfReadBeatLevelAllRanking) Opcode() network.PacketID {
func (m *MsgMhfReadBeatLevelAllRanking) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { func (m *MsgMhfReadBeatLevelAllRanking) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32() m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32() m.Unk0 = bf.ReadUint32()
m.GuildID = bf.ReadInt32() m.MonsterID = bf.ReadInt32()
m.Unk2 = bf.ReadInt32() m.Unk2 = bf.ReadInt32()
return nil return nil
} }

View File

@@ -1089,30 +1089,29 @@ func handleMsgMhfUnreserveSrg(s *Session, p mhfpacket.MHFPacket) {
} }
func handleMsgMhfKickExportForce(s *Session, p mhfpacket.MHFPacket) {} func handleMsgMhfKickExportForce(s *Session, p mhfpacket.MHFPacket) {}
func cleanupEarthStatus(s *Session) {
s.server.db.Exec("DELETE FROM events WHERE event_type='tower'")
s.server.db.Exec("DELETE FROM events WHERE event_type='pallone'")
s.server.db.Exec("DELETE FROM events WHERE event_type='conquest'")
func cleanupEarthStatus(s *Session) {
s.server.db.Exec("DELETE FROM events WHERE event_type='earth'")
} }
func generateEarthStatusTimestamps(s *Session, start uint32, debug bool) []uint32 { func generateEarthStatusTimestamps(s *Session, start uint32, debug bool) []uint32 {
timestamps := make([]uint32, 3) timestamps := make([]uint32, 4)
midnight := TimeMidnight() midnight := TimeMidnight()
if start == 0 || TimeAdjusted().Unix() > int64(start)+2977200 { if start == 0 || TimeAdjusted().Unix() > int64(start)+1814400 {
cleanupEarthStatus(s) cleanupEarthStatus(s)
// Generate a new festa, starting midnight tomorrow
start = uint32(midnight.Add(24 * time.Hour).Unix()) start = uint32(midnight.Add(24 * time.Hour).Unix())
s.server.db.Exec("INSERT INTO events (event_type, start_time) VALUES ('tower', to_timestamp($1)::timestamp without time zone)", start) s.server.db.Exec("INSERT INTO events (event_type, start_time) VALUES ('earth', to_timestamp($1)::timestamp without time zone)", start)
} }
if debug { if debug {
timestamps[0] = uint32(TimeWeekStart().Unix()) timestamps[0] = uint32(TimeWeekStart().Unix())
timestamps[1] = uint32(TimeWeekNext().Unix()) timestamps[1] = uint32(TimeWeekNext().Unix())
timestamps[1] = uint32(TimeWeekNext().Add((time.Duration(7) * time.Hour * 24)).Unix()) timestamps[2] = uint32(TimeWeekNext().Add(time.Duration(7) * time.Hour * 24).Unix())
timestamps[3] = uint32(TimeWeekNext().Add(time.Duration(14) * time.Hour * 24).Unix())
} else { } else {
timestamps[0] = start timestamps[0] = start
timestamps[1] = timestamps[0] + 604800 timestamps[1] = timestamps[0] + 604800
timestamps[2] = timestamps[1] + 604800 timestamps[2] = timestamps[1] + 604800
timestamps[3] = timestamps[2] + 604800
} }
return timestamps return timestamps
} }
@@ -1120,30 +1119,31 @@ func generateEarthStatusTimestamps(s *Session, start uint32, debug bool) []uint3
func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetEarthStatus) pkt := p.(*mhfpacket.MsgMhfGetEarthStatus)
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
//Conquest
var conquestTimestamps []uint32 var earthTimestamps []uint32
var debug = s.server.erupeConfig.EarthDebug var debug = s.server.erupeConfig.EarthDebug
conquestId, conquestStart := int32(0xBEEFEE), uint32(0) earthId, earthStart := int32(0x01BEEFEE), uint32(0)
rows, _ := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='conquest'") rows, _ := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='earth'")
if rows == nil { if rows == nil {
log.Println("No rows found") log.Println("No rows found")
} else { } else {
for rows.Next() { for rows.Next() {
rows.Scan(&conquestId, &conquestStart) rows.Scan(&earthId, &earthStart)
} }
} }
conquestTimestamps = generateEarthStatusTimestamps(s, conquestStart, debug) earthTimestamps = generateEarthStatusTimestamps(s, earthStart, debug)
if TimeAdjusted().After(time.UnixMilli(int64(conquestTimestamps[1]))) {
bf.WriteUint32(conquestTimestamps[0]) // Start // Conquest
bf.WriteUint32(conquestTimestamps[1]) // End if uint32(TimeAdjusted().Unix()) > earthTimestamps[0] {
bf.WriteInt32(1) //Conquest Earth Status ID //1 and 2 UNK the difference bf.WriteUint32(earthTimestamps[0]) // Start
bf.WriteInt32(conquestId) //ID bf.WriteUint32(earthTimestamps[1]) // End
bf.WriteInt32(1) //Conquest Earth Status ID //1 and 2 UNK the difference
bf.WriteInt32(earthId) //ID
} else { } else {
bf.WriteUint32(conquestTimestamps[1]) // Start bf.WriteUint32(earthTimestamps[1]) // Start
bf.WriteUint32(conquestTimestamps[2]) // End bf.WriteUint32(earthTimestamps[2]) // End
bf.WriteInt32(2) //Conquest Earth Status ID //1 and 2 UNK the difference bf.WriteInt32(2) //Conquest Earth Status ID //1 and 2 UNK the difference
bf.WriteInt32(conquestId) //ID bf.WriteInt32(earthId) //ID
} }
for i, m := range s.server.erupeConfig.EarthMonsters { for i, m := range s.server.erupeConfig.EarthMonsters {
//Changed from G9 to G8 to get conquest working in g9.1 //Changed from G9 to G8 to get conquest working in g9.1
@@ -1157,32 +1157,19 @@ func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
} }
bf.WriteInt32(m) bf.WriteInt32(m)
} }
//Pallone
var palloneTimestamps []uint32
palloneId, palloneStart := int32(0xBEEFEE), uint32(0)
rows, _ = s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='pallone'")
if rows == nil {
log.Println("No rows found")
// Pallone
if uint32(TimeAdjusted().Unix()) > earthTimestamps[1] {
bf.WriteUint32(earthTimestamps[1]) // Start
bf.WriteUint32(earthTimestamps[2]) // End
bf.WriteInt32(11) //Pallone Earth Status ID //11 is Fest //12 is Reward
bf.WriteInt32(earthId + 1) //ID
} else { } else {
for rows.Next() { bf.WriteUint32(earthTimestamps[2]) // Start
rows.Scan(&palloneId, &palloneStart) bf.WriteUint32(earthTimestamps[3]) // End
} bf.WriteInt32(12) //Pallone Earth Status ID //11 is Fest //12 is Reward
bf.WriteInt32(earthId + 1) //ID
} }
palloneTimestamps = generateEarthStatusTimestamps(s, palloneStart, debug)
if TimeAdjusted().After(time.UnixMilli(int64(palloneTimestamps[1]))) {
bf.WriteUint32(palloneTimestamps[0]) // Start
bf.WriteUint32(palloneTimestamps[1]) // End
bf.WriteInt32(11) //Pallone Earth Status ID //11 is Fest //12 is Reward
bf.WriteInt32(palloneId) //ID
} else {
bf.WriteUint32(palloneTimestamps[1]) // Start
bf.WriteUint32(palloneTimestamps[2]) // End
bf.WriteInt32(12) //Pallone Earth Status ID //11 is Fest //12 is Reward
bf.WriteInt32(palloneId) //ID
}
for i, m := range s.server.erupeConfig.EarthMonsters { for i, m := range s.server.erupeConfig.EarthMonsters {
//Changed from G9 to G8 to get conquest working in g9.1 //Changed from G9 to G8 to get conquest working in g9.1
if _config.ErupeConfig.RealClientMode <= _config.G8 { if _config.ErupeConfig.RealClientMode <= _config.G8 {
@@ -1196,34 +1183,23 @@ func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
bf.WriteInt32(m) bf.WriteInt32(m)
} }
//TOWER // Tower
var towerTimestamps []uint32 if uint32(TimeAdjusted().Unix()) > earthTimestamps[2] {
towerId, towerStart := int32(0xBEEFEE), uint32(0) bf.WriteUint32(earthTimestamps[2]) // Start
rows, _ = s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='tower'") bf.WriteUint32(earthTimestamps[3]) // End
if rows == nil { bf.WriteInt32(21) //Tower Earth Status ID
log.Println("No rows found") bf.WriteInt32(earthId + 2) //ID
for i, m := range s.server.erupeConfig.EarthMonsters {
} else { if _config.ErupeConfig.RealClientMode <= _config.G8 {
for rows.Next() { if i == 3 {
rows.Scan(&towerId, &towerStart) break
} }
} }
towerTimestamps = generateEarthStatusTimestamps(s, towerStart, debug) if i == 4 {
bf.WriteUint32(towerTimestamps[0]) // Start
bf.WriteUint32(towerTimestamps[1]) // End
bf.WriteInt32(21) //Tower Earth Status ID
bf.WriteInt32(towerId) //ID
for i, m := range s.server.erupeConfig.EarthMonsters {
//Changed from G9 to G8 to get conquest working in g9.1
if _config.ErupeConfig.RealClientMode <= _config.G8 {
if i == 3 {
break break
} }
bf.WriteInt32(m)
} }
if i == 4 {
break
}
bf.WriteInt32(m)
} }
doAckBufSucceed(s, pkt.AckHandle, bf.Data()) doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }

View File

@@ -100,21 +100,19 @@ func handleMsgMhfGetTinyBin(s *Session, p mhfpacket.MHFPacket) {
//Conquest: Unk0 0 Unk1 2 Unk2 1 //Conquest: Unk0 0 Unk1 2 Unk2 1
type TinyBinItem struct { type TinyBinItem struct {
ItemId uint16 ItemID uint16
Amount uint8 Quantity uint16
Unk2 uint8 //if 4 the Red message "There are some items and points that cannot be recieved." Shows
} }
tinyBinItems := []TinyBinItem{{7, 2, 4}, {8, 1, 0}, {9, 1, 0}, {300, 4, 0}, {10, 1, 0}} tinyBinItems := []TinyBinItem{{7, 2}, {8, 1}, {9, 1}, {300, 4}, {10, 1}}
pkt := p.(*mhfpacket.MsgMhfGetTinyBin) pkt := p.(*mhfpacket.MsgMhfGetTinyBin)
// requested after conquest quests // requested after conquest quests
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
bf.SetLE() bf.SetLE()
for _, items := range tinyBinItems { for _, items := range tinyBinItems {
bf.WriteUint16(items.ItemId) bf.WriteUint16(items.ItemID)
bf.WriteUint8(items.Amount) bf.WriteUint16(items.Quantity)
bf.WriteUint8(items.Unk2)
} }
doAckBufSucceed(s, pkt.AckHandle, bf.Data()) doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }

View File

@@ -7,10 +7,10 @@ import (
) )
type BreakSeibatuLevelReward struct { type BreakSeibatuLevelReward struct {
Item int32 Item int32
Value int32 Quantity int32
Level int32 Level int32
Unk int32 Unk int32
} }
func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) {
@@ -63,9 +63,9 @@ func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) {
for _, seibatuData := range weeklySeibatuRankingRewards { for _, seibatuData := range weeklySeibatuRankingRewards {
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
bf.WriteInt32(seibatuData.Item) // Item bf.WriteInt32(seibatuData.Item)
bf.WriteInt32(seibatuData.Value) // Value bf.WriteInt32(seibatuData.Quantity)
bf.WriteInt32(seibatuData.Level) //Level bf.WriteInt32(seibatuData.Level)
bf.WriteInt32(seibatuData.Unk) bf.WriteInt32(seibatuData.Unk)
data = append(data, bf) data = append(data, bf)
} }
@@ -612,9 +612,9 @@ func handleMsgMhfGetWeeklySeibatuRankingReward(s *Session, p mhfpacket.MHFPacket
} }
type FixedSeibatuRankingTable struct { type FixedSeibatuRankingTable struct {
Rank int32 Rank int32
Level int32 Level int32
UnkArray string Name string
} }
func handleMsgMhfGetFixedSeibatuRankingTable(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetFixedSeibatuRankingTable(s *Session, p mhfpacket.MHFPacket) {
@@ -686,15 +686,11 @@ func handleMsgMhfGetFixedSeibatuRankingTable(s *Session, p mhfpacket.MHFPacket)
} }
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
for _, seibatuData := range fixedSeibatuRankingTable { for _, seibatuData := range fixedSeibatuRankingTable {
bf.WriteInt32(seibatuData.Rank) bf.WriteInt32(seibatuData.Rank)
bf.WriteInt32(seibatuData.Level) bf.WriteInt32(seibatuData.Level)
bf.WriteBytes(stringsupport.PaddedString(seibatuData.UnkArray, 32, true)) bf.WriteBytes(stringsupport.PaddedString(seibatuData.Name, 32, true))
} }
doAckBufSucceed(s, pkt.AckHandle, bf.Data()) doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }
@@ -728,7 +724,6 @@ func handleMsgMhfReadLastWeekBeatRanking(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfUpdateBeatLevel(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfUpdateBeatLevel(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfUpdateBeatLevel) pkt := p.(*mhfpacket.MsgMhfUpdateBeatLevel)
doAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00}) doAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
} }