diff --git a/src/Quest.cc b/src/Quest.cc index e8b62ce2..2bd3f50f 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -461,17 +461,22 @@ bool Quest::has_version_any_language(Version v) const { return ((it != this->versions.end()) && ((it->first & 0xFF00) == k)); } -shared_ptr Quest::version(Version v, uint8_t language) const { +shared_ptr Quest::version(Version v, uint8_t language, bool allow_language_fallback) const { // Return the requested version, if it exists try { return this->versions.at(this->versions_key(v, language)); } catch (const out_of_range&) { } + if (!allow_language_fallback) { + return nullptr; + } + // Return the English version, if it exists try { return this->versions.at(this->versions_key(v, 1)); } catch (const out_of_range&) { } + // Return the first language, if it exists auto it = this->versions.lower_bound(this->versions_key(v, 0)); if ((it == this->versions.end()) || ((it->first & 0xFF00) != this->versions_key(v, 0))) { diff --git a/src/Quest.hh b/src/Quest.hh index d44881b3..49083911 100644 --- a/src/Quest.hh +++ b/src/Quest.hh @@ -123,7 +123,7 @@ public: void add_version(std::shared_ptr vq); bool has_version(Version v, uint8_t language) const; bool has_version_any_language(Version v) const; - std::shared_ptr version(Version v, uint8_t language) const; + std::shared_ptr version(Version v, uint8_t language, bool allow_language_fallback = true) const; static uint32_t versions_key(Version v, uint8_t language); diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 7999e8ac..893c74f1 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -405,7 +405,7 @@ void on_login_complete(shared_ptr c) { default: q_language = 1; // English (US Plus v1.2 + customizations) } - auto vq = q->version(is_ep3(c->version()) ? Version::GC_V3 : c->version(), q_language); + auto vq = q->version(is_ep3(c->version()) ? Version::GC_V3 : c->version(), q_language, false); if (vq) { c->config.set_flag(Client::Flag::HAS_SEND_FUNCTION_CALL); c->config.set_flag(Client::Flag::SEND_FUNCTION_CALL_NO_CACHE_PATCH);