@etothepii/satisfactory-file-parser 0.1.19 → 0.1.21
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/README.md +1 -1
- package/build/parser/satisfactory/blueprint/blueprint-reader.js +4 -4
- package/build/parser/satisfactory/blueprint/blueprint-writer.d.ts +1 -0
- package/build/parser/satisfactory/blueprint/blueprint-writer.js +29 -5
- package/build/parser/satisfactory/save/save-writer.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,17 +103,17 @@ class BlueprintReader extends byte_reader_class_1.ByteReader {
|
|
|
103
103
|
const objectHeadersBinarySize = reader.readInt32();
|
|
104
104
|
let objects = [];
|
|
105
105
|
level_class_1.Level.ReadObjectHeaders(reader, objects, () => { });
|
|
106
|
-
const
|
|
107
|
-
BlueprintReader.ReadBlueprintObjectContents(
|
|
106
|
+
const someChecksumThing = reader.readInt32();
|
|
107
|
+
BlueprintReader.ReadBlueprintObjectContents(reader, objects, 0);
|
|
108
108
|
const pos = reader.getBufferPosition();
|
|
109
109
|
return objects;
|
|
110
110
|
}
|
|
111
|
-
static ReadBlueprintObjectContents(
|
|
111
|
+
static ReadBlueprintObjectContents(reader, objectsList, buildVersion) {
|
|
112
112
|
const countEntities = reader.readInt32();
|
|
113
113
|
for (let i = 0; i < countEntities; i++) {
|
|
114
114
|
const len = reader.readInt32();
|
|
115
115
|
if (len === 0) {
|
|
116
|
-
throw new parser_error_1.CorruptSaveError(`check number is a wrong value (${len}). This normally indicates a corrupt entity or
|
|
116
|
+
throw new parser_error_1.CorruptSaveError(`check number is a wrong value (${len}). This normally indicates a corrupt entity or blueprint.`);
|
|
117
117
|
}
|
|
118
118
|
const obj = objectsList[i];
|
|
119
119
|
if ((0, SaveEntity_1.isSaveEntity)(obj)) {
|
|
@@ -8,6 +8,7 @@ export declare class BlueprintWriter extends ByteWriter {
|
|
|
8
8
|
static SerializeHeader(writer: ByteWriter, header: BlueprintHeader): void;
|
|
9
9
|
generateChunks(compressionInfo: ChunkCompressionInfo, posAfterHeader: number, onBinaryBeforeCompressing: (binary: ArrayBuffer) => void, onHeader: (header: Uint8Array) => void, onChunk: (chunk: Uint8Array) => void): ChunkSummary[];
|
|
10
10
|
static SerializeObjects(writer: ByteWriter, objects: (SaveEntity | SaveComponent)[]): void;
|
|
11
|
+
static SerializeObjectContents(writer: ByteWriter, objects: (SaveEntity | SaveComponent)[], buildVersion: number, levelName: string): void;
|
|
11
12
|
}
|
|
12
13
|
export declare class BlueprintConfigWriter extends ByteWriter {
|
|
13
14
|
constructor();
|
|
@@ -4,6 +4,8 @@ exports.BlueprintConfigWriter = exports.BlueprintWriter = void 0;
|
|
|
4
4
|
const alignment_enum_1 = require("../../byte/alignment.enum");
|
|
5
5
|
const byte_writer_class_1 = require("../../byte/byte-writer.class");
|
|
6
6
|
const parser_error_1 = require("../../error/parser.error");
|
|
7
|
+
const SaveComponent_1 = require("../objects/SaveComponent");
|
|
8
|
+
const SaveEntity_1 = require("../objects/SaveEntity");
|
|
7
9
|
const level_class_1 = require("../save/level.class");
|
|
8
10
|
const save_writer_1 = require("../save/save-writer");
|
|
9
11
|
const util_types_1 = require("../structs/util.types");
|
|
@@ -14,10 +16,15 @@ class BlueprintWriter extends byte_writer_class_1.ByteWriter {
|
|
|
14
16
|
static SerializeHeader(writer, header) {
|
|
15
17
|
writer.writeInt32(2);
|
|
16
18
|
writer.writeInt32(42);
|
|
17
|
-
writer.writeInt32(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
writer.writeInt32(263910);
|
|
20
|
+
let dimensions = [
|
|
21
|
+
header.designerDimension?.x ?? 4,
|
|
22
|
+
header.designerDimension?.y ?? 4,
|
|
23
|
+
header.designerDimension?.z ?? 4,
|
|
24
|
+
].map(dim => dim < 4 ? 4 : dim);
|
|
25
|
+
writer.writeInt32(dimensions[0]);
|
|
26
|
+
writer.writeInt32(dimensions[1]);
|
|
27
|
+
writer.writeInt32(dimensions[2]);
|
|
21
28
|
writer.writeInt32(header.itemCosts.length);
|
|
22
29
|
for (const itemCost of header.itemCosts) {
|
|
23
30
|
writer.writeInt32(0);
|
|
@@ -45,7 +52,24 @@ class BlueprintWriter extends byte_writer_class_1.ByteWriter {
|
|
|
45
52
|
writer.writeInt32(0);
|
|
46
53
|
level_class_1.Level.SerializeObjectHeaders(writer, objects);
|
|
47
54
|
writer.writeBinarySizeFromPosition(headersLenIndicator, headersLenIndicator + 4);
|
|
48
|
-
|
|
55
|
+
BlueprintWriter.SerializeObjectContents(writer, objects, 0, '');
|
|
56
|
+
}
|
|
57
|
+
static SerializeObjectContents(writer, objects, buildVersion, levelName) {
|
|
58
|
+
const lenIndicatorEntities = writer.getBufferPosition();
|
|
59
|
+
writer.writeInt32(0);
|
|
60
|
+
writer.writeInt32(objects.length);
|
|
61
|
+
for (const obj of objects) {
|
|
62
|
+
const lenReplacementPosition = writer.getBufferPosition();
|
|
63
|
+
writer.writeInt32(0);
|
|
64
|
+
if ((0, SaveEntity_1.isSaveEntity)(obj)) {
|
|
65
|
+
SaveEntity_1.SaveEntity.SerializeData(writer, obj, buildVersion);
|
|
66
|
+
}
|
|
67
|
+
else if ((0, SaveComponent_1.isSaveComponent)(obj)) {
|
|
68
|
+
SaveComponent_1.SaveComponent.SerializeData(writer, obj, buildVersion);
|
|
69
|
+
}
|
|
70
|
+
writer.writeBinarySizeFromPosition(lenReplacementPosition, lenReplacementPosition + 4);
|
|
71
|
+
}
|
|
72
|
+
writer.writeBinarySizeFromPosition(lenIndicatorEntities, lenIndicatorEntities + 4);
|
|
49
73
|
}
|
|
50
74
|
}
|
|
51
75
|
exports.BlueprintWriter = BlueprintWriter;
|
|
@@ -72,7 +72,7 @@ class SaveWriter extends byte_writer_class_1.ByteWriter {
|
|
|
72
72
|
const saveBody = new Uint8Array(bufferArray.byteLength + 4);
|
|
73
73
|
saveBody.set(new Uint8Array(bufferArray), 4);
|
|
74
74
|
const miniView = new DataView(saveBody.buffer);
|
|
75
|
-
miniView.setInt32(0, totalUncompressedSize
|
|
75
|
+
miniView.setInt32(0, totalUncompressedSize, alignment === alignment_enum_1.Alignment.LITTLE_ENDIAN);
|
|
76
76
|
onBinaryBeforeCompressing(saveBody.buffer);
|
|
77
77
|
let handledByte = 0;
|
|
78
78
|
const chunkSummary = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etothepii/satisfactory-file-parser",
|
|
3
3
|
"author": "etothepii",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.21",
|
|
5
5
|
"description": "A file parser for satisfactory files. Includes save files and blueprint files.",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
7
7
|
"main": "./build/index.js",
|