-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
60 lines (51 loc) · 1.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h> //printf
#include <stdlib.h> //atof, atoi
#include <chrono> //timer
#include "mpp.h"
int main(int argc, char** argv) {
if (argc <= 1) {
printf("MPP v1.2 - Usage: mpp <file_location> [<score>] [<mod_int>]\n");
return 0;
}
int score = 1000000, mods = 0;
std::string fileLocation = "";
try {
fileLocation = std::string(argv[1]);
if (argc > 2)
score = atoi(argv[2]);
if (argc > 3)
mods = atoi(argv[3]);
} catch (char *m) {
printf("Encountered an error: %s", m);
}
if (score > 1000000 || score < 1 || (score > 500000 && mods & 256)) {
printf("Invalid score.\n");
return 0;
}
if (fileLocation != "") {
//timer
using std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
using std::chrono::duration;
using std::chrono::milliseconds;
//timer
auto t1 = high_resolution_clock::now();
// MPP 2
mpp::calculator a((char*)fileLocation.c_str());
a.setMods(mods);
printf("Beatmap: %s - %s [%s] | %dK\n", a.bmap_data.artist.c_str(), a.bmap_data.title.c_str(), a.bmap_data.version.c_str(), a.bmap_data.keys);
printf("Performance: %.2lf\n", a.getPerformance(score));
printf("Difficulty: %.2lf\n", a.bmap_data.difficulty);
/*
// Legacy MPP
mpp a((char*)fileLocation.c_str());
a.setMods(mods);
printf("Performance: %lf\n", a.calculatePP());
*/
//timer
auto t2 = high_resolution_clock::now();
duration<double, std::milli> ms_double = t2 - t1;
printf("\nOperation took: %.2lfms.\n\n", ms_double.count());
}
return 0;
}