madden-franchise 2.3.2 → 2.3.3
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/FranchiseFileTable.js +60 -48
- package/package.json +1 -1
package/FranchiseFileTable.js
CHANGED
|
@@ -165,56 +165,68 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
165
165
|
// If so, we need to consider the record as no longer empty
|
|
166
166
|
// So we need to adjust the empty records
|
|
167
167
|
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
168
|
+
// First, check if the record's length is greater than 4 bytes (32 bits)
|
|
169
|
+
// If less than 4 bytes, it can never become empty...probably. :)
|
|
170
|
+
if (that.header.record1Size >= 4) {
|
|
171
|
+
|
|
172
|
+
// Ex: Empty record list looks like this: A -> B -> C
|
|
173
|
+
// When B's value is changed, the records need updated to: A -> C
|
|
174
|
+
const emptyRecordReference = that.emptyRecords.get(this.index);
|
|
175
|
+
const changedRecordWasEmpty = emptyRecordReference !== null && emptyRecordReference !== undefined;
|
|
176
|
+
|
|
177
|
+
if (changedRecordWasEmpty) {
|
|
178
|
+
// Check if the record's first four bytes still have a reference to the 0th table.
|
|
179
|
+
// If so, then the record is still considered empty.
|
|
180
|
+
|
|
181
|
+
// We need to check the buffer because the first field is not always a reference.
|
|
182
|
+
const referenceData = utilService.getReferenceData(this._data.slice(0, 32));
|
|
183
|
+
if (referenceData.tableId !== 0) {
|
|
184
|
+
|
|
185
|
+
// Delete the empty record entry because it is no longer empty
|
|
186
|
+
that.emptyRecords.delete(this.index);
|
|
187
|
+
|
|
188
|
+
// Set the isEmpty back to false because it's no longer empty
|
|
189
|
+
this.isEmpty = false;
|
|
190
|
+
|
|
191
|
+
// Check if there is a previous empty record
|
|
192
|
+
const previousEmptyReference = that.emptyRecords.get(emptyRecordReference.previous);
|
|
193
|
+
|
|
194
|
+
if (previousEmptyReference) {
|
|
195
|
+
// Set the previous empty record to point to the old reference's next node
|
|
196
|
+
that.emptyRecords.set(emptyRecordReference.previous, {
|
|
197
|
+
previous: that.emptyRecords.get(emptyRecordReference.previous).previous,
|
|
198
|
+
next: emptyRecordReference.next
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// change the table buffer and record buffer to reflect this change
|
|
202
|
+
changeRecordBuffers(emptyRecordReference.previous, emptyRecordReference.next);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// If there is a next empty reference, update the previous value accordingly to now point
|
|
206
|
+
// to the current record's previous index.
|
|
207
|
+
const nextEmptyReference = that.emptyRecords.get(emptyRecordReference.next);
|
|
208
|
+
|
|
209
|
+
if (nextEmptyReference) {
|
|
210
|
+
that.emptyRecords.set(emptyRecordReference.next, {
|
|
211
|
+
previous: emptyRecordReference.previous,
|
|
212
|
+
next: that.emptyRecords.get(emptyRecordReference.next).next
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (!previousEmptyReference) {
|
|
216
|
+
// If no previous empty record exists and a next record exists, we need to update the header to
|
|
217
|
+
// point to this record as the next record to use.
|
|
218
|
+
updateNextRecordToUseHeaderAndBuffer(emptyRecordReference.next);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// If there are no previous or next empty references
|
|
223
|
+
// Then there are no more empty references in the table
|
|
224
|
+
// Update the table header nextRecordToUse back to the table record capacity
|
|
225
|
+
if (!previousEmptyReference && !nextEmptyReference) {
|
|
226
|
+
updateNextRecordToUseHeaderAndBuffer(that.header.recordCapacity);
|
|
227
|
+
}
|
|
209
228
|
}
|
|
210
229
|
}
|
|
211
|
-
|
|
212
|
-
// If there are no previous or next empty references
|
|
213
|
-
// Then there are no more empty references in the table
|
|
214
|
-
// Update the table header nextRecordToUse back to the table record capacity
|
|
215
|
-
if (!previousEmptyReference && !nextEmptyReference) {
|
|
216
|
-
updateNextRecordToUseHeaderAndBuffer(that.header.recordCapacity);
|
|
217
|
-
}
|
|
218
230
|
}
|
|
219
231
|
|
|
220
232
|
that.emit('change');
|