From ba3016f89cd6b89ec05bc8f51836e27699174dbe Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 14 Nov 2023 20:12:11 -0800 Subject: [PATCH] filter non-download quests by episode --- src/Quest.cc | 6 ++++-- src/Quest.hh | 2 +- src/ReceiveCommands.cc | 4 ++-- system/config.example.json | 14 +++++++------- tests/config.json | 14 +++++++------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Quest.cc b/src/Quest.cc index b0dfc85c..dd68a59c 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -703,10 +703,12 @@ shared_ptr QuestIndex::get(uint32_t quest_number) const { } } -vector> QuestIndex::filter(uint32_t category_id, QuestScriptVersion version) const { +vector> QuestIndex::filter(Episode episode, uint32_t category_id, QuestScriptVersion version) const { vector> ret; for (auto it : this->quests_by_number) { - if ((it.second->category_id == category_id) && it.second->has_version_any_language(version)) { + if (((episode == Episode::NONE) || (it.second->episode == episode)) && + (it.second->category_id == category_id) && + it.second->has_version_any_language(version)) { ret.emplace_back(it.second); } } diff --git a/src/Quest.hh b/src/Quest.hh index f80d7184..54abf227 100644 --- a/src/Quest.hh +++ b/src/Quest.hh @@ -123,7 +123,7 @@ struct QuestIndex { QuestIndex(const std::string& directory, std::shared_ptr category_index, bool is_ep3); std::shared_ptr get(uint32_t quest_number) const; - std::vector> filter(uint32_t category_id, QuestScriptVersion version) const; + std::vector> filter(Episode episode, uint32_t category_id, QuestScriptVersion version) const; }; std::string encode_download_quest_data( diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 0ebdc35c..9859b0f2 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1971,7 +1971,7 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { if (num_ep3_categories == 1) { auto quest_index = s->quest_index_for_client(c); if (quest_index) { - auto quests = quest_index->filter(ep3_category_id, c->quest_version()); + auto quests = quest_index->filter(Episode::EP3, ep3_category_id, c->quest_version()); send_quest_menu(c, MenuID::QUEST, quests, true); } else { send_lobby_message_box(c, "$C6Quests are not available."); @@ -2225,7 +2225,7 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { break; } shared_ptr l = c->lobby.lock(); - auto quests = quest_index->filter(item_id, c->quest_version()); + auto quests = quest_index->filter(l ? l->episode : Episode::NONE, item_id, c->quest_version()); // Hack: Assume the menu to be sent is the download quest menu if the // client is not in any lobby diff --git a/system/config.example.json b/system/config.example.json index 1e1dce1b..9323e1b4 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -488,13 +488,13 @@ // category_name: what appears in the quest menu on the client. // description: what appears in the category description window (may // contain color escape codes like $C6). - [0x21, "retrieval", "Retrieval", "$E$C6Quests that involve\nretrieving an object"], - [0x21, "extermination", "Extermination", "$E$C6Quests that involve\ndestroying all\nmonsters"], - [0x21, "events", "Events", "$E$C6Quests that are part\nof an event"], - [0x21, "shops", "Shops", "$E$C6Quests that contain\nshops"], - [0x21, "vr", "Virtual Reality", "$E$C6Quests that are\ndone in a simulator"], - [0xA1, "tower", "Control Tower", "$E$C6Quests that take\nplace at the Control\nTower"], - [0xA1, "team", "Team", "$E$C6Quests for you\nand your team\nmembers."], + [0x01, "retrieval", "Retrieval", "$E$C6Quests that involve\nretrieving an object"], + [0x01, "extermination", "Extermination", "$E$C6Quests that involve\ndestroying all\nmonsters"], + [0x01, "events", "Events", "$E$C6Quests that are part\nof an event"], + [0x01, "shops", "Shops", "$E$C6Quests that contain\nshops"], + [0x01, "vr", "Virtual Reality", "$E$C6Quests that are\ndone in a simulator"], + [0x81, "tower", "Control Tower", "$E$C6Quests that take\nplace at the Control\nTower"], + [0x81, "team", "Team", "$E$C6Quests for you\nand your team\nmembers."], [0x02, "battle", "Battle", "$E$C6Battle mode rule\nsets"], [0x04, "challenge-ep1", "Challenge (Episode 1)", "$E$C6Challenge mode\nquests in Episode 1"], [0x84, "challenge-ep2", "Challenge (Episode 2)", "$E$C6Challenge mode\nquests in Episode 2"], diff --git a/tests/config.json b/tests/config.json index dce1ad27..b4939a0e 100644 --- a/tests/config.json +++ b/tests/config.json @@ -127,13 +127,13 @@ }, "QuestCategories": [ - [0x21, "retrieval", "Retrieval", "$E$C6Quests that involve\nretrieving an object"], - [0x21, "extermination", "Extermination", "$E$C6Quests that involve\ndestroying all\nmonsters"], - [0x21, "events", "Events", "$E$C6Quests that are part\nof an event"], - [0x21, "shops", "Shops", "$E$C6Quests that contain\nshops"], - [0x21, "vr", "Virtual Reality", "$E$C6Quests that are\ndone in a simulator"], - [0xA1, "tower", "Control Tower", "$E$C6Quests that take\nplace at the Control\nTower"], - [0xA1, "team", "Team", "$E$C6Quests for you\nand your team\nmembers."], + [0x01, "retrieval", "Retrieval", "$E$C6Quests that involve\nretrieving an object"], + [0x01, "extermination", "Extermination", "$E$C6Quests that involve\ndestroying all\nmonsters"], + [0x01, "events", "Events", "$E$C6Quests that are part\nof an event"], + [0x01, "shops", "Shops", "$E$C6Quests that contain\nshops"], + [0x01, "vr", "Virtual Reality", "$E$C6Quests that are\ndone in a simulator"], + [0x81, "tower", "Control Tower", "$E$C6Quests that take\nplace at the Control\nTower"], + [0x81, "team", "Team", "$E$C6Quests for you\nand your team\nmembers."], [0x02, "battle", "Battle", "$E$C6Battle mode rule\nsets"], [0x04, "challenge-ep1", "Challenge (Episode 1)", "$E$C6Challenge mode\nquests in Episode 1"], [0x84, "challenge-ep2", "Challenge (Episode 2)", "$E$C6Challenge mode\nquests in Episode 2"],