@@ -6763,6 +6763,14 @@ void ServerLobby::updateGnuElimination()
6763
6763
void ServerLobby::storeResults ()
6764
6764
{
6765
6765
#ifdef ENABLE_SQLITE3
6766
+ std::string powerup_string = powerup_manager->getFileName ();
6767
+ std::string kc_string = kart_properties_manager->getFileName ();
6768
+ // TODO: don't use file names as constants
6769
+ if (powerup_string == " powerup.xml" )
6770
+ powerup_string = " " ;
6771
+ if (kc_string == " kart_characteristics.xml" )
6772
+ kc_string = " " ;
6773
+
6766
6774
bool racing_mode = false ;
6767
6775
bool ffa = RaceManager::get ()->getMinorMode () ==
6768
6776
RaceManager::MINOR_MODE_FREE_FOR_ALL;
@@ -6792,9 +6800,11 @@ void ServerLobby::storeResults()
6792
6800
{
6793
6801
std::string get_query = StringUtils::insertValues (" SELECT username, "
6794
6802
" result FROM '%s' WHERE venue = '%s' and reverse = '%s' "
6795
- " and mode = '%s' and laps = %d order by result asc, time asc limit 1;" ,
6803
+ " and mode = '%s' and laps = %d and config = '%s' "
6804
+ " and items = '%s' and is_quit = 0 "
6805
+ " order by result asc, time asc limit 1;" ,
6796
6806
records_table_name.c_str (), track_name.c_str (), reverse_string.c_str (), mode_name.c_str (),
6797
- laps_number);
6807
+ laps_number, kc_string. c_str (), powerup_string. c_str () );
6798
6808
auto ret = vectorSQLQuery (get_query, 2 );
6799
6809
record_fetched = ret.first ;
6800
6810
if (record_fetched && ret.second [0 ].size () > 0 )
@@ -6821,8 +6831,11 @@ void ServerLobby::storeResults()
6821
6831
std::vector<std::string> scores;
6822
6832
std::vector<std::string> karts;
6823
6833
std::vector<int > lap_counts;
6834
+ std::vector<float > colors;
6835
+ std::vector<int > has_quit;
6824
6836
for (int i = 0 ; i < player_count; i++)
6825
6837
{
6838
+ // TODO why I cannot use get()->getPlayerName?
6826
6839
std::string username = StringUtils::wideToUtf8 (
6827
6840
RaceManager::get ()->getKartInfo (i).getPlayerName ());
6828
6841
for (std::string& username: usernames) {
@@ -6835,11 +6848,12 @@ void ServerLobby::storeResults()
6835
6848
double score = DISCONNECT_TIME;
6836
6849
std::string kart_name = w->getKart (i)->getIdent ();
6837
6850
std::stringstream elapsed_string;
6851
+ float kart_color = RaceManager::get ()->getKartColor (i);
6838
6852
6839
6853
if (racing_mode)
6840
6854
{
6841
- if (!w-> getKart (i)-> isEliminated ())
6842
- score = RaceManager::get ()-> getKartRaceTime (i );
6855
+ score = RaceManager::get ()-> getKartRaceTime (i);
6856
+ has_quit. push_back (w-> getKart (i)-> isEliminated () ? 1 : 0 );
6843
6857
elapsed_string << std::setprecision (4 ) << std::fixed << score;
6844
6858
if (best_cur_player_idx == -1 || score < best_cur_time)
6845
6859
{
@@ -6852,6 +6866,7 @@ void ServerLobby::storeResults()
6852
6866
{
6853
6867
if (w->getKart (i)->isEliminated ())
6854
6868
continue ;
6869
+ has_quit.push_back (0 );
6855
6870
if (ffa_world)
6856
6871
{
6857
6872
score = ffa_world->getKartScore (i);
@@ -6863,6 +6878,7 @@ void ServerLobby::storeResults()
6863
6878
scores.push_back (elapsed_string.str ());
6864
6879
karts.push_back (kart_name);
6865
6880
lap_counts.push_back (laps_number);
6881
+ colors.push_back (kart_color);
6866
6882
}
6867
6883
if (ServerConfig::m_preserve_battle_scores)
6868
6884
{
@@ -6872,6 +6888,8 @@ void ServerLobby::storeResults()
6872
6888
lap_counts.push_back (0 );
6873
6889
scores.push_back (std::to_string (p.second ));
6874
6890
karts.push_back (" unknown" );
6891
+ colors.push_back (-1 );
6892
+ has_quit.push_back (1 );
6875
6893
}
6876
6894
}
6877
6895
m_saved_ffa_points.clear ();
@@ -6881,18 +6899,19 @@ void ServerLobby::storeResults()
6881
6899
" INSERT INTO %s "
6882
6900
" (username, venue, reverse, mode, laps, result"
6883
6901
#ifdef ENABLE_RECORDS_V2
6884
- " , difficulty, kart, config"
6902
+ " , difficulty, kart, config, items, kart_color, is_quit "
6885
6903
#endif
6886
6904
" ) "
6887
6905
" VALUES (?, '%s', '%s', '%s', %d, '%s'"
6888
6906
#ifdef ENABLE_RECORDS_V2
6889
- " , %d, '%s', '%s'"
6907
+ " , %d, '%s', '%s', '%s', %f, %d "
6890
6908
#endif
6891
6909
" );" ,
6892
6910
m_results_table_name.c_str (), track_name.c_str (),
6893
6911
reverse_string.c_str (), mode_name.c_str (), lap_counts[i], scores[i].c_str ()
6894
6912
#ifdef ENABLE_RECORDS_V2
6895
- , getDifficulty (), karts[i].c_str (), " "
6913
+ , getDifficulty (), karts[i].c_str (), kc_string.c_str (),
6914
+ powerup_string.c_str (), colors[i], has_quit[i]
6896
6915
#endif
6897
6916
);
6898
6917
std::string name = usernames[i];
0 commit comments