diff --git a/src/Quest.cc b/src/Quest.cc index 2cbcfdcb..97a64d26 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -773,7 +773,7 @@ string encode_download_quest_data(const string& compressed_data, size_t decompre return data; } -shared_ptr VersionedQuest::create_download_quest() const { +shared_ptr VersionedQuest::create_download_quest(uint8_t override_language) const { // The download flag needs to be set in the bin header, or else the client // will ignore it when scanning for download quests in an offline game. To set // this flag, we need to decompress the quest's .bin file, set the flag, then @@ -795,13 +795,17 @@ shared_ptr VersionedQuest::create_download_quest() const { if (decompressed_bin.size() < sizeof(PSOQuestHeaderDC)) { throw runtime_error("bin file is too small for header"); } - reinterpret_cast(data_ptr)->is_download = 0x01; + if (override_language != 0xFF) { + reinterpret_cast(data_ptr)->language = override_language; + } break; case QuestScriptVersion::PC_V2: if (decompressed_bin.size() < sizeof(PSOQuestHeaderPC)) { throw runtime_error("bin file is too small for header"); } - reinterpret_cast(data_ptr)->is_download = 0x01; + if (override_language != 0xFF) { + reinterpret_cast(data_ptr)->language = override_language; + } break; case QuestScriptVersion::GC_NTE: case QuestScriptVersion::GC_V3: @@ -809,7 +813,9 @@ shared_ptr VersionedQuest::create_download_quest() const { if (decompressed_bin.size() < sizeof(PSOQuestHeaderGC)) { throw runtime_error("bin file is too small for header"); } - reinterpret_cast(data_ptr)->is_download = 0x01; + if (override_language != 0xFF) { + reinterpret_cast(data_ptr)->language = override_language; + } break; case QuestScriptVersion::BB_V4: throw invalid_argument("PSOBB does not support download quests"); diff --git a/src/Quest.hh b/src/Quest.hh index 1347cae2..13179bb9 100644 --- a/src/Quest.hh +++ b/src/Quest.hh @@ -82,7 +82,7 @@ struct VersionedQuest { std::string bin_filename() const; std::string dat_filename() const; - std::shared_ptr create_download_quest() const; + std::shared_ptr create_download_quest(uint8_t override_language = 0xFF) const; std::string encode_qst() const; }; diff --git a/src/QuestScript.cc b/src/QuestScript.cc index 853a35de..7685c123 100644 --- a/src/QuestScript.cc +++ b/src/QuestScript.cc @@ -836,9 +836,7 @@ std::string disassemble_quest_script(const void* data, size_t size, QuestScriptV code_offset = header.code_offset; function_table_offset = header.function_table_offset; lines.emplace_back(string_printf(".quest_num %hu", header.quest_number.load())); - if (header.is_download) { - lines.emplace_back(string_printf(".is_download_quest")); - } + lines.emplace_back(string_printf(".language %hhu", header.language)); lines.emplace_back(".name " + JSON(header.name.decode(language)).serialize()); lines.emplace_back(".short_desc " + JSON(header.short_description.decode(language)).serialize()); lines.emplace_back(".long_desc " + JSON(header.long_description.decode(language)).serialize()); @@ -850,9 +848,7 @@ std::string disassemble_quest_script(const void* data, size_t size, QuestScriptV code_offset = header.code_offset; function_table_offset = header.function_table_offset; lines.emplace_back(string_printf(".quest_num %hu", header.quest_number.load())); - if (header.is_download) { - lines.emplace_back(string_printf(".is_download_quest")); - } + lines.emplace_back(string_printf(".language %hhu", header.language)); lines.emplace_back(".name " + JSON(header.name.decode(language)).serialize()); lines.emplace_back(".short_desc " + JSON(header.short_description.decode(language)).serialize()); lines.emplace_back(".long_desc " + JSON(header.long_description.decode(language)).serialize()); @@ -866,9 +862,7 @@ std::string disassemble_quest_script(const void* data, size_t size, QuestScriptV code_offset = header.code_offset; function_table_offset = header.function_table_offset; lines.emplace_back(string_printf(".quest_num %hhu", header.quest_number)); - if (header.is_download) { - lines.emplace_back(string_printf(".is_download_quest")); - } + lines.emplace_back(string_printf(".language %hhu", header.language)); lines.emplace_back(string_printf(".episode %hhu", header.episode)); lines.emplace_back(".name " + JSON(header.name.decode(language)).serialize()); lines.emplace_back(".short_desc " + JSON(header.short_description.decode(language)).serialize()); diff --git a/src/QuestScript.hh b/src/QuestScript.hh index f9d57b2d..e67a05e5 100644 --- a/src/QuestScript.hh +++ b/src/QuestScript.hh @@ -29,7 +29,7 @@ struct PSOQuestHeaderDC { // Same format for DC v1 and v2 /* 0004 */ le_uint32_t function_table_offset; /* 0008 */ le_uint32_t size; /* 000C */ le_uint32_t unused; - /* 0010 */ uint8_t is_download; + /* 0010 */ uint8_t language; /* 0011 */ uint8_t unknown1; /* 0012 */ le_uint16_t quest_number; // 0xFFFF for challenge quests /* 0014 */ pstring name; @@ -43,7 +43,7 @@ struct PSOQuestHeaderPC { /* 0004 */ le_uint32_t function_table_offset; /* 0008 */ le_uint32_t size; /* 000C */ le_uint32_t unused; - /* 0010 */ uint8_t is_download; + /* 0010 */ uint8_t language; /* 0011 */ uint8_t unknown1; /* 0012 */ le_uint16_t quest_number; // 0xFFFF for challenge quests /* 0014 */ pstring name; @@ -59,7 +59,7 @@ struct PSOQuestHeaderGC { /* 0004 */ le_uint32_t function_table_offset; /* 0008 */ le_uint32_t size; /* 000C */ le_uint32_t unused; - /* 0010 */ uint8_t is_download; + /* 0010 */ uint8_t language; /* 0011 */ uint8_t unknown1; /* 0012 */ uint8_t quest_number; /* 0013 */ uint8_t episode; // 1 = Ep2. Apparently some quests have 0xFF here, which means ep1 (?) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 4f36fa64..ce98ef49 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2173,7 +2173,7 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { if (vq->version == QuestScriptVersion::GC_EP3) { send_open_quest_file(c, q->name, vq->bin_filename(), vq->bin_contents, QuestFileType::EPISODE_3); } else { - vq = vq->create_download_quest(); + vq = vq->create_download_quest(c->language()); send_open_quest_file(c, q->name, vq->bin_filename(), vq->bin_contents, QuestFileType::DOWNLOAD); send_open_quest_file(c, q->name, vq->dat_filename(), vq->dat_contents, QuestFileType::DOWNLOAD); }