diff options
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UCommon.pas | 53 | ||||
-rw-r--r-- | Game/Code/Classes/UConfig.pas | 48 | ||||
-rw-r--r-- | Game/Code/Classes/UPlatformLinux.pas | 22 |
3 files changed, 63 insertions, 60 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 |