use client's language when generating download quests
This commit is contained in:
+10
-4
@@ -773,7 +773,7 @@ string encode_download_quest_data(const string& compressed_data, size_t decompre
|
||||
return data;
|
||||
}
|
||||
|
||||
shared_ptr<VersionedQuest> VersionedQuest::create_download_quest() const {
|
||||
shared_ptr<VersionedQuest> 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> VersionedQuest::create_download_quest() const {
|
||||
if (decompressed_bin.size() < sizeof(PSOQuestHeaderDC)) {
|
||||
throw runtime_error("bin file is too small for header");
|
||||
}
|
||||
reinterpret_cast<PSOQuestHeaderDC*>(data_ptr)->is_download = 0x01;
|
||||
if (override_language != 0xFF) {
|
||||
reinterpret_cast<PSOQuestHeaderDC*>(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<PSOQuestHeaderPC*>(data_ptr)->is_download = 0x01;
|
||||
if (override_language != 0xFF) {
|
||||
reinterpret_cast<PSOQuestHeaderPC*>(data_ptr)->language = override_language;
|
||||
}
|
||||
break;
|
||||
case QuestScriptVersion::GC_NTE:
|
||||
case QuestScriptVersion::GC_V3:
|
||||
@@ -809,7 +813,9 @@ shared_ptr<VersionedQuest> VersionedQuest::create_download_quest() const {
|
||||
if (decompressed_bin.size() < sizeof(PSOQuestHeaderGC)) {
|
||||
throw runtime_error("bin file is too small for header");
|
||||
}
|
||||
reinterpret_cast<PSOQuestHeaderGC*>(data_ptr)->is_download = 0x01;
|
||||
if (override_language != 0xFF) {
|
||||
reinterpret_cast<PSOQuestHeaderGC*>(data_ptr)->language = override_language;
|
||||
}
|
||||
break;
|
||||
case QuestScriptVersion::BB_V4:
|
||||
throw invalid_argument("PSOBB does not support download quests");
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ struct VersionedQuest {
|
||||
std::string bin_filename() const;
|
||||
std::string dat_filename() const;
|
||||
|
||||
std::shared_ptr<VersionedQuest> create_download_quest() const;
|
||||
std::shared_ptr<VersionedQuest> create_download_quest(uint8_t override_language = 0xFF) const;
|
||||
std::string encode_qst() const;
|
||||
};
|
||||
|
||||
|
||||
+3
-9
@@ -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());
|
||||
|
||||
+3
-3
@@ -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<TextEncoding::MARKED, 0x20> 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<TextEncoding::UTF16, 0x20> 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 (?)
|
||||
|
||||
@@ -2173,7 +2173,7 @@ static void on_10(shared_ptr<Client> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user