decrypt Ep3 player config at load time
This commit is contained in:
@@ -1177,6 +1177,19 @@ void PlayerConfig::encrypt(uint8_t basis) {
|
||||
this->basis = basis;
|
||||
}
|
||||
|
||||
bool PlayerConfig::card_count_checksums_correct() const {
|
||||
for (size_t z = 0; z < this->card_count_checksums.size(); z++) {
|
||||
uint16_t checksum_value = 0;
|
||||
for (size_t w = 0; w < 20; w++) {
|
||||
checksum_value += reinterpret_cast<const uint8_t*>(&this->card_counts)[z * 50 + w];
|
||||
}
|
||||
if (this->card_count_checksums[z] != checksum_value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerConfigNTE::PlayerConfigNTE(const PlayerConfig& config)
|
||||
: rank_text(config.rank_text),
|
||||
unknown_a1(config.unknown_a1),
|
||||
|
||||
@@ -865,7 +865,8 @@ struct PlayerConfig {
|
||||
/* 0138:---- */ PlayerRecordsBattleBE unused_offline_records;
|
||||
/* 0150:---- */ parray<uint8_t, 4> unknown_a4;
|
||||
// The PlayerDataSegment structure begins here. In newserv, we combine this
|
||||
// structure into PlayerConfig since the two are always used together.
|
||||
// structure into PlayerConfig since the two are always used together on the
|
||||
// server side.
|
||||
/* 0154:0000 */ uint8_t is_encrypted;
|
||||
/* 0155:0001 */ uint8_t basis;
|
||||
/* 0156:0002 */ parray<uint8_t, 2> unused;
|
||||
@@ -938,6 +939,8 @@ struct PlayerConfig {
|
||||
|
||||
void decrypt();
|
||||
void encrypt(uint8_t basis);
|
||||
|
||||
bool card_count_checksums_correct() const;
|
||||
} __packed_ws__(PlayerConfig, 0x2350);
|
||||
|
||||
struct PlayerConfigNTE {
|
||||
|
||||
@@ -3426,6 +3426,12 @@ static asio::awaitable<void> on_61_98(shared_ptr<Client> c, Channel::Message& ms
|
||||
}
|
||||
const auto* cmd3 = &check_size_t<C_CharacterData_Ep3_61_98>(msg.data);
|
||||
c->ep3_config = make_shared<Episode3::PlayerConfig>(cmd3->ep3_config);
|
||||
c->ep3_config->decrypt();
|
||||
if (c->ep3_config->card_count_checksums_correct()) {
|
||||
c->log.info_f("Card count checksums are correct");
|
||||
} else {
|
||||
c->log.info_f("Card count checksums are incorrect");
|
||||
}
|
||||
cmd = reinterpret_cast<const C_CharacterData_V3_61_98*>(cmd3);
|
||||
if (specific_version_is_indeterminate(c->specific_version)) {
|
||||
c->specific_version = SPECIFIC_VERSION_GC_EP3_JP; // 3SJ0
|
||||
|
||||
Reference in New Issue
Block a user