mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-06 08:08:28 +08:00
Fixed a bug in QST header parsing.
Headers were parsed incorrectly if the basename of the file chunk was less than 5 characters.
This commit is contained in:
parent
48f525a3bd
commit
2caa4eea2b
@ -5,6 +5,7 @@ import { Cursor } from "../../cursor/Cursor";
|
|||||||
import { ResizableBufferCursor } from "../../cursor/ResizableBufferCursor";
|
import { ResizableBufferCursor } from "../../cursor/ResizableBufferCursor";
|
||||||
import { WritableCursor } from "../../cursor/WritableCursor";
|
import { WritableCursor } from "../../cursor/WritableCursor";
|
||||||
import { ResizableBuffer } from "../../ResizableBuffer";
|
import { ResizableBuffer } from "../../ResizableBuffer";
|
||||||
|
import { basename } from "../../../util";
|
||||||
|
|
||||||
const logger = Logger.get("core/data_formats/parsing/quest/qst");
|
const logger = Logger.get("core/data_formats/parsing/quest/qst");
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ function parse_headers(cursor: Cursor): QstHeader[] {
|
|||||||
if (
|
if (
|
||||||
prev_quest_id != undefined &&
|
prev_quest_id != undefined &&
|
||||||
prev_file_name != undefined &&
|
prev_file_name != undefined &&
|
||||||
(quest_id !== prev_quest_id || file_name.slice(0, 5) !== prev_file_name.slice(0, 5))
|
(quest_id !== prev_quest_id || basename(file_name) !== basename(prev_file_name))
|
||||||
) {
|
) {
|
||||||
cursor.seek(-88);
|
cursor.seek(-88);
|
||||||
break;
|
break;
|
||||||
|
@ -26,3 +26,18 @@ export function array_buffers_equal(a: ArrayBuffer, b: ArrayBuffer): boolean {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given filename without the file extension.
|
||||||
|
*/
|
||||||
|
export function basename(filename: string): string {
|
||||||
|
const dot_idx = filename.lastIndexOf(".");
|
||||||
|
|
||||||
|
// < 0 means filenames doesn't contain any "."
|
||||||
|
// also skip index 0 because that would mean the basename is empty
|
||||||
|
if (dot_idx > 1) {
|
||||||
|
return filename.slice(0, dot_idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user