aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UCommon.pas24
-rw-r--r--Game/Code/Classes/ULight.pas29
-rw-r--r--Game/Code/Classes/UPlatformLinux.pas101
-rw-r--r--Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch54
-rw-r--r--Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas9
-rw-r--r--Game/Code/lib/JEDI-SDL/moduleloader-libc.patch25
-rw-r--r--Game/Code/switches.inc6
7 files changed, 119 insertions, 129 deletions
diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas
index 418c0c1a..768abe89 100644
--- a/Game/Code/Classes/UCommon.pas
+++ b/Game/Code/Classes/UCommon.pas
@@ -88,15 +88,26 @@ uses
{$IFDEF Delphi}
Dialogs,
{$ENDIF}
- {$IFDEF LINUX}
- libc,
+ {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ clocale,
{$ENDIF}
UMain,
UConfig;
+
+// data used by the ...Locale() functions
+{$IFDEF LINUX}
var
PrevNumLocale: string;
+{$IFNDEF FPC_VERSION_2_2_2_PLUS}
+const
+ __LC_NUMERIC = 1;
+
+function setlocale(category: integer; locale: pchar): pchar; cdecl; external 'c' name 'setlocale';
+{$ENDIF}
+{$ENDIF}
+
// In Linux and maybe MacOSX some units (like cwstring) call setlocale(LC_ALL, '')
// to set the language/country specific locale (e.g. charset) for this application.
// Unfortunately, LC_NUMERIC is set by this call too.
@@ -116,15 +127,15 @@ var
procedure SetDefaultNumericLocale();
begin
{$ifdef LINUX}
- PrevNumLocale := setlocale(LC_NUMERIC, nil);
- setlocale(LC_NUMERIC, 'C');
+ PrevNumLocale := setlocale(__LC_NUMERIC, nil);
+ setlocale(__LC_NUMERIC, 'C');
{$endif}
end;
procedure RestoreNumericLocale();
begin
{$ifdef LINUX}
- setlocale(LC_NUMERIC, PChar(PrevNumLocale));
+ setlocale(__LC_NUMERIC, PChar(PrevNumLocale));
{$endif}
end;
@@ -258,13 +269,14 @@ function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool;
end;
begin
- // Use clock_gettime here maybe ... from libc
+ // Use clock_gettime(CLOCK_REALTIME, ...) here (but not from the libc unit)
lpPerformanceCount := RDTSC();
result := true;
end;
function QueryPerformanceFrequency(lpFrequency:TLARGEINTEGER):Bool;
begin
+ // clock_getres(CLOCK_REALTIME, ...)
lpFrequency := 0;
result := true;
end;
diff --git a/Game/Code/Classes/ULight.pas b/Game/Code/Classes/ULight.pas
index f91d614c..a4bebfd2 100644
--- a/Game/Code/Classes/ULight.pas
+++ b/Game/Code/Classes/ULight.pas
@@ -41,42 +41,25 @@ uses
{$IFDEF UseSerialPort}
zlportio,
{$ENDIF}
- {$IFNDEF win32}
- libc,
- {$ENDIF}
UTime;
{$IFDEF FPC}
function GetTime: TDateTime;
- {$IFDEF win32}
var
SystemTime: TSystemTime;
begin
GetLocalTime(SystemTime);
with SystemTime do
-{$IFDEF DARWIN}
+ begin
+ {$IFDEF UNIX}
Result := EncodeTime(Hour, Minute, Second, MilliSecond);
-{$ELSE}
+ {$ELSE}
Result := EncodeTime(wHour, wMinute, wSecond, wMilliSeconds);
-{$ENDIF}
- end;
- {$ELSE}
- Type
- Time_t = longint;
- TTime_T = Time_t;
- var
- T : TTime_T;
- TV: TTimeVal;
- UT: TUnixTime;
- begin
- gettimeofday(TV, nil);
- T := TV.tv_sec;
- localtime_r(@T, @UT);
- Result := EncodeTime(UT.tm_hour, UT.tm_min, UT.tm_sec, TV.tv_usec div 1000);
+ {$ENDIF}
+ end;
end;
- {$ENDIF}
-
+
{$ENDIF}
diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas
index 985f9db1..fabca659 100644
--- a/Game/Code/Classes/UPlatformLinux.pas
+++ b/Game/Code/Classes/UPlatformLinux.pas
@@ -8,13 +8,15 @@ interface
{$I switches.inc}
-uses Classes, UPlatform;
+uses
+ Classes,
+ UPlatform;
type
TPlatformLinux = class(TInterfacedObject, IPlatform)
private
- function GetHomedir(): string;
+ function GetHomeDir(): string;
public
function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean;
@@ -29,28 +31,23 @@ type
implementation
-// check for version of FPC >= 2.2.0
-{$IFDEF FPC}
- {$IF (FPC_VERSION > 2) or ((FPC_VERSION = 2) and (FPC_RELEASE >= 2))}
- {$DEFINE FPC_VERSION_2_2_0_PLUS}
- {$IFEND}
-{$ENDIF}
-
-uses
- libc,
+uses
UCommandLine,
BaseUnix,
+ {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ pwd,
+ {$ENDIF}
SysUtils,
ULog,
UConfig;
function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
var
- i : Integer;
- TheDir : pDir;
- ADirent : pDirent;
- Entry : Longint;
- lAttrib : integer;
+ i : Integer;
+ TheDir : pDir;
+ ADirent : pDirent;
+ Entry : Longint;
+ lAttrib : integer;
begin
i := 0;
Filter := LowerCase(Filter);
@@ -61,7 +58,7 @@ begin
repeat
ADirent := FpReadDir(TheDir^);
- If Assigned(ADirent) and (ADirent^.d_name <> '.') and (ADirent^.d_name <> '..') then
+ if Assigned(ADirent) and (ADirent^.d_name <> '.') and (ADirent^.d_name <> '..') then
begin
lAttrib := FileGetAttr(Dir + ADirent^.d_name);
if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then
@@ -91,14 +88,14 @@ function TPlatformLinux.GetLogPath : WideString;
begin
if FindCmdLineSwitch( cUseLocalPaths ) then
begin
- result := ExtractFilePath(ParamStr(0));
+ Result := ExtractFilePath(ParamStr(0));
end
else
begin
{$IFDEF UseLocalDirs}
- result := ExtractFilePath(ParamStr(0));
+ Result := ExtractFilePath(ParamStr(0));
{$ELSE}
- result := LogPath+'/';
+ Result := LogPath + PathDelim;
{$ENDIF}
end;
@@ -108,43 +105,63 @@ end;
function TPlatformLinux.GetGameSharedPath : WideString;
begin
if FindCmdLineSwitch( cUseLocalPaths ) then
- result := ExtractFilePath(ParamStr(0))
+ Result := ExtractFilePath(ParamStr(0))
else
begin
-{$IFDEF UseLocalDirs}
- result := ExtractFilePath(ParamStr(0));
-{$ELSE}
- result := SharedPath+'/';
-{$ENDIF}
+ {$IFDEF UseLocalDirs}
+ Result := ExtractFilePath(ParamStr(0));
+ {$ELSE}
+ Result := SharedPath + PathDelim;
+ {$ENDIF}
end;
end;
-function TPlatformLinux.GetGameUserPath : WideString;
+function TPlatformLinux.GetGameUserPath: WideString;
begin
if FindCmdLineSwitch( cUseLocalPaths ) then
- result := ExtractFilePath(ParamStr(0))
+ Result := ExtractFilePath(ParamStr(0))
else
begin
-{$IFDEF UseLocalDirs}
- result := ExtractFilePath(ParamStr(0));
-{$ELSE}
- result := get_homedir()+'/.'+PathSuffix+'/';
-{$ENDIF}
+ {$IFDEF UseLocalDirs}
+ Result := ExtractFilePath(ParamStr(0));
+ {$ELSE}
+ Result := GetHomeDir() + '.'+PathSuffix + PathDelim;
+ {$ENDIF}
end;
end;
-function TPlatformLinux.GetHomedir(): string;
+(**
+ * Returns the user's home directory terminated by a path delimiter
+ *)
+function TPlatformLinux.GetHomeDir(): string;
+{$IFDEF FPC_VERSION_2_2_2_PLUS}
var
- pPasswdEntry : Ppasswd;
- lUserName : String;
+ PasswdEntry: PPasswd;
+{$ENDIF}
begin
- pPasswdEntry := getpwuid( getuid() );
- result := pPasswdEntry^.pw_dir;
+ Result := '';
+
+ {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ // try to retrieve the info from passwd
+ PasswdEntry := FpGetpwuid(FpGetuid());
+ if (PasswdEntry <> nil) then
+ Result := PasswdEntry.pw_dir;
+ {$ENDIF}
+ // fallback if passwd does not contain the path
+ if (Result = '') then
+ Result := GetEnvironmentVariable('HOME');
+ // add trailing path delimiter (normally '/')
+ if (Result <> '') then
+ Result := IncludeTrailingPathDelimiter(Result);
+
+ {$IFDEF FPC_VERSION_2_2_2_PLUS}
+ // GetUserDir() is another function that returns a user path.
+ // It uses env-var HOME or a fallback to a temp-dir.
+ //Result := GetUserDir();
+ {$ENDIF}
end;
-// FIXME: just a dirty-fix to make the linux build work again.
-// This i the same as the corresponding function for MacOSX.
-// Maybe this should be TPlatformBase.Halt()
+// FIXME: Maybe this should be TPlatformBase.Halt() for all platforms
procedure TPlatformLinux.Halt;
begin
System.Halt;
@@ -152,7 +169,7 @@ end;
function TPlatformLinux.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean;
begin
- // Linux and Mac don't check for running apps at the moment
+ // Linux does not check for running apps at the moment
Result := false;
end;
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch b/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch
index aeebeee5..e08ca63e 100644
--- a/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch
+++ b/Game/Code/lib/JEDI-SDL/OpenGL-Set8087CW.patch
@@ -14,57 +14,3 @@ Index: OpenGL/Pas/gl.pas
LoadOpenGL( GLLibName );
-Index: OpenGL/Pas/opengl12.pas
-===================================================================
---- OpenGL/Pas/opengl12.pas (revision 961)
-+++ OpenGL/Pas/opengl12.pas (working copy)
-@@ -7125,16 +7125,15 @@
-
- //----------------------------------------------------------------------------------------------------------------------
-
--{$ifndef VER140}
-+// RaiseLastOSError did not exist in Delphi 5
-+{$ifdef VER130}
-
- procedure RaiseLastOSError;
- begin
-- {$ifndef FPC}
- RaiseLastWin32Error;
-- {$endif}
- end;
-
--{$endif VER140}
-+{$endif}
-
- //----------------------------------------------------------------------------------------------------------------------
-
-@@ -9948,21 +9947,16 @@
- end;
-
- //----------------------------------------------------------------------------------------------------------------------
--{$ifdef FPC}
--const Default8087CW: Word = $1332;
-
--{$ASMMODE INTEL}
--procedure Set8087CW(NewCW: Word); Assembler;
--asm
-- MOV Default8087CW, AX
--end;
--{$endif}
--
--//----------------------------------------------------------------------------------------------------------------------
--
- initialization
-- ContextList := TThreadList.Create;
-- Set8087CW($133F);
-+ ContextList := TThreadList.Create;
-+ {$IF Defined(CPU386) or Defined(CPUI386) or Defined(CPUX86_64)}
-+ // FPC has its own implementation of Set8087CW now. The wrongly
-+ // coded (the important asm-directives were missing so it was not of any use!!!)
-+ // implementation was removed from this unit so it does not hide the correct FPC version anymore.
-+ // This should fix some EDivByZero exceptions in floating-point expressions.
-+ Set8087CW($133F);
-+ {$IFEND}
- finalization
- CloseOpenGL;
- ContextList.Free;
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas
index 56863ea5..ea4f220c 100644
--- a/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas
+++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas
@@ -185,15 +185,16 @@ end;
{$IFDEF Unix}
uses
-{$ifdef Linux}
- Types,
- Libc;
-{$else}
+{$ifdef FPC}
dl,
Types,
Baseunix,
Unix;
+{$else}
+ Types,
+ Libc;
{$endif}
+
type
// Handle to a loaded .so
TModuleHandle = Pointer;
diff --git a/Game/Code/lib/JEDI-SDL/moduleloader-libc.patch b/Game/Code/lib/JEDI-SDL/moduleloader-libc.patch
new file mode 100644
index 00000000..02255db0
--- /dev/null
+++ b/Game/Code/lib/JEDI-SDL/moduleloader-libc.patch
@@ -0,0 +1,25 @@
+Index: SDL/Pas/moduleloader.pas
+===================================================================
+--- SDL/Pas/moduleloader.pas (revision 1144)
++++ SDL/Pas/moduleloader.pas (working copy)
+@@ -185,15 +185,16 @@
+
+ {$IFDEF Unix}
+ uses
+-{$ifdef Linux}
+- Types,
+- Libc;
+-{$else}
++{$ifdef FPC}
+ dl,
+ Types,
+ Baseunix,
+ Unix;
++{$else}
++ Types,
++ Libc;
+ {$endif}
++
+ type
+ // Handle to a loaded .so
+ TModuleHandle = Pointer;
diff --git a/Game/Code/switches.inc b/Game/Code/switches.inc
index 52df7e7d..20956492 100644
--- a/Game/Code/switches.inc
+++ b/Game/Code/switches.inc
@@ -20,6 +20,12 @@
{$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}