implement quest version separation
This commit is contained in:
+26
-42
@@ -52,47 +52,33 @@ struct QuestCategoryIndex {
|
||||
const Category& at(uint32_t category_id) const;
|
||||
};
|
||||
|
||||
class VersionedQuest {
|
||||
public:
|
||||
struct DATSectionHeader {
|
||||
le_uint32_t type; // 1 = objects, 2 = enemies. There are other types too
|
||||
le_uint32_t section_size; // Includes this header
|
||||
le_uint32_t area;
|
||||
le_uint32_t data_size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct VersionedQuest {
|
||||
uint32_t quest_number;
|
||||
uint32_t category_id;
|
||||
Episode episode;
|
||||
bool joinable;
|
||||
QuestScriptVersion version;
|
||||
std::string file_basename; // we append -<version>.<bin/dat> when reading
|
||||
QuestFileFormat file_format;
|
||||
bool has_mnm_extension;
|
||||
bool is_dlq_encoded;
|
||||
std::u16string name;
|
||||
QuestScriptVersion version;
|
||||
uint8_t language;
|
||||
bool is_dlq_encoded;
|
||||
std::u16string short_description;
|
||||
std::u16string long_description;
|
||||
std::shared_ptr<const std::string> bin_contents;
|
||||
std::shared_ptr<const std::string> dat_contents;
|
||||
|
||||
VersionedQuest(const std::string& file_basename, QuestScriptVersion version, std::shared_ptr<const QuestCategoryIndex> category_index);
|
||||
VersionedQuest(const VersionedQuest&) = default;
|
||||
VersionedQuest(VersionedQuest&&) = default;
|
||||
VersionedQuest& operator=(const VersionedQuest&) = default;
|
||||
VersionedQuest& operator=(VersionedQuest&&) = default;
|
||||
VersionedQuest(
|
||||
uint32_t quest_number,
|
||||
uint32_t category_id,
|
||||
QuestScriptVersion version,
|
||||
uint8_t language,
|
||||
std::shared_ptr<const std::string> bin_contents,
|
||||
std::shared_ptr<const std::string> dat_contents);
|
||||
|
||||
std::string bin_filename() const;
|
||||
std::string dat_filename() const;
|
||||
|
||||
std::shared_ptr<const std::string> bin_contents() const;
|
||||
std::shared_ptr<const std::string> dat_contents() const;
|
||||
|
||||
std::shared_ptr<VersionedQuest> create_download_quest() const;
|
||||
std::string encode_qst() const;
|
||||
|
||||
private:
|
||||
// these are populated when requested
|
||||
mutable std::shared_ptr<std::string> bin_contents_ptr;
|
||||
mutable std::shared_ptr<std::string> dat_contents_ptr;
|
||||
};
|
||||
|
||||
class Quest {
|
||||
@@ -104,18 +90,18 @@ public:
|
||||
Quest& operator=(const Quest&) = default;
|
||||
Quest& operator=(Quest&&) = default;
|
||||
|
||||
void add_version(shared_ptr<const VersionedQuest> vq);
|
||||
bool has_version(QuestScriptVersion v) const;
|
||||
shared_ptr<const VersionedQuest> version(QuestScriptVersion v) const;
|
||||
void add_version(std::shared_ptr<const VersionedQuest> vq);
|
||||
bool has_version(QuestScriptVersion v, uint8_t language) const;
|
||||
std::shared_ptr<const VersionedQuest> version(QuestScriptVersion v, uint8_t language) const;
|
||||
|
||||
static uint16_t versions_key(QuestScriptVersion v, uint8_t language);
|
||||
|
||||
uint32_t quest_number;
|
||||
uint32_t category_id;
|
||||
Episode episode;
|
||||
bool joinable;
|
||||
std::u16string name;
|
||||
|
||||
uint16_t versions_present;
|
||||
std::unordered_map<QuestScriptVersion, std::shared_ptr<const VersionedQuest>> versions;
|
||||
std::map<uint16_t, std::shared_ptr<const VersionedQuest>> versions;
|
||||
};
|
||||
|
||||
struct QuestIndex {
|
||||
@@ -130,29 +116,27 @@ struct QuestIndex {
|
||||
|
||||
std::shared_ptr<const Quest> get(uint32_t quest_number) const;
|
||||
std::shared_ptr<const std::string> get_gba(const std::string& name) const;
|
||||
std::vector<std::shared_ptr<const Quest>> filter(uint32_t category_id, QuestScriptVersion version) const;
|
||||
std::vector<std::shared_ptr<const Quest>> filter(uint32_t category_id, QuestScriptVersion version, uint8_t language) const;
|
||||
};
|
||||
|
||||
std::string encode_download_quest_file(
|
||||
std::string encode_download_quest_data(
|
||||
const std::string& compressed_data,
|
||||
size_t decompressed_size = 0,
|
||||
uint32_t encryption_seed = 0);
|
||||
|
||||
std::string decode_gci_file(
|
||||
const std::string& filename,
|
||||
std::string decode_gci_data(
|
||||
const std::string& data,
|
||||
ssize_t find_seed_num_threads = -1,
|
||||
int64_t known_seed = -1,
|
||||
bool skip_checksum = false);
|
||||
std::string decode_vms_file(
|
||||
const std::string& filename,
|
||||
std::string decode_vms_data(
|
||||
const std::string& data,
|
||||
ssize_t find_seed_num_threads = -1,
|
||||
int64_t known_seed = -1,
|
||||
bool skip_checksum = false);
|
||||
|
||||
std::string decode_dlq_file(const std::string& filename);
|
||||
std::string decode_dlq_data(const std::string& data);
|
||||
std::pair<std::string, std::string> decode_qst_data(const std::string& data);
|
||||
|
||||
std::pair<std::string, std::string> decode_qst_file(const std::string& filename);
|
||||
std::string encode_qst_file(
|
||||
const std::string& bin_data,
|
||||
const std::string& dat_data,
|
||||
|
||||
Reference in New Issue
Block a user