madden-franchise 3.2.0 → 3.2.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/FranchiseFileTable.js +1 -0
- package/FranchiseFileTable3Field.js +1 -4
- package/package.json +1 -1
- package/scripts/scratchpad.js +2 -2
- package/strategies/common/table/FranchiseTableStrategy.js +24 -0
- package/strategies/common/table3Field/FranchiseTable3FieldStrategy.js +7 -2
- package/strategies/franchise/m19/M19TableStrategy.js +1 -0
- package/strategies/franchise/m20/M20TableStrategy.js +1 -0
- package/strategies/franchise/m24/M24TableStrategy.js +1 -0
package/FranchiseFileTable.js
CHANGED
|
@@ -502,6 +502,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
502
502
|
// if the record contains any string values, point the string values to
|
|
503
503
|
// their correct offsets
|
|
504
504
|
this.strategy.recalculateStringOffsets(this, object);
|
|
505
|
+
this.strategy.recalculateBlobOffsets(this, object);
|
|
505
506
|
|
|
506
507
|
// Delete the empty record entry because it is no longer empty
|
|
507
508
|
this.emptyRecords.delete(object.index);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
const EventEmitter = require('events').EventEmitter;
|
|
2
|
-
const utilService = require('./services/utilService');
|
|
3
|
-
|
|
4
1
|
class FranchiseFileTable3Field {
|
|
5
2
|
constructor (index, maxLength, parent) {
|
|
6
3
|
this._value = '';
|
|
@@ -42,7 +39,7 @@ class FranchiseFileTable3Field {
|
|
|
42
39
|
|
|
43
40
|
set value (value) {
|
|
44
41
|
this._value = value;
|
|
45
|
-
this._unformattedValue = this._strategy.setUnformattedValueFromFormatted(value, this.maxLength);
|
|
42
|
+
this._unformattedValue = this._strategy.setUnformattedValueFromFormatted(value, this._unformattedValue, this.maxLength);
|
|
46
43
|
|
|
47
44
|
if (this.lengthAtLastSave === null) {
|
|
48
45
|
this.lengthAtLastSave = getLengthOfUnformattedValue(this._unformattedValue);
|
package/package.json
CHANGED
package/scripts/scratchpad.js
CHANGED
|
@@ -45,8 +45,8 @@ const schemaPath = 'C:\\Users\\Matt\\AppData\\Roaming\\madden-franchise-editor\\
|
|
|
45
45
|
table3s.forEach((table) => { console.log(`${table.header.tableId} - ${table.name}`)});
|
|
46
46
|
|
|
47
47
|
const buf = fs.readFileSync('D:\\Projects\\Madden 24\\franchise\\characterVisualIsolated.dat');
|
|
48
|
-
const test = zlib.gunzipSync(buf.subarray(
|
|
49
|
-
|
|
48
|
+
const test = zlib.gunzipSync(buf.subarray(3));
|
|
49
|
+
fs.writeFileSync('D:\\Projects\\Madden 24\\franchise\\characterVisualUnzipped.dat', test);
|
|
50
50
|
const test2 = zlib.gzipSync(test);
|
|
51
51
|
console.log(test2);
|
|
52
52
|
})();
|
|
@@ -59,4 +59,28 @@ FranchiseTableStrategy.recalculateStringOffsets = (table, record) => {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
FranchiseTableStrategy.recalculateBlobOffsets = (table, record) => {
|
|
63
|
+
// First, calculate length allocated per record in table2
|
|
64
|
+
const byteLengthPerRecord = table.offsetTable.filter((offsetEntry) => {
|
|
65
|
+
return offsetEntry.type === 'binaryblob';
|
|
66
|
+
}).reduce((accum, cur) => {
|
|
67
|
+
return accum + cur.maxLength;
|
|
68
|
+
}, 0);
|
|
69
|
+
|
|
70
|
+
// Then, go through each string field sorted by offset index, and assign offsets to the table2 fields
|
|
71
|
+
let runningOffset = 0;
|
|
72
|
+
|
|
73
|
+
record.fieldsArray.filter((field) => {
|
|
74
|
+
return field.offset.type === 'binaryblob';
|
|
75
|
+
}).sort((a, b) => {
|
|
76
|
+
return a.offset.index - b.offset.index;
|
|
77
|
+
}).forEach((field) => {
|
|
78
|
+
if (field.thirdTableField) {
|
|
79
|
+
field.thirdTableField.offset = (record.index * byteLengthPerRecord) + runningOffset;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
runningOffset += field.offset.maxLength;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
62
86
|
module.exports = FranchiseTableStrategy;
|
|
@@ -2,16 +2,21 @@ const zlib = require('zlib');
|
|
|
2
2
|
|
|
3
3
|
let FranchiseTable3FieldStrategy = {};
|
|
4
4
|
|
|
5
|
+
FranchiseTable3FieldStrategy.getZlibDataStartIndex = (unformattedValue) => {
|
|
6
|
+
return unformattedValue.indexOf(Buffer.from([0x1F, 0x8B]));
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
FranchiseTable3FieldStrategy.getInitialUnformattedValue = (field, data) => {
|
|
6
10
|
return data.slice(field.thirdTableField.index, (field.thirdTableField.index + field.offset.maxLength + 2));
|
|
7
11
|
// extend maxLength + 2 because the first 2 bytes are the size of the zipped data
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
FranchiseTable3FieldStrategy.getFormattedValueFromUnformatted = (unformattedValue) => {
|
|
11
|
-
|
|
15
|
+
const zlibDataStartIndex = FranchiseTable3FieldStrategy.getZlibDataStartIndex(unformattedValue);
|
|
16
|
+
return zlib.gunzipSync(unformattedValue.subarray(zlibDataStartIndex)).toString(); // first few bytes are the size of the zipped data & other flags, so skip those.
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
FranchiseTable3FieldStrategy.setUnformattedValueFromFormatted = (formattedValue, maxLength) => {
|
|
19
|
+
FranchiseTable3FieldStrategy.setUnformattedValueFromFormatted = (formattedValue, oldUnformattedValue, maxLength) => {
|
|
15
20
|
let zippedData = zlib.gzipSync(formattedValue);
|
|
16
21
|
let padding = Buffer.alloc(maxLength - zippedData.length); // table3s all have the same length and are zero padded to the end.
|
|
17
22
|
|
|
@@ -10,5 +10,6 @@ M19TableStrategy.getTable2BinaryData = FranchiseTableStrategy.getTable2BinaryDat
|
|
|
10
10
|
M19TableStrategy.getTable3BinaryData = FranchiseTableStrategy.getTable2BinaryData;
|
|
11
11
|
M19TableStrategy.getMandatoryOffsets = FranchiseTableStrategy.getMandatoryOffsets;
|
|
12
12
|
M19TableStrategy.recalculateStringOffsets = FranchiseTableStrategy.recalculateStringOffsets;
|
|
13
|
+
M19TableStrategy.recalculateBlobOffsets = FranchiseTableStrategy.recalculateBlobOffsets;
|
|
13
14
|
|
|
14
15
|
module.exports = M19TableStrategy;
|
|
@@ -10,5 +10,6 @@ M20TableStrategy.getTable2BinaryData = FranchiseTableStrategy.getTable2BinaryDat
|
|
|
10
10
|
M20TableStrategy.getTable3BinaryData = FranchiseTableStrategy.getTable2BinaryData;
|
|
11
11
|
M20TableStrategy.getMandatoryOffsets = FranchiseTableStrategy.getMandatoryOffsets;
|
|
12
12
|
M20TableStrategy.recalculateStringOffsets = FranchiseTableStrategy.recalculateStringOffsets;
|
|
13
|
+
M20TableStrategy.recalculateBlobOffsets = FranchiseTableStrategy.recalculateBlobOffsets;
|
|
13
14
|
|
|
14
15
|
module.exports = M20TableStrategy;
|
|
@@ -11,5 +11,6 @@ M24TableStrategy.getTable2BinaryData = FranchiseTableStrategy.getTable2BinaryDat
|
|
|
11
11
|
M24TableStrategy.getTable3BinaryData = FranchiseTableStrategy.getTable2BinaryData;
|
|
12
12
|
M24TableStrategy.getMandatoryOffsets = FranchiseTableStrategy.getMandatoryOffsets;
|
|
13
13
|
M24TableStrategy.recalculateStringOffsets = FranchiseTableStrategy.recalculateStringOffsets;
|
|
14
|
+
M24TableStrategy.recalculateBlobOffsets = FranchiseTableStrategy.recalculateBlobOffsets;
|
|
14
15
|
|
|
15
16
|
module.exports = M24TableStrategy;
|