From 74b2872c860073f7e30dc651da013c16d19ba6c6 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 14 Apr 2010 13:15:14 +0000 Subject: - fix crash when not existing skin is selected in config file - restrict loading of themes w/o correct version tag 'USD 110' - remove version tag from classic theme because it causes a crash on load due to missing statics and or texts that some screens assume to be there, e.g. score screen git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2239 b956fd51-792f-4845-bead-9b4dfca2ff2c --- game/themes/Classic.ini | 1 - src/base/UIni.pas | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/game/themes/Classic.ini b/game/themes/Classic.ini index 1ea83f5e..f317e55e 100644 --- a/game/themes/Classic.ini +++ b/game/themes/Classic.ini @@ -5,7 +5,6 @@ [Theme] Name=Classic -US_Version=USD 101 [Colors] White = 255 255 255 diff --git a/src/base/UIni.pas b/src/base/UIni.pas index 6f875e50..6e86c558 100644 --- a/src/base/UIni.pas +++ b/src/base/UIni.pas @@ -721,6 +721,7 @@ var SearchResult: TSearchRec; ThemeIni: TMemIniFile; ThemeName: string; + ThemeVersion: string; I: integer; Iter: IFileIterator; FileInfo: TFileInfo; @@ -737,10 +738,18 @@ begin Log.LogStatus('Found Theme: ' + FileInfo.Name.ToNative, 'Theme'); //Read Themename from Theme - ThemeIni := TMemIniFile.Create(FileInfo.Name.ToNative); + ThemeIni := TMemIniFile.Create(ThemePath.Append(FileInfo.Name).ToNative); ThemeName := UpperCase(ThemeIni.ReadString('Theme','Name', FileInfo.Name.SetExtension('').ToNative)); + ThemeVersion := Trim(UpperCase(ThemeIni.ReadString('Theme','US_Version', 'no version tag'))); ThemeIni.Free; + // don't load theme with wrong version tag + if ThemeVersion <> 'USD 110' then + begin + Log.LogWarn('Wrong Version (' + ThemeVersion + ') in Theme : ' + ThemeName, 'Theme'); + Continue; + end; + //Search for Skins for this Theme for I := Low(Skin.Skin) to High(Skin.Skin) do begin @@ -767,6 +776,12 @@ begin Skin.onThemeChange; SkinNo := GetArrayIndex(ISkin, IniFile.ReadString('Themes', 'Skin', ISkin[0])); + + { there may be a not existing skin in the ini file + e.g. due to manual edit or corrupted file. + in this case we load the first Skin } + if SkinNo = -1 then + SkinNo := 0; end; procedure TIni.LoadScreenModes(IniFile: TCustomIniFile); -- cgit v1.2.3