add support for PSO DC v1/v2

This commit is contained in:
Martin Michelsen
2022-08-27 01:34:49 -07:00
parent 4abd91cb8f
commit 5d3d1e1900
30 changed files with 4004 additions and 585 deletions
+9
View File
@@ -203,6 +203,15 @@ Channel::Message Channel::recv(bool print_contents) {
< static_cast<ssize_t>(command_data.size())) {
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()) {
this->crypt_in->decrypt(command_data.data(), command_data.size());
}