@@ -122,10 +122,7 @@ export class BeatmapPPData extends AbstractEntity {
122
122
wLogger . debug (
123
123
`maxPP -> ${ this . currAttributes . maxThisPlayPP } pp -> ${ pp } stars -> ${ stars } `
124
124
) ;
125
- const maxThisPlayPP =
126
- pp > this . currAttributes . maxThisPlayPP
127
- ? pp
128
- : this . currAttributes . maxThisPlayPP ;
125
+ const maxThisPlayPP = Math . max ( pp , this . currAttributes . maxThisPlayPP ) ;
129
126
130
127
this . currAttributes = {
131
128
...this . currAttributes ,
@@ -143,9 +140,9 @@ export class BeatmapPPData extends AbstractEntity {
143
140
}
144
141
145
142
updateBPM ( commonBPM : number , minBPM : number , maxBPM : number ) {
146
- this . commonBPM = commonBPM ;
147
- this . minBPM = minBPM ;
148
- this . maxBPM = maxBPM ;
143
+ this . commonBPM = Math . round ( commonBPM ) ;
144
+ this . minBPM = Math . round ( minBPM ) ;
145
+ this . maxBPM = Math . round ( maxBPM ) ;
149
146
}
150
147
151
148
updateTimings ( firstObj : number , full : number ) {
@@ -227,25 +224,28 @@ export class BeatmapPPData extends AbstractEntity {
227
224
228
225
let oldStrains : number [ ] = [ ] ;
229
226
230
- const offset : number = strains . sectionLength ;
231
-
232
227
let lazerBeatmap : ParsedBeatmap ;
233
-
234
228
try {
235
229
const decoder = new BeatmapDecoder ( ) ;
236
230
237
231
lazerBeatmap = await decoder . decodeFromPath ( mapPath , {
238
232
parseColours : false ,
239
233
parseDifficulty : false ,
240
234
parseEditor : false ,
241
- parseEvents : false ,
235
+ parseEvents : true ,
242
236
parseGeneral : false ,
243
237
parseMetadata : false
244
238
} ) ;
245
239
246
240
const { bpm, bpmMin, bpmMax } = lazerBeatmap ;
247
241
248
- this . updateBPM ( bpm , bpmMin , bpmMax ) ;
242
+ menuData . BackgroundFilename =
243
+ lazerBeatmap . events . backgroundPath || '' ;
244
+ this . updateBPM (
245
+ bpm * mapAttributes . clockRate ,
246
+ bpmMin * mapAttributes . clockRate ,
247
+ bpmMax * mapAttributes . clockRate
248
+ ) ;
249
249
250
250
const firstObj = Math . round (
251
251
lazerBeatmap . hitObjects . at ( 0 ) ?. startTime ?? 0
@@ -261,28 +261,45 @@ export class BeatmapPPData extends AbstractEntity {
261
261
return ;
262
262
}
263
263
264
+ const offset = strains . sectionLength ;
265
+ const firstObj = this . timings . firstObj / mapAttributes . clockRate ;
266
+ const lastObj = this . timings . full / mapAttributes . clockRate ;
267
+ const graphLength = lastObj - firstObj ;
268
+ const mp3Length = menuData . MP3Length / mapAttributes . clockRate ;
269
+
264
270
const beatmap_parse_time = performance . now ( ) ;
265
271
wLogger . debug (
266
272
`(updateMapMetadata) Spend:${ (
267
273
beatmap_parse_time - calculation_time
268
274
) . toFixed ( 2 ) } ms on parsing beatmap`
269
275
) ;
270
276
271
- const LEFT_OFFSET = Math . floor ( this . timings . firstObj / offset ) ;
277
+ const LEFT_OFFSET = Math . floor ( firstObj / offset ) ;
272
278
const RIGHT_OFFSET =
273
- menuData . MP3Length > this . timings . full
274
- ? Math . ceil ( ( menuData . MP3Length - this . timings . full ) / offset )
279
+ mp3Length >= lastObj
280
+ ? Math . ceil ( ( mp3Length - lastObj ) / offset )
275
281
: 0 ;
276
282
277
283
const updateWithOffset = ( name : string , values : number [ ] ) => {
278
284
let data : number [ ] = [ ] ;
285
+ let approximateTime =
286
+ LEFT_OFFSET * offset +
287
+ values . length * offset +
288
+ RIGHT_OFFSET * offset ;
279
289
280
290
if ( Number . isFinite ( LEFT_OFFSET ) && LEFT_OFFSET > 0 )
281
291
data = Array ( LEFT_OFFSET ) . fill ( - 100 ) ;
282
292
data = data . concat ( values ) ;
283
293
if ( Number . isFinite ( RIGHT_OFFSET ) && RIGHT_OFFSET > 0 )
284
294
data = data . concat ( Array ( RIGHT_OFFSET ) . fill ( - 100 ) ) ;
285
295
296
+ const missingPoints =
297
+ mp3Length >= approximateTime
298
+ ? Math . ceil ( ( mp3Length - approximateTime ) / offset )
299
+ : 0 ;
300
+ if ( missingPoints > 0 )
301
+ data = data . concat ( Array ( missingPoints ) . fill ( - 100 ) ) ;
302
+
286
303
resultStrains . series . push ( { name, data } ) ;
287
304
} ;
288
305
@@ -335,13 +352,13 @@ export class BeatmapPPData extends AbstractEntity {
335
352
resultStrains . xaxis . push ( i * offset ) ;
336
353
}
337
354
338
- const amount = Math . ceil ( this . timings . full / offset ) ;
355
+ const amount = Math . ceil ( graphLength / offset ) ;
339
356
for ( let i = 0 ; i < amount ; i ++ ) {
340
- resultStrains . xaxis . push ( this . timings . firstObj + i * offset ) ;
357
+ resultStrains . xaxis . push ( firstObj + i * offset ) ;
341
358
}
342
359
343
360
for ( let i = 0 ; i < RIGHT_OFFSET ; i ++ ) {
344
- resultStrains . xaxis . push ( this . timings . full + i * offset ) ;
361
+ resultStrains . xaxis . push ( lastObj + i * offset ) ;
345
362
}
346
363
347
364
const end_time = performance . now ( ) ;
0 commit comments