madden-franchise 2.3.8 → 2.3.13

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.
@@ -103,7 +103,7 @@ class FranchiseFileTable extends EventEmitter {
103
103
  this.header.nextRecordToUse = index;
104
104
 
105
105
  // And finally update the buffer to reflect this change
106
- this.data.writeUInt32BE(index, this.header.headerOffset - 4);
106
+ this.data.writeUInt32BE(index, this.header.offsetStart - 4);
107
107
  };
108
108
 
109
109
  recalculateEmptyRecordReferences() {
@@ -149,9 +149,38 @@ class FranchiseFileTable extends EventEmitter {
149
149
  + `The nextRecordToUse has NOT been updated.`);
150
150
  }
151
151
  else {
152
- const nextRecordToUse = unreachableRecords[0];
153
- this._setNextRecordToUseBuffer(nextRecordToUse.index);
152
+ let nextRecordToUse = this.header.recordCapacity;
153
+
154
+ if (unreachableRecords.length === 1) {
155
+ nextRecordToUse = unreachableRecords[0].index;
156
+ }
157
+
158
+ this._setNextRecordToUseBuffer(nextRecordToUse);
154
159
  this.emptyRecords = this._parseEmptyRecords();
160
+ this.emit('change');
161
+ }
162
+ };
163
+
164
+ async replaceRawData(buf, shouldReadRecords) {
165
+ this.data = buf;
166
+
167
+ // Reset fields
168
+ this.recordsRead = false;
169
+ this.header = this.strategy.parseHeader(this.data);
170
+ this.name = this.header.name;
171
+ this.isArray = this.header.isArray;
172
+ this.loadedOffsets = [];
173
+ this.isChanged = false;
174
+ this.records = [];
175
+ this.table2Records = [];
176
+ this.arraySizes = [];
177
+ this.emptyRecords = new Map();
178
+
179
+ this.emit('change');
180
+
181
+ // Re-read records if desired
182
+ if (shouldReadRecords) {
183
+ return this.readRecords();
155
184
  }
156
185
  };
157
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.3.8",
3
+ "version": "2.3.13",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {