From 07996444a1f56eb99d11e5a23eecd018e2eef883 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 7 Feb 2024 10:23:37 -0800 Subject: [PATCH] fix download quests with PVR files --- src/Quest.cc | 12 +++++++++--- src/Quest.hh | 1 + src/ReceiveCommands.cc | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Quest.cc b/src/Quest.cc index 03f74577..94fa0560 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -356,6 +356,14 @@ string VersionedQuest::dat_filename() const { } } +string VersionedQuest::pvr_filename() const { + if (this->episode == Episode::EP3) { + throw logic_error("Episode 3 quests do not have .pvr files"); + } else { + return string_printf("quest%" PRIu32 ".pvr", this->quest_number); + } +} + string VersionedQuest::xb_filename() const { if (this->episode == Episode::EP3) { throw logic_error("Episode 3 quests do not have Xbox filenames"); @@ -911,9 +919,7 @@ shared_ptr VersionedQuest::create_download_quest(uint8_t overrid auto dlq = make_shared(*this); dlq->bin_contents = make_shared(encode_download_quest_data(compressed_bin, decompressed_bin.size())); dlq->dat_contents = make_shared(encode_download_quest_data(*this->dat_contents)); - if (this->pvr_contents) { - dlq->pvr_contents = make_shared(encode_download_quest_data(*this->pvr_contents)); - } + dlq->pvr_contents = this->pvr_contents; dlq->is_dlq_encoded = true; return dlq; } diff --git a/src/Quest.hh b/src/Quest.hh index ab88d4ac..f508a46a 100644 --- a/src/Quest.hh +++ b/src/Quest.hh @@ -90,6 +90,7 @@ struct VersionedQuest { std::string bin_filename() const; std::string dat_filename() const; + std::string pvr_filename() const; std::string xb_filename() const; std::shared_ptr create_download_quest(uint8_t override_language = 0xFF) const; diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 5e05231d..e941b943 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2564,7 +2564,7 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { send_open_quest_file(c, q->name, vq->bin_filename(), xb_filename, vq->quest_number, type, vq->bin_contents); send_open_quest_file(c, q->name, vq->dat_filename(), xb_filename, vq->quest_number, type, vq->dat_contents); if (vq->pvr_contents) { - send_open_quest_file(c, q->name, vq->dat_filename(), xb_filename, vq->quest_number, type, vq->pvr_contents); + send_open_quest_file(c, q->name, vq->pvr_filename(), xb_filename, vq->quest_number, type, vq->pvr_contents); } } }