fix bug causing private subcommands to get truncated

This commit is contained in:
Martin Michelsen
2022-04-03 23:36:22 -07:00
parent 139ccb27c8
commit 54f01713bc
4 changed files with 45 additions and 18 deletions
+7 -7
View File
@@ -445,7 +445,7 @@ void process_ep3_menu_challenge(shared_ptr<ServerState>, shared_ptr<Client> c,
uint16_t, uint32_t flag, const string& data) { // DC
check_size_v(data.size(), 0);
if (flag != 0) {
send_command(c, 0xDC);
send_command(c, 0xDC, 0x00);
}
}
@@ -1030,7 +1030,7 @@ void process_quest_ready(shared_ptr<ServerState> s, shared_ptr<Client> c,
// if they're all done, start the quest
if (x == l->max_clients) {
send_command(l, 0xAC);
send_command(l, 0xAC, 0x00);
}
}
@@ -1710,7 +1710,7 @@ void process_team_command_bb(shared_ptr<ServerState>, shared_ptr<Client> c,
void process_encryption_ok_patch(shared_ptr<ServerState>, shared_ptr<Client> c,
uint16_t, uint32_t, const string& data) {
check_size_v(data.size(), 0);
send_command(c, 0x04); // this requests the user's login information
send_command(c, 0x04, 0x00); // This requests the user's login information
}
void process_login_patch(shared_ptr<ServerState> s, shared_ptr<Client> c,
@@ -1762,13 +1762,13 @@ independently.\r\n\
send_check_directory_patch(c, ".");
send_check_directory_patch(c, "data");
send_check_directory_patch(c, "scene");
send_command(c, 0x0A);
send_command(c, 0x0A);
send_command(c, 0x0A);
send_command(c, 0x0A, 0x00);
send_command(c, 0x0A, 0x00);
send_command(c, 0x0A, 0x00);
// This command terminates the patch connection successfully. PSOBB complains
// if we don't check the above directories before sending this though
send_command(c, 0x0012, 0x00000000);
send_command(c, 0x12, 0x00);
}
////////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -78,7 +78,7 @@ static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
if (command_is_ep3 && !(target->flags & Client::Flag::EPISODE_3)) {
return;
}
send_command(target, command, flag, data);
send_command(target, command, flag, data, size);
} else {
if (command_is_ep3) {
@@ -86,7 +86,7 @@ static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
if (!target || (target == c) || !(target->flags & Client::Flag::EPISODE_3)) {
continue;
}
send_command(target, command, flag, data);
send_command(target, command, flag, data, size);
}
} else {
+1 -1
View File
@@ -1017,7 +1017,7 @@ void send_player_leave_notification(shared_ptr<Lobby> l, uint8_t leaving_client_
}
void send_get_player_info(shared_ptr<Client> c) {
send_command(c, 0x95);
send_command(c, 0x95, 0x00);
}
+35 -8
View File
@@ -17,22 +17,49 @@
// Note: There are so many versions of this function for a few reasons:
// - There are a lot of different target types (sometimes we want to send a
// command to one client, sometimes to everyone in a lobby, etc.)
// - For the const void* versions, the data and size arguments should not be
// independently optional - this can lead to bugs where a non-null data
// pointer is given but size is accidentally not given zero (e.g. if the type
// of data in the calling function is changed from string to void*).
void send_command(struct bufferevent* bev, GameVersion version,
PSOEncryption* crypt, uint16_t command, uint32_t flag = 0,
const void* data = nullptr, size_t size = 0, const char* name_str = nullptr);
PSOEncryption* crypt, uint16_t command, uint32_t flag, const void* data,
size_t size, const char* name_str = nullptr);
void send_command(std::shared_ptr<Client> c, uint16_t command,
uint32_t flag = 0, const void* data = nullptr, size_t size = 0);
uint32_t flag, const void* data, size_t size);
inline void send_command(std::shared_ptr<Client> c, uint16_t command,
uint32_t flag) {
send_command(c, command, flag, nullptr, 0);
}
void send_command_excluding_client(std::shared_ptr<Lobby> l,
std::shared_ptr<Client> c, uint16_t command, uint32_t flag = 0,
const void* data = nullptr, size_t size = 0);
std::shared_ptr<Client> c, uint16_t command, uint32_t flag,
const void* data, size_t size);
void send_command(std::shared_ptr<Lobby> l, uint16_t command, uint32_t flag = 0,
const void* data = nullptr, size_t size = 0);
inline void send_command_excluding_client(std::shared_ptr<Lobby> l,
std::shared_ptr<Client> c, uint16_t command, uint32_t flag) {
send_command_excluding_client(l, c, command, flag, nullptr, 0);
}
void send_command(std::shared_ptr<Lobby> l, uint16_t command, uint32_t flag,
const void* data, size_t size);
inline void send_command(std::shared_ptr<Lobby> l, uint16_t command, uint32_t flag) {
send_command(l, command, flag, nullptr, 0);
}
void send_command(std::shared_ptr<ServerState> s, uint16_t command,
uint32_t flag = 0, const void* data = nullptr, size_t size = 0);
uint32_t flag, const void* data, size_t size);
inline void send_command(std::shared_ptr<ServerState> s, uint16_t command,
uint32_t flag) {
send_command(s, command, flag, nullptr, 0);
}
template <typename TargetT, typename StructT>
static void send_command(std::shared_ptr<TargetT> c, uint16_t command, uint32_t flag,