add force English flag for Tethealla BB client

This commit is contained in:
Martin Michelsen
2023-10-31 11:00:54 -07:00
parent 9e682e7c13
commit 8c85868e08
4 changed files with 24 additions and 4 deletions
+1
View File
@@ -39,6 +39,7 @@ struct Client : public std::enable_shared_from_this<Client> {
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,
+16 -4
View File
@@ -875,9 +875,7 @@ static void on_93_BB(shared_ptr<Client> 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<Client> 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;
+3
View File
@@ -630,6 +630,9 @@ void send_approve_player_choice_bb(shared_ptr<Client> c) {
void send_complete_player_bb(shared_ptr<Client> 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;
+4
View File
@@ -145,6 +145,10 @@ struct parray {
return *reinterpret_cast<const parray<ItemT, SubCount>*>(&this->items[offset]);
}
std::string as_string() const {
return std::string(reinterpret_cast<const char*>(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];