|
1 | 1 | import { |
2 | | - Beatmap, |
3 | 2 | ConfigBinding, |
4 | 3 | ConfigManager, |
5 | 4 | JsonSafeParse, |
6 | | - PerformanceArgs, |
7 | 5 | downloadFile, |
8 | 6 | getCachePath, |
9 | 7 | getProgramPath, |
@@ -366,74 +364,75 @@ export default function buildBaseApi(server: Server) { |
366 | 364 | }); |
367 | 365 |
|
368 | 366 | server.app.route('/api/calculate/pp', 'GET', (req, res) => { |
369 | | - const query: any = req.query; |
370 | | - |
371 | | - const osuInstance: any = req.instanceManager.getInstance( |
372 | | - req.instanceManager.focusedClient |
373 | | - ); |
374 | | - if (!osuInstance) { |
375 | | - throw new Error('osu is not ready/running'); |
376 | | - } |
377 | | - |
378 | | - const { global, menu, beatmapPP } = osuInstance.getServices([ |
379 | | - 'global', |
380 | | - 'menu', |
381 | | - 'beatmapPP' |
382 | | - ]); |
383 | | - |
384 | | - let beatmap: Beatmap; |
385 | | - const exists = fs.existsSync(query.path); |
386 | | - if (exists) { |
387 | | - const beatmapFilePath = path.join( |
388 | | - global.songsFolder, |
389 | | - menu.folder, |
390 | | - menu.filename |
391 | | - ); |
392 | | - |
393 | | - const beatmapContent = fs.readFileSync(beatmapFilePath, 'utf8'); |
394 | | - beatmap = osuInstance.calculator.beatmap( |
395 | | - beatmapContent, |
396 | | - query.mode |
397 | | - ); |
398 | | - } else { |
399 | | - beatmap = beatmapPP.getCurrentBeatmap(); |
400 | | - } |
401 | | - |
402 | | - const params: PerformanceArgs = {}; |
403 | | - |
404 | | - if (query.ar !== undefined) params.ar = +query.ar; |
405 | | - if (query.cs !== undefined) params.cs = +query.cs; |
406 | | - if (query.hp !== undefined) params.hp = +query.hp; |
407 | | - if (query.od !== undefined) params.od = +query.od; |
408 | | - |
409 | | - if (query.clockRate !== undefined) params.clockRate = +query.clockRate; |
410 | | - if (query.passedObjects !== undefined) |
411 | | - params.passedObjects = +query.passedObjects; |
412 | | - if (query.combo !== undefined) params.combo = +query.combo; |
413 | | - if (query.nMisses !== undefined) params.misses = +query.nMisses; |
414 | | - if (query.n100 !== undefined) params.n100 = +query.n100; |
415 | | - if (query.n300 !== undefined) params.n300 = +query.n300; |
416 | | - if (query.n50 !== undefined) params.n50 = +query.n50; |
417 | | - if (query.nGeki !== undefined) params.nGeki = +query.nGeki; |
418 | | - if (query.nKatu !== undefined) params.nKatu = +query.nKatu; |
419 | | - if (query.mods !== undefined) |
420 | | - params.mods = Array.isArray(query.mods) ? query.mods : +query.mods; |
421 | | - if (query.acc !== undefined) params.accuracy = +query.acc; |
422 | | - if (query.sliderEndHits !== undefined) |
423 | | - params.sliderEndHits = +query.sliderEndHits; |
424 | | - if (query.smallTickHits !== undefined) |
425 | | - params.smallTickHits = +query.smallTickHits; |
426 | | - if (query.largeTickHits !== undefined) |
427 | | - params.largeTickHits = +query.largeTickHits; |
428 | | - if (query.hitresultPriority !== undefined) |
429 | | - params.hitresultPriority = +query.hitresultPriority; |
430 | | - |
431 | | - const calculate = osuInstance.calculator.performance(params, beatmap); |
432 | | - sendJson(res, calculate); |
433 | | - |
434 | | - // free beatmap only when map path specified |
435 | | - if (query.path) beatmap.free(); |
436 | | - calculate.free(); |
| 367 | + res.end(''); |
| 368 | + // const query: any = req.query; |
| 369 | + |
| 370 | + // const osuInstance: any = req.instanceManager.getInstance( |
| 371 | + // req.instanceManager.focusedClient |
| 372 | + // ); |
| 373 | + // if (!osuInstance) { |
| 374 | + // throw new Error('osu is not ready/running'); |
| 375 | + // } |
| 376 | + |
| 377 | + // const { global, menu, beatmapPP } = osuInstance.getServices([ |
| 378 | + // 'global', |
| 379 | + // 'menu', |
| 380 | + // 'beatmapPP' |
| 381 | + // ]); |
| 382 | + |
| 383 | + // let beatmap: Beatmap; |
| 384 | + // const exists = fs.existsSync(query.path); |
| 385 | + // if (exists) { |
| 386 | + // const beatmapFilePath = path.join( |
| 387 | + // global.songsFolder, |
| 388 | + // menu.folder, |
| 389 | + // menu.filename |
| 390 | + // ); |
| 391 | + |
| 392 | + // const beatmapContent = fs.readFileSync(beatmapFilePath, 'utf8'); |
| 393 | + // beatmap = osuInstance.calculator.beatmap( |
| 394 | + // beatmapContent, |
| 395 | + // query.mode |
| 396 | + // ); |
| 397 | + // } else { |
| 398 | + // beatmap = beatmapPP.getCurrentBeatmap(); |
| 399 | + // } |
| 400 | + |
| 401 | + // const params: PerformanceArgs = {}; |
| 402 | + |
| 403 | + // if (query.ar !== undefined) params.ar = +query.ar; |
| 404 | + // if (query.cs !== undefined) params.cs = +query.cs; |
| 405 | + // if (query.hp !== undefined) params.hp = +query.hp; |
| 406 | + // if (query.od !== undefined) params.od = +query.od; |
| 407 | + |
| 408 | + // if (query.clockRate !== undefined) params.clockRate = +query.clockRate; |
| 409 | + // if (query.passedObjects !== undefined) |
| 410 | + // params.passedObjects = +query.passedObjects; |
| 411 | + // if (query.combo !== undefined) params.combo = +query.combo; |
| 412 | + // if (query.nMisses !== undefined) params.misses = +query.nMisses; |
| 413 | + // if (query.n100 !== undefined) params.n100 = +query.n100; |
| 414 | + // if (query.n300 !== undefined) params.n300 = +query.n300; |
| 415 | + // if (query.n50 !== undefined) params.n50 = +query.n50; |
| 416 | + // if (query.nGeki !== undefined) params.nGeki = +query.nGeki; |
| 417 | + // if (query.nKatu !== undefined) params.nKatu = +query.nKatu; |
| 418 | + // if (query.mods !== undefined) |
| 419 | + // params.mods = Array.isArray(query.mods) ? query.mods : +query.mods; |
| 420 | + // if (query.acc !== undefined) params.accuracy = +query.acc; |
| 421 | + // if (query.sliderEndHits !== undefined) |
| 422 | + // params.sliderEndHits = +query.sliderEndHits; |
| 423 | + // if (query.smallTickHits !== undefined) |
| 424 | + // params.smallTickHits = +query.smallTickHits; |
| 425 | + // if (query.largeTickHits !== undefined) |
| 426 | + // params.largeTickHits = +query.largeTickHits; |
| 427 | + // if (query.hitresultPriority !== undefined) |
| 428 | + // params.hitresultPriority = +query.hitresultPriority; |
| 429 | + |
| 430 | + // const calculate = osuInstance.calculator.performance(params, beatmap); |
| 431 | + // sendJson(res, calculate); |
| 432 | + |
| 433 | + // // free beatmap only when map path specified |
| 434 | + // if (query.path) beatmap.free(); |
| 435 | + // calculate.free(); |
437 | 436 | }); |
438 | 437 |
|
439 | 438 | server.app.route('/api/generateReport', 'GET', async (req, res) => { |
|
0 commit comments