support old format of 93 command
This commit is contained in:
+14
-13
@@ -878,24 +878,25 @@ struct C_Login_BB_93 {
|
|||||||
ptext<char, 0x20> unused2;
|
ptext<char, 0x20> unused2;
|
||||||
ptext<char, 0x10> password;
|
ptext<char, 0x10> password;
|
||||||
ptext<char, 0x28> unused3;
|
ptext<char, 0x28> unused3;
|
||||||
uint64_t hardware_info;
|
|
||||||
// Note: Unlike other versions, BB puts the version string in the client
|
// Note: Unlike other versions, BB puts the version string in the client
|
||||||
// config at connect time. So the first time the server gets this command, it
|
// config at connect time. So the first time the server gets this command, it
|
||||||
// will be something like "Ver. 1.24.3". Note also that some old versions
|
// will be something like "Ver. 1.24.3". Note also that some old versions
|
||||||
// (before 1.23.8?) omit the hardware_info field before the client config, so
|
// (before 1.23.8?) omit the hardware_info field before the client config, so
|
||||||
// the client config starts 8 bytes earlier on those versions and the entire
|
// the client config starts 8 bytes earlier on those versions and the entire
|
||||||
// command is 8 bytes shorter.
|
// command is 8 bytes shorter, hence this odd-looking union.
|
||||||
union ClientConfigFields {
|
union VariableLengthSection {
|
||||||
ClientConfigBB cfg;
|
union ClientConfigFields {
|
||||||
ptext<char, 0x28> version_string;
|
ClientConfigBB cfg;
|
||||||
ClientConfigFields() : version_string() { }
|
ptext<char, 0x28> version_string;
|
||||||
ClientConfigFields(const ClientConfigFields& other)
|
};
|
||||||
: version_string(other.version_string) { }
|
|
||||||
inline ClientConfigFields& operator=(const ClientConfigFields& other) {
|
ClientConfigFields old_clients_cfg;
|
||||||
this->version_string = other.version_string;
|
struct NewFormat {
|
||||||
return *this;
|
uint64_t hardware_info;
|
||||||
}
|
ClientConfigFields cfg;
|
||||||
} client_config;
|
} new_clients;
|
||||||
|
} var;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 94: Invalid command
|
// 94: Invalid command
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ static bool process_server_bb_03(shared_ptr<ServerState>,
|
|||||||
if (!session.detector_crypt.get()) {
|
if (!session.detector_crypt.get()) {
|
||||||
throw runtime_error("BB linked session has no detector crypt");
|
throw runtime_error("BB linked session has no detector crypt");
|
||||||
}
|
}
|
||||||
if (!session.login_command_bb.username.len()) {
|
if (session.login_command_bb.empty()) {
|
||||||
throw logic_error("linked BB session does not have a saved login command");
|
throw logic_error("linked BB session does not have a saved login command");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,8 +251,7 @@ static bool process_server_bb_03(shared_ptr<ServerState>,
|
|||||||
session.detector_crypt, cmd.client_key.data(), sizeof(cmd.client_key), false));
|
session.detector_crypt, cmd.client_key.data(), sizeof(cmd.client_key), false));
|
||||||
|
|
||||||
// Forward the login command we saved during the unlinked session.
|
// Forward the login command we saved during the unlinked session.
|
||||||
session.send_to_end(true, 0x93, 0x00, &session.login_command_bb,
|
session.send_to_end(true, 0x93, 0x00, session.login_command_bb);
|
||||||
sizeof(session.login_command_bb));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -276,7 +276,7 @@ void ProxyServer::UnlinkedSession::on_client_input() {
|
|||||||
uint32_t sub_version = 0;
|
uint32_t sub_version = 0;
|
||||||
string character_name;
|
string character_name;
|
||||||
ClientConfigBB client_config;
|
ClientConfigBB client_config;
|
||||||
C_Login_BB_93 login_command_bb;
|
string login_command_bb;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for_each_received_command(this->bev.get(), this->version, this->crypt_in.get(),
|
for_each_received_command(this->bev.get(), this->version, this->crypt_in.get(),
|
||||||
@@ -318,7 +318,7 @@ void ProxyServer::UnlinkedSession::on_client_input() {
|
|||||||
const auto& cmd = check_size_t<C_Login_BB_93>(data);
|
const auto& cmd = check_size_t<C_Login_BB_93>(data);
|
||||||
license = this->server->state->license_manager->verify_bb(
|
license = this->server->state->license_manager->verify_bb(
|
||||||
cmd.username, cmd.password);
|
cmd.username, cmd.password);
|
||||||
login_command_bb = cmd;
|
login_command_bb = data;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw logic_error("unsupported unlinked session version");
|
throw logic_error("unsupported unlinked session version");
|
||||||
@@ -379,7 +379,7 @@ void ProxyServer::UnlinkedSession::on_client_input() {
|
|||||||
try {
|
try {
|
||||||
if (this->version == GameVersion::BB) {
|
if (this->version == GameVersion::BB) {
|
||||||
session->resume(move(this->bev), this->crypt_in, this->crypt_out,
|
session->resume(move(this->bev), this->crypt_in, this->crypt_out,
|
||||||
this->detector_crypt, login_command_bb);
|
this->detector_crypt, move(login_command_bb));
|
||||||
} else {
|
} else {
|
||||||
session->resume(move(this->bev), this->crypt_in, this->crypt_out,
|
session->resume(move(this->bev), this->crypt_in, this->crypt_out,
|
||||||
this->detector_crypt, sub_version, character_name);
|
this->detector_crypt, sub_version, character_name);
|
||||||
@@ -502,8 +502,8 @@ void ProxyServer::LinkedSession::resume(
|
|||||||
shared_ptr<PSOEncryption> client_input_crypt,
|
shared_ptr<PSOEncryption> client_input_crypt,
|
||||||
shared_ptr<PSOEncryption> client_output_crypt,
|
shared_ptr<PSOEncryption> client_output_crypt,
|
||||||
shared_ptr<PSOBBMultiKeyDetectorEncryption> detector_crypt,
|
shared_ptr<PSOBBMultiKeyDetectorEncryption> detector_crypt,
|
||||||
C_Login_BB_93 login_command_bb) {
|
string&& login_command_bb) {
|
||||||
this->login_command_bb = login_command_bb;
|
this->login_command_bb = move(login_command_bb);
|
||||||
this->resume_inner(move(client_bev), client_input_crypt, client_output_crypt,
|
this->resume_inner(move(client_bev), client_input_crypt, client_output_crypt,
|
||||||
detector_crypt);
|
detector_crypt);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,7 @@ public:
|
|||||||
GameVersion version;
|
GameVersion version;
|
||||||
uint32_t sub_version;
|
uint32_t sub_version;
|
||||||
std::string character_name;
|
std::string character_name;
|
||||||
C_Login_BB_93 login_command_bb;
|
std::string login_command_bb;
|
||||||
|
|
||||||
uint32_t remote_guild_card_number;
|
uint32_t remote_guild_card_number;
|
||||||
parray<uint8_t, 0x20> remote_client_config_data;
|
parray<uint8_t, 0x20> remote_client_config_data;
|
||||||
@@ -132,7 +132,7 @@ public:
|
|||||||
std::shared_ptr<PSOEncryption> client_input_crypt,
|
std::shared_ptr<PSOEncryption> client_input_crypt,
|
||||||
std::shared_ptr<PSOEncryption> client_output_crypt,
|
std::shared_ptr<PSOEncryption> client_output_crypt,
|
||||||
std::shared_ptr<PSOBBMultiKeyDetectorEncryption> detector_crypt,
|
std::shared_ptr<PSOBBMultiKeyDetectorEncryption> detector_crypt,
|
||||||
C_Login_BB_93 login_command_bb);
|
std::string&& login_command_bb);
|
||||||
void resume(struct bufferevent* client_bev);
|
void resume(struct bufferevent* client_bev);
|
||||||
void resume_inner(
|
void resume_inner(
|
||||||
std::unique_ptr<struct bufferevent, void(*)(struct bufferevent*)>&& client_bev,
|
std::unique_ptr<struct bufferevent, void(*)(struct bufferevent*)>&& client_bev,
|
||||||
|
|||||||
+16
-2
@@ -311,7 +311,17 @@ void process_login_d_e_pc_gc(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
|
|
||||||
void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||||
uint16_t, uint32_t, const string& data) { // 93
|
uint16_t, uint32_t, const string& data) { // 93
|
||||||
const auto& cmd = check_size_t<C_Login_BB_93>(data);
|
const auto& cmd = check_size_t<C_Login_BB_93>(data,
|
||||||
|
sizeof(C_Login_BB_93) - 8, sizeof(C_Login_BB_93));
|
||||||
|
|
||||||
|
bool is_old_format;
|
||||||
|
if (data.size() == sizeof(C_Login_BB_93) - 8) {
|
||||||
|
is_old_format = true;
|
||||||
|
} else if (data.size() == sizeof(C_Login_BB_93)) {
|
||||||
|
is_old_format = false;
|
||||||
|
} else {
|
||||||
|
throw runtime_error("invalid size for 93 command");
|
||||||
|
}
|
||||||
|
|
||||||
c->flags |= flags_for_version(c->version, 0);
|
c->flags |= flags_for_version(c->version, 0);
|
||||||
|
|
||||||
@@ -326,7 +336,11 @@ void process_login_bb(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
c->import_config(cmd.client_config.cfg);
|
if (is_old_format) {
|
||||||
|
c->import_config(cmd.var.old_clients_cfg.cfg);
|
||||||
|
} else {
|
||||||
|
c->import_config(cmd.var.new_clients.cfg.cfg);
|
||||||
|
}
|
||||||
if (c->bb_game_state < ClientStateBB::IN_GAME) {
|
if (c->bb_game_state < ClientStateBB::IN_GAME) {
|
||||||
c->bb_game_state++;
|
c->bb_game_state++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user