@etothepii/satisfactory-file-parser 0.4.11 → 0.4.12

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 CHANGED
@@ -18,25 +18,15 @@ Game Version Files of U5 and below are NOT supported.
18
18
  | <= U5 | ❌ |
19
19
  | U6 + U7 | ✅ 0.0.1 - 0.0.34 |
20
20
  | U8 | ✅ 0.1.20 - 0.3.7 |
21
- | U1.0 | ✅ >= 0.4.11 |
21
+ | U1.0 | ✅ >= 0.4.12 |
22
22
 
23
23
 
24
24
  ## Installation via npm
25
25
  `npm install @etothepii/satisfactory-file-parser`
26
26
 
27
27
  ## Usage of Save Parsing
28
- For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
29
- ```js
30
- import * as fs from 'fs';
31
- import { Parser } from "@etothepii/satisfactory-file-parser";
32
28
 
33
- const file = fs.readFileSync('./MySave.sav') as Buffer;
34
- const parsedSave = Parser.ParseSaveFile(file);
35
- ```
36
-
37
- ### Save Parsing via Stream
38
-
39
- You can parse via stream, to save RAM. The binary data will still be in memory, but the converted JSON won't.
29
+ I recommend parsing via stream, to save RAM. The binary data of the whole save will still be in memory, but the converted JSON won't.
40
30
  The returned `stream` is a readable WHATWG stream of type string.
41
31
  WHATWG is used by default by browsers. Node js can use them using `Writable.toWeb()` and `Writable.fromWeb()` for example.
42
32
 
@@ -82,6 +72,18 @@ Parser.WriteSave(save, binaryBeforeCompressed => {
82
72
  fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header!, ...bodyChunks]));
83
73
  ```
84
74
 
75
+
76
+ ### Old Usage of Save Parsing. Deprecated.
77
+ For reading a save file (`.sav`) and parse In-Memory, just pass a Buffer to the parser with the file content.
78
+ ```js
79
+ import * as fs from 'fs';
80
+ import { Parser } from "@etothepii/satisfactory-file-parser";
81
+
82
+ const file = fs.readFileSync('./MySave.sav') as Buffer;
83
+ const parsedSave = Parser.ParseSaveFile(file);
84
+ ```
85
+
86
+
85
87
  ## Usage of Blueprint Parsing
86
88
  Blueprint parsing works very similiar. Note, that blueprints consist of 2 files. The `.sbp` main file and the config file `.sbpcfg`.
87
89
 
@@ -34,7 +34,11 @@ class StructProperty extends BasicProperty_1.AbstractBaseProperty {
34
34
  struct.value = StructProperty.ParseValue(reader, struct.subtype, size);
35
35
  const readBytes = reader.getBufferPosition() - before;
36
36
  if (readBytes !== size) {
37
- throw new Error(`possibly corrupt. Read ${readBytes} for StructProperty Content of ${struct.subtype}, but ${size} were indicated.`);
37
+ if (size - readBytes === 4 && reader.readInt32() === 0) {
38
+ }
39
+ else {
40
+ throw new Error(`possibly corrupt. Read ${readBytes} for StructProperty Content of ${struct.subtype}, but ${size} were indicated.`);
41
+ }
38
42
  }
39
43
  return struct;
40
44
  }
@@ -152,9 +152,6 @@ class Level {
152
152
  const collectable = ObjectReference_1.ObjectReference.read(reader);
153
153
  collected.push(collectable);
154
154
  }
155
- if (process.env.NODE_ENV === 'debug' && countSmthing > 0) {
156
- console.log(printSmthWhenItsCollectables, countSmthing, collected.map(coll => coll.pathName).join(', '));
157
- }
158
155
  }
159
156
  return collected;
160
157
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@etothepii/satisfactory-file-parser",
3
3
  "author": "etothepii",
4
- "version": "0.4.11",
4
+ "version": "0.4.12",
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",