47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
|
const Reader = require("./reader");
|
||
|
const Lotheader = require("./lotheader");
|
||
|
|
||
|
module.exports = function (_x, _y) {
|
||
|
const info = Lotheader(`${_x}_${_y}.lotheader`);
|
||
|
const buf = new Reader(`world_${_x}_${_y}.lotpack`);
|
||
|
let out = [];
|
||
|
|
||
|
for (let cx = 0; cx < 30; cx++) {
|
||
|
for (let cy = 0; cy < 30; cy++) {
|
||
|
let skip = 0;
|
||
|
let index = cx * 30 + cy;
|
||
|
buf.offset = 4 + index * 8;
|
||
|
let pos = buf.read_i32();
|
||
|
buf.offset = pos;
|
||
|
|
||
|
for (let z = 0; z < info.levels; z++) {
|
||
|
for (let x = 0; x < 10; x++) {
|
||
|
for (let y = 0; y < 10; y++) {
|
||
|
if (skip > 0) {
|
||
|
--skip;
|
||
|
} else {
|
||
|
let count = buf.read_i32();
|
||
|
if (count === -1) {
|
||
|
skip = buf.read_i32();
|
||
|
if (skip > 0) {
|
||
|
skip--;
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
if (count > 1 && count < 30) {
|
||
|
let room = buf.read_i32();
|
||
|
out.push(room);
|
||
|
for (let n = 1; n < count; n++) {
|
||
|
let d = buf.read_i32();
|
||
|
out.push(info.strings[d]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return out;
|
||
|
}
|