madden-franchise 3.2.0 → 3.2.1

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.
@@ -1,6 +1,3 @@
1
- const EventEmitter = require('events').EventEmitter;
2
- const utilService = require('./services/utilService');
3
-
4
1
  class FranchiseFileTable3Field {
5
2
  constructor (index, maxLength, parent) {
6
3
  this._value = '';
@@ -42,7 +39,7 @@ class FranchiseFileTable3Field {
42
39
 
43
40
  set value (value) {
44
41
  this._value = value;
45
- this._unformattedValue = this._strategy.setUnformattedValueFromFormatted(value, this.maxLength);
42
+ this._unformattedValue = this._strategy.setUnformattedValueFromFormatted(value, this._unformattedValue, this.maxLength);
46
43
 
47
44
  if (this.lengthAtLastSave === null) {
48
45
  this.lengthAtLastSave = getLengthOfUnformattedValue(this._unformattedValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {
@@ -45,8 +45,8 @@ const schemaPath = 'C:\\Users\\Matt\\AppData\\Roaming\\madden-franchise-editor\\
45
45
  table3s.forEach((table) => { console.log(`${table.header.tableId} - ${table.name}`)});
46
46
 
47
47
  const buf = fs.readFileSync('D:\\Projects\\Madden 24\\franchise\\characterVisualIsolated.dat');
48
- const test = zlib.gunzipSync(buf.subarray(2));
49
- // fs.writeFileSync('D:\\Projects\\Madden 24\\franchise\\characterVisualUnzipped.dat', test);
48
+ const test = zlib.gunzipSync(buf.subarray(3));
49
+ fs.writeFileSync('D:\\Projects\\Madden 24\\franchise\\characterVisualUnzipped.dat', test);
50
50
  const test2 = zlib.gzipSync(test);
51
51
  console.log(test2);
52
52
  })();
@@ -2,16 +2,21 @@ const zlib = require('zlib');
2
2
 
3
3
  let FranchiseTable3FieldStrategy = {};
4
4
 
5
+ FranchiseTable3FieldStrategy.getZlibDataStartIndex = (unformattedValue) => {
6
+ return unformattedValue.indexOf(Buffer.from([0x1F, 0x8B]));
7
+ };
8
+
5
9
  FranchiseTable3FieldStrategy.getInitialUnformattedValue = (field, data) => {
6
10
  return data.slice(field.thirdTableField.index, (field.thirdTableField.index + field.offset.maxLength + 2));
7
11
  // extend maxLength + 2 because the first 2 bytes are the size of the zipped data
8
12
  };
9
13
 
10
14
  FranchiseTable3FieldStrategy.getFormattedValueFromUnformatted = (unformattedValue) => {
11
- return zlib.gunzipSync(unformattedValue.subarray(2)).toString(); // first 2 bytes are the size of the zipped data, so skip those.
15
+ const zlibDataStartIndex = FranchiseTable3FieldStrategy.getZlibDataStartIndex(unformattedValue);
16
+ return zlib.gunzipSync(unformattedValue.subarray(zlibDataStartIndex)).toString(); // first few bytes are the size of the zipped data & other flags, so skip those.
12
17
  };
13
18
 
14
- FranchiseTable3FieldStrategy.setUnformattedValueFromFormatted = (formattedValue, maxLength) => {
19
+ FranchiseTable3FieldStrategy.setUnformattedValueFromFormatted = (formattedValue, oldUnformattedValue, maxLength) => {
15
20
  let zippedData = zlib.gzipSync(formattedValue);
16
21
  let padding = Buffer.alloc(maxLength - zippedData.length); // table3s all have the same length and are zero padded to the end.
17
22