madden-franchise 2.2.0 → 2.2.4
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 +3 -0
- package/FranchiseFileRecord.js +26 -1
- package/FranchiseFileTable.js +28 -1
- package/data/schemas/21/M21_220_0.gz +0 -0
- package/data/schemas/22/M22_328_1.gz +0 -0
- package/package.json +1 -1
- package/scripts/deflate.js +2 -2
- package/strategies/common/header/m19/M19TableHeaderStrategy.js +25 -15
- package/strategies/common/header/m20/M20TableHeaderStrategy.js +0 -1
- package/data/schemas/21/M21_202_15.gz +0 -0
package/FranchiseFile.js
CHANGED
|
@@ -408,6 +408,9 @@ function getGameYear(data, isCompressed, format) {
|
|
|
408
408
|
else if (yearIdentifier[2] === 0x31) {
|
|
409
409
|
return 21;
|
|
410
410
|
}
|
|
411
|
+
else if (yearIdentifier[2] === 0x32) {
|
|
412
|
+
return 22;
|
|
413
|
+
}
|
|
411
414
|
else {
|
|
412
415
|
const schemaMajor = getCompressedSchema(data).major;
|
|
413
416
|
const year = schemaMax.find((schema) => { return schema.max >= schemaMajor; }).year;
|
package/FranchiseFileRecord.js
CHANGED
|
@@ -10,6 +10,7 @@ class FranchiseFileRecord extends EventEmitter {
|
|
|
10
10
|
this.index = index;
|
|
11
11
|
this._fields = parseRecordFields(data, offsetTable);
|
|
12
12
|
this.isChanged = false;
|
|
13
|
+
this.arraySize = null;
|
|
13
14
|
|
|
14
15
|
const that = this;
|
|
15
16
|
this._fields.forEach((field) => {
|
|
@@ -24,7 +25,31 @@ class FranchiseFileRecord extends EventEmitter {
|
|
|
24
25
|
|
|
25
26
|
field.on('change', function () {
|
|
26
27
|
that._data = utilService.replaceAt(that._data, this.offset.offset, this.unformattedValue);
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
// NOTE: At this time, we can only change the size of arrays of references.
|
|
30
|
+
// I'm not sure how to change the size of non-reference arrays, or if it's even possible.
|
|
31
|
+
if (that.arraySize) {
|
|
32
|
+
const referenceData = this.referenceData;
|
|
33
|
+
|
|
34
|
+
// If the field is outside of the previous array size and was edited to a valid reference,
|
|
35
|
+
// then reset the array size
|
|
36
|
+
if (this.offset.index >= that.arraySize) {
|
|
37
|
+
if (this.isReference) {
|
|
38
|
+
if (referenceData.tableId !== 0 || referenceData.rowNumber !== 0) {
|
|
39
|
+
that.arraySize = this.offset.index + 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If the value was changed to 0s, then shrink the array size to this index.
|
|
45
|
+
else if (this.isReference) {
|
|
46
|
+
if (referenceData.tableId === 0 && referenceData.rowNumber === 0) {
|
|
47
|
+
that.arraySize = this.offset.index;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
that.emit('change', this.offset);
|
|
28
53
|
});
|
|
29
54
|
});
|
|
30
55
|
};
|
package/FranchiseFileTable.js
CHANGED
|
@@ -21,6 +21,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
21
21
|
this.isChanged = false;
|
|
22
22
|
this.records = [];
|
|
23
23
|
this.table2Records = [];
|
|
24
|
+
this.arraySizes = [];
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
get hexData () {
|
|
@@ -31,6 +32,21 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
31
32
|
let currentOffset = 0;
|
|
32
33
|
let bufferArrays = [];
|
|
33
34
|
|
|
35
|
+
// Add all of the array sizes to the buffer if the table is an array
|
|
36
|
+
if (this.isArray) {
|
|
37
|
+
// Push the header data
|
|
38
|
+
bufferArrays.push(this.data.slice(currentOffset, this.header.headerSize));
|
|
39
|
+
|
|
40
|
+
let arraySizeBuffer = Buffer.alloc(this.header.data1RecordCount * 4);
|
|
41
|
+
|
|
42
|
+
this.arraySizes.forEach((arraySize) => {
|
|
43
|
+
arraySizeBuffer.writeUInt32BE(arraySize);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
bufferArrays.push(arraySizeBuffer);
|
|
47
|
+
currentOffset += this.header.headerSize + this.header.data1RecordCount * 4;
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
for (let i = 0; i < changedRecords.length; i++) {
|
|
35
51
|
let record = changedRecords[i];
|
|
36
52
|
record.isChanged = false;
|
|
@@ -74,6 +90,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
74
90
|
} else if (this.isArray) {
|
|
75
91
|
const numberOfFields = this.header.record1Size / 4;
|
|
76
92
|
let offsetTable = [];
|
|
93
|
+
let arraySizes = [];
|
|
77
94
|
|
|
78
95
|
for (let i = 0; i < numberOfFields; i++) {
|
|
79
96
|
const offset = {
|
|
@@ -96,7 +113,12 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
96
113
|
offsetTable.push(offset);
|
|
97
114
|
}
|
|
98
115
|
|
|
116
|
+
for (let i = 0; i < this.header.data1RecordCount; i++) {
|
|
117
|
+
arraySizes.push(this.data.readUInt32BE(this.header.headerSize + (i * 4)));
|
|
118
|
+
}
|
|
119
|
+
|
|
99
120
|
this.offsetTable = offsetTable;
|
|
121
|
+
this.arraySizes = arraySizes;
|
|
100
122
|
} else {
|
|
101
123
|
reject('Cannot read records: Schema is not defined.');
|
|
102
124
|
}
|
|
@@ -122,9 +144,14 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
this.records.forEach((record, index) => {
|
|
147
|
+
if (this.isArray) {
|
|
148
|
+
record.arraySize = this.arraySizes[index];
|
|
149
|
+
}
|
|
150
|
+
|
|
125
151
|
const that = this;
|
|
126
|
-
record.on('change', function () {
|
|
152
|
+
record.on('change', function (changedOffset) {
|
|
127
153
|
this.isChanged = true;
|
|
154
|
+
that.arraySizes[index] = this.arraySize;
|
|
128
155
|
that.emit('change');
|
|
129
156
|
});
|
|
130
157
|
});
|
|
Binary file
|
|
Binary file
|
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
|
|
5
|
-
const outputPath = 'D:\\Projects\\Madden
|
|
4
|
+
const filePath = 'D:\\Projects\\Madden 22\\Expressions\\franchise-expressions-binary.frt';
|
|
5
|
+
const outputPath = 'D:\\Projects\\Madden 22\\Expressions\\modified-Franchise-Expression-binary.FTC'
|
|
6
6
|
|
|
7
7
|
const stream = fs.createReadStream(filePath)
|
|
8
8
|
|
|
@@ -54,9 +54,9 @@ M19TableHeaderStrategy.parseHeader = (data) => {
|
|
|
54
54
|
let records1Size = 0;
|
|
55
55
|
|
|
56
56
|
if (isArray) {
|
|
57
|
-
headerSize =
|
|
58
|
-
const binaryData = utilService.getBitArray(data.slice(0, headerSize));
|
|
59
|
-
records1Size =
|
|
57
|
+
headerSize = 0xE4 + tableStoreLength;
|
|
58
|
+
// const binaryData = utilService.getBitArray(data.slice(0, headerSize));
|
|
59
|
+
records1Size = data2RecordWords * 4;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return {
|
|
@@ -93,8 +93,8 @@ M19TableHeaderStrategy.parseHeader = (data) => {
|
|
|
93
93
|
'table1Length2': table1Length2,
|
|
94
94
|
'tableTotalLength': tableTotalLength,
|
|
95
95
|
'hasSecondTable': hasSecondTable,
|
|
96
|
-
'table1StartIndex': tableStoreLength === 0 && !isArray ? headerSize : headerSize
|
|
97
|
-
'table2StartIndex': tableStoreLength === 0 && !isArray ? headerSize + (data1RecordCount * records1Size) :
|
|
96
|
+
'table1StartIndex': tableStoreLength === 0 && !isArray ? headerSize : headerSize + (data1RecordCount * 4),
|
|
97
|
+
'table2StartIndex': tableStoreLength === 0 && !isArray ? headerSize + (data1RecordCount * records1Size) : headerSize + (data1RecordCount * 4) + (data1RecordCount * records1Size),
|
|
98
98
|
'data2recordWords': data2RecordWords,
|
|
99
99
|
'data2RecordCapacity': data2RecordCapacity,
|
|
100
100
|
'data2IndexEntries': data2IndexEntries,
|
|
@@ -103,16 +103,26 @@ M19TableHeaderStrategy.parseHeader = (data) => {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
M19TableHeaderStrategy.parseHeaderAttributesFromSchema = (schema, data, header) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
if (header.isArray) {
|
|
107
|
+
return {
|
|
108
|
+
'headerSize': header.headerSize,
|
|
109
|
+
'record1Size': header.record1Size,
|
|
110
|
+
'table1StartIndex': header.table1StartIndex,
|
|
111
|
+
'table2StartIndex': header.table2StartIndex
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
headerSize = header.headerOffset + (schema.numMembers * 4) + header.tableStoreLength;
|
|
116
|
+
const binaryData = utilService.getBitArray(data.slice(0, headerSize));
|
|
117
|
+
records1Size = utilService.bin2dec(binaryData.slice(header.record1SizeOffset, header.record1SizeOffset + header.record1SizeLength));
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
'headerSize': headerSize,
|
|
121
|
+
'record1Size': records1Size,
|
|
122
|
+
'table1StartIndex': headerSize,
|
|
123
|
+
'table2StartIndex': headerSize + (header.data1RecordCount * records1Size)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
116
126
|
};
|
|
117
127
|
|
|
118
128
|
module.exports = M19TableHeaderStrategy;
|
|
Binary file
|