diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 1840635b1ce51b070fb950c573b8db8093fe7d8e..7864bedebfd18c005a89a1e1c7003f51d39cb3d2 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
+(* 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/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
unit g_main;
interface
implementation
uses
- SDL2, GL, GLExt, WADEDITOR, e_log, g_window,
+ SDL2, GL, GLExt, wadreader, e_log, g_window,
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, sfs;
+ MAPSTRUCT, g_menu, g_language, g_net,
+ utils, conbuf, envvars;
var
charbuff: Array [0..15] of Char;
procedure Main();
+var
+ sdlflags: LongWord;
begin
+ e_InitWritelnDriver();
+
GetDir(0, GameDir);
MapsDir := GameDir + '/maps/';
DataDir := GameDir + '/data/';
e_WriteLog('Read config file', MSG_NOTIFY);
g_Options_Read(GameDir + '/' + CONFIG_FILENAME);
+{$IFDEF HEADLESS}
+ conbufDumpToStdOut := true;
+{$ENDIF}
+ e_WriteToStdOut := False; //{$IFDEF HEADLESS}True;{$ELSE}False;{$ENDIF}
+
//GetSystemDefaultLCID()
//e_WriteLog('Read language file', MSG_NOTIFY);
e_WriteLog(gLanguage, MSG_NOTIFY);
g_Language_Set(gLanguage);
-{$IFDEF USE_SDLMIXER}
- if SDL_Init({SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO or SDL_INIT_AUDIO}SDL_INIT_EVERYTHING) < 0 then
+{$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}
- if SDL_Init(SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO) < 0 then
+ {$IFDEF USE_SDLMIXER}
+ sdlflags := SDL_INIT_EVERYTHING;
+ {$ELSE}
+ sdlflags := SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO;
+ {$ENDIF}
{$ENDIF}
+ if SDL_Init(sdlflags) < 0 then
raise Exception.Create('SDL: Init failed: ' + SDL_GetError());
+{$IFDEF HEADLESS}
SDL_StartTextInput();
+{$ENDIF}
e_WriteLog('Entering SDLMain', MSG_NOTIFY);
- {$WARNINGS OFF}
+{$WARNINGS OFF}
SDLMain();
- {$WARNINGS ON}
+{$WARNINGS ON}
+{$IFDEF HEADLESS}
SDL_StopTextInput();
+{$ENDIF}
e_WriteLog('Releasing SDL', MSG_NOTIFY);
SDL_Quit();
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();
else
e_WriteLog('Input: No Joysticks.', MSG_NOTIFY);
- if not gNoSound then
+ if (not gNoSound) then
begin
e_WriteLog('Initializing sound system', MSG_NOTIFY);
- e_InitSoundSystem();
+ e_InitSoundSystem(NoSound);
end;
e_WriteLog('Init game', MSG_NOTIFY);
else
begin
for a := 0 to 14 do charbuff[a] := charbuff[a+1];
- charbuff[15] := SFSUpCase(C);
+ charbuff[15] := UpCase1251(C);
Cheat();
end;
end;