diff --git a/patch-schema/event_quests.sql b/patch-schema/event_quests.sql index 8350d0a70..b2566e50d 100644 --- a/patch-schema/event_quests.sql +++ b/patch-schema/event_quests.sql @@ -2,10 +2,11 @@ BEGIN; create table if not exists event_quests ( - id serial primary key, + id serial primary key, max_players integer, - quest_type integer, - quest_id uint16 not null + quest_type integer not null, + quest_id integer not null, + mark integer ); END; \ No newline at end of file diff --git a/server/channelserver/handlers_quest.go b/server/channelserver/handlers_quest.go index 2baf6fb17..99002afe0 100644 --- a/server/channelserver/handlers_quest.go +++ b/server/channelserver/handlers_quest.go @@ -177,8 +177,9 @@ func loadQuestFile(s *Session, questId string) []byte { func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { var id int32 - var maxPlayers, questType, questId uint16 - rows.Scan(&id, &maxPlayers, &questType, &questId) + var questId uint16 + var maxPlayers, questType, mark uint8 + rows.Scan(&id, &maxPlayers, &questType, &questId, &mark) bf := byteframe.NewByteFrame() bf.SetLE() @@ -186,14 +187,16 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) { // Reconstructing the event-header itself. A lot of the data is not actually necessary for the quest to operate normally. bf.WriteInt32(id) bf.WriteInt32(0) - bf.WriteBytes([]byte{0x0F, byte(maxPlayers), byte(questType), 0x01}) + bf.WriteUint8(0) // Indexer + bf.WriteUint8(maxPlayers) + bf.WriteUint8(questType) + bf.WriteUint8(mark) + bf.WriteUint16(0) + bf.WriteUint32(0) bf.WriteUint16(0) bf.WriteUint16(0) - bf.WriteBytes([]byte{0x00, 0x01}) - bf.WriteUint16(0) - bf.WriteBytes([]byte{0x02, 0x00}) - data := loadQuestFile(s, fmt.Sprintf("%d", questId)+"d0") + data := loadQuestFile(s, fmt.Sprintf("%05d", questId)+"d0") if data == nil { return nil, fmt.Errorf("failed to load quest file") @@ -218,7 +221,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) { bf := byteframe.NewByteFrame() bf.WriteUint16(0) - rows, _ := s.server.db.Query("SELECT id, max_players, quest_type, quest_id 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 FROM event_quests ORDER BY quest_id") // Loop through each row and load the quest entry if it exists. for rows.Next() {