From 074a1ba82dbfd61f8aa56491c67f441214ad5f20 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 4 Oct 2013 23:02:54 +0200 Subject: [PATCH] Change signature of getDBScores --- Vocaluxe/Base/CDataBase.cs | 10 +++++----- Vocaluxe/Base/CGame.cs | 8 ++++---- Vocaluxe/Screens/CScreenHighscore.cs | 17 ++++++----------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index ada2a0a6..888ea52d 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -247,21 +247,20 @@ namespace Vocaluxe.Base return lastInsertID; } - public static void LoadScore(out List scores, int songID, EGameMode gameMode) + public static List LoadScore(int songID, EGameMode gameMode) { + var scores = new List(); using (var connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + _HighscoreFilePath; - scores = new List(); - try { connection.Open(); } catch (Exception) { - return; + return scores; } using (var command = new SQLiteCommand(connection)) @@ -284,7 +283,7 @@ namespace Vocaluxe.Base int dataBaseSongID = _GetDataBaseSongID(songID, command); if (dataBaseSongID < 0) - return; + return scores; command.CommandText = "SELECT PlayerName, Score, Date, Difficulty, LineNr, id FROM Scores " + "WHERE [SongID] = @SongID AND [Medley] = @Medley AND [Duet] = @Duet AND [ShortSong] = @ShortSong " + @@ -315,6 +314,7 @@ namespace Vocaluxe.Base } } } + return scores; } private static void _IncreaseSongCounter(int dataBaseSongID, SQLiteCommand command) diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index c64eaabc..de97c5b0 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -149,14 +149,14 @@ namespace Vocaluxe.Base return _SongQueue.GetSong(); } - public static CSong GetSong(int num) + public static CSong GetSong(int round) { - return _SongQueue.GetSong(num); + return _SongQueue.GetSong(round); } - public static EGameMode GetGameMode(int num) + public static EGameMode GetGameMode(int round) { - return _SongQueue.GetGameMode(num); + return _SongQueue.GetGameMode(round); } public static int GetNumSongs() diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 9a75c943..ab44c452 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -194,10 +194,6 @@ namespace Vocaluxe.Screens base.OnShow(); _Round = 0; _Pos = 0; - CPoints points = CGame.GetPoints(); - _Scores = new List[points.NumRounds]; - for (int i = 0; i < _Scores.Length; i++) - _Scores[i] = new List(); _NewEntryIDs.Clear(); _AddScoresToDB(); _LoadScores(); @@ -231,15 +227,14 @@ namespace Vocaluxe.Screens private void _LoadScores() { - CPoints points = CGame.GetPoints(); - if (points == null) - return; - _Pos = 0; - for (int round = 0; round < points.NumRounds; round++) + int rounds = CGame.NumRounds; + _Scores = new List[rounds]; + for (int round = 0; round < rounds; round++) { - SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; - CDataBase.LoadScore(out _Scores[round], player.SongID, player.GameMode); + int songID = CGame.GetSong(round).ID; + EGameMode gameMode = CGame.GetGameMode(round); + _Scores[round] = CDataBase.LoadScore(songID, gameMode); } }