filter non-download quests by episode

This commit is contained in:
Martin Michelsen
2023-11-14 20:12:11 -08:00
parent c5605c8685
commit ba3016f89c
5 changed files with 21 additions and 19 deletions
+4 -2
View File
@@ -703,10 +703,12 @@ shared_ptr<const Quest> QuestIndex::get(uint32_t quest_number) const {
}
}
vector<shared_ptr<const Quest>> QuestIndex::filter(uint32_t category_id, QuestScriptVersion version) const {
vector<shared_ptr<const Quest>> QuestIndex::filter(Episode episode, uint32_t category_id, QuestScriptVersion version) const {
vector<shared_ptr<const Quest>> 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);
}
}
+1 -1
View File
@@ -123,7 +123,7 @@ struct QuestIndex {
QuestIndex(const std::string& directory, std::shared_ptr<const QuestCategoryIndex> category_index, bool is_ep3);
std::shared_ptr<const Quest> get(uint32_t quest_number) const;
std::vector<std::shared_ptr<const Quest>> filter(uint32_t category_id, QuestScriptVersion version) const;
std::vector<std::shared_ptr<const Quest>> filter(Episode episode, uint32_t category_id, QuestScriptVersion version) const;
};
std::string encode_download_quest_data(
+2 -2
View File
@@ -1971,7 +1971,7 @@ static void on_10(shared_ptr<Client> 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<Client> c, uint16_t, uint32_t, string& data) {
break;
}
shared_ptr<Lobby> 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