mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 08:55:31 +01:00
Removed EarthStatus for Event System
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
_config "erupe-ce/config"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -32,7 +33,7 @@ func stubEnumerateNoResults(s *Session, ackHandle uint32) {
|
||||
|
||||
func doAckEarthSucceed(s *Session, ackHandle uint32, data []*byteframe.ByteFrame) {
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(uint32(s.server.erupeConfig.EarthID))
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(uint32(len(data)))
|
||||
@@ -1088,14 +1089,130 @@ 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 generateEarthStatusTimestamps(s *Session, start uint32, debug bool) []uint32 {
|
||||
timestamps := make([]uint32, 3)
|
||||
midnight := TimeMidnight()
|
||||
if start == 0 || TimeAdjusted().Unix() > int64(start)+2977200 {
|
||||
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)
|
||||
}
|
||||
if debug {
|
||||
timestamps[0] = uint32(TimeWeekStart().Unix())
|
||||
timestamps[1] = uint32(TimeWeekNext().Unix())
|
||||
timestamps[1] = uint32(TimeWeekNext().Add((time.Duration(7) * time.Hour * 24)).Unix())
|
||||
|
||||
} else {
|
||||
timestamps[0] = start
|
||||
timestamps[1] = timestamps[0] + 604800
|
||||
timestamps[2] = timestamps[1] + 604800
|
||||
}
|
||||
return timestamps
|
||||
}
|
||||
|
||||
func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetEarthStatus)
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(uint32(TimeWeekStart().Unix())) // Start
|
||||
bf.WriteUint32(uint32(TimeWeekNext().Unix())) // End
|
||||
bf.WriteInt32(s.server.erupeConfig.EarthStatus)
|
||||
bf.WriteInt32(s.server.erupeConfig.EarthID)
|
||||
//Conquest
|
||||
var conquestTimestamps []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'")
|
||||
if rows == nil {
|
||||
log.Println("No rows found")
|
||||
|
||||
} else {
|
||||
for rows.Next() {
|
||||
rows.Scan(&conquestId, &conquestStart)
|
||||
}
|
||||
}
|
||||
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
|
||||
} 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
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
if i == 4 {
|
||||
break
|
||||
}
|
||||
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")
|
||||
|
||||
} else {
|
||||
for rows.Next() {
|
||||
rows.Scan(&palloneId, &palloneStart)
|
||||
}
|
||||
}
|
||||
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 {
|
||||
if i == 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if i == 4 {
|
||||
break
|
||||
}
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user