diff --git a/src/Client.hh b/src/Client.hh index 58e3de1e..1f6181f4 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -39,6 +39,7 @@ struct Client : public std::enable_shared_from_this { IS_BB_PATCH = 0x0000000000000080, NO_D6_AFTER_LOBBY = 0x0000000000000100, NO_D6 = 0x0000000000000200, + FORCE_ENGLISH_LANGUAGE_BB = 0x0000000000000400, // Flags describing the behavior for send_function_call NO_SEND_FUNCTION_CALL = 0x0000000000001000, diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 4f1f4152..1b193b88 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -875,9 +875,7 @@ static void on_93_BB(shared_ptr c, uint16_t, uint32_t, string& data) { } c->config.set_flags_for_version(c->version(), -1); - // Note: We ignore cmd.language in this case because there are many patched - // clients out there that use the Japanese codebase but English data files - // (and hence are inaccurately reported as Japanese here). + c->channel.language = cmd.language; try { auto l = s->license_index->verify_bb(cmd.username.decode(), cmd.password.decode()); @@ -920,8 +918,22 @@ static void on_93_BB(shared_ptr c, uint16_t, uint32_t, string& data) { c->config.parse_from(cmd.var.new_clients.client_config); } } catch (const invalid_argument&) { - } + string version_string = is_old_format + ? cmd.var.old_client_config.as_string() + : cmd.var.new_clients.client_config.as_string(); + print_data(stderr, version_string); + strip_trailing_zeroes(version_string); + // Note: Tethealla PSOBB is actually Japanese PSOBB, but with most of the + // files replaced with English text/graphics/etc. For this reason, it still + // reports its language as Japanese, so we have to account for that + // manually here. + if (starts_with(version_string, "TethVer")) { + c->log.info("Client is TethVer subtype; forcing English language"); + c->config.set_flag(Client::Flag::FORCE_ENGLISH_LANGUAGE_BB); + } + } + c->channel.language = c->config.check_flag(Client::Flag::FORCE_ENGLISH_LANGUAGE_BB) ? 1 : cmd.language; c->bb_connection_phase = cmd.connection_phase; c->game_data.bb_player_index = cmd.character_slot; diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 3d604696..e3a9e45b 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -630,6 +630,9 @@ void send_approve_player_choice_bb(shared_ptr c) { void send_complete_player_bb(shared_ptr c) { auto account = c->game_data.account(); auto player = c->game_data.player(true, false); + if (c->config.check_flag(Client::Flag::FORCE_ENGLISH_LANGUAGE_BB)) { + player->inventory.language = 1; + } SC_SyncCharacterSaveFile_BB_00E7 cmd; cmd.inventory = player->inventory; diff --git a/src/Text.hh b/src/Text.hh index 86b46c25..436a488f 100644 --- a/src/Text.hh +++ b/src/Text.hh @@ -145,6 +145,10 @@ struct parray { return *reinterpret_cast*>(&this->items[offset]); } + std::string as_string() const { + return std::string(reinterpret_cast(this->data()), sizeof(ItemT) * Count); + } + void assign_range(const ItemT* new_items, size_t count = Count, size_t start_offset = 0) { for (size_t x = start_offset; (x < Count) && (x < start_offset + count); x++) { this->items[x] = new_items[x];