display quest names in client's native language in game info window
This commit is contained in:
@@ -335,9 +335,29 @@ uint32_t Quest::versions_key(Version v, uint8_t language) {
|
|||||||
return (static_cast<uint32_t>(v) << 8) | language;
|
return (static_cast<uint32_t>(v) << 8) | language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string& Quest::name_for_language(uint8_t language) const {
|
||||||
|
if (!this->names_by_language.at(language).empty()) {
|
||||||
|
return this->names_by_language[language];
|
||||||
|
}
|
||||||
|
if (!this->names_by_language[1].empty()) {
|
||||||
|
return this->names_by_language[1];
|
||||||
|
}
|
||||||
|
for (const string& name : this->names_by_language) {
|
||||||
|
if (!name.empty()) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this->meta.name;
|
||||||
|
}
|
||||||
|
|
||||||
void Quest::add_version(shared_ptr<const VersionedQuest> vq) {
|
void Quest::add_version(shared_ptr<const VersionedQuest> vq) {
|
||||||
this->meta.assert_compatible(vq->meta);
|
this->meta.assert_compatible(vq->meta);
|
||||||
this->versions.emplace(this->versions_key(vq->version, vq->language), vq);
|
this->versions.emplace(this->versions_key(vq->version, vq->language), vq);
|
||||||
|
|
||||||
|
auto& name_by_language = this->names_by_language.at(vq->language);
|
||||||
|
if (name_by_language.empty()) {
|
||||||
|
name_by_language = vq->meta.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const SuperMap> Quest::get_supermap(int64_t random_seed) const {
|
std::shared_ptr<const SuperMap> Quest::get_supermap(int64_t random_seed) const {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ struct Quest {
|
|||||||
QuestMetadata meta;
|
QuestMetadata meta;
|
||||||
mutable std::shared_ptr<const SuperMap> supermap;
|
mutable std::shared_ptr<const SuperMap> supermap;
|
||||||
std::map<uint32_t, std::shared_ptr<const VersionedQuest>> versions;
|
std::map<uint32_t, std::shared_ptr<const VersionedQuest>> versions;
|
||||||
|
std::array<std::string, 8> names_by_language;
|
||||||
|
|
||||||
Quest() = delete;
|
Quest() = delete;
|
||||||
explicit Quest(std::shared_ptr<const VersionedQuest> initial_version);
|
explicit Quest(std::shared_ptr<const VersionedQuest> initial_version);
|
||||||
@@ -106,6 +107,8 @@ struct Quest {
|
|||||||
|
|
||||||
std::shared_ptr<const SuperMap> get_supermap(int64_t random_seed) const;
|
std::shared_ptr<const SuperMap> get_supermap(int64_t random_seed) const;
|
||||||
|
|
||||||
|
const std::string& name_for_language(uint8_t language) const;
|
||||||
|
|
||||||
void add_version(std::shared_ptr<const VersionedQuest> vq);
|
void add_version(std::shared_ptr<const VersionedQuest> vq);
|
||||||
bool has_version(Version v, uint8_t language) const;
|
bool has_version(Version v, uint8_t language) const;
|
||||||
bool has_version_any_language(Version v) const;
|
bool has_version_any_language(Version v) const;
|
||||||
|
|||||||
@@ -2265,7 +2265,7 @@ static asio::awaitable<void> on_09(shared_ptr<Client> c, Channel::Message& msg)
|
|||||||
|
|
||||||
if (game->quest) {
|
if (game->quest) {
|
||||||
info += (game->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)) ? "$C6Quest: " : "$C4Quest: ";
|
info += (game->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)) ? "$C6Quest: " : "$C4Quest: ";
|
||||||
info += remove_color(game->quest->meta.name);
|
info += remove_color(game->quest->name_for_language(c->language()));
|
||||||
info += "\n";
|
info += "\n";
|
||||||
} else if (game->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)) {
|
} else if (game->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)) {
|
||||||
info += "$C6Quest in progress\n";
|
info += "$C6Quest in progress\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user