Skip to content

Commit

Permalink
Fix SqliteConnector always returning valid beatmap objects
Browse files Browse the repository at this point in the history
Will now return null when beatmap cant be found.
  • Loading branch information
Piotrekol committed Sep 27, 2016
1 parent 8fe4432 commit 7ddbc45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions osu!StreamCompanion/Code/Core/SqliteConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,25 @@ private void FillBeatmapParameters(Beatmap beatmap)

}
public Beatmap GetBeatmap(int mapId)
{//mapId should be >0

{
string sql = "SELECT * FROM `withID` WHERE MapId = " + mapId;
var reader = Query(sql);
var beatmap = new Beatmap();
Beatmap beatmap = null;

if (reader.Read())
{
beatmap = new Beatmap();
beatmap.Read(reader);
}
else
{
reader.Dispose();
sql = "SELECT * FROM `Temp` WHERE MapId = " + mapId;
reader = Query(sql);
beatmap = new Beatmap();

if (reader.Read())
{
beatmap = new Beatmap();
beatmap.Read(reader);
}
reader.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion osu!StreamCompanion/Code/Core/SqliteControler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void StoreTempBeatmap(Beatmap beatmap)
///
/// </summary>
/// <param name="mapId"></param>
/// <returns>Beatmap object with filled or not map data (use mapId property as check if data is set)</returns>
/// <returns>Beatmap object with data, or null on not found</returns>
public Beatmap GetBeatmap(int mapId)
{
lock (_sqlConnector)
Expand Down

0 comments on commit 7ddbc45

Please sign in to comment.