make quests appear in the menu even if they don't exist in player's language
This commit is contained in:
+8
-4
@@ -416,6 +416,12 @@ bool Quest::has_version(QuestScriptVersion v, uint8_t language) const {
|
||||
return this->versions.count(this->versions_key(v, language));
|
||||
}
|
||||
|
||||
bool Quest::has_version_any_language(QuestScriptVersion v) const {
|
||||
uint16_t k = this->versions_key(v, 0);
|
||||
auto it = this->versions.lower_bound(k);
|
||||
return ((it != this->versions.end()) && ((it->first & 0xFF00) == k));
|
||||
}
|
||||
|
||||
shared_ptr<const VersionedQuest> Quest::version(QuestScriptVersion v, uint8_t language) const {
|
||||
// Return the requested version, if it exists
|
||||
try {
|
||||
@@ -727,12 +733,10 @@ shared_ptr<const string> QuestIndex::get_gba(const string& name) const {
|
||||
}
|
||||
}
|
||||
|
||||
vector<shared_ptr<const Quest>> QuestIndex::filter(uint32_t category_id, QuestScriptVersion version, uint8_t language) const {
|
||||
vector<shared_ptr<const Quest>> QuestIndex::filter(uint32_t category_id, QuestScriptVersion version) const {
|
||||
vector<shared_ptr<const Quest>> ret;
|
||||
for (auto it : this->quests_by_number) {
|
||||
// Show English quests, and quests that exist in the player's language
|
||||
if ((it.second->category_id == category_id) &&
|
||||
(it.second->has_version(version, language) || it.second->has_version(version, 1))) {
|
||||
if ((it.second->category_id == category_id) && it.second->has_version_any_language(version)) {
|
||||
ret.emplace_back(it.second);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -98,6 +98,7 @@ public:
|
||||
|
||||
void add_version(std::shared_ptr<const VersionedQuest> vq);
|
||||
bool has_version(QuestScriptVersion v, uint8_t language) const;
|
||||
bool has_version_any_language(QuestScriptVersion v) const;
|
||||
std::shared_ptr<const VersionedQuest> version(QuestScriptVersion v, uint8_t language) const;
|
||||
|
||||
static uint16_t versions_key(QuestScriptVersion v, uint8_t language);
|
||||
@@ -124,7 +125,7 @@ struct QuestIndex {
|
||||
|
||||
std::shared_ptr<const Quest> get(uint32_t quest_number) const;
|
||||
std::shared_ptr<const std::string> get_gba(const std::string& name) const;
|
||||
std::vector<std::shared_ptr<const Quest>> filter(uint32_t category_id, QuestScriptVersion version, uint8_t language) const;
|
||||
std::vector<std::shared_ptr<const Quest>> filter(uint32_t category_id, QuestScriptVersion version) const;
|
||||
};
|
||||
|
||||
std::string encode_download_quest_data(
|
||||
|
||||
@@ -1979,7 +1979,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(), c->language());
|
||||
auto quests = quest_index->filter(ep3_category_id, c->quest_version());
|
||||
send_quest_menu(c, MenuID::QUEST, quests, true);
|
||||
} else {
|
||||
send_lobby_message_box(c, "$C6Quests are not available.");
|
||||
@@ -2233,7 +2233,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(), c->language());
|
||||
auto quests = quest_index->filter(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
|
||||
|
||||
Reference in New Issue
Block a user