From f2bf8be1aec115c727ae62783d19250acdc17b50 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Sun, 20 Aug 2023 07:58:08 +0900 Subject: [PATCH 01/32] Auto-cycle event quests in the database --- server/channelserver/handlers_quest.go | 106 ++++++++++++++++++++----- 1 file changed, 87 insertions(+), 19 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index d45b3725b..bc61a955c 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -51,14 +51,25 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) { pkt.Filename = seasonConversion(s, pkt.Filename) } - data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", pkt.Filename))) - if err != nil { - s.logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) - // This will crash the game. + if _config.ErupeConfig.RealClientMode <= _config.F5 { + data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("old_quests/%s.bin", pkt.Filename))) + if err != nil { + s.logger.Error(fmt.Sprintf("Failed to open file: %s/old_quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) + // This will crash the game. + doAckBufSucceed(s, pkt.AckHandle, data) + return + } + doAckBufSucceed(s, pkt.AckHandle, data) + } else { + data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", pkt.Filename))) + if err != nil { + s.logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) + // This will crash the game. + doAckBufSucceed(s, pkt.AckHandle, data) + return + } doAckBufSucceed(s, pkt.AckHandle, data) - return } - doAckBufSucceed(s, pkt.AckHandle, data) } } @@ -142,11 +153,16 @@ func loadQuestFile(s *Session, questId int) []byte { return questBody.Data() } -func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { +func makeEventQuest(s *Session, rows *sql.Rows, weeklyCycle int, currentCycle int) ([]byte, error) { var id, mark uint32 var questId int var maxPlayers, questType uint8 - rows.Scan(&id, &maxPlayers, &questType, &questId, &mark) + var availableInAllCycles bool + + err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &weeklyCycle, &availableInAllCycles) + if err != nil { + return nil, err + } data := loadQuestFile(s, questId) if data == nil { @@ -195,23 +211,75 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { bf := byteframe.NewByteFrame() bf.WriteUint16(0) - rows, _ := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark FROM event_quests ORDER BY quest_id") + // Check weekly_cycle_info to get the current cycle and the last timestamp + var lastCycleUpdate time.Time + var currentCycle int + + if s.server.erupeConfig.DevModeOptions.WeeklyQuestCycle { + err := s.server.db.QueryRow("SELECT current_cycle_number, last_cycle_update_timestamp FROM weekly_cycle_info").Scan(¤tCycle, &lastCycleUpdate) + if err != nil { + if err == sql.ErrNoRows { + // Insert the first data if there isn't + _, err := s.server.db.Exec("INSERT INTO weekly_cycle_info (current_cycle_number, last_cycle_update_timestamp) VALUES ($1, $2)", 1, TimeWeekStart()) + if err != nil { + panic(err) + } + currentCycle = 1 + lastCycleUpdate = TimeWeekStart() + } else { + panic(err) + } + } + } + + // Check if it's time to update the cycle + if lastCycleUpdate.Add(7 * 24 * time.Hour).Before(TimeMidnight()) { + // Update the cycle and the timestamp in the weekly_cycle_info table + newCycle := (currentCycle % 5) + 1 + _, err := s.server.db.Exec("UPDATE weekly_cycle_info SET current_cycle_number = $1, last_cycle_update_timestamp = $2", newCycle, TimeWeekStart()) + if err != nil { + panic(err) + } + currentCycle = newCycle + } + + var tableName = "event_quests" + /* This is an example of how I have to test and avoid issues, might be a thing later? + var tableName string + if _config.ErupeConfig.RealClientMode <= _config.F5 { + tableName = "event_quests_older" + } else { + tableName = "event_quests" + } + */ + + // Check the event_quests_older table to load the current week quests + rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, weekly_cycle, available_in_all_cycles FROM "+tableName+" WHERE weekly_cycle = $1 OR available_in_all_cycles = true ORDER BY quest_id", currentCycle) + if err != nil { + panic(err) + } + defer rows.Close() + + // Process the current week quests for rows.Next() { - data, err := makeEventQuest(s, rows) + var id, mark uint32 + var questId, weeklyCycle int + var maxPlayers, questType uint8 + var availableInAllCycles bool + err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &weeklyCycle, &availableInAllCycles) if err != nil { continue - } else { - if len(data) > 896 || len(data) < 352 { + } + + if (availableInAllCycles && questId != 0) || (questId != 0 && (weeklyCycle == currentCycle || availableInAllCycles)) { + data, err := makeEventQuest(s, rows, weeklyCycle, currentCycle) + if err != nil { continue } else { - totalCount++ - if _config.ErupeConfig.RealClientMode == _config.F5 { - if totalCount > pkt.Offset && len(bf.Data()) < 21550 { - returnedCount++ - bf.WriteBytes(data) - continue - } + if len(data) > 896 || len(data) < 352 { + continue } else { + totalCount++ if totalCount > pkt.Offset && len(bf.Data()) < 60000 { returnedCount++ bf.WriteBytes(data) From 292426bb5d20badc1c4f2af54b644be55e9aeb8f Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Sun, 20 Aug 2023 07:58:59 +0900 Subject: [PATCH 02/32] Update config for auto-cycle --- config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.go b/config/config.go index ac7e48af6..c380b7859 100644 --- a/config/config.go +++ b/config/config.go @@ -111,6 +111,7 @@ type DevModeOptions struct { EarthStatusOverride int32 EarthIDOverride int32 EarthMonsterOverride int32 + WeeklyQuestCycle bool SaveDumps SaveDumpOptions } From fe465b5de4262926a6cbbe81ac107bdbbd7a5630 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Sun, 20 Aug 2023 07:59:45 +0900 Subject: [PATCH 03/32] Update config.json for auto-cycle --- config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config.json b/config.json index d3de778bb..f8ddc2442 100644 --- a/config.json +++ b/config.json @@ -30,6 +30,7 @@ "EarthStatusOverride": 0, "EarthIDOverride": 0, "EarthMonsterOverride": 0, + "WeeklyQuestCycle": false, "SaveDumps": { "Enabled": true, "OutputDir": "save-backups" From f5b40b55b9a84a661227add5faabe57a403a0f12 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Sun, 20 Aug 2023 08:00:39 +0900 Subject: [PATCH 04/32] Update 03-event_quests.sql for auto-cycle --- patch-schema/03-event_quests.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/patch-schema/03-event_quests.sql b/patch-schema/03-event_quests.sql index 94aac0c65..affaf3954 100644 --- a/patch-schema/03-event_quests.sql +++ b/patch-schema/03-event_quests.sql @@ -6,9 +6,17 @@ create table if not exists event_quests max_players integer, quest_type integer not null, quest_id integer not null, - mark integer + mark integer, + weekly_cycle INT, + available_in_all_cycles bool default true ); ALTER TABLE IF EXISTS public.servers DROP COLUMN IF EXISTS season; -END; \ No newline at end of file +CREATE TABLE IF NOT EXISTS weekly_cycle_info ( + id SERIAL PRIMARY KEY, + current_cycle_number INT, + last_cycle_update_timestamp TIMESTAMP WITH TIME ZONE +); + +END; From f643960b6288ce4a62e346db9e18d0b4bfe6845d Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Sun, 20 Aug 2023 08:38:23 +0900 Subject: [PATCH 05/32] Cleaning leftover of personal if-else --- server/channelserver/handlers_quest.go | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index bc61a955c..d3f5a9d7a 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -51,25 +51,14 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) { pkt.Filename = seasonConversion(s, pkt.Filename) } - if _config.ErupeConfig.RealClientMode <= _config.F5 { - data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("old_quests/%s.bin", pkt.Filename))) - if err != nil { - s.logger.Error(fmt.Sprintf("Failed to open file: %s/old_quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) - // This will crash the game. - doAckBufSucceed(s, pkt.AckHandle, data) - return - } - doAckBufSucceed(s, pkt.AckHandle, data) - } else { - data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", pkt.Filename))) - if err != nil { - s.logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) - // This will crash the game. - doAckBufSucceed(s, pkt.AckHandle, data) - return - } + data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", pkt.Filename))) + if err != nil { + s.logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename)) + // This will crash the game. doAckBufSucceed(s, pkt.AckHandle, data) + return } + doAckBufSucceed(s, pkt.AckHandle, data) } } From f7c4a1c925719b57a7739da6b3a384ed036f0d56 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 03:20:46 +0900 Subject: [PATCH 06/32] Update auto-cycle code Cycle amount can now be set in the config.json. Instead of making a new database table it's now using the events table. --- server/channelserver/handlers_quest.go | 42 +++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index d3f5a9d7a..11c9c980f 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -205,29 +205,37 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { var currentCycle int if s.server.erupeConfig.DevModeOptions.WeeklyQuestCycle { - err := s.server.db.QueryRow("SELECT current_cycle_number, last_cycle_update_timestamp FROM weekly_cycle_info").Scan(¤tCycle, &lastCycleUpdate) + // Check if the "EventQuests" entry exists in the events table + var eventTypeExists bool + err := s.server.db.QueryRow("SELECT EXISTS (SELECT 1 FROM events WHERE event_type = 'EventQuests')").Scan(&eventTypeExists) if err != nil { - if err == sql.ErrNoRows { - // Insert the first data if there isn't - _, err := s.server.db.Exec("INSERT INTO weekly_cycle_info (current_cycle_number, last_cycle_update_timestamp) VALUES ($1, $2)", 1, TimeWeekStart()) - if err != nil { - panic(err) - } - currentCycle = 1 - lastCycleUpdate = TimeWeekStart() - } else { - panic(err) + fmt.Printf("Error checking for EventQuests entry: %v\n", err) + } + + if !eventTypeExists { + // Insert the initial "EventQuests" entry with the current cycle number + _, err := s.server.db.Exec("INSERT INTO events (event_type, start_time, current_cycle_number) VALUES ($1, $2, $3)", + "EventQuests", TimeWeekStart(), 1) + if err != nil { + fmt.Printf("Error inserting EventQuests entry: %v\n", err) } } + + // Get the current cycle number and last cycle update timestamp from the events table + err = s.server.db.QueryRow("SELECT current_cycle_number, start_time FROM events WHERE event_type = 'EventQuests'").Scan(¤tCycle, &lastCycleUpdate) + if err != nil { + fmt.Printf("Error getting EventQuests entry: %v\n", err) + } } // Check if it's time to update the cycle - if lastCycleUpdate.Add(7 * 24 * time.Hour).Before(TimeMidnight()) { - // Update the cycle and the timestamp in the weekly_cycle_info table - newCycle := (currentCycle % 5) + 1 - _, err := s.server.db.Exec("UPDATE weekly_cycle_info SET current_cycle_number = $1, last_cycle_update_timestamp = $2", newCycle, TimeWeekStart()) + if lastCycleUpdate.Add(time.Duration(s.server.erupeConfig.DevModeOptions.WeeklyCycleAmount) * 24 * time.Hour).Before(TimeMidnight()) { + // Update the cycle and the timestamp in the events table + newCycle := (currentCycle % s.server.erupeConfig.DevModeOptions.WeeklyCycleAmount) + 1 + _, err := s.server.db.Exec("UPDATE events SET current_cycle_number = $1, start_time = $2 WHERE event_type = 'EventQuests'", + newCycle, TimeWeekStart()) if err != nil { - panic(err) + fmt.Printf("Error updating EventQuests entry: %v\n", err) } currentCycle = newCycle } @@ -245,7 +253,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { // Check the event_quests_older table to load the current week quests rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, weekly_cycle, available_in_all_cycles FROM "+tableName+" WHERE weekly_cycle = $1 OR available_in_all_cycles = true ORDER BY quest_id", currentCycle) if err != nil { - panic(err) + fmt.Printf("Error querying event quests: %v\n", err) } defer rows.Close() From 6708c9fc8f1c6f3553405026e9a24d9a5ed3c5a2 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 03:21:49 +0900 Subject: [PATCH 07/32] Update config.json auto cycle --- config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config.json b/config.json index f8ddc2442..86273ac40 100644 --- a/config.json +++ b/config.json @@ -31,6 +31,7 @@ "EarthIDOverride": 0, "EarthMonsterOverride": 0, "WeeklyQuestCycle": false, + "WeeklyCycleAmount": 5, "SaveDumps": { "Enabled": true, "OutputDir": "save-backups" From c0d11bea4bc113abcd88591050e21e4171d30ac2 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 03:22:45 +0900 Subject: [PATCH 08/32] Update config.go auto-cycle --- config/config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index c380b7859..1d5990d37 100644 --- a/config/config.go +++ b/config/config.go @@ -111,7 +111,8 @@ type DevModeOptions struct { EarthStatusOverride int32 EarthIDOverride int32 EarthMonsterOverride int32 - WeeklyQuestCycle bool + WeeklyQuestCycle bool // Enable weekly event quests cycle + WeeklyCycleAmount int // Set the amount of cycles (week) SaveDumps SaveDumpOptions } From 30a215396b3ba199f6882196f4d7c23ccd53f463 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 03:23:37 +0900 Subject: [PATCH 09/32] Update 03-event_quests.sql auto-cycle --- patch-schema/03-event_quests.sql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/patch-schema/03-event_quests.sql b/patch-schema/03-event_quests.sql index affaf3954..53c184765 100644 --- a/patch-schema/03-event_quests.sql +++ b/patch-schema/03-event_quests.sql @@ -13,10 +13,7 @@ create table if not exists event_quests ALTER TABLE IF EXISTS public.servers DROP COLUMN IF EXISTS season; -CREATE TABLE IF NOT EXISTS weekly_cycle_info ( - id SERIAL PRIMARY KEY, - current_cycle_number INT, - last_cycle_update_timestamp TIMESTAMP WITH TIME ZONE -); +ALTER TABLE IF EXISTS public.events ADD COLUMN IF NOT EXISTS current_cycle_number int; +ALTER TYPE event_type ADD VALUE 'EventQuests'; END; From 5d156021dceb778ece01b0ec00fee38c65004f5b Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 08:53:49 +0900 Subject: [PATCH 10/32] Update a condition --- server/channelserver/handlers_quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 11c9c980f..ed57ab208 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -268,7 +268,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { continue } - if (availableInAllCycles && questId != 0) || (questId != 0 && (weeklyCycle == currentCycle || availableInAllCycles)) { + if questId != 0 && (availableInAllCycles || (weeklyCycle == currentCycle && weeklyCycle != 0)) { data, err := makeEventQuest(s, rows, weeklyCycle, currentCycle) if err != nil { continue From 391e0c9d988ab97101c1522bef5ccb34227f76e2 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Mon, 21 Aug 2023 08:55:05 +0900 Subject: [PATCH 11/32] Update default weeklyCycle value This value cannot be null or the quests won't appear in game. --- patch-schema/03-event_quests.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patch-schema/03-event_quests.sql b/patch-schema/03-event_quests.sql index 53c184765..6bad468fc 100644 --- a/patch-schema/03-event_quests.sql +++ b/patch-schema/03-event_quests.sql @@ -7,7 +7,7 @@ create table if not exists event_quests quest_type integer not null, quest_id integer not null, mark integer, - weekly_cycle INT, + weekly_cycle integer default 1, available_in_all_cycles bool default true ); From d3a6121b2cc64cb554bd094ce95a34ce5515d8e6 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Wed, 23 Aug 2023 05:28:49 +0900 Subject: [PATCH 12/32] Reworke auto-cycle code --- server/channelserver/handlers_quest.go | 80 ++++++++------------------ 1 file changed, 23 insertions(+), 57 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index ed57ab208..6191a4166 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -142,16 +142,12 @@ func loadQuestFile(s *Session, questId int) []byte { return questBody.Data() } -func makeEventQuest(s *Session, rows *sql.Rows, weeklyCycle int, currentCycle int) ([]byte, error) { +func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { var id, mark uint32 - var questId int + var questId, activeDuration, inactiveDuration int var maxPlayers, questType uint8 - var availableInAllCycles bool - - err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &weeklyCycle, &availableInAllCycles) - if err != nil { - return nil, err - } + var startTime time.Time + rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &startTime, &activeDuration, &inactiveDuration) data := loadQuestFile(s, questId) if data == nil { @@ -200,46 +196,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { bf := byteframe.NewByteFrame() bf.WriteUint16(0) - // Check weekly_cycle_info to get the current cycle and the last timestamp - var lastCycleUpdate time.Time - var currentCycle int - - if s.server.erupeConfig.DevModeOptions.WeeklyQuestCycle { - // Check if the "EventQuests" entry exists in the events table - var eventTypeExists bool - err := s.server.db.QueryRow("SELECT EXISTS (SELECT 1 FROM events WHERE event_type = 'EventQuests')").Scan(&eventTypeExists) - if err != nil { - fmt.Printf("Error checking for EventQuests entry: %v\n", err) - } - - if !eventTypeExists { - // Insert the initial "EventQuests" entry with the current cycle number - _, err := s.server.db.Exec("INSERT INTO events (event_type, start_time, current_cycle_number) VALUES ($1, $2, $3)", - "EventQuests", TimeWeekStart(), 1) - if err != nil { - fmt.Printf("Error inserting EventQuests entry: %v\n", err) - } - } - - // Get the current cycle number and last cycle update timestamp from the events table - err = s.server.db.QueryRow("SELECT current_cycle_number, start_time FROM events WHERE event_type = 'EventQuests'").Scan(¤tCycle, &lastCycleUpdate) - if err != nil { - fmt.Printf("Error getting EventQuests entry: %v\n", err) - } - } - - // Check if it's time to update the cycle - if lastCycleUpdate.Add(time.Duration(s.server.erupeConfig.DevModeOptions.WeeklyCycleAmount) * 24 * time.Hour).Before(TimeMidnight()) { - // Update the cycle and the timestamp in the events table - newCycle := (currentCycle % s.server.erupeConfig.DevModeOptions.WeeklyCycleAmount) + 1 - _, err := s.server.db.Exec("UPDATE events SET current_cycle_number = $1, start_time = $2 WHERE event_type = 'EventQuests'", - newCycle, TimeWeekStart()) - if err != nil { - fmt.Printf("Error updating EventQuests entry: %v\n", err) - } - currentCycle = newCycle - } - + currentTime := time.Now() var tableName = "event_quests" /* This is an example of how I have to test and avoid issues, might be a thing later? var tableName string @@ -249,27 +206,36 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { tableName = "event_quests" } */ - - // Check the event_quests_older table to load the current week quests - rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, weekly_cycle, available_in_all_cycles FROM "+tableName+" WHERE weekly_cycle = $1 OR available_in_all_cycles = true ORDER BY quest_id", currentCycle) + // Check the event_quests table to load the quests with rotation system + rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, active_duration, inactive_duration FROM " + tableName + "") if err != nil { fmt.Printf("Error querying event quests: %v\n", err) } defer rows.Close() - // Process the current week quests for rows.Next() { var id, mark uint32 - var questId, weeklyCycle int + var questId, activeDuration, inactiveDuration int var maxPlayers, questType uint8 - var availableInAllCycles bool - err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &weeklyCycle, &availableInAllCycles) + var startTime time.Time + err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &startTime, &activeDuration, &inactiveDuration) if err != nil { continue } - if questId != 0 && (availableInAllCycles || (weeklyCycle == currentCycle && weeklyCycle != 0)) { - data, err := makeEventQuest(s, rows, weeklyCycle, currentCycle) + // Calculate the rotation time based on start time, active duration, and inactive duration + rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Hour) + if currentTime.After(rotationTime) { + // The rotation time has passed, update the start time and reset the rotation + _, err := s.server.db.Exec("UPDATE "+tableName+" SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) + if err != nil { + fmt.Printf("Error updating start time for quest: %v\n", err) + } + } + + // Check if the quest is currently active + if currentTime.After(startTime) && currentTime.Sub(startTime) <= time.Duration(activeDuration)*24*time.Hour { + data, err := makeEventQuest(s, rows) if err != nil { continue } else { From c4f11721c6de5f9ec8c7a6db74b5608225f2fc25 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Wed, 23 Aug 2023 05:30:02 +0900 Subject: [PATCH 13/32] Removed auto-cycle option --- config.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/config.json b/config.json index 86273ac40..d3de778bb 100644 --- a/config.json +++ b/config.json @@ -30,8 +30,6 @@ "EarthStatusOverride": 0, "EarthIDOverride": 0, "EarthMonsterOverride": 0, - "WeeklyQuestCycle": false, - "WeeklyCycleAmount": 5, "SaveDumps": { "Enabled": true, "OutputDir": "save-backups" From 43c59da809902e03c4f41f670d568ddf7da49bac Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Wed, 23 Aug 2023 05:30:27 +0900 Subject: [PATCH 14/32] Removed auto-cycle option --- config/config.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/config.go b/config/config.go index 1d5990d37..ac7e48af6 100644 --- a/config/config.go +++ b/config/config.go @@ -111,8 +111,6 @@ type DevModeOptions struct { EarthStatusOverride int32 EarthIDOverride int32 EarthMonsterOverride int32 - WeeklyQuestCycle bool // Enable weekly event quests cycle - WeeklyCycleAmount int // Set the amount of cycles (week) SaveDumps SaveDumpOptions } From 5cd268df23d0298167eb73143b02dcc213d1ccc9 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Wed, 23 Aug 2023 05:31:12 +0900 Subject: [PATCH 15/32] Update 03-event_quests.sql auto-cycle --- patch-schema/03-event_quests.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/patch-schema/03-event_quests.sql b/patch-schema/03-event_quests.sql index 6bad468fc..b8003954f 100644 --- a/patch-schema/03-event_quests.sql +++ b/patch-schema/03-event_quests.sql @@ -7,13 +7,11 @@ create table if not exists event_quests quest_type integer not null, quest_id integer not null, mark integer, - weekly_cycle integer default 1, - available_in_all_cycles bool default true + start_time timestamp with time zone NOT NULL DEFAULT (CURRENT_DATE + interval '0 second'), + active_duration int not null, + inactive_duration int not null ); ALTER TABLE IF EXISTS public.servers DROP COLUMN IF EXISTS season; -ALTER TABLE IF EXISTS public.events ADD COLUMN IF NOT EXISTS current_cycle_number int; -ALTER TYPE event_type ADD VALUE 'EventQuests'; - END; From b74e571beb52982a35fe4dae80012521a0aec485 Mon Sep 17 00:00:00 2001 From: "Ewerton B. S" Date: Wed, 23 Aug 2023 08:07:15 +0900 Subject: [PATCH 16/32] Update handlers_quest.go --- server/channelserver/handlers_quest.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 6191a4166..721ffc831 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -199,17 +199,14 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { currentTime := time.Now() var tableName = "event_quests" /* This is an example of how I have to test and avoid issues, might be a thing later? - var tableName string - if _config.ErupeConfig.RealClientMode <= _config.F5 { + if _config.ErupeConfig.RealClientMode <= _config.F5 { tableName = "event_quests_older" - } else { - tableName = "event_quests" } */ // Check the event_quests table to load the quests with rotation system rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, active_duration, inactive_duration FROM " + tableName + "") if err != nil { - fmt.Printf("Error querying event quests: %v\n", err) + return } defer rows.Close() @@ -229,7 +226,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { // The rotation time has passed, update the start time and reset the rotation _, err := s.server.db.Exec("UPDATE "+tableName+" SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) if err != nil { - fmt.Printf("Error updating start time for quest: %v\n", err) + return } } From a27d15bff197c446b38c2770a0a13cb84c68f33e Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 16 Nov 2023 02:38:58 -0500 Subject: [PATCH 17/32] style: Fixed inconsistent spacing and cleaned up SQL query strings --- server/channelserver/handlers_quest.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index deefe05ea..df7496f58 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -197,14 +197,9 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { bf.WriteUint16(0) currentTime := time.Now() - var tableName = "event_quests" - /* This is an example of how I have to test and avoid issues, might be a thing later? - if _config.ErupeConfig.RealClientMode <= _config.F5 { - tableName = "event_quests_older" - } - */ + // Check the event_quests table to load the quests with rotation system - rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, active_duration, inactive_duration FROM " + tableName + "") + rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, active_duration, inactive_duration FROM event_quests") if err != nil { return } @@ -224,14 +219,14 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Hour) if currentTime.After(rotationTime) { // The rotation time has passed, update the start time and reset the rotation - _, err := s.server.db.Exec("UPDATE "+tableName+" SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) + _, err := s.server.db.Exec("UPDATE event_quests SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) if err != nil { return } } // Check if the quest is currently active - if currentTime.After(startTime) && currentTime.Sub(startTime) <= time.Duration(activeDuration)*24*time.Hour { + if currentTime.After(startTime) && currentTime.Sub(startTime) <= time.Duration(activeDuration) * 24 * time.Hour { data, err := makeEventQuest(s, rows) if err != nil { continue From 800e993c1fa2ebb5fffe27bd79c548a035f2f455 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Nov 2023 21:14:19 -0500 Subject: [PATCH 18/32] sql: Added 11-event_quest_cycling migration sql --- patch-schema/11-event_quest_cycling.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 patch-schema/11-event_quest_cycling.sql diff --git a/patch-schema/11-event_quest_cycling.sql b/patch-schema/11-event_quest_cycling.sql new file mode 100644 index 000000000..cabc928a7 --- /dev/null +++ b/patch-schema/11-event_quest_cycling.sql @@ -0,0 +1,7 @@ +BEGIN; + +ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS start_time timestamp with time zone NOT NULL DEFAULT (CURRENT_DATE + interval '0 second'); +ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS active_duration int DEFAULT 4; +ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS inactive_duration int DEFAULT 3; + +END; \ No newline at end of file From 233990f452dc9111cf42a79d2ba7531e5d9b0c01 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Nov 2023 22:18:07 -0500 Subject: [PATCH 19/32] refactor: Change event quest updating to use transactions rather than directly commiting --- server/channelserver/handlers_quest.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index df7496f58..edf7f7ae2 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -205,11 +205,15 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { } defer rows.Close() + // Commit event quest changes to a transaction instead of doing it one by one for to help with performance + transaction, _ := s.server.db.Begin() + for rows.Next() { var id, mark uint32 var questId, activeDuration, inactiveDuration int var maxPlayers, questType uint8 var startTime time.Time + err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &startTime, &activeDuration, &inactiveDuration) if err != nil { continue @@ -219,14 +223,14 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Hour) if currentTime.After(rotationTime) { // The rotation time has passed, update the start time and reset the rotation - _, err := s.server.db.Exec("UPDATE event_quests SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) + _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) if err != nil { return } } // Check if the quest is currently active - if currentTime.After(startTime) && currentTime.Sub(startTime) <= time.Duration(activeDuration) * 24 * time.Hour { + if currentTime.After(startTime) && currentTime.Sub(startTime) <= time.Duration(activeDuration)*24*time.Hour { data, err := makeEventQuest(s, rows) if err != nil { continue @@ -245,6 +249,9 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { } } + // Commit transaction so to write to the database. + transaction.Commit() + type tuneValue struct { ID uint16 Value uint16 From 50d3ec36b25b173c41c35272ffc07d0fb7ccdb43 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Nov 2023 22:21:15 -0500 Subject: [PATCH 20/32] chore: Fix formatting --- server/channelserver/handlers_quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index edf7f7ae2..011db2617 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -220,7 +220,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { } // Calculate the rotation time based on start time, active duration, and inactive duration - rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Hour) + rotationTime := startTime.Add((time.Duration(activeDuration+inactiveDuration) * 24) * time.Hour) if currentTime.After(rotationTime) { // The rotation time has passed, update the start time and reset the rotation _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) From a34a0e42b24efe3bf66a1d55e3417115b34de2b5 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Nov 2023 22:21:48 -0500 Subject: [PATCH 21/32] fix: Commit to database via unique index rather than quest_id --- server/channelserver/handlers_quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 011db2617..e53b2b54d 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -223,7 +223,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { rotationTime := startTime.Add((time.Duration(activeDuration+inactiveDuration) * 24) * time.Hour) if currentTime.After(rotationTime) { // The rotation time has passed, update the start time and reset the rotation - _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE quest_id = $2", rotationTime, questId) + _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE id = $2", rotationTime, id) if err != nil { return } From c20380b79d65f3cf72dca01e0ca238496d3d1b8b Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 17 Nov 2023 22:27:50 -0500 Subject: [PATCH 22/32] fix: Continue instead of ending event quest parsing if an error occurs on a single quest --- server/channelserver/handlers_quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index e53b2b54d..37ae822a8 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -225,7 +225,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { // The rotation time has passed, update the start time and reset the rotation _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE id = $2", rotationTime, id) if err != nil { - return + continue } } From 47ca3023844b6eee1424e142d059622483cc91a2 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 18 Nov 2023 03:18:35 -0500 Subject: [PATCH 23/32] feat: Cycle simulation (simulate cycles if beyond a single set) --- config.json | 4 ++-- server/channelserver/handlers_quest.go | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index d3de778bb..b175451e4 100644 --- a/config.json +++ b/config.json @@ -119,9 +119,9 @@ ], "Database": { "Host": "localhost", - "Port": 5432, + "Port": 5433, "User": "postgres", - "Password": "", + "Password": "admin", "Database": "erupe" }, "Sign": { diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 37ae822a8..90c477708 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -190,6 +190,14 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { return bf.Data(), nil } +func calculateNumberOfCycles(duration time.Duration, lastStartTime time.Time) int { + timeDifference := time.Now().Sub(lastStartTime) + println(timeDifference.String()) + println(float64(duration)) + numberOfCycles := int(timeDifference.Nanoseconds() / int64(duration)) + return numberOfCycles +} + func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfEnumerateQuest) var totalCount, returnedCount uint16 @@ -219,14 +227,22 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { continue } + // Count the number of cycles necessary to align quest with actual time. + cycleCount := calculateNumberOfCycles(time.Duration(activeDuration+inactiveDuration)*24*time.Hour, startTime) + // Calculate the rotation time based on start time, active duration, and inactive duration - rotationTime := startTime.Add((time.Duration(activeDuration+inactiveDuration) * 24) * time.Hour) + rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Duration(cycleCount) * time.Hour) if currentTime.After(rotationTime) { - // The rotation time has passed, update the start time and reset the rotation - _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE id = $2", rotationTime, id) + // take the rotationTime and normalize it to midnight + newRotationTime := time.Date(rotationTime.Year(), rotationTime.Month(), rotationTime.Day(), 0, 0, 0, 0, rotationTime.Location()) + newRotationTime = newRotationTime.Add(time.Duration(TimeMidnight().Add(13 * time.Hour).Nanosecond())) + + _, err := transaction.Exec("UPDATE event_quests SET start_time = $1 WHERE id = $2", newRotationTime, id) if err != nil { - continue + transaction.Rollback() // Rollback if an error occurs + break } + startTime = newRotationTime // Set the new start time so the quest can be used immediatelyw } // Check if the quest is currently active From 3778d03402d452af362ab6984362d04c51ab0a19 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:39:59 -0500 Subject: [PATCH 24/32] feat: Default to always active if inactive time is not set --- server/channelserver/handlers_quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 90c477708..7fc901cd0 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -207,7 +207,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { currentTime := time.Now() // Check the event_quests table to load the quests with rotation system - rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, active_duration, inactive_duration FROM event_quests") + rows, err := s.server.db.Query("SELECT id, COALESCE(max_players, 4) AS max_players, quest_type, quest_id, COALESCE(mark, 0) AS mark, start_time, COALESCE(active_duration, 1) AS active_duration, COALESCE(inactive_duration, 0) AS inactive_duration FROM event_quests") if err != nil { return } From 6bd2b637a721dde1f0445b85c2110a0da0c359f2 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:44:11 -0500 Subject: [PATCH 25/32] refactor: Moved quest duration variables to uint8 --- server/channelserver/handlers_quest.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 7fc901cd0..76b3fbef9 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -218,8 +218,8 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { for rows.Next() { var id, mark uint32 - var questId, activeDuration, inactiveDuration int - var maxPlayers, questType uint8 + var questId int + var maxPlayers, questType, activeDuration, inactiveDuration uint8 var startTime time.Time err := rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &startTime, &activeDuration, &inactiveDuration) From 858a9adb1777265f9a335d12a16ac2fa94845493 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:45:30 -0500 Subject: [PATCH 26/32] chore: Removed debug code --- server/channelserver/handlers_quest.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 76b3fbef9..24c5f2035 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -192,8 +192,6 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { func calculateNumberOfCycles(duration time.Duration, lastStartTime time.Time) int { timeDifference := time.Now().Sub(lastStartTime) - println(timeDifference.String()) - println(float64(duration)) numberOfCycles := int(timeDifference.Nanoseconds() / int64(duration)) return numberOfCycles } From ffb0d25a4324575957e6452b226f3aeb5eb21208 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:48:43 -0500 Subject: [PATCH 27/32] docs: Fixed and cleaned a bit of the documentation --- server/channelserver/handlers_quest.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 24c5f2035..e329dab1b 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -225,13 +225,13 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { continue } - // Count the number of cycles necessary to align quest with actual time. + // Count the number of cycles necessary to align quest with the correct date range. cycleCount := calculateNumberOfCycles(time.Duration(activeDuration+inactiveDuration)*24*time.Hour, startTime) - // Calculate the rotation time based on start time, active duration, and inactive duration + // Calculate the rotation time based on start time, active duration, and inactive duration. rotationTime := startTime.Add(time.Duration(activeDuration+inactiveDuration) * 24 * time.Duration(cycleCount) * time.Hour) if currentTime.After(rotationTime) { - // take the rotationTime and normalize it to midnight + // take the rotationTime and normalize it to midnight as to align with the ingame message for event quest rotation. newRotationTime := time.Date(rotationTime.Year(), rotationTime.Month(), rotationTime.Day(), 0, 0, 0, 0, rotationTime.Location()) newRotationTime = newRotationTime.Add(time.Duration(TimeMidnight().Add(13 * time.Hour).Nanosecond())) @@ -240,7 +240,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { transaction.Rollback() // Rollback if an error occurs break } - startTime = newRotationTime // Set the new start time so the quest can be used immediatelyw + startTime = newRotationTime // Set the new start time so the quest can be used/remove immediately. } // Check if the quest is currently active From 8dbc54fa1463feaff8b38a4e51eea40a26af113e Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:49:19 -0500 Subject: [PATCH 28/32] config: Fixed config back to default values --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index b175451e4..d3de778bb 100644 --- a/config.json +++ b/config.json @@ -119,9 +119,9 @@ ], "Database": { "Host": "localhost", - "Port": 5433, + "Port": 5432, "User": "postgres", - "Password": "admin", + "Password": "", "Database": "erupe" }, "Sign": { From 3b33c1917c82247ee65fb98849b33380c4294ea2 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 13:52:03 -0500 Subject: [PATCH 29/32] sql: Remove new migration code from old patch-schema --- patch-schema/03-event_quests.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/patch-schema/03-event_quests.sql b/patch-schema/03-event_quests.sql index b8003954f..1374a3d08 100644 --- a/patch-schema/03-event_quests.sql +++ b/patch-schema/03-event_quests.sql @@ -6,10 +6,7 @@ create table if not exists event_quests max_players integer, quest_type integer not null, quest_id integer not null, - mark integer, - start_time timestamp with time zone NOT NULL DEFAULT (CURRENT_DATE + interval '0 second'), - active_duration int not null, - inactive_duration int not null + mark integer ); ALTER TABLE IF EXISTS public.servers DROP COLUMN IF EXISTS season; From 46587b8d0182d135f000fb4a57275e981901673f Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 14:27:53 -0500 Subject: [PATCH 30/32] fix: Fix variables --- config.json | 4 ++-- server/channelserver/handlers_quest.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index d3de778bb..b175451e4 100644 --- a/config.json +++ b/config.json @@ -119,9 +119,9 @@ ], "Database": { "Host": "localhost", - "Port": 5432, + "Port": 5433, "User": "postgres", - "Password": "", + "Password": "admin", "Database": "erupe" }, "Sign": { diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index e329dab1b..35471269a 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -240,7 +240,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { transaction.Rollback() // Rollback if an error occurs break } - startTime = newRotationTime // Set the new start time so the quest can be used/remove immediately. + startTime = newRotationTime // Set the new start time so the quest can be used/removed immediately. } // Check if the quest is currently active From e141b7980c477cbf5680ba1fe6f6f64a8a602847 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 19 Nov 2023 14:35:20 -0500 Subject: [PATCH 31/32] chore: Fix config --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index b175451e4..d3de778bb 100644 --- a/config.json +++ b/config.json @@ -119,9 +119,9 @@ ], "Database": { "Host": "localhost", - "Port": 5433, + "Port": 5432, "User": "postgres", - "Password": "admin", + "Password": "", "Database": "erupe" }, "Sign": { From b823cbf2ae1fb3e70e5364f029679ec6b8479b1d Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 24 Nov 2023 03:25:35 -0500 Subject: [PATCH 32/32] chore: Rename schema to prevent confusion --- .../{11-event_quest_cycling.sql => 12-event_quest_cycling.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename patch-schema/{11-event_quest_cycling.sql => 12-event_quest_cycling.sql} (100%) diff --git a/patch-schema/11-event_quest_cycling.sql b/patch-schema/12-event_quest_cycling.sql similarity index 100% rename from patch-schema/11-event_quest_cycling.sql rename to patch-schema/12-event_quest_cycling.sql