rewrite comments & change quest flag code

This commit is contained in:
wish
2023-11-18 15:44:59 +11:00
parent 6384d79a7a
commit 490aecd94b
2 changed files with 12 additions and 13 deletions

View File

@@ -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;

View File

@@ -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 {