summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9107de6)
raw | patch | inline | side by side (parent: 9107de6)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 21 Oct 2019 20:01:27 +0000 (23:01 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 21 Oct 2019 20:01:27 +0000 (23:01 +0300) |
src/engine/e_log.pas | patch | blob | history | |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_main.pas | patch | blob | history | |
src/game/g_options.pas | patch | blob | history |
diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas
index e717595c64d6ba710778c7951bce2ca3e1883690..7159c18445614beaff3ba4fc3f534df33d2cf474 100644 (file)
--- a/src/engine/e_log.pas
+++ b/src/engine/e_log.pas
procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
-
procedure e_WriteStackTrace (const msg: AnsiString);
-
-var
- e_WriteToStdOut: Boolean = False;
-
-
implementation
uses
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index 561dc361399d0b4b413567cbd33d8318df712d50..076980afd984b2fdb3001407bea70026cac7caaf 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
begin
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
-{$IFDEF ANDROID}
-{$I-}
- e_SetSafeSlowLog(true);
- if SDL_AndroidGetExternalStorageState() <> 0 then
- begin
- storage := SDL_AndroidGetExternalStoragePath();
- Chdir(storage);
- e_WriteLog('Use external storage: ' + storage, TMsgType.Notify)
- end
- else
- begin
- storage := SDL_AndroidGetInternalStoragePath();
- Chdir(storage);
- e_WriteLog('Use internal storage: ' + storage, TMsgType.Notify)
- end;
- if IOresult <> 0 then
- begin
- SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, PChar('Invalid path'), PChar('Can''t chdir to ' + storage), nil);
- result := 1;
- exit
- end;
- SetEnvVar('TIMIDITY_CFG', 'timidity.cfg');
-{$ENDIF ANDROID}
-
f := 1;
while f <= ParamCount do
begin
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 0e349afbbdc61f35e582f3c00d6bf7bcaf147bae..16085cead25ca40398edda2a2a43bb8a4b6f51e6 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
{$ENDIF}
{$IFDEF LINUX}
BaseUnix,
+{$ENDIF}
+{$IFDEF USE_SDL2}
+ SDL2,
{$ENDIF}
wadreader, e_log, g_window,
e_graphics, e_input, g_game, g_console, g_gui,
if (length(result) > 0) and (result[length(result)] <> '/') then result := result+'/';
end;
+procedure PrintDirs (msg: AnsiString; dirs: SSArray);
+ var dir: AnsiString;
+begin
+ e_LogWriteln(msg + ':');
+ for dir in dirs do
+ e_LogWriteln(' ' + dir);
+end;
procedure InitPath;
- var i: Integer; rwdir, rodir: AnsiString;
+ var i: Integer; rwdir, rodir: AnsiString; rwdirs, rodirs: SSArray;
//first: Boolean = true;
procedure xput (s: AnsiString);
//writeln('NEW PATH(1): ['+str+']');
end;
- procedure AddDef (var arr: SSArray; str: AnsiString);
- begin
- if (length(arr) = 0) then AddPath(arr, str, false)
+ procedure AddDef (var dirs: SSArray; base: SSArray; append: AnsiString);
+ var s: AnsiString;
+ begin
+ if Length(dirs) = 0 then
+ for s in base do
+ AddPath(dirs, e_CatPath(s, append), false)
+ end;
+
+ procedure AddDir (var dirs: SSArray; append: AnsiString);
+ begin
+ SetLength(dirs, Length(dirs) + 1);
+ dirs[High(dirs)] := append
+ end;
+
+ function GetDefaultRODirs (): SSArray;
+ {$IFDEF UNIX}
+ var home: AnsiString;
+ {$ENDIF}
+ begin
+ {$IFDEF USE_SDL2}
+ AddDir(result, SDL_GetBasePath());
+ AddDir(result, SDL_GetPrefPath('', 'doom2df'));
+ {$ENDIF}
+ {$IFDEF UNIX}
+ AddDir(result, '/usr/share/doom2df');
+ AddDir(result, '/usr/local/share/doom2df');
+ home := GetEnvironmentVariable('HOME');
+ if home <> '' then
+ AddDir(result, e_CatPath(home, '.doom2df'));
+ {$ENDIF}
+ {$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
+ AddDir(result, SDL_AndroidGetInternalStoragePath());
+ if SDL_AndroidGetExternalStorageState() <> 0 then
+ AddDir(result, SDL_AndroidGetExternalStoragePath());
+ {$ENDIF}
+ AddDir(result, '.');
+ end;
+
+ function GetDefaultRWDirs (): SSArray;
+ {$IFDEF UNIX}
+ var home: AnsiString;
+ {$ENDIF}
+ begin
+ {$IF DEFINED(USE_SDL2)}
+ AddDir(result, SDL_GetPrefPath('', 'doom2df'));
+ {$ENDIF}
+ {$IFDEF UNIX}
+ home := GetEnvironmentVariable('HOME');
+ if home <> '' then
+ AddDir(result, e_CatPath(home, '.doom2df'));
+ {$ENDIF}
+ {$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
+ if SDL_AndroidGetExternalStorageState() <> 0 then
+ AddDir(result, SDL_AndroidGetExternalStoragePath());
+ {$ENDIF}
+ AddDir(result, '.');
end;
begin
binPath := GetBinaryPath();
xput('binPath=['+binPath+']');
- for i := 1 to ParamCount do if (ParamStr(i) = '--cwd') then begin forceCurrentDir := true; break; end;
+ for i := 1 to ParamCount do
+ begin
+ if (ParamStr(i) = '--cwd') then
+ begin
+ forceCurrentDir := true;
+ break
+ end
+ end;
i := 1;
while i < ParamCount do
end;
(* RO *)
- AddDef(DataDirs, 'data');
- AddDef(ModelDirs, 'data/models');
- AddDef(MegawadDirs, 'maps/megawads');
- AddDef(MapDirs, 'maps');
- AddDef(WadDirs, 'wads');
+ rodirs := GetDefaultRODirs();
+ AddDef(DataDirs, rodirs, 'data');
+ AddDef(ModelDirs, rodirs, 'data/models');
+ AddDef(MegawadDirs, rodirs, 'maps/megawads');
+ AddDef(MapDirs, rodirs, 'maps');
+ AddDef(WadDirs, rodirs, 'wads');
+
(* RW *)
- AddDef(LogDirs, '.');
- AddDef(SaveDirs, 'data');
- AddDef(CacheDirs, 'data/cache');
- AddDef(ConfigDirs, '.');
- AddDef(MapDownloadDirs, 'maps/downloads');
- AddDef(WadDownloadDirs, 'wads/downloads');
- AddDef(ScreenshotDirs, 'screenshots');
+ rwdirs := GetDefaultRWDirs();
+ AddDef(LogDirs, rwdirs, '');
+ AddDef(SaveDirs, rwdirs, 'data');
+ AddDef(CacheDirs, rwdirs, 'data/cache');
+ AddDef(ConfigDirs, rwdirs, '');
+ AddDef(MapDownloadDirs, rwdirs, 'maps/downloads');
+ AddDef(WadDownloadDirs, rwdirs, 'wads/downloads');
+ AddDef(ScreenshotDirs, rwdirs, 'screenshots');
for i := 0 to High(MapDirs) do
AddPath(AllMapDirs, MapDirs[i]);
{$IFDEF HEADLESS}
LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log');
{$ELSE}
- LogFileName := e_Catpath(rwdir, 'Doom2DF.log');
+ LogFileName := e_CatPath(rwdir, 'Doom2DF.log');
{$ENDIF}
end
end;
xput('binPath=['+binPath+']');
end;
-procedure Main();
-{$IFDEF ENABLE_HOLMES}
- var flexloaded: Boolean;
-{$ENDIF}
- var s: AnsiString;
+procedure InitPrep;
+ {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
+ var timiditycfg: AnsiString;
+ {$ENDIF}
+ var i: Integer;
begin
- InitPath;
+ {$IFDEF HEADLESS}
+ conbufDumpToStdOut := true;
+ {$ENDIF}
+ for i := 1 to ParamCount do
+ begin
+ if (ParamStr(i) = '--con-stdout') then
+ begin
+ conbufDumpToStdOut := true;
+ break
+ end
+ end;
+
if LogFileName <> '' then
e_InitLog(LogFileName, TWriteMode.WM_NEWFILE);
e_InitWritelnDriver();
+ e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify);
+ e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify);
-// e_InitLog(GameDir + '/' + LogFileName, TWriteMode.WM_NEWFILE);
+ e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify);
- e_WriteLog(
- 'Doom 2D: Forever version ' + GAME_VERSION +
- ' proto ' + IntToStr(NET_PROTOCOL_VER),
- TMsgType.Notify
- );
- e_WriteLog(
- 'Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME,
- TMsgType.Notify
- );
+ PrintDirs('DataDirs', DataDirs);
+ PrintDirs('ModelDirs', ModelDirs);
+ PrintDirs('MegawadDirs', MegawadDirs);
+ PrintDirs('MapDirs', MapDirs);
+ PrintDirs('WadDirs', WadDirs);
- e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify);
+ PrintDirs('LogDirs', LogDirs);
+ PrintDirs('SaveDirs', SaveDirs);
+ PrintDirs('CacheDirs', CacheDirs);
+ PrintDirs('ConfigDirs', ConfigDirs);
+ PrintDirs('ScreenshotDirs', ScreenshotDirs);
+ PrintDirs('MapDownloadDirs', MapDownloadDirs);
+ PrintDirs('WadDownloadDirs', WadDownloadDirs);
GameWAD := e_FindWad(DataDirs, 'GAME');
- assert(GameWad <> '', 'GAME.WAD not installed?');
+ if GameWad = '' then
+ begin
+ e_WriteLog('GAME.WAD not installed?', TMsgType.Fatal);
+ {$IFDEF USE_SDL2}
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, 'Doom 2D Forever', 'GAME.WAD not installed?', nil);
+ {$ENDIF}
+ Halt(1);
+ end;
-{$IFDEF HEADLESS}
- conbufDumpToStdOut := true;
-{$ENDIF}
- e_WriteToStdOut := False; //{$IFDEF HEADLESS}True;{$ELSE}False;{$ENDIF}
+ {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
+ timiditycfg := 'timidity.cfg';
+ if e_FindResource(ConfigDirs, timiditycfg) = true then
+ begin
+ timiditycfg := ExpandFileName(timiditycfg);
+ SetEnvVar('TIMIDITY_CFG', timiditycfg);
+ e_LogWritefln('Set TIMIDITY_CFG = "%s"', [timiditycfg]);
+ end;
+ {$ENDIF}
+end;
+procedure Main();
+{$IFDEF ENABLE_HOLMES}
+ var flexloaded: Boolean;
+{$ENDIF}
+ var s: AnsiString;
+begin
+ InitPath;
+ InitPrep;
e_InitInput;
-
sys_Init;
s := CONFIG_FILENAME;
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index f15e7c7718e8568906c3afea23ba9ed108daf5d6..7aea70fc0a5f9add839ce28ab3bfe334a975fc9f 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
{$IFDEF USE_SDL2}
procedure g_Options_SetDefaultVideo;
-var
- target, closest, display: TSDL_DisplayMode;
- percentage: Integer;
+ var display: TSDL_DisplayMode;
+ {$IFNDEF ANDROID}
+ var target, closest: TSDL_DisplayMode; percentage: Integer;
+ {$ENDIF}
begin
(* Display 0 = Primary display *)
gScreenWidth := 640;