summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fe33d1f)
raw | patch | inline | side by side (parent: fe33d1f)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Tue, 1 Aug 2017 02:51:23 +0000 (05:51 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Tue, 1 Aug 2017 02:51:23 +0000 (05:51 +0300) |
src/engine/e_fixedbuffer.pas | patch | blob | history | |
src/game/Doom2DF.dpr | patch | blob | history | |
src/game/g_main.pas | patch | blob | history | |
src/shared/envvars.pas | [new file with mode: 0644] | patch | blob |
index e71445f08a171eed516a0416b060a1b7fc0c8b62..92c984c9d6115165241836d2b8778a540503a062 100644 (file)
if (B^.WritePos + N > B^.Len) then
B^.Len := B^.WritePos + N + 1;
- CopyMemory(Pointer(Cardinal(Addr(B^.Data)) + B^.WritePos),
+ CopyMemory(Pointer(NativeUInt(Addr(B^.Data)) + B^.WritePos),
@V, N);
B^.WritePos := B^.WritePos + N;
begin
if (B^.ReadPos + N >= BUF_SIZE) then Exit;
- CopyMemory(@V, Pointer(Cardinal(Addr(B^.Data)) + B^.ReadPos), N);
+ CopyMemory(@V, Pointer(NativeUInt(Addr(B^.Data)) + B^.ReadPos), N);
B^.ReadPos := B^.ReadPos + N;
end;
if (P > B^.Len) then B^.Len := P;
- CopyMemory(Pointer(Cardinal(Addr(B^.Data)) + B^.WritePos),
+ CopyMemory(Pointer(NativeUInt(Addr(B^.Data)) + B^.WritePos),
@V[1], Len);
B^.WritePos := P;
Len := B^.Len - B^.ReadPos;
SetLength(Result, Len);
- CopyMemory(@Result[1], Pointer(Cardinal(Addr(B^.Data)) + B^.ReadPos), Len);
+ CopyMemory(@Result[1], Pointer(NativeUInt(Addr(B^.Data)) + B^.ReadPos), Len);
B^.ReadPos := B^.ReadPos + Len;
end;
procedure e_Raw_Read_Generic(P: Pointer; var V; N: Cardinal);
begin
- CopyMemory(@V, Pointer(Cardinal(P) + RawPos), N);
+ CopyMemory(@V, Pointer(NativeUInt(P) + RawPos), N);
RawPos := RawPos + N;
end;
if Len = 0 then Exit;
SetLength(Result, Len);
- CopyMemory(@Result[1], Pointer(Cardinal(P) + RawPos), Len);
+ CopyMemory(@Result[1], Pointer(NativeUInt(P) + RawPos), Len);
RawPos := RawPos + Len;
end;
diff --git a/src/game/Doom2DF.dpr b/src/game/Doom2DF.dpr
index 3fbd82967e4ab008d93e2f75585f3aad9b4ddc49..a410545235488e6f622c29dc43437d8f9d9721a7 100644 (file)
--- a/src/game/Doom2DF.dpr
+++ b/src/game/Doom2DF.dpr
fmodtypes in '../lib/FMOD/fmodtypes.pas',
{$ENDIF}
BinEditor in '../shared/BinEditor.pas',
+ envvars in '../shared/envvars.pas',
g_panel in 'g_panel.pas',
g_language in 'g_language.pas',
ImagingTypes,
on E: Exception do
e_WriteLog(Format(_lc[I_SYSTEM_ERROR_MSG], [E.Message]), MSG_FATALERROR);
else
- e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [LongWord(ExceptAddr())]), MSG_FATALERROR);
+ e_WriteLog(Format(_lc[I_SYSTEM_ERROR_UNKNOWN], [NativeUInt(ExceptAddr())]), MSG_FATALERROR);
end;
end.
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 59e78702837c555b40e90103f08bccf5633806ac..2d9d7e4eb2df64e2d08e858a4dea80816045716d 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
e_graphics, e_input, g_game, g_console, g_gui,
e_sound, g_options, g_sound, g_player,
g_weapons, SysUtils, g_triggers, MAPDEF, g_map,
- MAPSTRUCT, g_menu, g_language, g_net, utils, conbuf;
+ MAPSTRUCT, g_menu, g_language, g_net,
+ utils, conbuf, envvars;
var
charbuff: Array [0..15] of Char;
g_Language_Set(gLanguage);
{$IFDEF HEADLESS}
+ {$IFDEF USE_SDLMIXER}
+ sdlflags := SDL_INIT_TIMER or SDL_INIT_AUDIO or $00004000;
+ // HACK: shit this into env and hope for the best
+ SetEnvVar('SDL_AUDIODRIVER', 'dummy');
+ {$ELSE}
sdlflags := SDL_INIT_TIMER or $00004000;
+ {$ENDIF}
{$ELSE}
{$IFDEF USE_SDLMIXER}
sdlflags := SDL_INIT_EVERYTHING;
procedure Init();
var
a: Integer;
+ NoSound: Boolean;
begin
Randomize;
+{$IFDEF HEADLESS}
+ {$IFDEF USE_SDLMIXER}
+ NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy
+ {$ELSE}
+ NoSound := True; // FMOD backend will sort it out
+ {$ENDIF}
+{$ELSE}
+ NoSound := False;
+{$ENDIF}
+
e_WriteLog('Init Input', MSG_NOTIFY);
e_InitInput();
if (not gNoSound) then
begin
e_WriteLog('Initializing sound system', MSG_NOTIFY);
- e_InitSoundSystem({$IFDEF HEADLESS}True{$ELSE}False{$ENDIF});
+ e_InitSoundSystem(NoSound);
end;
e_WriteLog('Init game', MSG_NOTIFY);
diff --git a/src/shared/envvars.pas b/src/shared/envvars.pas
--- /dev/null
+++ b/src/shared/envvars.pas
@@ -0,0 +1,48 @@
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$MODE OBJFPC}
+unit envvars;
+
+interface
+
+uses SysUtils, CTypes;
+
+function SetEnvVar(const VarName: AnsiString; const VarVal: AnsiString): Boolean;
+
+implementation
+
+{$IFDEF WINDOWS}
+uses Windows;
+function setenv(const VarStr: PChar; const VarVal: PChar; Repl: cint): cint;
+begin
+ if (SetEnvironmentVariable(VarStr, VarVal)) then
+ Result := 0
+ else
+ Result := -1;
+end;
+{$ELSE}
+{$LINKLIB c}
+const clib = 'c';
+function setenv(const VarStr: PChar; const VarVal: PChar; Repl: cint): cint;
+cdecl; external clib name 'setenv';
+{$ENDIF}
+
+function SetEnvVar(const VarName: AnsiString; const VarVal: AnsiString): Boolean;
+begin
+ Result := (setenv(PChar(VarName), PChar(VarVal), 1) = 0);
+end;
+
+end.