diff options
author | b_krueger <b_krueger@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-18 10:52:29 +0000 |
---|---|---|
committer | b_krueger <b_krueger@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-18 10:52:29 +0000 |
commit | 92336ab5d99d185d9316330d39a3bb8f881eb9f3 (patch) | |
tree | 39249f0f2d571d5913e78bf1c0d846ba074da8d0 /src/base | |
parent | 9ceadd2532207fcb512fcfecbd2895055422ad99 (diff) | |
download | usdx-92336ab5d99d185d9316330d39a3bb8f881eb9f3.tar.gz usdx-92336ab5d99d185d9316330d39a3bb8f881eb9f3.tar.xz usdx-92336ab5d99d185d9316330d39a3bb8f881eb9f3.zip |
- Commented delay of error.log in mainloop (error-log is no longer generated without any error)
- If an old 1.01 Ultrastar.db exists, it will no longer deleted on startup, it will be converted into the new 1.1 schema
--> added new column in us_songs: rating. This will allow to rate songs in upcoming versions
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1847 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | src/base/UDataBase.pas | 50 | ||||
-rw-r--r-- | src/base/UMain.pas | 4 |
2 files changed, 31 insertions, 23 deletions
diff --git a/src/base/UDataBase.pas b/src/base/UDataBase.pas index 0f9d88a7..6691e475 100644 --- a/src/base/UDataBase.pas +++ b/src/base/UDataBase.pas @@ -131,6 +131,7 @@ const procedure TDataBaseSystem.Init(const Filename: string); var Version: integer; + finalizeConvertion : boolean; begin if Assigned(ScoreDB) then Exit; @@ -143,24 +144,30 @@ begin ScoreDB := TSQLiteDatabase.Create(Filename); fFilename := Filename; - // Close and delete outdated file Version := GetVersion(); - if ((Version <> 0) and (Version <> cDBVersion)) then + + if not ScoreDB.TableExists(cUS_Statistics_Info) then begin - Log.LogInfo('Outdated cover-database file found', 'TDataBaseSystem.Init'); - // Close and delete outdated file - ScoreDB.Free; - if (not DeleteFile(Filename)) then - raise Exception.Create('Could not delete ' + Filename); - // Reopen - ScoreDB := TSQLiteDatabase.Create(Filename); + Log.LogInfo('Outdated song-database file found', 'TDataBaseSystem.Init'); Version := 0; - end; - + //following just works with convertion of usdx1.01 to usdx1.1! + //Rename old Tables - to be able to insert new table-structures + ScoreDB.ExecSQL('ALTER TABLE US_Scores RENAME TO us_scores_101;'); + ScoreDB.ExecSQL('ALTER TABLE US_Songs RENAME TO us_songs_101;'); + + ScoreDB.ExecSQL('CREATE TABLE IF NOT EXISTS ['+cUS_Statistics_Info+'] (' + + '[ResetTime] INTEGER' + + ');'); + // insert creation timestamp + ScoreDB.ExecSQL(Format('INSERT INTO ['+cUS_Statistics_Info+'] ' + + '([ResetTime]) VALUES(%d);', + [DateTimeToUnix(Now())])); + finalizeConvertion := true; //means: convertion has to be done! + end else finalizeConvertion := false; + // Set version number after creation if (Version = 0) then SetVersion(cDBVersion); - // SQLite does not handle VARCHAR(n) or INT(n) as expected. // Texts do not have a restricted length, no matter which type is used, @@ -181,20 +188,21 @@ begin '[ID] INTEGER PRIMARY KEY, ' + '[Artist] TEXT NOT NULL, ' + '[Title] TEXT NOT NULL, ' + - '[TimesPlayed] INTEGER NOT NULL' + + '[TimesPlayed] INTEGER NOT NULL, ' + + '[Rating] INTEGER NULL' + ');'); - if not ScoreDB.TableExists(cUS_Statistics_Info) then + if finalizeConvertion then begin - ScoreDB.ExecSQL('CREATE TABLE IF NOT EXISTS ['+cUS_Statistics_Info+'] (' + - '[ResetTime] INTEGER' + - ');'); - // insert creation timestamp - ScoreDB.ExecSQL(Format('INSERT INTO ['+cUS_Statistics_Info+'] ' + - '([ResetTime]) VALUES(%d);', - [DateTimeToUnix(Now())])); + //insert old values in new db-schemes (/tables) + ScoreDB.ExecSQL('INSERT INTO '+cUS_Scores+' SELECT SongID, Difficulty, Player, Score FROM us_scores_101;'); + ScoreDB.ExecSQL('INSERT INTO '+cUS_Songs+' SELECT ID, Artist, Title, TimesPlayed, ''NULL'' FROM us_songs_101;'); + //now drop old tables + ScoreDB.ExecSQL('DROP TABLE us_scores_101;'); + ScoreDB.ExecSQL('DROP TABLE us_songs_101;'); end; + except on E: Exception do begin diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 275510fc..187318a6 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -359,11 +359,11 @@ begin CountMidTime; Delay := Floor(1000 / MAX_FPS - 1000 * TimeMid); - Log.LogError ('MainLoop', 'Delay: ' + intToStr(Delay)); + //Log.LogError ('MainLoop', 'Delay: ' + intToStr(Delay)); if Delay >= 1 then SDL_Delay(Delay); // dynamic, maximum is 100 fps - Log.LogError ('MainLoop', 'Delay: ok ' + intToStr(Delay)); + //Log.LogError ('MainLoop', 'Delay: ok ' + intToStr(Delay)); CountSkipTime; |