From 2bb04d205b5b0302907d3f14c25ccf440fa97dc4 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Fri, 28 Mar 2008 00:31:17 +0000 Subject: fixed EIntOverflow in function TMenu.WideCharUpperCase when used on Linux ( or other Unix Systems ) this fix should make Eddies fix for same or similar problem Correct, because the previous fix simply did an UpperCase which is not WideString Compatible. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@977 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 23 ++++++++++++++++++++++- Game/Code/UltraStar.lpr | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'Game') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 4fd9262a..fa09145d 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -163,6 +163,7 @@ const implementation uses UCommon, + ULog, UMain, UDrawTexture, UGraphic, @@ -1546,12 +1547,32 @@ end; function TMenu.WideCharUpperCase(const wchar : WideChar) : WideString; begin + // JB - I got EIntOverflow in this function ( on Linux ), the same as eddie may have... + // after a little investigation I found this info : http://www.hu.freepascal.org/lists/fpc-pascal/2007-October/015233.html + // seems we need "cwstring", which I added to UltraStar.lpr and all seems to work now.. + // I assume it will work correcty on Darwin also. Im not sure if Eddie uses the Ultrastar.lpr file.. if not then maybe we need + // to move some of that stuff to the dpr file with appropriate IFDEF's to make it easier to maintain. + + {$IFDEF Win32} + Result := WideUpperCase(wchar); + {$ELSE} + debugwriteln( 'WideCharUpperCase('+wchar+'):'+inttostr(length(wchar)) ); + + // fpc implementation dosnt seem to like non wide strings... or Empty strings + if ( wchar <> emptyWideStr ) then + Result := WideUpperCase(wchar) + else + Result := UpperCase(wchar); + {$ENDIF} + +(* {$IFDEF DARWIN} // eddie: WideUpperCase crashes on the mac with WideChars. Result := UpperCase(wchar); {$ELSE} Result := WideUpperCase(wchar); - {$ENDIF} + {$ENDIF} +*) end; procedure TMenu.onHide; diff --git a/Game/Code/UltraStar.lpr b/Game/Code/UltraStar.lpr index ab4a6534..06a6f86e 100644 --- a/Game/Code/UltraStar.lpr +++ b/Game/Code/UltraStar.lpr @@ -7,6 +7,7 @@ program UltraStar; uses {$ifdef unix} // http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial cthreads, // THIS MUST be the first used unit !! + cwstring, {$endif} {$ifdef MSWINDOWS} // do not initialize the widgets in linux -> see below {$ifdef LCL} -- cgit v1.2.3