@etothepii/satisfactory-file-parser 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +41 -51
- package/build/parser/byte/alignment.enum.js +8 -18
- package/build/parser/byte/binary-operable.interface.js +2 -12
- package/build/parser/byte/binary-readable.interface.js +2 -12
- package/build/parser/byte/byte-reader.class.js +122 -132
- package/build/parser/byte/byte-writer.class.js +133 -143
- package/build/parser/error/parser.error.js +40 -50
- package/build/parser/file.types.js +2 -12
- package/build/parser/parser.d.ts +0 -9
- package/build/parser/parser.js +84 -192
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +109 -119
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +56 -66
- package/build/parser/satisfactory/blueprint/blueprint.types.js +2 -12
- package/build/parser/satisfactory/objects/DataFields.js +297 -307
- package/build/parser/satisfactory/objects/ObjectReference.js +14 -24
- package/build/parser/satisfactory/objects/Property.js +967 -977
- package/build/parser/satisfactory/objects/SaveComponent.js +28 -38
- package/build/parser/satisfactory/objects/SaveEntity.js +65 -75
- package/build/parser/satisfactory/objects/SaveObject.js +26 -36
- package/build/parser/satisfactory/save/asynchronous-level.class.js +60 -70
- package/build/parser/satisfactory/save/level.class.js +122 -133
- package/build/parser/satisfactory/save/satisfactory-save.js +10 -20
- package/build/parser/satisfactory/save/save-reader.js +158 -168
- package/build/parser/satisfactory/save/save-writer.js +97 -107
- package/build/parser/satisfactory/save/save.types.js +2 -12
- package/build/parser/satisfactory/structs/util.types.js +89 -99
- package/build/parser/stream/byte-stream-reader.class.js +217 -227
- package/build/parser/stream/json-stream-state-writer.js +15 -25
- package/build/parser/stream/json-stream-writable.js +72 -82
- package/build/parser/stream/json-stream-writer.js +122 -132
- package/build/parser/stream/save-stream-json-stringifier.js +29 -39
- package/build/parser/stream/save-stream-reader.class.js +106 -116
- package/build/parser/stream/save-stream-writer.class.js +90 -100
- package/build/parser/stream/stream-level.class.js +93 -103
- package/package.json +1 -1
package/build/parser/parser.js
CHANGED
|
@@ -1,196 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Parser = void 0;
|
|
4
|
+
const blueprint_reader_1 = require("./satisfactory/blueprint/blueprint-reader");
|
|
5
|
+
const blueprint_writer_1 = require("./satisfactory/blueprint/blueprint-writer");
|
|
6
|
+
const level_class_1 = require("./satisfactory/save/level.class");
|
|
7
|
+
const satisfactory_save_1 = require("./satisfactory/save/satisfactory-save");
|
|
8
|
+
const save_reader_1 = require("./satisfactory/save/save-reader");
|
|
9
|
+
const save_writer_1 = require("./satisfactory/save/save-writer");
|
|
10
|
+
class Parser {
|
|
11
|
+
static WriteSave(save, onBinaryBeforeCompressing, onHeader, onChunk) {
|
|
12
|
+
const writer = new save_writer_1.SaveWriter();
|
|
13
|
+
save_writer_1.SaveWriter.WriteHeader(writer, save.header);
|
|
14
|
+
const posAfterHeader = writer.getBufferPosition();
|
|
15
|
+
save_writer_1.SaveWriter.WriteLevels(writer, save, save.header.buildVersion);
|
|
16
|
+
writer.endWriting();
|
|
17
|
+
const chunkSummary = writer.generateChunks(save.compressionInfo, posAfterHeader, onBinaryBeforeCompressing, onHeader, onChunk);
|
|
18
|
+
return chunkSummary;
|
|
5
19
|
}
|
|
6
|
-
|
|
7
|
-
|
|
20
|
+
static ParseSaveFile(file, onDecompressedSaveBody = () => { }, onProgress = () => { }) {
|
|
21
|
+
const reader = new save_reader_1.SaveReader(new Uint8Array(file).buffer, onProgress);
|
|
22
|
+
const header = reader.readHeader();
|
|
23
|
+
const save = new satisfactory_save_1.SatisfactorySave(header);
|
|
24
|
+
const inflateResult = reader.inflateChunks();
|
|
25
|
+
onDecompressedSaveBody(reader.getBuffer());
|
|
26
|
+
const levelParseResult = reader.readLevels();
|
|
27
|
+
save.levels = reader.levels;
|
|
28
|
+
save.compressionInfo = reader.compressionInfo;
|
|
29
|
+
save.trailingCollectedObjects = reader.trailingCollectedObjects;
|
|
30
|
+
return save;
|
|
8
31
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
start: (controller) => {
|
|
26
|
-
},
|
|
27
|
-
transform: async (chunk, controller) => {
|
|
28
|
-
chunk = await chunk;
|
|
29
|
-
controller.enqueue(chunk);
|
|
30
|
-
},
|
|
31
|
-
flush: (controller) => {
|
|
32
|
-
console.log('on passthrough dispose.');
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
32
|
+
static WriteBlueprintFiles(blueprint, onMainFileBinaryBeforeCompressing = () => { }, onMainFileHeader = () => { }, onMainFileChunk = () => { }) {
|
|
33
|
+
const blueprintWriter = new blueprint_writer_1.BlueprintWriter();
|
|
34
|
+
blueprint_writer_1.BlueprintWriter.SerializeHeader(blueprintWriter, blueprint.header);
|
|
35
|
+
const saveBodyPos = blueprintWriter.getBufferPosition();
|
|
36
|
+
blueprint_writer_1.BlueprintWriter.SerializeObjects(blueprintWriter, blueprint.objects);
|
|
37
|
+
blueprintWriter.endWriting();
|
|
38
|
+
let binaryChunks = [];
|
|
39
|
+
let binaryHeader;
|
|
40
|
+
const mainFileChunkSummary = blueprintWriter.generateChunks(blueprint.compressionInfo, saveBodyPos, onMainFileBinaryBeforeCompressing, onMainFileHeader, onMainFileChunk);
|
|
41
|
+
const configWriter = new blueprint_writer_1.BlueprintConfigWriter();
|
|
42
|
+
blueprint_writer_1.BlueprintConfigWriter.SerializeConfig(configWriter, blueprint.config);
|
|
43
|
+
const configFileBinary = configWriter.endWriting();
|
|
44
|
+
return {
|
|
45
|
+
mainFileChunkSummary,
|
|
46
|
+
configFileBinary
|
|
47
|
+
};
|
|
36
48
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const binaryOutWriter = binaryOutput ? binaryOutput.getWriter() : undefined;
|
|
54
|
-
const writer = new save_stream_writer_class_1.SaveStreamWriter(output.getWriter());
|
|
55
|
-
const reader = new save_stream_reader_class_1.SaveStreamReader(input.getReader(), 500 * 1000 * 1000);
|
|
56
|
-
const passthrough = new PassthroughWebTransform();
|
|
57
|
-
const passthroughWriter = passthrough.writable.getWriter();
|
|
58
|
-
const passthroughReader = new save_stream_reader_class_1.SaveStreamReader(passthrough.readable.getReader(), 3000 * 1000 * 1000);
|
|
59
|
-
await writer.beginSave();
|
|
60
|
-
const header = await reader.readHeader();
|
|
61
|
-
await writer.writeHeader(header);
|
|
62
|
-
let contentParsingPromise;
|
|
63
|
-
const decompressionPromise = Parser.DecompressStreamSave(reader, writer, passthroughWriter, async () => {
|
|
64
|
-
console.log('start streaming content');
|
|
65
|
-
passthroughReader.debug = true;
|
|
66
|
-
contentParsingPromise = await Parser.ParseStreamSave(passthroughReader, writer, header);
|
|
67
|
-
await writer.close();
|
|
68
|
-
return resolve();
|
|
69
|
-
}, binaryOutWriter);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
static async ParseStreamSave(reader, jsonWriter, header) {
|
|
73
|
-
return new Promise(async (resolve, reject) => {
|
|
74
|
-
reader.onCloseCallback = async () => {
|
|
75
|
-
console.log('content reader closes.');
|
|
76
|
-
await jsonWriter.endLevels();
|
|
77
|
-
await jsonWriter.endSave();
|
|
78
|
-
return resolve();
|
|
79
|
-
};
|
|
80
|
-
console.log('before open levels');
|
|
81
|
-
await jsonWriter.openLevels();
|
|
82
|
-
const dataLength = await reader.readInt32();
|
|
83
|
-
await reader.allocate(Math.min(1000, dataLength));
|
|
84
|
-
console.log(`incoming body size should be ${dataLength} bytes big.`);
|
|
85
|
-
await reader.streamLevelsToOutput(jsonWriter, header);
|
|
86
|
-
await reader.close();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
static async DecompressStreamSave(reader, jsonWriter, outputWriter, onDecompressionInfoWritten, debugAdditionalBinaryOutputWriter) {
|
|
90
|
-
return new Promise(async (resolve, reject) => {
|
|
91
|
-
reader.onCloseCallback = async () => {
|
|
92
|
-
console.log('decompress reader closes.');
|
|
93
|
-
return resolve();
|
|
94
|
-
};
|
|
95
|
-
let first = true;
|
|
96
|
-
while (reader.hasInput()) {
|
|
97
|
-
const decompressedChunk = await reader.readBodyChunk();
|
|
98
|
-
if (first && reader.compressionInfo) {
|
|
99
|
-
await jsonWriter.writeCompressionInfo(reader.compressionInfo);
|
|
100
|
-
onDecompressionInfoWritten();
|
|
101
|
-
first = false;
|
|
102
|
-
}
|
|
103
|
-
if (debugAdditionalBinaryOutputWriter) {
|
|
104
|
-
debugAdditionalBinaryOutputWriter.write(decompressedChunk);
|
|
105
|
-
}
|
|
106
|
-
outputWriter.write(decompressedChunk);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
static ParseSaveFile(file, onDecompressedSaveBody = () => { }, onProgress = () => { }) {
|
|
111
|
-
const reader = new save_reader_1.SaveReader(new Uint8Array(file).buffer, onProgress);
|
|
112
|
-
const header = reader.readHeader();
|
|
113
|
-
const save = new satisfactory_save_1.SatisfactorySave(header);
|
|
114
|
-
const inflateResult = reader.inflateChunks();
|
|
115
|
-
onDecompressedSaveBody(reader.getBuffer());
|
|
116
|
-
const levelParseResult = reader.readLevels();
|
|
117
|
-
save.levels = reader.levels;
|
|
118
|
-
save.compressionInfo = reader.compressionInfo;
|
|
119
|
-
save.trailingCollectedObjects = reader.trailingCollectedObjects;
|
|
120
|
-
return save;
|
|
121
|
-
}
|
|
122
|
-
static async ParseSaveFileAsynchronousToOutput(file, outputJson, onDecompressedSaveBody = () => { }, onProgress = () => { }) {
|
|
123
|
-
const reader = new save_reader_1.SaveReader(new Uint8Array(file).buffer, onProgress);
|
|
124
|
-
const writer = new save_stream_writer_class_1.SaveStreamWriter(outputJson.getWriter());
|
|
125
|
-
await writer.beginSave();
|
|
126
|
-
const header = reader.readHeader();
|
|
127
|
-
const save = new satisfactory_save_1.SatisfactorySave(header);
|
|
128
|
-
await writer.writeHeader(save.header);
|
|
129
|
-
await writer.writeCompressionInfo({});
|
|
130
|
-
const inflateResult = reader.inflateChunks();
|
|
131
|
-
onDecompressedSaveBody(reader.getBuffer());
|
|
132
|
-
const levelParseResult = await reader.readLevelsAsynchronously(writer);
|
|
133
|
-
save.levels = reader.levels;
|
|
134
|
-
save.compressionInfo = reader.compressionInfo;
|
|
135
|
-
save.trailingCollectedObjects = reader.trailingCollectedObjects;
|
|
136
|
-
await writer.endSave();
|
|
137
|
-
return save;
|
|
138
|
-
}
|
|
139
|
-
static WriteBlueprintFiles(blueprint, onMainFileBinaryBeforeCompressing = () => { }, onMainFileHeader = () => { }, onMainFileChunk = () => { }) {
|
|
140
|
-
const blueprintWriter = new blueprint_writer_1.BlueprintWriter();
|
|
141
|
-
blueprint_writer_1.BlueprintWriter.SerializeHeader(blueprintWriter, blueprint.header);
|
|
142
|
-
const saveBodyPos = blueprintWriter.getBufferPosition();
|
|
143
|
-
blueprint_writer_1.BlueprintWriter.SerializeObjects(blueprintWriter, blueprint.objects);
|
|
144
|
-
blueprintWriter.endWriting();
|
|
145
|
-
let binaryChunks = [];
|
|
146
|
-
let binaryHeader;
|
|
147
|
-
const mainFileChunkSummary = blueprintWriter.generateChunks(blueprint.compressionInfo, saveBodyPos, onMainFileBinaryBeforeCompressing, onMainFileHeader, onMainFileChunk);
|
|
148
|
-
const configWriter = new blueprint_writer_1.BlueprintConfigWriter();
|
|
149
|
-
blueprint_writer_1.BlueprintConfigWriter.SerializeConfig(configWriter, blueprint.config);
|
|
150
|
-
const configFileBinary = configWriter.endWriting();
|
|
151
|
-
return {
|
|
152
|
-
mainFileChunkSummary,
|
|
153
|
-
configFileBinary
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
static ParseBlueprintFiles(name, blueprintFile, blueprintConfigFile, onDecompressedBlueprintBody = () => { }) {
|
|
157
|
-
const blueprintConfigReader = new blueprint_reader_1.BlueprintConfigReader(new Uint8Array(blueprintConfigFile).buffer);
|
|
158
|
-
const config = blueprint_reader_1.BlueprintConfigReader.ParseConfig(blueprintConfigReader);
|
|
159
|
-
const blueprintReader = new blueprint_reader_1.BlueprintReader(new Uint8Array(blueprintFile).buffer);
|
|
160
|
-
const header = blueprint_reader_1.BlueprintReader.ReadHeader(blueprintReader);
|
|
161
|
-
const inflateResult = blueprintReader.inflateChunks();
|
|
162
|
-
onDecompressedBlueprintBody(inflateResult.inflatedData);
|
|
163
|
-
const blueprintObjects = blueprint_reader_1.BlueprintReader.ParseObjects(blueprintReader);
|
|
164
|
-
const blueprint = {
|
|
165
|
-
name,
|
|
166
|
-
compressionInfo: blueprintReader.compressionInfo,
|
|
167
|
-
header: header,
|
|
168
|
-
config,
|
|
169
|
-
objects: blueprintObjects
|
|
170
|
-
};
|
|
171
|
-
return blueprint;
|
|
172
|
-
}
|
|
173
|
-
static ProjectSave(save, config) {
|
|
174
|
-
return {
|
|
175
|
-
header: save.header,
|
|
176
|
-
trailingCollectedObjects: save.trailingCollectedObjects,
|
|
177
|
-
levels: save.levels.map(level => {
|
|
178
|
-
const lvl = new level_class_1.Level(level.name);
|
|
179
|
-
lvl.collectables = level.collectables;
|
|
180
|
-
lvl.objects = level.objects.filter(obj => (0, save_reader_1.projectionFilterApplies)(config, obj));
|
|
181
|
-
return lvl;
|
|
182
|
-
})
|
|
183
|
-
};
|
|
184
|
-
}
|
|
49
|
+
static ParseBlueprintFiles(name, blueprintFile, blueprintConfigFile, onDecompressedBlueprintBody = () => { }) {
|
|
50
|
+
const blueprintConfigReader = new blueprint_reader_1.BlueprintConfigReader(new Uint8Array(blueprintConfigFile).buffer);
|
|
51
|
+
const config = blueprint_reader_1.BlueprintConfigReader.ParseConfig(blueprintConfigReader);
|
|
52
|
+
const blueprintReader = new blueprint_reader_1.BlueprintReader(new Uint8Array(blueprintFile).buffer);
|
|
53
|
+
const header = blueprint_reader_1.BlueprintReader.ReadHeader(blueprintReader);
|
|
54
|
+
const inflateResult = blueprintReader.inflateChunks();
|
|
55
|
+
onDecompressedBlueprintBody(inflateResult.inflatedData);
|
|
56
|
+
const blueprintObjects = blueprint_reader_1.BlueprintReader.ParseObjects(blueprintReader);
|
|
57
|
+
const blueprint = {
|
|
58
|
+
name,
|
|
59
|
+
compressionInfo: blueprintReader.compressionInfo,
|
|
60
|
+
header: header,
|
|
61
|
+
config,
|
|
62
|
+
objects: blueprintObjects
|
|
63
|
+
};
|
|
64
|
+
return blueprint;
|
|
185
65
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
66
|
+
static ProjectSave(save, config) {
|
|
67
|
+
return {
|
|
68
|
+
header: save.header,
|
|
69
|
+
trailingCollectedObjects: save.trailingCollectedObjects,
|
|
70
|
+
levels: save.levels.map(level => {
|
|
71
|
+
const lvl = new level_class_1.Level(level.name);
|
|
72
|
+
lvl.collectables = level.collectables;
|
|
73
|
+
lvl.objects = level.objects.filter(obj => (0, save_reader_1.projectionFilterApplies)(config, obj));
|
|
74
|
+
return lvl;
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
Parser.JSONStringifyModified = (obj, indent = 0) => JSON.stringify(obj, (key, value) => {
|
|
80
|
+
if (typeof value === 'bigint') {
|
|
81
|
+
return value.toString();
|
|
82
|
+
}
|
|
83
|
+
else if (value === 0 && 1 / value < 0) {
|
|
84
|
+
return '-0';
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}, indent);
|
|
88
|
+
exports.Parser = Parser;
|
|
@@ -1,134 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
4
|
};
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BlueprintConfigReader = exports.BlueprintReader = void 0;
|
|
7
|
+
const pako_1 = __importDefault(require("pako"));
|
|
8
|
+
const alignment_enum_1 = require("../../byte/alignment.enum");
|
|
9
|
+
const byte_reader_class_1 = require("../../byte/byte-reader.class");
|
|
10
|
+
const parser_error_1 = require("../../error/parser.error");
|
|
11
|
+
const level_class_1 = require("../save/level.class");
|
|
12
|
+
const util_types_1 = require("../structs/util.types");
|
|
13
|
+
class BlueprintReader extends byte_reader_class_1.ByteReader {
|
|
14
|
+
constructor(bluePrintBuffer) {
|
|
15
|
+
super(bluePrintBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
16
|
+
this.compressionInfo = {
|
|
17
|
+
packageFileTag: 0,
|
|
18
|
+
maxChunkContentSize: 0,
|
|
19
|
+
chunkHeaderSize: 48
|
|
20
|
+
};
|
|
8
21
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
packageFileTag: 0,
|
|
27
|
-
maxChunkContentSize: 0,
|
|
28
|
-
chunkHeaderSize: 48
|
|
29
|
-
};
|
|
22
|
+
static ReadHeader(reader) {
|
|
23
|
+
const unk = reader.readBytes(3 * 4);
|
|
24
|
+
const positionThingOrWhat = (0, util_types_1.ParseVec3)(reader);
|
|
25
|
+
let itemTypeCount = reader.readInt32();
|
|
26
|
+
const itemCosts = new Array(itemTypeCount).fill(['', 0]);
|
|
27
|
+
for (let i = 0; i < itemTypeCount; i++) {
|
|
28
|
+
let indexOrWhat = reader.readInt32();
|
|
29
|
+
let itemPathName = reader.readString();
|
|
30
|
+
let itemCount = reader.readInt32();
|
|
31
|
+
itemCosts[i] = [itemPathName, itemCount];
|
|
32
|
+
}
|
|
33
|
+
let recipeCount = reader.readInt32();
|
|
34
|
+
const recipeRefs = new Array(recipeCount).fill('');
|
|
35
|
+
for (let i = 0; i < recipeCount; i++) {
|
|
36
|
+
let indexOrWhat = reader.readInt32();
|
|
37
|
+
const recipeName = reader.readString();
|
|
38
|
+
recipeRefs[i] = recipeName;
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
return {
|
|
41
|
+
recipeReferences: recipeRefs,
|
|
42
|
+
itemCosts
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
inflateChunks() {
|
|
46
|
+
this.fileBuffer = this.fileBuffer.slice(this.currentByte);
|
|
47
|
+
this.handledByte = 0;
|
|
48
|
+
this.currentByte = 0;
|
|
49
|
+
this.maxByte = this.fileBuffer.byteLength;
|
|
50
|
+
let currentChunks = [];
|
|
51
|
+
let totalUncompressedBodySize = 0;
|
|
52
|
+
while (this.handledByte < this.maxByte) {
|
|
53
|
+
let chunkHeader = new DataView(this.fileBuffer.slice(0, this.compressionInfo.chunkHeaderSize));
|
|
54
|
+
this.currentByte = this.compressionInfo.chunkHeaderSize;
|
|
55
|
+
this.handledByte += this.compressionInfo.chunkHeaderSize;
|
|
56
|
+
if (this.compressionInfo.packageFileTag <= 0) {
|
|
57
|
+
this.compressionInfo.packageFileTag = chunkHeader.getUint32(0, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
41
58
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < recipeCount; i++) {
|
|
45
|
-
let indexOrWhat = reader.readInt32();
|
|
46
|
-
const recipeName = reader.readString();
|
|
47
|
-
recipeRefs[i] = recipeName;
|
|
59
|
+
if (this.compressionInfo.maxChunkContentSize <= 0) {
|
|
60
|
+
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
63
|
+
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
64
|
+
totalUncompressedBodySize += chunkUncompressedLength;
|
|
65
|
+
const currentChunkSize = chunkCompressedLength;
|
|
66
|
+
let currentChunk = this.fileBuffer.slice(this.currentByte, this.currentByte + currentChunkSize);
|
|
67
|
+
this.handledByte += currentChunkSize;
|
|
68
|
+
this.currentByte += currentChunkSize;
|
|
55
69
|
this.fileBuffer = this.fileBuffer.slice(this.currentByte);
|
|
56
|
-
this.handledByte = 0;
|
|
57
70
|
this.currentByte = 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let chunkHeader = new DataView(this.fileBuffer.slice(0, this.compressionInfo.chunkHeaderSize));
|
|
63
|
-
this.currentByte = this.compressionInfo.chunkHeaderSize;
|
|
64
|
-
this.handledByte += this.compressionInfo.chunkHeaderSize;
|
|
65
|
-
if (this.compressionInfo.packageFileTag <= 0) {
|
|
66
|
-
this.compressionInfo.packageFileTag = chunkHeader.getUint32(0, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
67
|
-
}
|
|
68
|
-
if (this.compressionInfo.maxChunkContentSize <= 0) {
|
|
69
|
-
this.compressionInfo.maxChunkContentSize = chunkHeader.getInt32(8, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
70
|
-
}
|
|
71
|
-
const chunkCompressedLength = chunkHeader.getInt32(32, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
72
|
-
const chunkUncompressedLength = chunkHeader.getInt32(40, this.alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
73
|
-
totalUncompressedBodySize += chunkUncompressedLength;
|
|
74
|
-
const currentChunkSize = chunkCompressedLength;
|
|
75
|
-
let currentChunk = this.fileBuffer.slice(this.currentByte, this.currentByte + currentChunkSize);
|
|
76
|
-
this.handledByte += currentChunkSize;
|
|
77
|
-
this.currentByte += currentChunkSize;
|
|
78
|
-
this.fileBuffer = this.fileBuffer.slice(this.currentByte);
|
|
79
|
-
this.currentByte = 0;
|
|
80
|
-
try {
|
|
81
|
-
let currentInflatedChunk = null;
|
|
82
|
-
currentInflatedChunk = pako_1.default.inflate(currentChunk);
|
|
83
|
-
currentChunks.push(currentInflatedChunk);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
throw new parser_error_1.ParserError('ParserError', 'An error occurred while calling pako inflate.' + err);
|
|
87
|
-
}
|
|
71
|
+
try {
|
|
72
|
+
let currentInflatedChunk = null;
|
|
73
|
+
currentInflatedChunk = pako_1.default.inflate(currentChunk);
|
|
74
|
+
currentChunks.push(currentInflatedChunk);
|
|
88
75
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
let currentLength = 0;
|
|
92
|
-
for (let i = 0; i < currentChunks.length; i++) {
|
|
93
|
-
bigWholeChunk.set(currentChunks[i], currentLength);
|
|
94
|
-
currentLength += currentChunks[i].length;
|
|
76
|
+
catch (err) {
|
|
77
|
+
throw new parser_error_1.ParserError('ParserError', 'An error occurred while calling pako inflate.' + err);
|
|
95
78
|
}
|
|
96
|
-
this.currentByte = 0;
|
|
97
|
-
this.maxByte = bigWholeChunk.buffer.byteLength;
|
|
98
|
-
this.bufferView = new DataView(bigWholeChunk.buffer);
|
|
99
|
-
return {
|
|
100
|
-
newChunkLength,
|
|
101
|
-
numChunks: currentChunks.length,
|
|
102
|
-
inflatedData: bigWholeChunk
|
|
103
|
-
};
|
|
104
79
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return objects;
|
|
80
|
+
let newChunkLength = currentChunks.map(cc => cc.length).reduce((prev, cur) => prev + cur);
|
|
81
|
+
const bigWholeChunk = new Uint8Array(newChunkLength);
|
|
82
|
+
let currentLength = 0;
|
|
83
|
+
for (let i = 0; i < currentChunks.length; i++) {
|
|
84
|
+
bigWholeChunk.set(currentChunks[i], currentLength);
|
|
85
|
+
currentLength += currentChunks[i].length;
|
|
112
86
|
}
|
|
87
|
+
this.currentByte = 0;
|
|
88
|
+
this.maxByte = bigWholeChunk.buffer.byteLength;
|
|
89
|
+
this.bufferView = new DataView(bigWholeChunk.buffer);
|
|
90
|
+
return {
|
|
91
|
+
newChunkLength,
|
|
92
|
+
numChunks: currentChunks.length,
|
|
93
|
+
inflatedData: bigWholeChunk
|
|
94
|
+
};
|
|
113
95
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
96
|
+
static ParseObjects(reader) {
|
|
97
|
+
const totalBodyRestSize = reader.readInt32();
|
|
98
|
+
const objectHeadersBinarySize = reader.readInt32();
|
|
99
|
+
let objects = [];
|
|
100
|
+
level_class_1.Level.ReadObjectHeaders(reader, objects, () => { });
|
|
101
|
+
level_class_1.Level.ReadObjectContents(reader, objects, 0, () => { });
|
|
102
|
+
return objects;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.BlueprintReader = BlueprintReader;
|
|
106
|
+
class BlueprintConfigReader extends byte_reader_class_1.ByteReader {
|
|
107
|
+
constructor(bluePrintConfigBuffer) {
|
|
108
|
+
super(bluePrintConfigBuffer, alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
109
|
+
this.bluePrintConfigBuffer = bluePrintConfigBuffer;
|
|
110
|
+
this.parse = () => BlueprintConfigReader.ParseConfig(this);
|
|
111
|
+
}
|
|
112
|
+
static ParseConfig(reader) {
|
|
113
|
+
const unk = reader.readInt32();
|
|
114
|
+
const description = reader.readString();
|
|
115
|
+
const unk3 = reader.readInt32();
|
|
116
|
+
const colorMaybe = (0, util_types_1.ParseCol4RGBA)(reader);
|
|
117
|
+
return {
|
|
118
|
+
description,
|
|
119
|
+
color: colorMaybe,
|
|
120
|
+
iconID: unk3
|
|
121
|
+
};
|
|
132
122
|
}
|
|
133
|
-
|
|
134
|
-
|
|
123
|
+
}
|
|
124
|
+
exports.BlueprintConfigReader = BlueprintConfigReader;
|