@@ -132,12 +132,17 @@ export function convertLoadoutFromStately(item: StatelyLoadout | StatelyLoadoutS
132
132
export function convertLoadoutParametersFromStately (
133
133
loParameters : StatelyLoadoutParameters ,
134
134
) : LoadoutParameters {
135
- const { assumeArmorMasterwork, statConstraints, modsByBucket, ...loParametersDefaulted } =
136
- stripTypeName ( loParameters ) ;
135
+ const {
136
+ assumeArmorMasterwork,
137
+ statConstraints,
138
+ modsByBucket,
139
+ artifactUnlocks,
140
+ inGameIdentifiers,
141
+ ...loParametersDefaulted
142
+ } = stripTypeName ( loParameters ) ;
137
143
return {
138
144
...stripDefaults ( loParametersDefaulted ) ,
139
- exoticArmorHash :
140
- loParameters . exoticArmorHash === 0n ? undefined : Number ( loParameters . exoticArmorHash ) ,
145
+ exoticArmorHash : exoticArmorHashFromStately ( loParameters . exoticArmorHash ) ,
141
146
// DIM's AssumArmorMasterwork enum starts at 1
142
147
assumeArmorMasterwork : ( assumeArmorMasterwork ?? 0 ) + 1 ,
143
148
statConstraints : statConstraintsFromStately ( statConstraints ) ,
@@ -146,14 +151,30 @@ export function convertLoadoutParametersFromStately(
146
151
: listToMap ( 'bucketHash' , 'modHashes' , modsByBucket ) ,
147
152
autoStatMods : true ,
148
153
includeRuntimeStatBenefits : true ,
154
+ artifactUnlocks : artifactUnlocks ? stripTypeName ( artifactUnlocks ) : undefined ,
155
+ inGameIdentifiers : inGameIdentifiers ? stripTypeName ( inGameIdentifiers ) : undefined ,
149
156
} ;
150
157
}
151
158
159
+ function exoticArmorHashFromStately ( hash : bigint ) {
160
+ if ( hash === 0n ) {
161
+ return undefined ;
162
+ }
163
+ // Some hashes got sign-flipped when I was changing data types from uint32 to
164
+ // int32 to int64 - the signed versions interpreted larger numbers (> 2^31) as
165
+ // signed, and everything got messed up. -1 and -2 are still valid special
166
+ // cases.
167
+ if ( hash < - 2 ) {
168
+ hash = 4294967296n + hash ; // The constant is 32 set bits, plus one
169
+ }
170
+ return Number ( hash ) ;
171
+ }
172
+
152
173
export function statConstraintsFromStately ( statConstraints : StatelyStatConstraint [ ] ) {
153
174
if ( statConstraints . length === 0 ) {
154
175
return undefined ;
155
176
}
156
- return statConstraints . map ( ( c ) => {
177
+ const constraints = statConstraints . map ( ( c ) => {
157
178
const constraint : StatConstraint = {
158
179
statHash : c . statHash ,
159
180
} ;
@@ -166,6 +187,14 @@ export function statConstraintsFromStately(statConstraints: StatelyStatConstrain
166
187
}
167
188
return constraint ;
168
189
} ) ;
190
+
191
+ // I screwed up the max constraints for some stored items, so we'll fix them here
192
+ if ( constraints . every ( ( c ) => c . maxTier === 0 ) ) {
193
+ for ( const c of constraints ) {
194
+ delete c . maxTier ;
195
+ }
196
+ }
197
+ return constraints ;
169
198
}
170
199
171
200
function convertLoadoutItemFromStately ( item : StatelyLoadoutItem ) : LoadoutItem {
0 commit comments