implement some parts of DC NTE (but not all of it)

This commit is contained in:
Martin Michelsen
2022-09-23 00:33:03 -07:00
parent 9524d05279
commit a9cf98a24f
9 changed files with 178 additions and 47 deletions
+7 -8
View File
@@ -204,16 +204,15 @@ Channel::Message Channel::recv(bool print_contents) {
throw logic_error("enough bytes available, but could not remove them");
}
// Some versions of PSO DC can send commands whose sizes are not a multiple of
// 4, but the server is expected to always use a multiple of 4 bytes when
// decrypting (the extra cipher bytes are lost). To emulate this behavior, we
// have to round up the size for DC commands here.
if (version == GameVersion::DC) {
command_data.resize((command_data.size() + 3) & (~3));
}
if (this->crypt_in.get()) {
// Some versions of PSO DC can send commands whose sizes are not a multiple
// of 4, but the server is expected to always use a multiple of 4 bytes when
// decrypting (the extra cipher bytes are lost). To emulate this behavior,
// we have to round up the size for DC commands here.
size_t orig_size = command_data.size();
command_data.resize((orig_size + 3) & (~3), 0);
this->crypt_in->decrypt(command_data.data(), command_data.size());
command_data.resize(orig_size);
}
command_data.resize(command_logical_size - header_size);