From aebc91a64ea8241a37785914fd62c4998bfd4927 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 12 Nov 2007 18:46:19 +0000 Subject: Fixed a typo and a some programming errors in UIni that lead to memory abuses git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1@606 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UIni.pas | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'Game') diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas index 3a77bda4..61f48c6a 100644 --- a/Game/Code/Classes/UIni.pas +++ b/Game/Code/Classes/UIni.pas @@ -1,4 +1,4 @@ -gunit UIni; +unit UIni; interface uses IniFiles, ULog, SysUtils; @@ -251,20 +251,32 @@ begin // Resolution SetLength(IResolution, 0); Modes := SDL_ListModes(nil, SDL_OPENGL or SDL_FULLSCREEN); // Check if there are any modes available - while Assigned(Modes) do //this should solve the biggest wine problem | THANKS Linnex (11.11.07) - begin - SetLength(IResolution, Length(IResolution) + 1); - IResolution[High(IResolution)] := IntToStr(Modes^.w) + 'x' + IntToStr(Modes^.h); - Inc(Modes); - end; - - // if no modes were set, then failback to 800x600 + + //this should solve the biggest wine problem | THANKS Linnex (11.11.07) + // if no modes were set, then fallback to 800x600 // as per http://sourceforge.net/forum/message.php?msg_id=4544965 // THANKS : linnex at users.sourceforge.net - if Length(IResolution) < 1 then + + if (modes = PPSDL_Rect( 0 ) ) then + begin //NO modes available => Fallback to 800x600 + SetLength(IResolution, 1); + IResolution[High(IResolution)] := '800x600'; + end + {Else If (modes = PPSDL_Rect(-1)) then begin - SetLength(IResolution, Length(IResolution) + 1); - IResolution[High(IResolution)] := IntToStr(800) + 'x' + IntToStr(600); + //All Resolutions are Available + //This may be handled, too + // to-do : for future Version + end} + Else //Add all valid Modes + begin + I := 0; + Repeat + SetLength(IResolution, I + 1); + IResolution[I] := IntToStr((modes^)^.w) + 'x' + IntToStr((modes^)^.h); + Inc(I); + Inc(modes) + Until (modes^)=nil; end; // reverse order -- cgit v1.2.3