mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 15:04:38 +01:00
rename Event Quest cycling 'duration' to 'days'
This commit is contained in:
@@ -4,5 +4,7 @@ ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS start_time ti
|
||||
ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS active_duration int;
|
||||
ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS inactive_duration int;
|
||||
UPDATE public.event_quests SET active_duration=NULL, inactive_duration=NULL;
|
||||
ALTER TABLE IF EXISTS public.event_quests RENAME active_duration TO active_days;
|
||||
ALTER TABLE IF EXISTS public.event_quests RENAME inactive_duration TO inactive_days;
|
||||
|
||||
END;
|
||||
@@ -236,32 +236,32 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint16(0)
|
||||
|
||||
rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, COALESCE(flags, -1), start_time, COALESCE(active_duration, 0) AS active_duration, COALESCE(inactive_duration, 0) AS inactive_duration FROM event_quests ORDER BY quest_id")
|
||||
rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, COALESCE(flags, -1), start_time, COALESCE(active_days, 0) AS active_days, COALESCE(inactive_days, 0) AS inactive_days FROM event_quests ORDER BY quest_id")
|
||||
if err == nil {
|
||||
currentTime := time.Now()
|
||||
tx, _ := s.server.db.Begin()
|
||||
|
||||
for rows.Next() {
|
||||
var id, mark uint32
|
||||
var questId, flags, activeDuration, inactiveDuration int
|
||||
var questId, flags, activeDays, inactiveDays int
|
||||
var maxPlayers, questType uint8
|
||||
var startTime time.Time
|
||||
|
||||
err = rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &flags, &startTime, &activeDuration, &inactiveDuration)
|
||||
err = rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &flags, &startTime, &activeDays, &inactiveDays)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Use the Event Cycling system
|
||||
if activeDuration > 0 {
|
||||
cycleLength := (time.Duration(activeDuration) + time.Duration(inactiveDuration)) * 24 * time.Hour
|
||||
if activeDays > 0 {
|
||||
cycleLength := (time.Duration(activeDays) + time.Duration(inactiveDays)) * 24 * time.Hour
|
||||
|
||||
// Count the number of full cycles elapsed since the last rotation.
|
||||
extraCycles := int(currentTime.Sub(startTime) / cycleLength)
|
||||
|
||||
if extraCycles > 0 {
|
||||
// Calculate the rotation time based on start time, active duration, and inactive duration.
|
||||
rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Hour * time.Duration(extraCycles))
|
||||
rotationTime := startTime.Add(time.Duration(activeDays+inactiveDays) * 24 * time.Hour * time.Duration(extraCycles))
|
||||
if currentTime.After(rotationTime) {
|
||||
// Normalize rotationTime to 12PM JST to align with the in-game events update notification.
|
||||
newRotationTime := time.Date(rotationTime.Year(), rotationTime.Month(), rotationTime.Day(), 12, 0, 0, 0, TimeAdjusted().Location())
|
||||
@@ -276,7 +276,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
|
||||
// Check if the quest is currently active
|
||||
if currentTime.Before(startTime) || currentTime.After(startTime.Add(time.Duration(activeDuration)*24*time.Hour)) {
|
||||
if currentTime.Before(startTime) || currentTime.After(startTime.Add(time.Duration(activeDays)*24*time.Hour)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user