From 490aecd94b5c31e368e01be2193881024cc6d839 Mon Sep 17 00:00:00 2001 From: wish Date: Sat, 18 Nov 2023 15:44:59 +1100 Subject: [PATCH] rewrite comments & change quest flag code --- ...est-flags.sql => 11-event-quest-flags.sql} | 2 +- server/channelserver/handlers_quest.go | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) rename patch-schema/{10-event-quest-flags.sql => 11-event-quest-flags.sql} (62%) diff --git a/patch-schema/10-event-quest-flags.sql b/patch-schema/11-event-quest-flags.sql similarity index 62% rename from patch-schema/10-event-quest-flags.sql rename to patch-schema/11-event-quest-flags.sql index 24b59db6a..5f88d732d 100644 --- a/patch-schema/10-event-quest-flags.sql +++ b/patch-schema/11-event-quest-flags.sql @@ -1,5 +1,5 @@ BEGIN; -ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS flag_override integer NOT NULL DEFAULT -1; +ALTER TABLE IF EXISTS public.event_quests ADD COLUMN IF NOT EXISTS flags integer; END; \ No newline at end of file diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 7c782fb60..fbabec35d 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -70,22 +70,22 @@ func seasonConversion(s *Session, questFile string) string { return filename } else { // Attempt to return the requested quest file if the seasonal file doesn't exist - if _, err := os.Stat(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", questFile))); err == nil { + if _, err = os.Stat(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", questFile))); err == nil { return questFile } // If the code reaches this point, it's most likely a custom quest with no seasonal variations in the files. // Since event quests when seasonal pick day or night and the client requests either one, we need to differentiate between the two to prevent issues. - var time string + var _time string if TimeGameAbsolute() > 2880 { - time = "d" + _time = "d" } else { - time = "n" + _time = "n" } - // Request a D0 or N0 file depending on the time of day. The time of day matters since the client will quite a few issues if it's different to the one it requests. - return fmt.Sprintf("%s%s%d", questFile[:5], time, 0) + // Request a d0 or n0 file depending on the time of day. The time of day matters and issues will occur if it's different to the one it requests. + return fmt.Sprintf("%s%s%d", questFile[:5], _time, 0) } } @@ -149,10 +149,9 @@ func loadQuestFile(s *Session, questId int) []byte { func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { var id, mark uint32 - var questId int + var questId, flags int var maxPlayers, questType uint8 - var questFlags int8 - rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &questFlags) + rows.Scan(&id, &maxPlayers, &questType, &questId, &mark, &flags) data := loadQuestFile(s, questId) if data == nil { @@ -201,10 +200,10 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { bf.WriteUint8(flagByte & 0b11100000) } else { // Allow for seasons to be specified in database, otherwise use the one in the file. - if questFlags == -1 { + if flags < 0 { bf.WriteUint8(flagByte) } else { - bf.WriteUint8(uint8(questFlags)) + bf.WriteUint8(uint8(flags)) } } @@ -229,7 +228,7 @@ 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, flags FROM event_quests ORDER BY quest_id") + rows, _ := 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) FROM event_quests ORDER BY quest_id") for rows.Next() { data, err := makeEventQuest(s, rows) if err != nil {