madden-franchise 3.0.1 → 3.0.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 +26 -7
- package/package.json +1 -1
- package/scripts/deflate.js +1 -1
- package/scripts/inflate.js +3 -3
- package/services/utilService.js +1 -1
- package/strategies/common/table/FranchiseTableStrategy.js +24 -0
- package/strategies/franchise/m19/M19TableStrategy.js +1 -0
- package/strategies/franchise/m20/M20TableStrategy.js +1 -0
- package/strategies/franchise-common/m19/M19FTCTableStrategy.js +1 -0
- package/strategies/franchise-common/m20/M20FTCTableStrategy.js +1 -0
package/FranchiseFileTable.js
CHANGED
|
@@ -96,6 +96,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
96
96
|
|
|
97
97
|
bufferArrays.push(this.data.slice(currentOffset, recordOffset));
|
|
98
98
|
const recordHexData = record.hexData;
|
|
99
|
+
|
|
99
100
|
bufferArrays.push(recordHexData);
|
|
100
101
|
currentOffset = recordOffset + recordHexData.length;
|
|
101
102
|
}
|
|
@@ -153,6 +154,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
153
154
|
record.isEmpty = isEmptyReference;
|
|
154
155
|
});
|
|
155
156
|
|
|
157
|
+
|
|
156
158
|
// We need to determine the starting node.
|
|
157
159
|
// To do that, we need to find the empty record which no other empty record points to.
|
|
158
160
|
const unreachableRecords = this.records.filter((record) => { return record.isEmpty; }).filter((record) => {
|
|
@@ -426,12 +428,20 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
426
428
|
const changedRecordWasEmpty = emptyRecordReference !== null && emptyRecordReference !== undefined;
|
|
427
429
|
|
|
428
430
|
if (changedRecordWasEmpty) {
|
|
429
|
-
//
|
|
430
|
-
//
|
|
431
|
+
// 1/5/23: Assume all changes to a field make the record not empty. Leaving comments
|
|
432
|
+
// below if this needs to be reverted in the future.
|
|
431
433
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
434
|
+
|
|
435
|
+
// Check if the record's first four bytes still have a reference to the 0th table.
|
|
436
|
+
// If so, then the record is still considered empty.
|
|
437
|
+
|
|
438
|
+
// We need to check the buffer because the first field is not always a reference.
|
|
439
|
+
// const referenceData = utilService.getReferenceDataFromBuffer(object.data.slice(0, 4));
|
|
440
|
+
// if (referenceData.tableId !== 0 || referenceData.rowNumber > this.header.recordCapacity) {
|
|
441
|
+
|
|
442
|
+
// if the record contains any string values, point the string values to
|
|
443
|
+
// their correct offsets
|
|
444
|
+
this.strategy.recalculateStringOffsets(this, object);
|
|
435
445
|
|
|
436
446
|
// Delete the empty record entry because it is no longer empty
|
|
437
447
|
this.emptyRecords.delete(object.index);
|
|
@@ -476,7 +486,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
476
486
|
if (!previousEmptyReference && !nextEmptyReference) {
|
|
477
487
|
this.setNextRecordToUse(this.header.recordCapacity);
|
|
478
488
|
}
|
|
479
|
-
}
|
|
489
|
+
// }
|
|
480
490
|
}
|
|
481
491
|
}
|
|
482
492
|
|
|
@@ -489,7 +499,16 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
489
499
|
}
|
|
490
500
|
else if (object instanceof FranchiseFileTable2Field) {
|
|
491
501
|
object.isChanged = true;
|
|
492
|
-
|
|
502
|
+
|
|
503
|
+
// When a table2 field changes, we need to check if the record is empty. If so, we need to mark it as not empty.
|
|
504
|
+
if (object.fieldReference) {
|
|
505
|
+
this.onEvent('change', object.fieldReference._parent);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
// Only emit change here if the field reference is empty.
|
|
509
|
+
// the onEvent call will emit a change in the above condition.
|
|
510
|
+
this.emit('change');
|
|
511
|
+
}
|
|
493
512
|
}
|
|
494
513
|
};
|
|
495
514
|
};
|
package/package.json
CHANGED
package/scripts/deflate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const zlib = require('zlib');
|
|
3
3
|
|
|
4
|
-
const filePath = 'D:\\Projects\\Madden
|
|
4
|
+
const filePath = 'D:\\Projects\\Madden 23\\FranTkData\\Franchise-Expression-binary.frt';
|
|
5
5
|
const outputPath = 'D:\\Projects\\Madden 22\\Update issue\\Expressions\\Franchise-Expression-binaryMERGED.FTC'
|
|
6
6
|
|
|
7
7
|
const stream = fs.createReadStream(filePath)
|
package/scripts/inflate.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const zlib = require('zlib');
|
|
3
3
|
|
|
4
|
-
const filePath = '
|
|
5
|
-
const outputPath = '
|
|
4
|
+
const filePath = 'D:\\Projects\\Madden 23\\FranTkData\\Franchise-Expression-binary.FTC';
|
|
5
|
+
const outputPath = 'D:\\Projects\\Madden 23\\FranTkData\\Franchise-Expression-binary.ftx'
|
|
6
6
|
|
|
7
7
|
const fileData = fs.readFileSync(filePath);
|
|
8
|
-
const inflateData = zlib.inflateSync(fileData
|
|
8
|
+
const inflateData = zlib.inflateSync(fileData);
|
|
9
9
|
fs.writeFileSync(outputPath, inflateData);
|
|
10
10
|
|
|
11
11
|
// let notDone = true;
|
package/services/utilService.js
CHANGED
|
@@ -221,7 +221,7 @@ utilService.toInteger = function (x) {
|
|
|
221
221
|
utilService.getReferenceData = function (value) {
|
|
222
222
|
return {
|
|
223
223
|
'tableId': utilService.bin2dec(value.substring(0, 15)),
|
|
224
|
-
'rowNumber': utilService.bin2dec(value.substring(
|
|
224
|
+
'rowNumber': utilService.bin2dec(value.substring(15))
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
227
|
|
|
@@ -33,4 +33,28 @@ FranchiseTableStrategy.getMandatoryOffsets = (offsets) => {
|
|
|
33
33
|
return [];
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
FranchiseTableStrategy.recalculateStringOffsets = (table, record) => {
|
|
37
|
+
// First, calculate length allocated per record in table2
|
|
38
|
+
const byteLengthPerRecord = table.offsetTable.filter((offsetEntry) => {
|
|
39
|
+
return offsetEntry.type === 'string';
|
|
40
|
+
}).reduce((accum, cur) => {
|
|
41
|
+
return accum + cur.maxLength;
|
|
42
|
+
}, 0);
|
|
43
|
+
|
|
44
|
+
// Then, go through each string field sorted by offset index, and assign offsets to the table2 fields
|
|
45
|
+
let runningOffset = 0;
|
|
46
|
+
|
|
47
|
+
record.fieldsArray.filter((field) => {
|
|
48
|
+
return field.offset.type === 'string';
|
|
49
|
+
}).sort((a, b) => {
|
|
50
|
+
return a.offset.index - b.offset.index;
|
|
51
|
+
}).forEach((field) => {
|
|
52
|
+
if (field.secondTableField) {
|
|
53
|
+
field.secondTableField.offset = (record.index * byteLengthPerRecord) + runningOffset;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
runningOffset += field.offset.maxLength;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
36
60
|
module.exports = FranchiseTableStrategy;
|
|
@@ -8,5 +8,6 @@ M19TableStrategy.parseHeaderAttributesFromSchema = M19TableHeaderStrategy.parseH
|
|
|
8
8
|
|
|
9
9
|
M19TableStrategy.getTable2BinaryData = FranchiseTableStrategy.getTable2BinaryData;
|
|
10
10
|
M19TableStrategy.getMandatoryOffsets = FranchiseTableStrategy.getMandatoryOffsets;
|
|
11
|
+
M19TableStrategy.recalculateStringOffsets = FranchiseTableStrategy.recalculateStringOffsets;
|
|
11
12
|
|
|
12
13
|
module.exports = M19TableStrategy;
|
|
@@ -8,5 +8,6 @@ M20TableStrategy.parseHeaderAttributesFromSchema = M20TableHeaderStrategy.parseH
|
|
|
8
8
|
|
|
9
9
|
M20TableStrategy.getTable2BinaryData = FranchiseTableStrategy.getTable2BinaryData;
|
|
10
10
|
M20TableStrategy.getMandatoryOffsets = FranchiseTableStrategy.getMandatoryOffsets;
|
|
11
|
+
M20TableStrategy.recalculateStringOffsets = FranchiseTableStrategy.recalculateStringOffsets;
|
|
11
12
|
|
|
12
13
|
module.exports = M20TableStrategy;
|
|
@@ -8,5 +8,6 @@ M19FTCTableStrategy.parseHeaderAttributesFromSchema = M19TableHeaderStrategy.par
|
|
|
8
8
|
|
|
9
9
|
M19FTCTableStrategy.getTable2BinaryData = FTCTableStrategy.getTable2BinaryData;
|
|
10
10
|
M19FTCTableStrategy.getMandatoryOffsets = FTCTableStrategy.getMandatoryOffsets;
|
|
11
|
+
M19FTCTableStrategy.recalculateStringOffsets = () => {};
|
|
11
12
|
|
|
12
13
|
module.exports = M19FTCTableStrategy;
|
|
@@ -8,5 +8,6 @@ M20FTCTableStrategy.parseHeaderAttributesFromSchema = M20TableHeaderStrategy.par
|
|
|
8
8
|
|
|
9
9
|
M20FTCTableStrategy.getTable2BinaryData = FTCTableStrategy.getTable2BinaryData;
|
|
10
10
|
M20FTCTableStrategy.getMandatoryOffsets = FTCTableStrategy.getMandatoryOffsets;
|
|
11
|
+
M20FTCTableStrategy.recalculateStringOffsets = () => {};
|
|
11
12
|
|
|
12
13
|
module.exports = M20FTCTableStrategy;
|