aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-16 15:00:46 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-16 15:00:46 +0000
commit4401ddfaa20d87492442cb7656c37d13b75995d7 (patch)
tree9caf2c1a46daf42f4ad8c5e7e2d3e59369ea3c73 /Game
parentf01995d31ad202ccbbe8f79213303e479923cd81 (diff)
downloadusdx-4401ddfaa20d87492442cb7656c37d13b75995d7.tar.gz
usdx-4401ddfaa20d87492442cb7656c37d13b75995d7.tar.xz
usdx-4401ddfaa20d87492442cb7656c37d13b75995d7.zip
Delphi 7 compatibility fix:
- "in"-operator does not work with WideChar operands, e.g. "mychar in ['a..z'] - FPC_VERSION/RELEASE/PATCH (e.g. {$IF FPC_VERSION > 2}) must be defined as constants because delphi 7 does not care about {$IFDEF FPC} sections and complains about undefined constant expressions. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1150 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UCommon.pas53
-rw-r--r--Game/Code/Classes/UConfig.pas48
-rw-r--r--Game/Code/Classes/UPlatformLinux.pas22
-rw-r--r--Game/Code/lib/ffmpeg/avutil.pas8
-rw-r--r--Game/Code/switches.inc6
5 files changed, 67 insertions, 70 deletions
diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas
index fe3ea6a4..3c32a804 100644
--- a/Game/Code/Classes/UCommon.pas
+++ b/Game/Code/Classes/UCommon.pas
@@ -16,6 +16,7 @@ uses
Messages,
{$ENDIF}
sdl,
+ UConfig,
ULog;
{$IFNDEF DARWIN}
@@ -88,11 +89,12 @@ uses
{$IFDEF Delphi}
Dialogs,
{$ENDIF}
- {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ {$IFDEF FPC}
+ {$IF FPC_VERSION_INT >= 2002002} // >= 2.2.2
clocale,
+ {$IFEND}
{$ENDIF}
- UMain,
- UConfig;
+ UMain;
// data used by the ...Locale() functions
@@ -100,11 +102,13 @@ uses
var
PrevNumLocale: string;
-{$IFNDEF FPC_VERSION_2_2_2_PLUS}
+{$IFDEF FPC}
+{$IF FPC_VERSION_INT < 2002002} // < 2.2.2
const
__LC_NUMERIC = 1;
function setlocale(category: integer; locale: pchar): pchar; cdecl; external 'c' name 'setlocale';
+{$IFEND}
{$ENDIF}
{$ENDIF}
@@ -660,19 +664,27 @@ end;
function IsAlphaChar(ch: WideChar): boolean;
begin
// TODO: add chars > 255 when unicode-fonts work?
- Result := ch in
- ['A'..'Z', // A-Z
- 'a'..'z', // a-z
- #170, #181, #186,
- #192..#214,
- #216..#246,
- #248..#255
- ];
+ case ch of
+ 'A'..'Z', // A-Z
+ 'a'..'z', // a-z
+ #170,#181,#186,
+ #192..#214,
+ #216..#246,
+ #248..#255:
+ Result := true;
+ else
+ Result := false;
+ end;
end;
function IsNumericChar(ch: WideChar): boolean;
begin
- Result := ch in ['0'..'9'];
+ case ch of
+ '0'..'9':
+ Result := true;
+ else
+ Result := false;
+ end;
end;
function IsAlphaNumericChar(ch: WideChar): boolean;
@@ -683,12 +695,23 @@ end;
function IsPunctuationChar(ch: WideChar): boolean;
begin
// TODO: add chars outside of Latin1 basic (0..127)?
- Result := ch in [ ' '..'/', ':'..'@', '['..'`', '{'..'~' ];
+ case ch of
+ ' '..'/',':'..'@','['..'`','{'..'~':
+ Result := true;
+ else
+ Result := false;
+ end;
end;
function IsControlChar(ch: WideChar): boolean;
begin
- Result := ch in [ #0..#31, #127..#159 ];
+ case ch of
+ #0..#31,
+ #127..#159:
+ Result := true;
+ else
+ Result := false;
+ end;
end;
(*
diff --git a/Game/Code/Classes/UConfig.pas b/Game/Code/Classes/UConfig.pas
index 4f87115a..46ba2e74 100644
--- a/Game/Code/Classes/UConfig.pas
+++ b/Game/Code/Classes/UConfig.pas
@@ -59,6 +59,7 @@ interface
{$IFDEF FPC}
{$MODE Delphi}
+ {$MACRO ON} // for evaluation of FPC_VERSION/RELEASE/PATCH
{$ENDIF}
{$I switches.inc}
@@ -106,41 +107,15 @@ const
USDX_STRING = 'UltraStar Deluxe';
(*
- * FPC_VERSION is already defined as a macro by FPC itself.
- * You should use the built-in macros
- * FPC_VERSION (=PPC_MAJOR)
- * FPC_RELEASE (=PPC_MINOR)
- * FPC_PATCH (=PPC_RELEASE)
- * instead of the PPC_* ones defined here.
- * This way Windows users do not need to set this.
- *
- * Note: It might be necessary to enable macros ({$MACRO ON} or -Sm)
- * first if you want to use the FPC_* macros.
- * In FPC 2.2.0 they work even without macros being enabled but
- * this might be different in other versions.
- *
- * Example (Check for version >= 2.0.1):
- * {$IF (FPC_VERSION > 2) or ((FPC_VERSION = 2) and
- * ( (FPC_RELEASE > 0) or ((FPC_RELEASE = 0) and
- * (FPC_PATCH >= 1)) ))}
- * {$DEFINE FPC_VER_201_PLUS}
- * {$ENDIF}
- *
- * IMPORTANT: do NOT check this way:
- * {$IF (FPC_VERSION >= 2) and (FPC_RELEASE >= 0) and (FPC_PATCH >= 1)}
- * ...
- * In this case version 3.0.0 does not match because Patch 0 is less than 1.
+ * FPC version numbers are already defined as built-in macros:
+ * FPC_VERSION (MAJOR)
+ * FPC_RELEASE (MINOR)
+ * FPC_PATCH (RELEASE)
+ * Since FPC_VERSION is already defined, we will use FPC_VERSION_INT as
+ * composed version number.
*)
-
- //PPC_VERSION_MAJOR = @PPC_VERSION_MAJOR@;
- //PPC_VERSION_MINOR = @PPC_VERSION_MINOR@;
- //PPC_VERSION_RELEASE = @PPC_VERSION_RELEASE@;
- //PPC_VERSION = (PPC_VERSION_MAJOR * VERSION_MAJOR) +
- // (PPC_VERSION_MINOR * VERSION_MINOR) +
- // (PPC_VERSION_RELEASE * VERSION_RELEASE);
-
- {$IFDEF Delphi}
- // Delphi evaluates every $IF-directive even if it is disabled by a surrounding
+ {$IFNDEF FPC}
+ // Delphi 7 evaluates every $IF-directive even if it is disabled by a surrounding
// $IF or $IFDEF so the follwing will give you an error in delphi:
// {$IFDEF FPC}{$IF (FPC_VERSION > 2)}...{$IFEND}{$ENDIF}
// The reason for this error is that FPC_VERSION is not a valid constant.
@@ -149,6 +124,11 @@ const
FPC_RELEASE = 0;
FPC_PATCH = 0;
{$ENDIF}
+
+ FPC_VERSION_INT = (FPC_VERSION * VERSION_MAJOR) +
+ (FPC_RELEASE * VERSION_MINOR) +
+ (FPC_PATCH * VERSION_RELEASE);
+
{$IFDEF HaveFFMpeg}
diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas
index fabca659..f9b83f2c 100644
--- a/Game/Code/Classes/UPlatformLinux.pas
+++ b/Game/Code/Classes/UPlatformLinux.pas
@@ -10,7 +10,8 @@ interface
uses
Classes,
- UPlatform;
+ UPlatform,
+ UConfig;
type
@@ -34,12 +35,11 @@ implementation
uses
UCommandLine,
BaseUnix,
- {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ {$IF FPC_VERSION_INT >= 2002002}
pwd,
- {$ENDIF}
+ {$IFEND}
SysUtils,
- ULog,
- UConfig;
+ ULog;
function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
var
@@ -134,19 +134,19 @@ end;
* Returns the user's home directory terminated by a path delimiter
*)
function TPlatformLinux.GetHomeDir(): string;
-{$IFDEF FPC_VERSION_2_2_2_PLUS}
+{$IF FPC_VERSION_INT >= 2002002}
var
PasswdEntry: PPasswd;
-{$ENDIF}
+{$IFEND}
begin
Result := '';
- {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ {$IF FPC_VERSION_INT >= 2002002}
// try to retrieve the info from passwd
PasswdEntry := FpGetpwuid(FpGetuid());
if (PasswdEntry <> nil) then
Result := PasswdEntry.pw_dir;
- {$ENDIF}
+ {$IFEND}
// fallback if passwd does not contain the path
if (Result = '') then
Result := GetEnvironmentVariable('HOME');
@@ -154,11 +154,11 @@ begin
if (Result <> '') then
Result := IncludeTrailingPathDelimiter(Result);
- {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ {$IF FPC_VERSION_INT >= 2002002}
// GetUserDir() is another function that returns a user path.
// It uses env-var HOME or a fallback to a temp-dir.
//Result := GetUserDir();
- {$ENDIF}
+ {$IFEND}
end;
// FIXME: Maybe this should be TPlatformBase.Halt() for all platforms
diff --git a/Game/Code/lib/ffmpeg/avutil.pas b/Game/Code/lib/ffmpeg/avutil.pas
index 3bd565c7..c4b6f633 100644
--- a/Game/Code/lib/ffmpeg/avutil.pas
+++ b/Game/Code/lib/ffmpeg/avutil.pas
@@ -71,10 +71,10 @@ const
{$IFEND}
{$IFDEF FPC}
- // check for version of FPC < 2.2.0
- {$IF (FPC_VERSION < 2) or ((FPC_VERSION = 2) and (FPC_RELEASE < 2))}
- type uint64 = QWord;
- {$IFEND}
+{$IF FPC_VERSION_INT < 2002000} // < 2.2.0
+type
+ uint64 = QWord;
+{$IFEND}
{$ENDIF}
type
diff --git a/Game/Code/switches.inc b/Game/Code/switches.inc
index 20956492..52df7e7d 100644
--- a/Game/Code/switches.inc
+++ b/Game/Code/switches.inc
@@ -20,12 +20,6 @@
{$DEFINE DEBUG}
{$ENDIF}
- // for transition from 2.2.0 to 2.2.2
- // remove 2.2.0 support as soon as packages for all distributions are available
- {$IF (FPC_VERSION > 2) or ((FPC_VERSION = 2) and ((FPC_RELEASE > 2) or ((FPC_RELEASE = 2) and (FPC_PATCH >= 2))))}
- {$DEFINE FPC_VERSION_2_2_2_PLUS}
- {$IFEND}
-
{$DEFINE HasInline}
{$ELSE}
{$DEFINE Delphi}