implement save file decryption/encryption
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "../Loggers.hh"
|
||||
#include "../Compression.hh"
|
||||
#include "../PSOEncryption.hh"
|
||||
#include "../Text.hh"
|
||||
#include "../Quest.hh"
|
||||
|
||||
@@ -1712,4 +1713,33 @@ shared_ptr<const COMDeckDefinition> DataIndex::random_com_deck() const {
|
||||
|
||||
|
||||
|
||||
void PlayerConfig::decrypt() {
|
||||
if (!this->is_encrypted) {
|
||||
return;
|
||||
}
|
||||
decrypt_trivial_gci_data(
|
||||
&this->card_counts,
|
||||
offsetof(PlayerConfig, decks) - offsetof(PlayerConfig, card_counts),
|
||||
this->basis);
|
||||
this->is_encrypted = 0;
|
||||
this->basis = 0;
|
||||
}
|
||||
|
||||
void PlayerConfig::encrypt(uint8_t basis) {
|
||||
if (this->is_encrypted) {
|
||||
if (this->basis == basis) {
|
||||
return;
|
||||
}
|
||||
this->decrypt();
|
||||
}
|
||||
decrypt_trivial_gci_data(
|
||||
&this->card_counts,
|
||||
offsetof(PlayerConfig, decks) - offsetof(PlayerConfig, card_counts),
|
||||
basis);
|
||||
this->is_encrypted = 1;
|
||||
this->basis = basis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Episode3
|
||||
|
||||
@@ -582,8 +582,8 @@ struct DeckDefinition {
|
||||
} __attribute__((packed)); // 0x84 bytes in total
|
||||
|
||||
struct PlayerConfig {
|
||||
// The first offsets in the comments in this struct are relative to start of
|
||||
// 61/98 command; the second are relative to the start of the
|
||||
// The first offsets in the comments in this struct are relative to the start
|
||||
// of the 61/98 command; the second are relative to the start of the
|
||||
// Ep3PlayerDataSegment structure in the reverse-engineering project.
|
||||
// TODO: Fill in the unknown fields here by looking around callsites of
|
||||
// get_player_data_segment
|
||||
@@ -626,6 +626,9 @@ struct PlayerConfig {
|
||||
/* 299C:2120 */ ptext<char, 0x10> name;
|
||||
/* 29AC:2130 */ parray<uint8_t, 0xCC> unknown_a11;
|
||||
/* 2A78:21FC */
|
||||
|
||||
void decrypt();
|
||||
void encrypt(uint8_t basis);
|
||||
} __attribute__((packed));
|
||||
|
||||
enum class HPType : uint8_t {
|
||||
|
||||
Reference in New Issue
Block a user