mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
various changes
This commit is contained in:
@@ -20,10 +20,9 @@
|
||||
"ClientMode": "G9.1",
|
||||
"QuestCacheExpiry": 300,
|
||||
"CommandPrefix": "!",
|
||||
|
||||
"AutoCreateAccount": true,
|
||||
"DefaultCourses": [1, 23, 24],
|
||||
"EarthDebug":true,
|
||||
"EarthDebug": false,
|
||||
"EarthMonsters": [116, 107, 2, 36],
|
||||
"SaveDumps": {
|
||||
"Enabled": true,
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
type MsgMhfReadBeatLevelAllRanking struct {
|
||||
AckHandle uint32
|
||||
Unk0 uint32
|
||||
GuildID int32
|
||||
MonsterID int32
|
||||
Unk2 int32
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (m *MsgMhfReadBeatLevelAllRanking) Opcode() network.PacketID {
|
||||
func (m *MsgMhfReadBeatLevelAllRanking) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||
m.AckHandle = bf.ReadUint32()
|
||||
m.Unk0 = bf.ReadUint32()
|
||||
m.GuildID = bf.ReadInt32()
|
||||
m.MonsterID = bf.ReadInt32()
|
||||
m.Unk2 = bf.ReadInt32()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1089,30 +1089,29 @@ func handleMsgMhfUnreserveSrg(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 {
|
||||
timestamps := make([]uint32, 3)
|
||||
timestamps := make([]uint32, 4)
|
||||
midnight := TimeMidnight()
|
||||
if start == 0 || TimeAdjusted().Unix() > int64(start)+2977200 {
|
||||
if start == 0 || TimeAdjusted().Unix() > int64(start)+1814400 {
|
||||
cleanupEarthStatus(s)
|
||||
// Generate a new festa, starting midnight tomorrow
|
||||
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 {
|
||||
timestamps[0] = uint32(TimeWeekStart().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 {
|
||||
timestamps[0] = start
|
||||
timestamps[1] = timestamps[0] + 604800
|
||||
timestamps[2] = timestamps[1] + 604800
|
||||
timestamps[3] = timestamps[2] + 604800
|
||||
}
|
||||
return timestamps
|
||||
}
|
||||
@@ -1120,30 +1119,31 @@ func generateEarthStatusTimestamps(s *Session, start uint32, debug bool) []uint3
|
||||
func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetEarthStatus)
|
||||
bf := byteframe.NewByteFrame()
|
||||
//Conquest
|
||||
var conquestTimestamps []uint32
|
||||
|
||||
var earthTimestamps []uint32
|
||||
var debug = s.server.erupeConfig.EarthDebug
|
||||
conquestId, conquestStart := 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='conquest'")
|
||||
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='earth'")
|
||||
if rows == nil {
|
||||
log.Println("No rows found")
|
||||
|
||||
} else {
|
||||
for rows.Next() {
|
||||
rows.Scan(&conquestId, &conquestStart)
|
||||
rows.Scan(&earthId, &earthStart)
|
||||
}
|
||||
}
|
||||
conquestTimestamps = generateEarthStatusTimestamps(s, conquestStart, debug)
|
||||
if TimeAdjusted().After(time.UnixMilli(int64(conquestTimestamps[1]))) {
|
||||
bf.WriteUint32(conquestTimestamps[0]) // Start
|
||||
bf.WriteUint32(conquestTimestamps[1]) // End
|
||||
bf.WriteInt32(1) //Conquest Earth Status ID //1 and 2 UNK the difference
|
||||
bf.WriteInt32(conquestId) //ID
|
||||
earthTimestamps = generateEarthStatusTimestamps(s, earthStart, debug)
|
||||
|
||||
// Conquest
|
||||
if uint32(TimeAdjusted().Unix()) > earthTimestamps[0] {
|
||||
bf.WriteUint32(earthTimestamps[0]) // Start
|
||||
bf.WriteUint32(earthTimestamps[1]) // End
|
||||
bf.WriteInt32(1) //Conquest Earth Status ID //1 and 2 UNK the difference
|
||||
bf.WriteInt32(earthId) //ID
|
||||
} else {
|
||||
bf.WriteUint32(conquestTimestamps[1]) // Start
|
||||
bf.WriteUint32(conquestTimestamps[2]) // End
|
||||
bf.WriteInt32(2) //Conquest Earth Status ID //1 and 2 UNK the difference
|
||||
bf.WriteInt32(conquestId) //ID
|
||||
bf.WriteUint32(earthTimestamps[1]) // Start
|
||||
bf.WriteUint32(earthTimestamps[2]) // End
|
||||
bf.WriteInt32(2) //Conquest Earth Status ID //1 and 2 UNK the difference
|
||||
bf.WriteInt32(earthId) //ID
|
||||
}
|
||||
for i, m := range s.server.erupeConfig.EarthMonsters {
|
||||
//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)
|
||||
}
|
||||
//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 {
|
||||
for rows.Next() {
|
||||
rows.Scan(&palloneId, &palloneStart)
|
||||
}
|
||||
bf.WriteUint32(earthTimestamps[2]) // Start
|
||||
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 {
|
||||
//Changed from G9 to G8 to get conquest working in g9.1
|
||||
if _config.ErupeConfig.RealClientMode <= _config.G8 {
|
||||
@@ -1196,34 +1183,23 @@ func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf.WriteInt32(m)
|
||||
}
|
||||
|
||||
//TOWER
|
||||
var towerTimestamps []uint32
|
||||
towerId, towerStart := 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='tower'")
|
||||
if rows == nil {
|
||||
log.Println("No rows found")
|
||||
|
||||
} else {
|
||||
for rows.Next() {
|
||||
rows.Scan(&towerId, &towerStart)
|
||||
}
|
||||
}
|
||||
towerTimestamps = generateEarthStatusTimestamps(s, towerStart, debug)
|
||||
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 {
|
||||
// Tower
|
||||
if uint32(TimeAdjusted().Unix()) > earthTimestamps[2] {
|
||||
bf.WriteUint32(earthTimestamps[2]) // Start
|
||||
bf.WriteUint32(earthTimestamps[3]) // End
|
||||
bf.WriteInt32(21) //Tower Earth Status ID
|
||||
bf.WriteInt32(earthId + 2) //ID
|
||||
for i, m := range s.server.erupeConfig.EarthMonsters {
|
||||
if _config.ErupeConfig.RealClientMode <= _config.G8 {
|
||||
if i == 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if i == 4 {
|
||||
break
|
||||
}
|
||||
bf.WriteInt32(m)
|
||||
}
|
||||
if i == 4 {
|
||||
break
|
||||
}
|
||||
bf.WriteInt32(m)
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
@@ -100,21 +100,19 @@ func handleMsgMhfGetTinyBin(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
//Conquest: Unk0 0 Unk1 2 Unk2 1
|
||||
type TinyBinItem struct {
|
||||
ItemId uint16
|
||||
Amount uint8
|
||||
Unk2 uint8 //if 4 the Red message "There are some items and points that cannot be recieved." Shows
|
||||
ItemID uint16
|
||||
Quantity uint16
|
||||
}
|
||||
|
||||
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)
|
||||
// requested after conquest quests
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.SetLE()
|
||||
for _, items := range tinyBinItems {
|
||||
bf.WriteUint16(items.ItemId)
|
||||
bf.WriteUint8(items.Amount)
|
||||
bf.WriteUint8(items.Unk2)
|
||||
bf.WriteUint16(items.ItemID)
|
||||
bf.WriteUint16(items.Quantity)
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
)
|
||||
|
||||
type BreakSeibatuLevelReward struct {
|
||||
Item int32
|
||||
Value int32
|
||||
Level int32
|
||||
Unk int32
|
||||
Item int32
|
||||
Quantity int32
|
||||
Level int32
|
||||
Unk int32
|
||||
}
|
||||
|
||||
func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) {
|
||||
@@ -63,9 +63,9 @@ func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) {
|
||||
for _, seibatuData := range weeklySeibatuRankingRewards {
|
||||
bf := byteframe.NewByteFrame()
|
||||
|
||||
bf.WriteInt32(seibatuData.Item) // Item
|
||||
bf.WriteInt32(seibatuData.Value) // Value
|
||||
bf.WriteInt32(seibatuData.Level) //Level
|
||||
bf.WriteInt32(seibatuData.Item)
|
||||
bf.WriteInt32(seibatuData.Quantity)
|
||||
bf.WriteInt32(seibatuData.Level)
|
||||
bf.WriteInt32(seibatuData.Unk)
|
||||
data = append(data, bf)
|
||||
}
|
||||
@@ -612,9 +612,9 @@ func handleMsgMhfGetWeeklySeibatuRankingReward(s *Session, p mhfpacket.MHFPacket
|
||||
}
|
||||
|
||||
type FixedSeibatuRankingTable struct {
|
||||
Rank int32
|
||||
Level int32
|
||||
UnkArray string
|
||||
Rank int32
|
||||
Level int32
|
||||
Name string
|
||||
}
|
||||
|
||||
func handleMsgMhfGetFixedSeibatuRankingTable(s *Session, p mhfpacket.MHFPacket) {
|
||||
@@ -686,15 +686,11 @@ func handleMsgMhfGetFixedSeibatuRankingTable(s *Session, p mhfpacket.MHFPacket)
|
||||
}
|
||||
|
||||
bf := byteframe.NewByteFrame()
|
||||
|
||||
for _, seibatuData := range fixedSeibatuRankingTable {
|
||||
|
||||
bf.WriteInt32(seibatuData.Rank)
|
||||
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())
|
||||
}
|
||||
|
||||
@@ -728,7 +724,6 @@ func handleMsgMhfReadLastWeekBeatRanking(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfUpdateBeatLevel(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfUpdateBeatLevel)
|
||||
|
||||
doAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user