madden-franchise 3.0.3 → 3.0.5
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 +4 -0
- package/FranchiseFileField.js +16 -1
- package/FranchiseFileRecord.js +21 -6
- package/FranchiseFileTable.js +16 -2
- package/package.json +1 -1
- package/strategies/common/header/m19/M19TableHeaderStrategy.js +1 -0
- package/strategies/common/header/m20/M20TableHeaderStrategy.js +1 -0
package/FranchiseFile.js
CHANGED
|
@@ -270,6 +270,10 @@ class FranchiseFile extends EventEmitter {
|
|
|
270
270
|
return this.tables[index];
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
+
getTableByUniqueId (id) {
|
|
274
|
+
return this.tables.find((table) => { return table.header && table.header.uniqueId === id; });
|
|
275
|
+
};
|
|
276
|
+
|
|
273
277
|
getReferencedRecord (referenceValue) {
|
|
274
278
|
const reference = utilService.getReferenceData(referenceValue);
|
|
275
279
|
return this.getTableById(reference.tableId).records[reference.rowNumber];
|
package/FranchiseFileField.js
CHANGED
|
@@ -10,6 +10,7 @@ class FranchiseFileField {
|
|
|
10
10
|
this._unformattedValue = null;
|
|
11
11
|
this._offset = offset;
|
|
12
12
|
this._parent = parent;
|
|
13
|
+
this._isChanged = false;
|
|
13
14
|
|
|
14
15
|
if (offset.valueInSecondTable) {
|
|
15
16
|
this.secondTableField = new FranchiseFileTable2Field(this._recordBuffer.readUInt32BE(offset.offset / 8), offset.maxLength);
|
|
@@ -53,12 +54,13 @@ class FranchiseFileField {
|
|
|
53
54
|
return null;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
set value (value) {
|
|
57
|
+
set value (value) {
|
|
57
58
|
if (this._unformattedValue === null) {
|
|
58
59
|
this._setUnformattedValueIfEmpty();
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
this._value = value;
|
|
63
|
+
this.isChanged = true;
|
|
62
64
|
|
|
63
65
|
if (this.offset.valueInSecondTable) {
|
|
64
66
|
this.secondTableField.value = value.toString();
|
|
@@ -149,6 +151,19 @@ class FranchiseFileField {
|
|
|
149
151
|
this._parent.onEvent('change', this);
|
|
150
152
|
};
|
|
151
153
|
|
|
154
|
+
get isChanged() {
|
|
155
|
+
return this._isChanged;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
set isChanged(changed) {
|
|
159
|
+
this._isChanged = changed;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
clearCachedValues() {
|
|
163
|
+
this._value = null;
|
|
164
|
+
this._unformattedValue = null;
|
|
165
|
+
};
|
|
166
|
+
|
|
152
167
|
_setUnformattedValueIfEmpty() {
|
|
153
168
|
this._value = null;
|
|
154
169
|
this._unformattedValue = new BitView(this._recordBuffer, this._recordBuffer.byteOffset);
|
package/FranchiseFileRecord.js
CHANGED
|
@@ -7,8 +7,8 @@ class FranchiseFileRecord {
|
|
|
7
7
|
this._offsetTable = offsetTable;
|
|
8
8
|
this.index = index;
|
|
9
9
|
this._fieldsArray = [];
|
|
10
|
-
this._fields = this.parseRecordFields(
|
|
11
|
-
this.
|
|
10
|
+
this._fields = this.parseRecordFields();
|
|
11
|
+
this._isChanged = false;
|
|
12
12
|
this.arraySize = null;
|
|
13
13
|
this.isEmpty = false;
|
|
14
14
|
this._parent = parent;
|
|
@@ -55,6 +55,20 @@ class FranchiseFileRecord {
|
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
get isChanged() {
|
|
59
|
+
return this._isChanged;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
set isChanged(changed) {
|
|
63
|
+
this._isChanged = changed;
|
|
64
|
+
|
|
65
|
+
if (changed === false) {
|
|
66
|
+
this.fieldsArray.forEach((field) => {
|
|
67
|
+
field.isChanged = false;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
getFieldByKey(key) {
|
|
59
73
|
return this._fields[key];
|
|
60
74
|
};
|
|
@@ -69,15 +83,16 @@ class FranchiseFileRecord {
|
|
|
69
83
|
return field ? field.referenceData : null;
|
|
70
84
|
};
|
|
71
85
|
|
|
72
|
-
parseRecordFields(
|
|
86
|
+
parseRecordFields() {
|
|
73
87
|
let fields = {};
|
|
88
|
+
this._fieldsArray = [];
|
|
74
89
|
|
|
75
|
-
for (let j = 0; j <
|
|
76
|
-
const offset =
|
|
90
|
+
for (let j = 0; j < this._offsetTable.length; j++) {
|
|
91
|
+
const offset = this._offsetTable[j];
|
|
77
92
|
|
|
78
93
|
// Push the entire record buffer to the field. No need to perform a calculation
|
|
79
94
|
// to subarray the buffer, BitView will take care of it in the Field.
|
|
80
|
-
fields[offset.name] = new FranchiseFileField(offset.name,
|
|
95
|
+
fields[offset.name] = new FranchiseFileField(offset.name, this._data, offset, this);
|
|
81
96
|
|
|
82
97
|
this._fieldsArray.push(fields[offset.name]);
|
|
83
98
|
}
|
package/FranchiseFileTable.js
CHANGED
|
@@ -145,7 +145,7 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
145
145
|
const firstOffset = this.offsetTable[0];
|
|
146
146
|
if (firstOffset.type !== 'string') {
|
|
147
147
|
isEmptyReference = true;
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
// Save the row number that this record points to.
|
|
150
150
|
emptyRecordReferenceIndicies.push(firstFourBytesReference.rowNumber);
|
|
151
151
|
}
|
|
@@ -154,7 +154,6 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
154
154
|
record.isEmpty = isEmptyReference;
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
|
|
158
157
|
// We need to determine the starting node.
|
|
159
158
|
// To do that, we need to find the empty record which no other empty record points to.
|
|
160
159
|
const unreachableRecords = this.records.filter((record) => { return record.isEmpty; }).filter((record) => {
|
|
@@ -439,6 +438,21 @@ class FranchiseFileTable extends EventEmitter {
|
|
|
439
438
|
// const referenceData = utilService.getReferenceDataFromBuffer(object.data.slice(0, 4));
|
|
440
439
|
// if (referenceData.tableId !== 0 || referenceData.rowNumber > this.header.recordCapacity) {
|
|
441
440
|
|
|
441
|
+
|
|
442
|
+
// if the changed field isn't included in the first 32 bits, zero out the first 32 bits.
|
|
443
|
+
// Otherwise, it's not necessary to zero out.
|
|
444
|
+
const changedFieldsInFirst4Bytes = object.fieldsArray.filter((field) => { return field.isChanged && field.offset.indexOffset < 32; });
|
|
445
|
+
if (changedFieldsInFirst4Bytes.length === 0) {
|
|
446
|
+
// set first 4 bytes to 0
|
|
447
|
+
this._changeRecordBuffers(object.index, 0);
|
|
448
|
+
|
|
449
|
+
// invalidate the cached values since we set the buffer directly
|
|
450
|
+
const fieldsInFirst4Bytes = object.fieldsArray.filter((field) => { return field.offset.indexOffset < 32; });
|
|
451
|
+
fieldsInFirst4Bytes.forEach((field) => {
|
|
452
|
+
field.clearCachedValues();
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
442
456
|
// if the record contains any string values, point the string values to
|
|
443
457
|
// their correct offsets
|
|
444
458
|
this.strategy.recalculateStringOffsets(this, object);
|
package/package.json
CHANGED