@@ -2594,238 +2594,31 @@ void Profile::RecalculateSSRs(bool OnlyOld) {
2594
2594
}
2595
2595
2596
2596
2597
- RString Profile::GetTopSSRSongName (unsigned int rank, int skillset) {
2598
- RString ck = GetTopSSRChartkey (rank, skillset);
2599
- Song* pSong = SONGMAN->GetSongByChartkey (ck);
2600
- if (!pSong)
2601
- return " " ;
2602
-
2603
- return pSong->GetMainTitle ();
2604
- }
2605
- float Profile::GetTopSSRValue (unsigned int rank, int skillset) {
2606
- if (rank <= 0 )
2607
- rank = 1 ;
2608
- HighScore *highScorePtr = GetTopSSRHighScore (rank, skillset);
2597
+ float Profile::GetTopSSRValue (unsigned int rank, int ss) {
2598
+ if (rank < 0 )
2599
+ rank = 0 ;
2600
+ HighScore *highScorePtr = GetTopSSRHighScore (rank, ss);
2609
2601
// Empty HighScore Pointer = NULL then return 0
2610
2602
if (highScorePtr == NULL )
2611
2603
return 0 .f ;
2612
2604
2613
- if (skillset >= 0 && skillset < NUM_Skillset)
2614
- return highScorePtr->GetSkillsetSSR (static_cast <Skillset>(skillset ));
2605
+ if (ss >= 0 && ss < NUM_Skillset && rank < pscores. TopSSRs [ss]. size () )
2606
+ return highScorePtr->GetSkillsetSSR (static_cast <Skillset>(ss ));
2615
2607
2616
2608
// Undefined skillset
2617
2609
return 0 .f ;
2618
2610
}
2619
- Song* Profile::GetTopSSRSong (unsigned int rank, int skillset) {
2620
- RString ck = GetTopSSRChartkey (rank, skillset);
2621
- return SONGMAN->GetSongByChartkey (ck);
2622
- }
2623
- Steps* Profile::GetTopSSRSteps (unsigned int rank, int skillset) {
2624
- RString ck = GetTopSSRChartkey (rank, skillset);
2625
- return SONGMAN->GetStepsByChartkey (ck);
2626
- }
2627
- RString Profile::GetTopSSRChartkey (unsigned int rank, int skillset) {
2628
- if (rank <= 0 )
2629
- rank = 1 ;
2630
- if (rank > static_cast <unsigned int >(topSSRChartkeys[skillset].size ()))
2631
- if (CalcTopSSRs (rank, skillset) == false ) {
2632
- return " " ;
2633
- }
2634
2611
2635
- LOG->Warn (pscores.TopSSRs [skillset][rank - 1 ]->GetHistoricChartKey ());
2636
-
2637
- if (skillset >= 0 && skillset < NUM_Skillset)
2638
- return pscores.TopSSRs [skillset][rank - 1 ]->GetHistoricChartKey ();
2639
-
2640
- // Undefined skillset
2641
- return " " ;
2642
- }
2643
2612
HighScore* Profile::GetTopSSRHighScore (unsigned int rank, int ss) {
2644
- if (rank <= 0 )
2645
- rank = 1 ;
2613
+ if (rank < 0 )
2614
+ rank = 0 ;
2646
2615
2647
- pscores.SortTopSSRPtrs (static_cast <Skillset>(ss));
2648
- if (ss >= 0 && ss < NUM_Skillset && rank < pscores.TopSSRs [ss].size ()) {
2649
- auto aa = &(*pscores.TopSSRs [ss][rank - 1 ]);
2650
- return aa;
2651
- }
2616
+ if (ss >= 0 && ss < NUM_Skillset && rank < pscores.TopSSRs [ss].size ())
2617
+ return &(*pscores.TopSSRs [ss][rank]);
2652
2618
2653
2619
return NULL ;
2654
2620
}
2655
2621
2656
- // Todo: Make it only iterate once - Nick12
2657
- bool Profile::CalcAllTopSSRs (unsigned int qty) {
2658
- bool ret = true ;
2659
- for (int i = 0 ; i < NUM_Skillset; i++)
2660
- ret = CalcTopSSRs (qty, i) && ret;
2661
- return ret;
2662
- }
2663
- bool Profile::CalcTopSSRs (unsigned int qty, int skillset) {
2664
- // undefined skillset
2665
- if (skillset < 0 || skillset >= NUM_Skillset)
2666
- return false ;
2667
-
2668
- vector<float > topSSRs; // Auxiliary vector to sort faster
2669
-
2670
- // Pointers to the skillset's vectors
2671
- vector<vector<HighScore>*> *topSSRHighScoreListsPtr = &topSSRHighScoreLists[skillset];
2672
- vector<unsigned int > *topSSRHighScoreIndexsPtr = &topSSRHighScoreIndexs[skillset];
2673
- vector<RString> *topSSRChartkeysPtr = &topSSRChartkeys[skillset];
2674
-
2675
- // Counter to see if we meet the required ranking size
2676
- unsigned int counter = 0 ;
2677
- // Axi
2678
- unsigned int poscounter;
2679
-
2680
- // Initialize vectors
2681
- HighScore* emptyHighScorePtr = NULL ;
2682
- vector<HighScore>* emptyHighScoreListsPtr = NULL ;
2683
- (*topSSRChartkeysPtr).clear ();
2684
- (*topSSRHighScoreListsPtr).clear ();
2685
- (*topSSRHighScoreIndexsPtr).clear ();
2686
-
2687
- // Empty the vectors if qty=0
2688
- if (qty == 0 )
2689
- return true ;
2690
-
2691
- for (unsigned int i = 0 ; i < qty; i++) {
2692
- topSSRs.emplace_back (0 );
2693
- (*topSSRChartkeysPtr).emplace_back (" " );
2694
- (*topSSRHighScoreListsPtr).emplace_back (emptyHighScoreListsPtr);
2695
- (*topSSRHighScoreIndexsPtr).emplace_back (0 );
2696
- }
2697
-
2698
- struct info {
2699
- float ssr;
2700
- unsigned int pos;
2701
- };
2702
- info temp[60 ];
2703
- for (int i = 0 ;i < 60 ;i++) {
2704
- temp[i].ssr = 0 ;
2705
- temp[i].pos = 0 ;
2706
- }
2707
-
2708
- bool replaced = false ;
2709
-
2710
- // Build the top
2711
- FOREACHM (SongID, HighScoresForASong, m_SongHighScores, i) {
2712
- const SongID& id = i->first ;
2713
-
2714
- HighScoresForASong& hsfas = i->second ;
2715
- FOREACHM (StepsID, HighScoresForASteps, hsfas.m_StepsHighScores , j) {
2716
- HighScoresForASteps& zz = j->second ;
2717
- const StepsID& stepsid = j->first ;
2718
- vector<HighScore>& hsv = zz.hsl .vHighScores ;
2719
-
2720
- Steps* psteps = SONGMAN->GetStepsByChartkey (stepsid);
2721
- if (!psteps)
2722
- continue ;
2723
-
2724
- if (!psteps->IsRecalcValid ())
2725
- continue ;
2726
-
2727
- for (int i = 0 ;i < 60 ;i++) {
2728
- temp[i].ssr = 0 ;
2729
- temp[i].pos = 0 ;
2730
- }
2731
-
2732
- for (size_t i = 0 ; i < hsv.size (); i++) {
2733
- float ssr = hsv[i].GetSkillsetSSR (static_cast <Skillset>(skillset));
2734
- int rate = static_cast <int >(hsv[i].GetMusicRate () * 20 );
2735
-
2736
- if ((temp[rate - 1 ]).ssr >= ssr)
2737
- continue ;
2738
- // Compare with the smallest value(last one) to see if we need to change the values
2739
- if (topSSRs[qty - 1 ] < ssr) {
2740
-
2741
- if ((temp[rate - 1 ]).ssr != 0 )
2742
- replaced = true ;
2743
- else
2744
- replaced = false ;
2745
-
2746
-
2747
- if (replaced) {
2748
- topSSRs.erase (topSSRs.begin () + temp[rate - 1 ].pos );
2749
- (*topSSRChartkeysPtr).erase ((*topSSRChartkeysPtr).begin () + temp[rate - 1 ].pos );
2750
- (*topSSRHighScoreListsPtr).erase ((*topSSRHighScoreListsPtr).begin () + temp[rate - 1 ].pos );
2751
- (*topSSRHighScoreIndexsPtr).erase ((*topSSRHighScoreIndexsPtr).begin () + temp[rate - 1 ].pos );
2752
- // qty--;
2753
- }
2754
-
2755
-
2756
- // Find the position of the inmediate smaller value
2757
- for (poscounter = qty - 1 ; topSSRs[poscounter - 1 ] < ssr && poscounter != 0 ;) {
2758
- poscounter--;
2759
- }
2760
-
2761
- temp[rate - 1 ].pos = poscounter;
2762
- temp[rate - 1 ].ssr = ssr;
2763
-
2764
- // insert in the proper place
2765
- topSSRs.emplace (topSSRs.begin () + poscounter, ssr);
2766
- (*topSSRChartkeysPtr).emplace ((*topSSRChartkeysPtr).begin () + poscounter, stepsid.GetKey ());
2767
- (*topSSRHighScoreListsPtr).emplace ((*topSSRHighScoreListsPtr).begin () + poscounter, &hsv);
2768
- (*topSSRHighScoreIndexsPtr).emplace ((*topSSRHighScoreIndexsPtr).begin () + poscounter, i+1 );
2769
-
2770
-
2771
- // erase last element to keep the same amount of elements(qty)
2772
- if (!replaced) {
2773
- counter++;
2774
- topSSRs.pop_back ();
2775
- (*topSSRChartkeysPtr).pop_back ();
2776
- (*topSSRHighScoreListsPtr).pop_back ();
2777
- (*topSSRHighScoreIndexsPtr).pop_back ();
2778
- }
2779
- }
2780
- }
2781
- }
2782
- }
2783
-
2784
- // If we didnt find enough ssr's to fill qty elements return false
2785
- if (counter >= qty)
2786
- return true ;
2787
- return false ;
2788
- }
2789
-
2790
-
2791
- void Profile::TopSSRsAddNewScore (HighScore *hs, StepsID stepsid, SongID songid) {
2792
- Steps* psteps = SONGMAN->GetStepsByChartkey (stepsid);
2793
- if (!psteps)
2794
- return ;
2795
-
2796
- if (!psteps->IsRecalcValid ())
2797
- return ;
2798
-
2799
- for (int skillset = 0 ; skillset < NUM_Skillset; skillset++) {
2800
- // Pointers to the skillset's vectors
2801
- vector<unsigned int > *topSSRHighScoreIndexsPtr = &topSSRHighScoreIndexs[skillset];
2802
- vector<vector<HighScore>*> *topSSRHighScoreListsPtr = &topSSRHighScoreLists[skillset];
2803
- vector<RString> *topSSRChartkeyPtr = &topSSRChartkeys[skillset];
2804
-
2805
- unsigned int qty = (*topSSRChartkeyPtr).size ();
2806
- if (qty == 0 )
2807
- continue ;
2808
-
2809
- float ssr = hs->GetSkillsetSSR (static_cast <Skillset>(skillset));
2810
- if (ssr == 0 )
2811
- return ;
2812
-
2813
-
2814
- // Compare with the smallest value(last one) to see if we need to change the values
2815
- if ( ((*topSSRHighScoreIndexsPtr)[qty - 1 ] != 0 ? (*topSSRHighScoreLists[skillset][qty - 1 ])[topSSRHighScoreIndexs[skillset][qty-1 ] - 1 ].GetSkillsetSSR (static_cast <Skillset>(skillset)) : 0 ) < ssr) {
2816
-
2817
-
2818
- // Screw it lets just try always recalculating to see if this works at the very least
2819
- // Todo:Make this not recalc all the time -Nick12
2820
- CalcAllTopSSRs (qty);
2821
- return ;
2822
- }
2823
-
2824
- }
2825
- return ;
2826
- }
2827
-
2828
-
2829
2622
float Profile::AggregateScores (vector<float >& invector, float rating, float res, int iter) const {
2830
2623
if (invector.size () == 0 )
2831
2624
return 0 .f ;
@@ -3508,25 +3301,12 @@ class LunaProfile : public Luna<Profile>
3508
3301
lua_pushnil (L);
3509
3302
return 1 ;
3510
3303
}
3511
- static int GetLastPlayedCourse (T* p, lua_State *L)
3512
- {
3513
- Course *pC = p->m_lastCourse .ToCourse ();
3514
- if (pC)
3515
- pC->PushSelf (L);
3516
- else
3517
- lua_pushnil (L);
3518
- return 1 ;
3519
- }
3520
- static int GetTopSSRSongName (T* p, lua_State *L) {
3521
- lua_pushstring (L, p->GetTopSSRSongName (IArg (1 ), IArg (2 )));
3522
- return 1 ;
3523
- }
3524
3304
static int GetTopSSRValue (T* p, lua_State *L) {
3525
- lua_pushnumber (L, p->GetTopSSRValue (IArg (1 ), IArg (2 )));
3305
+ lua_pushnumber (L, p->GetTopSSRValue (IArg (1 ) - 1 , IArg (2 )));
3526
3306
return 1 ;
3527
3307
}
3528
3308
static int GetTopSSRHighScore (T* p, lua_State *L) {
3529
- HighScore* ths = p->GetTopSSRHighScore (IArg (1 ), IArg (2 ));
3309
+ HighScore* ths = p->GetTopSSRHighScore (IArg (1 ) - 1 , IArg (2 ));
3530
3310
if (ths)
3531
3311
ths->PushSelf (L);
3532
3312
else
@@ -3538,14 +3318,7 @@ class LunaProfile : public Luna<Profile>
3538
3318
lua_pushnumber (L, p->m_fPlayerSkillsets [lel]);
3539
3319
return 1 ;
3540
3320
}
3541
- static int GetSongFromSSR (T* p, lua_State *L) {
3542
- p->GetTopSSRSong (IArg (1 ), IArg (2 ))->PushSelf (L);
3543
- return 1 ;
3544
- }
3545
- static int GetStepsFromSSR (T* p, lua_State *L) {
3546
- p->GetTopSSRSteps (IArg (1 ), IArg (2 ))->PushSelf (L);
3547
- return 1 ;
3548
- }
3321
+
3549
3322
static int SortAllSSRs (T* p, lua_State *L) {
3550
3323
for (size_t i = 0 ; i < NUM_Skillset; ++i)
3551
3324
p->pscores .SortTopSSRPtrs (static_cast <Skillset>(i));
@@ -3643,7 +3416,6 @@ class LunaProfile : public Luna<Profile>
3643
3416
ADD_METHOD ( GetTotalDancePoints );
3644
3417
ADD_METHOD ( GetUserTable );
3645
3418
ADD_METHOD ( GetLastPlayedSong );
3646
- ADD_METHOD ( GetLastPlayedCourse );
3647
3419
ADD_METHOD ( GetGUID );
3648
3420
ADD_METHOD ( GetPlayerRating );
3649
3421
ADD_METHOD ( GetPlayerSkillsetRating );
0 commit comments