madden-franchise 3.0.6 → 3.1.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.
- package/FranchiseFile.js +1 -1
- package/FranchiseFileSettings.js +2 -1
- package/FranchiseFileTable.js +52 -49
- package/README.md +4 -0
- package/package.json +1 -1
package/FranchiseFile.js
CHANGED
|
@@ -117,7 +117,7 @@ class FranchiseFile extends EventEmitter {
|
|
|
117
117
|
|
|
118
118
|
const tableData = this.unpackedFileContents.slice(currentTable, nextTable);
|
|
119
119
|
|
|
120
|
-
const newFranchiseTable = new FranchiseFileTable(tableData, currentTable, this._gameYear, this.strategy);
|
|
120
|
+
const newFranchiseTable = new FranchiseFileTable(tableData, currentTable, this._gameYear, this.strategy, this.settings);
|
|
121
121
|
newFranchiseTable.index = i;
|
|
122
122
|
this.tables.push(newFranchiseTable);
|
|
123
123
|
|
package/FranchiseFileSettings.js
CHANGED
|
@@ -3,7 +3,8 @@ class FranchiseFileSettings {
|
|
|
3
3
|
this.saveOnChange = settings && settings.saveOnChange ? settings.saveOnChange : false;
|
|
4
4
|
this.schemaOverride = settings && settings.schemaOverride ? settings.schemaOverride: false;
|
|
5
5
|
this.schemaDirectory = settings && settings.schemaDirectory ? settings.schemaDirectory : false;
|
|
6
|
-
this.autoParse = settings && (settings.autoParse !== null && settings.autoParse !== undefined) ? settings.autoParse : true
|
|
6
|
+
this.autoParse = settings && (settings.autoParse !== null && settings.autoParse !== undefined) ? settings.autoParse : true;
|
|
7
|
+
this.autoUnempty = settings && (settings.autoUnempty !== null && settings.autoUnempty !== undefined) ? settings.autoUnempty : false;
|
|
7
8
|
}
|
|
8
9
|
};
|
|
9
10
|
|
package/FranchiseFileTable.js
CHANGED
|
@@ -4,7 +4,7 @@ const FranchiseFileRecord = require('./FranchiseFileRecord');
|
|
|
4
4
|
const FranchiseFileTable2Field = require('./FranchiseFileTable2Field');
|
|
5
5
|
|
|
6
6
|
class FranchiseFileTable extends EventEmitter {
|
|
7
|
-
constructor(data, offset, gameYear, strategy) {
|
|
7
|
+
constructor(data, offset, gameYear, strategy, settings) {
|
|
8
8
|
super();
|
|
9
9
|
this.index = -1;
|
|
10
10
|
this.data = data;
|
|
@@ -23,6 +23,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
23
23
|
this.table2Records = [];
|
|
24
24
|
this.arraySizes = [];
|
|
25
25
|
this.emptyRecords = new Map();
|
|
26
|
+
this._settings = settings;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
get hexData () {
|
|
@@ -426,10 +427,8 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
426
427
|
const emptyRecordReference = this.emptyRecords.get(object.index);
|
|
427
428
|
const changedRecordWasEmpty = emptyRecordReference !== null && emptyRecordReference !== undefined;
|
|
428
429
|
|
|
430
|
+
// Automatically un-empty the row if the setting is enabled and the changed record was empty.
|
|
429
431
|
if (changedRecordWasEmpty) {
|
|
430
|
-
// 1/5/23: Assume all changes to a field make the record not empty. Leaving comments
|
|
431
|
-
// below if this needs to be reverted in the future.
|
|
432
|
-
|
|
433
432
|
|
|
434
433
|
// Check if the record's first four bytes still have a reference to the 0th table.
|
|
435
434
|
// If so, then the record is still considered empty.
|
|
@@ -442,7 +441,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
442
441
|
// if the changed field isn't included in the first 32 bits, zero out the first 32 bits.
|
|
443
442
|
// Otherwise, it's not necessary to zero out.
|
|
444
443
|
const changedFieldsInFirst4Bytes = object.fieldsArray.filter((field) => { return field.isChanged && field.offset.indexOffset < 32; });
|
|
445
|
-
if (changedFieldsInFirst4Bytes.length === 0) {
|
|
444
|
+
if (this._settings.autoUnempty && changedFieldsInFirst4Bytes.length === 0) {
|
|
446
445
|
// set first 4 bytes to 0
|
|
447
446
|
this._changeRecordBuffers(object.index, 0);
|
|
448
447
|
|
|
@@ -452,53 +451,57 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
452
451
|
field.clearCachedValues();
|
|
453
452
|
});
|
|
454
453
|
}
|
|
454
|
+
|
|
455
|
+
// If autoUnempty is disabled, only un-empty the row if a field in the first 4 bytes changed.
|
|
456
|
+
// If autoUnempty is enabled, un-empty the row if ANY field changed.
|
|
457
|
+
if (this._settings.autoUnempty || changedFieldsInFirst4Bytes.length > 0) {
|
|
458
|
+
// if the record contains any string values, point the string values to
|
|
459
|
+
// their correct offsets
|
|
460
|
+
this.strategy.recalculateStringOffsets(this, object);
|
|
461
|
+
|
|
462
|
+
// Delete the empty record entry because it is no longer empty
|
|
463
|
+
this.emptyRecords.delete(object.index);
|
|
464
|
+
|
|
465
|
+
// Set the isEmpty back to false because it's no longer empty
|
|
466
|
+
object.isEmpty = false;
|
|
467
|
+
|
|
468
|
+
// Check if there is a previous empty record
|
|
469
|
+
const previousEmptyReference = this.emptyRecords.get(emptyRecordReference.previous);
|
|
470
|
+
|
|
471
|
+
if (previousEmptyReference) {
|
|
472
|
+
// Set the previous empty record to point to the old reference's next node
|
|
473
|
+
this.emptyRecords.set(emptyRecordReference.previous, {
|
|
474
|
+
previous: this.emptyRecords.get(emptyRecordReference.previous).previous,
|
|
475
|
+
next: emptyRecordReference.next
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// change the table buffer and record buffer to reflect object change
|
|
479
|
+
this._changeRecordBuffers(emptyRecordReference.previous, emptyRecordReference.next);
|
|
480
|
+
}
|
|
455
481
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
this.emptyRecords.set(emptyRecordReference.previous, {
|
|
472
|
-
previous: this.emptyRecords.get(emptyRecordReference.previous).previous,
|
|
473
|
-
next: emptyRecordReference.next
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
// change the table buffer and record buffer to reflect object change
|
|
477
|
-
this._changeRecordBuffers(emptyRecordReference.previous, emptyRecordReference.next);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// If there is a next empty reference, update the previous value accordingly to now point
|
|
481
|
-
// to the current record's previous index.
|
|
482
|
-
const nextEmptyReference = this.emptyRecords.get(emptyRecordReference.next);
|
|
483
|
-
|
|
484
|
-
if (nextEmptyReference) {
|
|
485
|
-
this.emptyRecords.set(emptyRecordReference.next, {
|
|
486
|
-
previous: emptyRecordReference.previous,
|
|
487
|
-
next: this.emptyRecords.get(emptyRecordReference.next).next
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
if (!previousEmptyReference) {
|
|
491
|
-
// If no previous empty record exists and a next record exists, we need to update the header to
|
|
492
|
-
// point to object record as the next record to use.
|
|
493
|
-
this.setNextRecordToUse(emptyRecordReference.next);
|
|
482
|
+
// If there is a next empty reference, update the previous value accordingly to now point
|
|
483
|
+
// to the current record's previous index.
|
|
484
|
+
const nextEmptyReference = this.emptyRecords.get(emptyRecordReference.next);
|
|
485
|
+
|
|
486
|
+
if (nextEmptyReference) {
|
|
487
|
+
this.emptyRecords.set(emptyRecordReference.next, {
|
|
488
|
+
previous: emptyRecordReference.previous,
|
|
489
|
+
next: this.emptyRecords.get(emptyRecordReference.next).next
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
if (!previousEmptyReference) {
|
|
493
|
+
// If no previous empty record exists and a next record exists, we need to update the header to
|
|
494
|
+
// point to object record as the next record to use.
|
|
495
|
+
this.setNextRecordToUse(emptyRecordReference.next);
|
|
496
|
+
}
|
|
494
497
|
}
|
|
495
|
-
}
|
|
496
498
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
499
|
+
// If there are no previous or next empty references
|
|
500
|
+
// Then there are no more empty references in the table
|
|
501
|
+
// Update the table header nextRecordToUse back to the table record capacity
|
|
502
|
+
if (!previousEmptyReference && !nextEmptyReference) {
|
|
503
|
+
this.setNextRecordToUse(this.header.recordCapacity);
|
|
504
|
+
}
|
|
502
505
|
}
|
|
503
506
|
// }
|
|
504
507
|
}
|
package/README.md
CHANGED
|
@@ -49,6 +49,10 @@ Franchise file settings
|
|
|
49
49
|
|
|
50
50
|
// AUTO PARSE - specify if you want the system to automatically parse all tables in the file, or if you want to explicity call file.parse()
|
|
51
51
|
'autoParse': true/false [default: true]
|
|
52
|
+
|
|
53
|
+
// AUTO UNEMPTY - specify if you want the system to automatically determine if an empty field should become un-empty once you edit it.
|
|
54
|
+
// Warning: may have unintended side-effects if you batch import. Enable with caution.
|
|
55
|
+
'autoUnempty': true/false [default: false]
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
#### fields
|