Up to four .qst headers are now parsed. This fixes parsing of The Value of Money.

This commit is contained in:
Daan Vanden Bosch 2019-09-13 22:47:50 +02:00
parent 1d0da754ca
commit 8f8da79041
3 changed files with 18 additions and 7 deletions

View File

@ -136,5 +136,4 @@ Features that are in ***bold italics*** are planned and not yet implemented.
- Switch (none door)
- Energy Barrier
- Teleporter
- [Load Quest](#load-quest): Can't parse quest 4
- [Load Quest](#load-quest): Can't parse quest 125 White Day

View File

@ -21,7 +21,7 @@ import { object_data, ObjectType, pso_id_to_object_type } from "./object_types";
import { parse_qst, QstContainedFile, write_qst } from "./qst";
import { NpcType } from "./npc_types";
const logger = Logger.get("data_formats/parsing/quest");
const logger = Logger.get("core/data_formats/parsing/quest");
export type Quest = {
readonly id: number;

View File

@ -6,7 +6,7 @@ import { ResizableBufferCursor } from "../../cursor/ResizableBufferCursor";
import { WritableCursor } from "../../cursor/WritableCursor";
import { ResizableBuffer } from "../../ResizableBuffer";
const logger = Logger.get("data_formats/parsing/quest/qst");
const logger = Logger.get("core/data_formats/parsing/quest/qst");
export type QstContainedFile = {
id?: number;
@ -110,13 +110,13 @@ type QstHeader = {
size: number;
};
/**
* TODO: Read all headers instead of just the first 2.
*/
function parse_headers(cursor: Cursor): QstHeader[] {
const headers: QstHeader[] = [];
for (let i = 0; i < 2; ++i) {
let prev_quest_id: number | undefined;
let prev_file_name: string | undefined;
for (let i = 0; i < 4; ++i) {
cursor.seek(4);
const quest_id = cursor.u16();
cursor.seek(38);
@ -125,6 +125,18 @@ function parse_headers(cursor: Cursor): QstHeader[] {
// Not sure what this is:
const file_name_2 = cursor.string_ascii(24, true, true);
if (
prev_quest_id != undefined &&
prev_file_name != undefined &&
(quest_id !== prev_quest_id || file_name.slice(0, 5) !== prev_file_name.slice(0, 5))
) {
cursor.seek(-88);
break;
}
prev_quest_id = quest_id;
prev_file_name = file_name;
headers.push({
quest_id,
file_name,