add decoder for Ep3 trial download quests
This commit is contained in:
+19
-3
@@ -165,8 +165,7 @@ string find_seed_and_decrypt_download_quest_data_section(
|
||||
string result;
|
||||
uint64_t result_seed = parallel_range<uint64_t>([&](uint64_t seed, size_t) {
|
||||
try {
|
||||
string ret = decrypt_download_quest_data_section<IsBigEndian>(
|
||||
data_section, size, seed);
|
||||
string ret = decrypt_download_quest_data_section<IsBigEndian>(data_section, size, seed);
|
||||
lock_guard<mutex> g(result_lock);
|
||||
result = std::move(ret);
|
||||
return true;
|
||||
@@ -522,7 +521,23 @@ string Quest::decode_gci_file(
|
||||
return compressed_data;
|
||||
}
|
||||
|
||||
} else if (header.game_id[2] == 'S') { // Episode 3
|
||||
} else if (header.is_ep3()) {
|
||||
if (header.is_trial()) {
|
||||
if (known_seed >= 0) {
|
||||
return decrypt_download_quest_data_section<true>(
|
||||
r.getv(header.data_size), header.data_size, known_seed);
|
||||
} else {
|
||||
if (find_seed_num_threads < 0) {
|
||||
throw runtime_error("file is encrypted");
|
||||
}
|
||||
if (find_seed_num_threads == 0) {
|
||||
find_seed_num_threads = thread::hardware_concurrency();
|
||||
}
|
||||
return find_seed_and_decrypt_download_quest_data_section<true>(
|
||||
r.getv(header.data_size), header.data_size, find_seed_num_threads);
|
||||
}
|
||||
|
||||
} else {
|
||||
// The first 0x10 bytes in the data segment appear to be unused. In most
|
||||
// files I've seen, the last half of it (8 bytes) are duplicates of the
|
||||
// first 8 bytes of the unscrambled, compressed data, though this is the
|
||||
@@ -552,6 +567,7 @@ string Quest::decode_gci_file(
|
||||
decompressed_size, sizeof(Episode3::MapDefinition)));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
} else {
|
||||
throw runtime_error("unknown game name in GCI header");
|
||||
|
||||
@@ -87,7 +87,7 @@ void PSOGCIFileHeader::check() const {
|
||||
if (this->developer_id[0] != '8' || this->developer_id[1] != 'P') {
|
||||
throw runtime_error("GCI file is not for a Sega game");
|
||||
}
|
||||
if (this->game_id[0] != 'G') {
|
||||
if ((this->game_id[0] != 'G') && (this->game_id[0] != 'D')) {
|
||||
throw runtime_error("GCI file is not for a GameCube game");
|
||||
}
|
||||
if (this->game_id[1] != 'P') {
|
||||
@@ -106,6 +106,10 @@ bool PSOGCIFileHeader::is_ep3() const {
|
||||
return (this->game_id[2] == 'S');
|
||||
}
|
||||
|
||||
bool PSOGCIFileHeader::is_trial() const {
|
||||
return (this->game_id[0] == 'D');
|
||||
}
|
||||
|
||||
uint32_t compute_psogc_timestamp(
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
|
||||
@@ -86,6 +86,7 @@ struct PSOGCIFileHeader {
|
||||
|
||||
bool is_ep12() const;
|
||||
bool is_ep3() const;
|
||||
bool is_trial() const;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct PSOGCSystemFile {
|
||||
|
||||
Reference in New Issue
Block a user