initial commit

This commit is contained in:
sam 2024-06-24 21:17:23 +12:00
commit 3018b0b4f7
11 changed files with 272839 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
0_0.lotheader Normal file

Binary file not shown.

BIN
40_22.lotheader Normal file

Binary file not shown.

4
lotheader-test.js Normal file
View file

@ -0,0 +1,4 @@
const { writeFileSync } = require("node:fs");
const Lotheader = require("./lotheader");
writeFileSync("output.json", JSON.stringify(Lotheader("0_0.lotheader"), undefined, 4));

57
lotheader.js Normal file
View file

@ -0,0 +1,57 @@
const Reader = require("./reader");
module.exports = (path) => {
let buf = new Reader(path);
let data = {};
data.version = buf.read_i32();
data.num_tiles = buf.read_i32();
data.strings = [];
for (let i = 0; i < data.num_tiles; i++) {
data.strings[i] = buf.read_string();
}
buf.read_u8();
data.lot_width = buf.read_i32();
data.lot_height = buf.read_i32();
data.levels = buf.read_i32();
data.num_rooms = buf.read_i32();
data.rooms = [];
for (let i = 0; i < data.num_rooms; i++) {
let room = {};
room.name = buf.read_string();
room.level = buf.read_i32();
room.num_rects = buf.read_i32();
room.rects = [];
for (let j = 0; j < room.num_rects; j++) {
room.rects[j] = {
x: buf.read_i32(), y: buf.read_i32(),
width: buf.read_i32(), height: buf.read_i32()
};
}
room.num_objects = buf.read_i32();
room.objects = [];
for (let j = 0; j < room.num_objects; j++) {
room.objects[j] = {
type: buf.read_i32(),
x: buf.read_i32(), y: buf.read_i32()
}
}
data.rooms[i] = room;
}
data.num_buildings = buf.read_i32();
data.buildings = [];
for (let i = 0; i < data.num_buildings; i++) {
let building = {};
building.num_rooms = buf.read_i32();
building.room_indices = [];
for (let j = 0; j < building.num_rooms; j++) {
building.room_indices[j] = buf.read_i32();
}
data.buildings[i] = building;
}
return data;
}

3
lotpack-test.js Normal file
View file

@ -0,0 +1,3 @@
const Lotpack = require("./lotpack");
require("fs").writeFileSync("output.txt", Lotpack(0, 0).join("\n"));

47
lotpack.js Normal file
View file

@ -0,0 +1,47 @@
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;
}

535
output.json Normal file
View file

