madden-franchise 2.3.6 → 2.3.7

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.
@@ -98,6 +98,8 @@ class FranchiseFileTable extends EventEmitter {
98
98
  this.updateBuffer();
99
99
  this.emptyRecords = this._parseEmptyRecords();
100
100
  }
101
+
102
+ this.emit('change');
101
103
  };
102
104
 
103
105
  // attribsToLoad is an array of attribute names (strings) to load. It is optional - if nothing is provided to the function it will load all attributes.
@@ -251,8 +253,21 @@ class FranchiseFileTable extends EventEmitter {
251
253
  // The field was not empty, let's check if it is now
252
254
  const referenceData = utilService.getReferenceData(this._data.slice(0, 32));
253
255
  if (referenceData.tableId === 0) {
254
- // In this case, the record is now empty. Add an entry to the empty record map
255
- // onRecordEmpty(this);
256
+ // The record has a reference to table id 0, now we need to see if its referencing the 0th record or not
257
+ // We have to be careful not to mistake a null reference for an empty reference to record 0
258
+ if (referenceData.rowNumber !== 0) {
259
+ // If the value is referencing a row number greater than 0, we need to treat this record as an empty reference.
260
+ // onRecordEmpty(record);
261
+ }
262
+ else {
263
+ // The record was updated to either be a null reference or an empty record reference to row 0.
264
+ // First let's make sure we aren't editing row 0...if we are, then the value is a null reference
265
+ // because a record cannot point to itself.
266
+ if (this.index > 0) {
267
+ // Now that we know that the edit isn't coming from row 0, let's check if row 0 is an empty reference.
268
+ // If it is NOT an empty reference, then the updated value is not an empty reference.
269
+ }
270
+ }
256
271
  }
257
272
  }
258
273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const zlib = require('zlib');
3
3
 
4
- const filePath = 'D:\\Projects\\Madden 22\\Expressions\\franchise-expressions-binary.frt';
4
+ const filePath = 'D:\\Projects\\Madden 22\\Expressions\\sabo-expression-binary.frt';
5
5
  const outputPath = 'D:\\Projects\\Madden 22\\Expressions\\modified-Franchise-Expression-binary.FTC'
6
6
 
7
7
  const stream = fs.createReadStream(filePath)
@@ -13,6 +13,9 @@ CommonAlgorithms.save = (units, oldData) => {
13
13
  let oldOffsetCounter = 0;
14
14
  let bufferArrays = [];
15
15
 
16
+ // Ensure the units are sorted by index in the actual file. Otherwise, we may overwrite data
17
+ units.sort((a, b) => { return a.index - b.index; });
18
+
16
19
  units.forEach((unit, index) => {
17
20
  if (unit.offset === 0 && index > 0) {
18
21
  // there are usually trailing records at the end of the table that reference
@@ -3,7 +3,8 @@ let FranchiseTableStrategy = {};
3
3
  FranchiseTableStrategy.getTable2BinaryData = (table2Records, fullTable2Buffer) => {
4
4
  let table2Data = [];
5
5
 
6
- const changedTable2Records = table2Records.filter((record) => { return record.isChanged; });
6
+ // Make sure to sort the table2 records by index
7
+ const changedTable2Records = table2Records.filter((record) => { return record.isChanged; }).sort((a, b) => { return a.index - b.index; });
7
8
  let currentOffset = 0;
8
9
 
9
10
  for (let i = 0; i < changedTable2Records.length; i++) {