madden-franchise 2.3.13 → 2.4.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 +30 -2
- package/FranchiseFileTable.js +21 -1
- package/package.json +1 -1
- package/scripts/deflate.js +2 -2
- package/services/schemaPicker.js +8 -1
- package/services/utilService.js +6 -0
- package/strategies/common/table/FTCTableStrategy.js +3 -1
- package/strategies/common/table/FranchiseTableStrategy.js +11 -11
package/FranchiseFile.js
CHANGED
|
@@ -286,6 +286,34 @@ class FranchiseFile extends EventEmitter {
|
|
|
286
286
|
return null;
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
+
|
|
290
|
+
getReferencesToRecord(tableId, recordIndex) {
|
|
291
|
+
const referencedTable = this.getTableById(tableId);
|
|
292
|
+
|
|
293
|
+
if (referencedTable) {
|
|
294
|
+
const fullBinary = utilService.getBinaryReferenceData(tableId, recordIndex);
|
|
295
|
+
const hex = utilService.bin2hex(fullBinary);
|
|
296
|
+
|
|
297
|
+
return this.tables.filter((table) => {
|
|
298
|
+
if (table.schema) {
|
|
299
|
+
return table.schema && table.schema.attributes.find((attribute) => {
|
|
300
|
+
return attribute.type === referencedTable.name;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
else if (table.isArray) {
|
|
304
|
+
return table.name.slice(0, table.name.length - 2) === referencedTable.name;
|
|
305
|
+
}
|
|
306
|
+
}).filter((table) => {
|
|
307
|
+
return table.data.indexOf(hex, 0, 'hex') !== -1;
|
|
308
|
+
}).map((table) => {
|
|
309
|
+
return {
|
|
310
|
+
tableId: table.header.tableId,
|
|
311
|
+
name: table.name,
|
|
312
|
+
table: table
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
};
|
|
289
317
|
};
|
|
290
318
|
|
|
291
319
|
module.exports = FranchiseFile;
|
|
@@ -379,7 +407,7 @@ function getGameYear(data, isCompressed, format) {
|
|
|
379
407
|
'max': 95
|
|
380
408
|
},
|
|
381
409
|
{
|
|
382
|
-
'year':
|
|
410
|
+
'year': 22,
|
|
383
411
|
'max': 999
|
|
384
412
|
}
|
|
385
413
|
];
|
|
@@ -431,7 +459,7 @@ function getGameYear(data, isCompressed, format) {
|
|
|
431
459
|
return 21;
|
|
432
460
|
}
|
|
433
461
|
else {
|
|
434
|
-
return
|
|
462
|
+
return null;
|
|
435
463
|
}
|
|
436
464
|
}
|
|
437
465
|
}
|
package/FranchiseFileTable.js
CHANGED
|
@@ -44,10 +44,30 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
44
44
|
get schema () {
|
|
45
45
|
return this._schema;
|
|
46
46
|
};
|
|
47
|
+
|
|
48
|
+
getBinaryReferenceToRecord(index) {
|
|
49
|
+
return utilService.getBinaryReferenceData(this.header.tableId, index);
|
|
50
|
+
};
|
|
47
51
|
|
|
48
52
|
updateBuffer() {
|
|
49
53
|
// need to check table2 data first because it may change offsets of the legit records.
|
|
50
54
|
const table2Data = this.strategy.getTable2BinaryData(this.table2Records, this.data.slice(this.header.table2StartIndex));
|
|
55
|
+
|
|
56
|
+
// update table2 length and table total length in table header (only if records have been read)
|
|
57
|
+
if (this.recordsRead) {
|
|
58
|
+
let table2DataLength = 0;
|
|
59
|
+
|
|
60
|
+
// Get length of all table2Data sub arrays
|
|
61
|
+
table2Data.forEach((arr) => {
|
|
62
|
+
table2DataLength += arr.length;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
this.header.table2Length = table2DataLength;
|
|
66
|
+
this.header.tableTotalLength = this.header.table1Length + this.header.table2Length;
|
|
67
|
+
|
|
68
|
+
this.data.writeUInt32BE(this.header.table2Length , this.header.offsetStart - 44);
|
|
69
|
+
this.data.writeUInt32BE(this.header.tableTotalLength, this.header.offsetStart - 24);
|
|
70
|
+
}
|
|
51
71
|
|
|
52
72
|
const changedRecords = this.records.filter((record) => { return record.isChanged; });
|
|
53
73
|
let currentOffset = 0;
|
|
@@ -576,7 +596,7 @@ function readOffsetTable(data, schema, header) {
|
|
|
576
596
|
'originalIndex': parseInt(attribute.index),
|
|
577
597
|
'name': attribute.name,
|
|
578
598
|
'type': (minValue < 0 || maxValue < 0) ? 's_' + attribute.type : attribute.type,
|
|
579
|
-
'isReference': !attribute.enum && (attribute.type[0] == attribute.type[0].toUpperCase() || attribute.type.includes('[]')) ? true : false,
|
|
599
|
+
'isReference': !attribute.enum && (attribute.type[0] == attribute.type[0].toUpperCase() || attribute.type.includes('[]') || attribute.type === 'record') ? true : false,
|
|
580
600
|
'valueInSecondTable': header.hasSecondTable && attribute.type === 'string',
|
|
581
601
|
'isSigned': minValue < 0 || maxValue < 0,
|
|
582
602
|
'minValue': minValue,
|
package/package.json
CHANGED
package/scripts/deflate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const zlib = require('zlib');
|
|
3
3
|
|
|
4
|
-
const filePath = 'D:\\Projects\\Madden 22\\
|
|
5
|
-
const outputPath = 'D:\\Projects\\Madden 22\\
|
|
4
|
+
const filePath = 'D:\\Projects\\Madden 22\\Misc\\FTC\\tuning.frt';
|
|
5
|
+
const outputPath = 'D:\\Projects\\Madden 22\\Misc\\FTC\\modified-Tuning.FTC'
|
|
6
6
|
|
|
7
7
|
const stream = fs.createReadStream(filePath)
|
|
8
8
|
|
package/services/schemaPicker.js
CHANGED
|
@@ -67,7 +67,14 @@ function getSchemasInFolder(dir) {
|
|
|
67
67
|
function findApplicableSchema(schemaMeta, gameYear, major, minor) {
|
|
68
68
|
// check if game year exists
|
|
69
69
|
if (schemaMeta) {
|
|
70
|
-
const schemasToSearch = schemaMeta.filter((schema) => {
|
|
70
|
+
const schemasToSearch = schemaMeta.filter((schema) => {
|
|
71
|
+
if (gameYear) {
|
|
72
|
+
return schema.gameYear == gameYear || schema.gameYear === null && schema.major !== null && schema.minor !== null;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return schema.major !== null && schema.minor !== null;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
71
78
|
|
|
72
79
|
// check if exact major exists
|
|
73
80
|
const exactMajor = schemasToSearch.filter((schema) => { return schema.major == major });
|
package/services/utilService.js
CHANGED
|
@@ -223,4 +223,10 @@ utilService.getReferenceData = function (value) {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
+
utilService.getBinaryReferenceData = function (tableId, rowNumber) {
|
|
227
|
+
const referenceBinary = utilService.dec2bin(tableId, 15);
|
|
228
|
+
const recordIndexBinary = utilService.dec2bin(rowNumber, 17);
|
|
229
|
+
return referenceBinary + recordIndexBinary;
|
|
230
|
+
};
|
|
231
|
+
|
|
226
232
|
module.exports = utilService;
|
|
@@ -2,7 +2,9 @@ const CommonAlgorithms = require('../CommonAlgorithms');
|
|
|
2
2
|
|
|
3
3
|
let FTCTableStrategy = {};
|
|
4
4
|
|
|
5
|
-
FTCTableStrategy.getTable2BinaryData =
|
|
5
|
+
FTCTableStrategy.getTable2BinaryData = (table2Records, fullTable2Buffer) => {
|
|
6
|
+
return [CommonAlgorithms.save(table2Records, fullTable2Buffer)];
|
|
7
|
+
};
|
|
6
8
|
|
|
7
9
|
FTCTableStrategy.getMandatoryOffsets = (offsets) => {
|
|
8
10
|
return offsets.filter((offset) => {
|
|
@@ -8,20 +8,20 @@ FranchiseTableStrategy.getTable2BinaryData = (table2Records, fullTable2Buffer) =
|
|
|
8
8
|
let currentOffset = 0;
|
|
9
9
|
|
|
10
10
|
for (let i = 0; i < changedTable2Records.length; i++) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
let record = changedTable2Records[i];
|
|
12
|
+
record.isChanged = false;
|
|
13
|
+
const recordOffset = record.index;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (i > 0 && recordOffset === 0) {
|
|
16
|
+
// this case is true for the last few rows with no data in them. They reference the first table2 value.
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
table2Data.push(fullTable2Buffer.slice(currentOffset, recordOffset));
|
|
21
|
+
const recordHexData = record.hexData;
|
|
22
|
+
table2Data.push(recordHexData);
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
currentOffset = recordOffset + recordHexData.length;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
table2Data.push(fullTable2Buffer.slice(currentOffset));
|