madden-franchise 2.3.1 → 2.3.2
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/FranchiseFileRecord.js +2 -0
- package/FranchiseFileTable.js +62 -43
- package/package.json +1 -1
package/FranchiseFileRecord.js
CHANGED
|
@@ -11,6 +11,7 @@ class FranchiseFileRecord extends EventEmitter {
|
|
|
11
11
|
this._fields = parseRecordFields(data, offsetTable);
|
|
12
12
|
this.isChanged = false;
|
|
13
13
|
this.arraySize = null;
|
|
14
|
+
this.isEmpty = false;
|
|
14
15
|
|
|
15
16
|
const that = this;
|
|
16
17
|
this._fields.forEach((field) => {
|
|
@@ -87,6 +88,7 @@ class FranchiseFileRecord extends EventEmitter {
|
|
|
87
88
|
|
|
88
89
|
empty() {
|
|
89
90
|
this.emit('empty');
|
|
91
|
+
this.isEmpty = true;
|
|
90
92
|
};
|
|
91
93
|
};
|
|
92
94
|
|
package/FranchiseFileTable.js
CHANGED
|
@@ -149,6 +149,10 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
149
149
|
record.arraySize = this.arraySizes[index];
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
if (this.emptyRecords.get(index)) {
|
|
153
|
+
record.isEmpty = true;
|
|
154
|
+
}
|
|
155
|
+
|
|
152
156
|
const that = this;
|
|
153
157
|
record.on('change', function (changedOffset) {
|
|
154
158
|
this.isChanged = true;
|
|
@@ -171,6 +175,9 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
171
175
|
// Delete the empty record entry because it is no longer empty
|
|
172
176
|
that.emptyRecords.delete(this.index);
|
|
173
177
|
|
|
178
|
+
// Set the isEmpty back to false because it's no longer empty
|
|
179
|
+
this.isEmpty = false;
|
|
180
|
+
|
|
174
181
|
// Check if there is a previous empty record
|
|
175
182
|
const previousEmptyReference = that.emptyRecords.get(emptyRecordReference.previous);
|
|
176
183
|
|
|
@@ -214,49 +221,54 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
214
221
|
});
|
|
215
222
|
|
|
216
223
|
record.on('empty', function () {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
224
|
+
// First, check if the record is already empty. If so, don't do anything...
|
|
225
|
+
// If not empty, then we need to empty it.
|
|
226
|
+
if (!this.isEmpty) {
|
|
227
|
+
this.isChanged = true;
|
|
228
|
+
const lastEmptyRecordMapEntry = Array.from(that.emptyRecords).pop();
|
|
229
|
+
|
|
230
|
+
// When we empty a record, we need to check if another empty record exists in the table.
|
|
231
|
+
if (lastEmptyRecordMapEntry !== null && lastEmptyRecordMapEntry !== undefined) {
|
|
232
|
+
|
|
233
|
+
// If an empty record already exists, we just need to get the last empty record
|
|
234
|
+
// and update its index to point to the current record that we want to empty.
|
|
235
|
+
const lastEmptyRecordIndex = lastEmptyRecordMapEntry[0];
|
|
236
|
+
|
|
237
|
+
that.emptyRecords.set(lastEmptyRecordIndex, {
|
|
238
|
+
previous: lastEmptyRecordMapEntry[1].previous,
|
|
239
|
+
next: this.index
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Then we need to update the current record index to point to the record capacity.
|
|
243
|
+
that.emptyRecords.set(this.index, {
|
|
244
|
+
previous: lastEmptyRecordIndex,
|
|
245
|
+
next: that.header.recordCapacity
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Finally, we need to update the buffers to reflect this data.
|
|
249
|
+
// First, place the new referenced index (will be the first 4 bytes)
|
|
250
|
+
// Next, fill the rest of the record with 0s (the last bytes of the record)
|
|
251
|
+
|
|
252
|
+
// And update both record's data. This will set the unformatted and formatted values
|
|
253
|
+
// without emitting an event
|
|
254
|
+
changeRecordBuffers(lastEmptyRecordIndex, this.index);
|
|
255
|
+
changeRecordBuffers(this.index, that.header.recordCapacity);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
// In this case, the record that was emptied is the first empty record in the table
|
|
259
|
+
that.emptyRecords.set(this.index, {
|
|
260
|
+
previous: null,
|
|
261
|
+
next: that.header.recordCapacity
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// Finally update the table header and buffer so that the game uses this new empty
|
|
265
|
+
// record as the next record to use (or fill)
|
|
266
|
+
updateNextRecordToUseHeaderAndBuffer(this.index);
|
|
267
|
+
changeRecordBuffers(this.index, that.header.recordCapacity);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
that.emit('change');
|
|
257
271
|
}
|
|
258
|
-
|
|
259
|
-
that.emit('change');
|
|
260
272
|
});
|
|
261
273
|
|
|
262
274
|
function updateNextRecordToUseHeaderAndBuffer(nextRecordToUse) {
|
|
@@ -279,7 +291,14 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
279
291
|
};
|
|
280
292
|
|
|
281
293
|
function setRecordInternalBuffer(index, emptyRecordReference) {
|
|
282
|
-
|
|
294
|
+
let newData = utilService.dec2bin(emptyRecordReference, 32);
|
|
295
|
+
|
|
296
|
+
const recordSizeInBits = that.header.record1Size * 8;
|
|
297
|
+
if (recordSizeInBits > 32) {
|
|
298
|
+
newData += utilService.dec2bin(0, recordSizeInBits - 32);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
that.records[index].data = newData;
|
|
283
302
|
};
|
|
284
303
|
});
|
|
285
304
|
|