@ -0,0 +1,535 @@
{
"version": 0,
"num_tiles": 316,
"strings": [
"appliances_cooking_01_14",
"appliances_cooking_01_26",
"appliances_cooking_01_33",
"appliances_laundry_01_1",
"appliances_laundry_01_5",
"appliances_refrigeration_01_8",
"blends_grassoverlays_01_0",
"blends_grassoverlays_01_1",
"blends_grassoverlays_01_2",
"blends_grassoverlays_01_3",
"blends_grassoverlays_01_4",
"blends_grassoverlays_01_5",
"blends_grassoverlays_01_8",
"blends_grassoverlays_01_9",
"blends_grassoverlays_01_10",
"blends_grassoverlays_01_11",
"blends_grassoverlays_01_12",
"blends_grassoverlays_01_13",
"blends_grassoverlays_01_16",
"blends_grassoverlays_01_17",
"blends_grassoverlays_01_18",
"blends_grassoverlays_01_19",
"blends_grassoverlays_01_20",
"blends_grassoverlays_01_21",
"blends_grassoverlays_01_24",
"blends_grassoverlays_01_25",
"blends_grassoverlays_01_26",
"blends_grassoverlays_01_27",
"blends_grassoverlays_01_28",
"blends_grassoverlays_01_29",
"blends_grassoverlays_01_32",
"blends_grassoverlays_01_33",
"blends_grassoverlays_01_34",
"blends_grassoverlays_01_35",
"blends_grassoverlays_01_36",
"blends_grassoverlays_01_37",
"blends_grassoverlays_01_40",
"blends_grassoverlays_01_41",
"blends_grassoverlays_01_42",
"blends_grassoverlays_01_43",
"blends_grassoverlays_01_44",
"blends_grassoverlays_01_45",
"blends_grassoverlays_01_48",
"blends_grassoverlays_01_49",
"blends_grassoverlays_01_50",
"blends_grassoverlays_01_51",
"blends_grassoverlays_01_52",
"blends_grassoverlays_01_53",
"blends_grassoverlays_01_56",
"blends_grassoverlays_01_57",
"blends_grassoverlays_01_59",
"blends_grassoverlays_01_60",
"blends_grassoverlays_01_64",
"blends_grassoverlays_01_65",
"blends_grassoverlays_01_66",
"blends_grassoverlays_01_67",
"blends_grassoverlays_01_68",
"blends_grassoverlays_01_69",
"blends_natural_01_0",
"blends_natural_01_5",
"blends_natural_01_6",
"blends_natural_01_7",
"blends_natural_01_16",
"blends_natural_01_17",
"blends_natural_01_18",
"blends_natural_01_19",
"blends_natural_01_20",
"blends_natural_01_21",
"blends_natural_01_22",
"blends_natural_01_23",
"blends_natural_01_24",
"blends_natural_01_25",
"blends_natural_01_26",
"blends_natural_01_27",
"blends_natural_01_28",
"blends_natural_01_29",
"blends_natural_01_30",
"blends_natural_01_31",
"blends_natural_01_32",
"blends_natural_01_33",
"blends_natural_01_34",
"blends_natural_01_35",
"blends_natural_01_36",
"blends_natural_01_37",
"blends_natural_01_38",
"blends_natural_01_39",
"blends_natural_01_40",
"blends_natural_01_41",
"blends_natural_01_42",
"blends_natural_01_43",
"blends_natural_01_44",
"blends_natural_01_45",
"blends_natural_01_46",
"blends_natural_01_47",
"blends_natural_01_48",
"blends_natural_01_50",
"blends_natural_01_51",
"blends_natural_01_53",
"blends_natural_01_54",
"blends_natural_01_55",
"blends_natural_01_57",
"blends_natural_01_59",
"blends_natural_01_63",
"blends_natural_01_64",
"blends_natural_01_69",
"blends_natural_01_70",
"blends_natural_01_71",
"blends_natural_01_80",
"blends_natural_01_83",
"blends_natural_01_84",
"blends_natural_01_85",
"blends_natural_01_86",
"blends_natural_01_87",
"blends_natural_01_89",
"blends_natural_01_91",
"blends_natural_02_0",
"blends_natural_02_1",
"blends_natural_02_2",
"blends_natural_02_3",
"blends_natural_02_4",
"blends_natural_02_5",
"blends_natural_02_6",
"blends_natural_02_7",
"blends_natural_02_8",
"blends_natural_02_9",
"blends_natural_02_10",
"blends_natural_02_11",
"blends_street_01_48",
"blends_street_01_53",
"blends_street_01_54",
"blends_street_01_55",
"blends_street_01_80",
"blends_street_01_85",
"blends_street_01_86",
"blends_street_01_87",
"blends_street_01_102",
"fencing_01_24",
"fencing_01_26",
"fencing_01_27",
"fencing_01_28",
"fencing_01_29",
"fixtures_bathroom_01_0",
"fixtures_bathroom_01_29",
"fixtures_bathroom_01_33",
"fixtures_bathroom_01_34",
"fixtures_bathroom_01_35",
"fixtures_bathroom_01_36",
"fixtures_counters_01_61",
"fixtures_counters_01_62",
"fixtures_counters_01_63",
"fixtures_doors_01_4",
"fixtures_doors_01_5",
"fixtures_doors_01_45",
"fixtures_doors_02_5",
"fixtures_doors_frames_01_5",
"fixtures_doors_frames_01_8",
"fixtures_doors_frames_01_9",
"fixtures_fireplaces_01_5",
"fixtures_fireplaces_01_23",
"fixtures_fireplaces_01_30",
"fixtures_fireplaces_01_31",
"fixtures_fireplaces_01_32",
"fixtures_fireplaces_01_33",
"fixtures_fireplaces_01_34",
"fixtures_sinks_01_1",
"fixtures_sinks_01_9",
"fixtures_windows_01_0",
"fixtures_windows_01_1",
"fixtures_windows_curtains_01_5",
"fixtures_windows_curtains_01_7",
"fixtures_windows_curtains_01_28",
"fixtures_windows_curtains_01_30",
"fixtures_windows_curtains_01_53",
"fixtures_windows_curtains_01_54",
"fixtures_windows_curtains_01_73",
"fixtures_windows_detailing_01_24",
"fixtures_windows_detailing_01_25",
"fixtures_windows_detailing_01_26",
"fixtures_windows_detailing_01_27",
"floors_interior_carpet_01_2",
"floors_interior_carpet_01_3",
"floors_interior_tilesandwood_01_12",
"floors_interior_tilesandwood_01_13",
"floors_interior_tilesandwood_01_18",
"floors_interior_tilesandwood_01_23",
"floors_rugs_01_28",
"floors_rugs_01_29",
"floors_rugs_01_36",
"floors_rugs_01_37",
"floors_rugs_01_44",
"floors_rugs_01_45",
"furniture_bedding_01_4",
"furniture_bedding_01_5",
"furniture_bedding_01_6",
"furniture_bedding_01_7",
"furniture_seating_indoor_02_0",
"furniture_seating_indoor_02_1",
"furniture_seating_indoor_02_2",
"furniture_seating_indoor_02_3",
"furniture_seating_indoor_02_20",
"furniture_seating_indoor_02_28",
"furniture_seating_indoor_02_29",
"furniture_seating_outdoor_01_0",
"furniture_seating_outdoor_01_1",
"furniture_shelving_01_0",
"furniture_shelving_01_26",
"furniture_shelving_01_27",
"furniture_shelving_01_29",
"furniture_shelving_01_32",
"furniture_shelving_01_36",
"furniture_shelving_01_45",
"furniture_storage_01_24",
"furniture_storage_01_25",
"furniture_storage_01_33",
"furniture_storage_01_53",
"furniture_storage_02_0",
"furniture_storage_02_38",
"furniture_storage_02_39",
"furniture_tables_high_01_10",
"furniture_tables_high_01_11",
"lighting_indoor_01_4",
"lighting_indoor_01_5",
"lighting_indoor_01_6",
"lighting_outdoor_01_24",
"lighting_outdoor_01_26",
"location_community_school_01_33",
"location_hospitality_sunstarmotel_02_13",
"overlay_grime_floor_01_28",
"overlay_grime_floor_01_29",
"overlay_grime_floor_01_36",
"overlay_grime_wall_01_16",
"overlay_grime_wall_01_17",
"overlay_grime_wall_01_18",
"roofs_01_3",
"roofs_01_4",
"roofs_01_5",
"roofs_01_14",
"roofs_01_22",
"street_curbs_01_8",
"street_decoration_01_19",
"trashcontainers_01_16",
"trashcontainers_01_20",
"trashcontainers_01_25",
"trashcontainers_01_26",
"vegetation_foliage_01_2",
"vegetation_foliage_01_4",
"vegetation_foliage_01_8",
"vegetation_foliage_01_9",
"vegetation_foliage_01_10",
"vegetation_foliage_01_11",
"vegetation_foliage_01_12",
"vegetation_foliage_01_13",
"vegetation_foliage_01_14",
"vegetation_groundcover_01_18",
"vegetation_groundcover_01_19",
"vegetation_groundcover_01_21",
"vegetation_groundcover_01_22",
"vegetation_groundcover_01_23",
"vegetation_indoor_01_7",
"vegetation_ornamental_01_8",
"vegetation_ornamental_01_9",
"vegetation_trees_01_8",
"vegetation_trees_01_9",
"vegetation_trees_01_10",
"vegetation_trees_01_11",
"walls_commercial_02_24",
"walls_commercial_02_25",
"walls_commercial_02_26",
"walls_decoration_01_35",
"walls_exterior_house_01_48",
"walls_exterior_house_01_49",
"walls_exterior_house_01_50",
"walls_exterior_house_01_51",
"walls_exterior_house_01_56",
"walls_exterior_house_01_57",
"walls_exterior_house_01_59",
"walls_exterior_roofs_03_3",
"walls_exterior_roofs_03_4",
"walls_exterior_roofs_03_5",
"walls_exterior_roofs_03_6",
"walls_exterior_roofs_03_11",
"walls_exterior_roofs_03_12",
"walls_exterior_roofs_03_13",
"walls_garage_01_32",
"walls_garage_01_33",
"walls_garage_01_34",
"walls_interior_bathroom_01_4",
"walls_interior_bathroom_01_5",
"walls_interior_bathroom_01_6",
"walls_interior_detailing_01_4",
"walls_interior_detailing_01_5",
"walls_interior_detailing_01_6",
"walls_interior_detailing_01_12",
"walls_interior_detailing_01_13",
"walls_interior_detailing_01_14",
"walls_interior_detailing_01_36",
"walls_interior_detailing_01_37",
"walls_interior_detailing_01_38",
"walls_interior_detailing_01_39",
"walls_interior_detailing_01_47",
"walls_interior_house_02_32",
"walls_interior_house_02_33",
"walls_interior_house_02_34",
"walls_interior_house_02_36",
"walls_interior_house_02_37",
"walls_interior_house_02_38",
"walls_interior_house_02_39",
"walls_interior_house_02_40",
"walls_interior_house_02_41",
"walls_interior_house_02_47",
"walls_interior_house_02_48",
"walls_interior_house_02_49",
"walls_interior_house_02_50",
"walls_interior_house_02_57",
"walls_interior_house_02_58",
"walls_interior_house_02_59"
],
"lot_width": 10,
"lot_height": 10,
"levels": 15,
"num_rooms": 6,
"rooms": [
{
"name": "livingroom",
"level": 0,
"num_rects": 3,
"rects": [
{
"x": 159,
"y": 69,
"width": 5,
"height": 1
},
{
"x": 152,
"y": 70,
"width": 12,
"height": 5
},
{
"x": 152,
"y": 75,
"width": 8,
"height": 1
}
],
"num_objects": 5,
"objects": [
{
"type": 7,
"x": 163,
"y": 69
},
{
"type": 3,
"x": 153,
"y": 70
},
{
"type": 3,
"x": 157,
"y": 70
},
{
"type": 7,
"x": 155,
"y": 75
},
{
"type": 4,
"x": 154,
"y": 75
}
]
},
{
"name": "kitchen",
"level": 0,
"num_rects": 1,
"rects": [
{
"x": 159,
"y": 64,
"width": 5,
"height": 5
}
],
"num_objects": 2,
"objects": [
{
"type": 1,
"x": 159,
"y": 65
},
{
"type": 7,
"x": 159,
"y": 66
}
]
},
{
"name": "bathroom",
"level": 0,
"num_rects": 1,
"rects": [
{
"x": 156,
"y": 67,
"width": 3,
"height": 3
}
],
"num_objects": 2,
"objects": [
{
"type": 7,
"x": 158,
"y": 69
},
{
"type": 4,
"x": 157,
"y": 69
}
]
},
{
"name": "bedroom",
"level": 0,
"num_rects": 1,
"rects": [
{
"x": 152,
"y": 64,
"width": 4,
"height": 6
}
],
"num_objects": 2,
"objects": [
{
"type": 7,
"x": 154,
"y": 69
},
{
"type": 4,
"x": 153,
"y": 69
}
]
},
{
"name": "laundry",
"level": 0,
"num_rects": 1,
"rects": [
{
"x": 156,
"y": 64,
"width": 3,
"height": 3
}
],
"num_objects": 2,
"objects": [
{
"type": 7,
"x": 158,
"y": 64
},
{
"type": 2,
"x": 158,
"y": 65
}
]
},
{
"name": "shed",
"level": 0,
"num_rects": 1,
"rects": [
{
"x": 155,
"y": 52,
"width": 3,
"height": 3
}
],
"num_objects": 3,
"objects": [
{
"type": 7,
"x": 157,
"y": 54
},
{
"type": 4,
"x": 156,
"y": 54
},
{
"type": 4,
"x": 156,
"y": 54
}
]
}
],
"num_buildings": 2,
"buildings": [
{
"num_rooms": 5,
"room_indices": [
0,
1,
2,
3,
4
]
},
{
"num_rooms": 1,
"room_indices": [
5
]
}
]
}

272158
output.txt Normal file

File diff suppressed because it is too large Load diff

35
reader.js Normal file
View file

@ -0,0 +1,35 @@
const { readFileSync } = require("node:fs");
module.exports = class Reader {
constructor(path) {
this.buf = readFileSync(path);
this.offset = 0;
}
read_i32() {
let value = this.buf.readInt32LE(this.offset);
this.offset += 4;
return value;
}
read_u8() {
let value = this.buf.readUint8(this.offset);
this.offset++;
return value;
}
read_char() {
return String.fromCharCode(this.read_u8());
}
read_string() {
let out = "";
while (this.offset < this.buf.length) {
let c = this.read_char();
if (c == '\n') break;
out += c;
}
return out;
}
}

BIN
world_0_0.lotpack Normal file

Binary file not shown.