DEADSOFTWARE

server: build headless with completely disabled render, system driver and menus
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 17 Jan 2022 20:15:58 +0000 (23:15 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 17 Jan 2022 20:15:58 +0000 (23:15 +0300)
13 files changed:
src/game/Doom2DF.lpr
src/game/g_console.pas
src/game/g_game.pas
src/game/g_gui.pas
src/game/g_language.pas
src/game/g_monsters.pas
src/game/g_net.pas
src/game/g_netmaster.pas
src/game/g_netmsg.pas
src/game/g_options.pas
src/game/g_player.pas
src/game/g_playermodel.pas
src/game/g_window.pas

index 1be6b0c4e9a3744003c22d5c9605084e349e28e2..4a74e6614da75779ca42cffceae0af86c9c646d8 100644 (file)
@@ -124,10 +124,8 @@ uses
   g_grid in 'g_grid.pas',
   g_game in 'g_game.pas',
   g_gfx in 'g_gfx.pas',
-  g_gui in 'g_gui.pas',
   g_items in 'g_items.pas',
   g_map in 'g_map.pas',
-  g_menu in 'g_menu.pas',
   g_monsters in 'g_monsters.pas',
   g_options in 'g_options.pas',
   g_phys in 'g_phys.pas',
@@ -139,19 +137,23 @@ uses
   g_triggers in 'g_triggers.pas',
   g_weapons in 'g_weapons.pas',
   g_window in 'g_window.pas',
-{$IFDEF USE_SYSSTUB}
-  g_system in 'stub/g_system.pas',
-  g_touch in 'stub/g_touch.pas',
-{$ENDIF}
-{$IFDEF USE_SDL}
-  g_system in 'sdl/g_system.pas',
-  g_touch in 'sdl/g_touch.pas',
-{$ENDIF}
-{$IFDEF USE_SDL2}
-  g_system in 'sdl2/g_system.pas',
-  g_touch in 'sdl2/g_touch.pas',
+{$IFNDEF HEADLESS}
+  {$IFDEF USE_SYSSTUB}
+    g_system in 'stub/g_system.pas',
+    g_touch in 'stub/g_touch.pas',
+  {$ENDIF}
+  {$IFDEF USE_SDL}
+    g_system in 'sdl/g_system.pas',
+    g_touch in 'sdl/g_touch.pas',
+  {$ENDIF}
+  {$IFDEF USE_SDL2}
+    g_system in 'sdl2/g_system.pas',
+    g_touch in 'sdl2/g_touch.pas',
+  {$ENDIF}
 {$ENDIF}
 
+{$IFNDEF HEADLESS}
+  {$I ../shared/vampimg.inc}
   r_animations in 'opengl/r_animations.pas',
   r_console in 'opengl/r_console.pas',
   r_game in 'opengl/r_game.pas',
@@ -168,6 +170,9 @@ uses
   r_textures in 'opengl/r_textures.pas',
   r_weapons in 'opengl/r_weapons.pas',
   r_window in 'opengl/r_window.pas',
+  g_gui in 'g_gui.pas',
+  g_menu in 'g_menu.pas',
+{$ENDIF}
 
 {$IFDEF USE_FMOD}
   fmod in '../lib/FMOD/fmod.pas',
@@ -201,7 +206,6 @@ uses
   fui_flexlay in '../flexui/fui_flexlay.pas',
   fui_ctls in '../flexui/fui_ctls.pas',
 {$ENDIF}
-  {$I ../shared/vampimg.inc}
 
   SysUtils, Classes;
 
@@ -229,7 +233,9 @@ begin
        if (NetMode = NET_SERVER) then g_Net_Host_Update()
   else if (NetMode = NET_CLIENT) then g_Net_Client_Update();
   // think
+{$IFNDEF HEADLESS}
   r_Render_Update;
+{$ENDIF}
   g_Game_Update();
   // server: send any accumulated outgoing data to clients
   if NetMode = NET_SERVER then g_Net_Flush();
@@ -242,7 +248,11 @@ var
   Time, Time_Delta: Int64;
   Frame: Int64;
 begin
-  result := sys_HandleInput();
+  {$IFDEF HEADLESS}
+    Result := False;
+  {$ELSE}
+    Result := sys_HandleInput();
+  {$ENDIF}
 
   Time := GetTickCount64();
   Time_Delta := Time-Time_Old;
@@ -290,8 +300,10 @@ begin
       gLerpFactor := 1.0
     else
       gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0);
+{$IFNDEF HEADLESS}
     r_Game_Draw;
     sys_Repaint;
+{$ENDIF}
     Frame := Time
   end
   else
@@ -911,18 +923,20 @@ end;
 
   procedure ScreenResize (w, h: Integer);
   begin
-    r_Render_Resize(w, h);
-    {$IFDEF ENABLE_HOLMES}
-      fuiScrWdt := w;
-      fuiScrHgt := h;
-    {$ENDIF}
-    {$IFNDEF ANDROID}
-      (* This will fix menu reset on keyboard showing *)
-      g_Menu_Reset;
-    {$ENDIF}
-    //g_Game_ClearLoading;
-    {$IFDEF ENABLE_HOLMES}
-      if assigned(oglInitCB) then oglInitCB;
+    {$IFNDEF HEADLESS}
+      r_Render_Resize(w, h);
+      {$IFDEF ENABLE_HOLMES}
+        fuiScrWdt := w;
+        fuiScrHgt := h;
+      {$ENDIF}
+      {$IFNDEF ANDROID}
+        (* This will fix menu reset on keyboard showing *)
+        g_Menu_Reset;
+      {$ENDIF}
+      //g_Game_ClearLoading;
+      {$IFDEF ENABLE_HOLMES}
+        if assigned(oglInitCB) then oglInitCB;
+      {$ENDIF}
     {$ENDIF}
   end;
 
@@ -934,24 +948,32 @@ end;
     InitPrep;
     e_Input_Initialize;
     e_InitSoundSystem(NoSound);
-    sys_Init;
-    sys_CharPress := @CharPress; (* install hook *)
-    sys_ScreenResize := @ScreenResize; (* install hook *)
+    {$IFNDEF HEADLESS}
+      sys_Init;
+      sys_CharPress := @CharPress; (* install hook *)
+      sys_ScreenResize := @ScreenResize; (* install hook *)
+    {$ENDIF}
     g_Options_SetDefault;
     g_Options_SetDefaultVideo;
     g_Console_Initialize;
     // TODO move load configs here
     g_Language_Set(gLanguage);
-    r_Render_Initialize;
-    g_Touch_Init;
+    {$IFNDEF HEADLESS}
+      r_Render_Initialize;
+      g_Touch_Init;
+    {$ENDIF}
     DebugOptions;
     g_Net_InitLowLevel;
     // TODO init serverlist
     {$IFDEF ENABLE_HOLMES}
       InitHolmes;
     {$ENDIF}
-    g_PlayerModel_LoadAll;
-    r_Render_Load;
+    {$IFDEF HEADLESS}
+      g_PlayerModel_LoadFake('doomer', 'doomer.wad');
+    {$ELSE}
+      g_PlayerModel_LoadAll;
+      r_Render_Load;
+    {$ENDIF}
     g_Game_Init;
     {$IFNDEF HEADLESS}
       g_Menu_Init;
@@ -970,16 +992,18 @@ end;
     {$IFNDEF HEADLESS}
       g_GUI_Destroy;
       g_Menu_Free;
+      r_Render_Free;
     {$ENDIF}
-    r_Render_Free;
     {$IFDEF ENABLE_HOLMES}
       FreeHolmes;
     {$ENDIF}
     g_Net_Slist_ShutdownAll;
     g_Net_DeinitLowLevel;
     (* g_Touch_Finalize; *)
-    r_Render_Finalize;
-    sys_Final;
+    {$IFNDEF HEADLESS}
+      r_Render_Finalize;
+      sys_Final;
+    {$ENDIF}
     g_Console_Finalize;
     e_ReleaseSoundSystem;
     e_Input_Finalize;
index feef35d638ad944f7b4352d12f11d24a0daa440b..91131d1d91e75bba067c9927f5d86ea118de5ef7 100644 (file)
@@ -100,9 +100,12 @@ var
 implementation
 
 uses
+  {$IFNDEF HEADLESS}
+    g_gui, g_menu, g_touch,
+  {$ENDIF}
   g_textures, e_input, g_game, g_gfx, g_player, g_items,
-  SysUtils, g_basic, g_options, Math, g_touch, e_res,
-  g_menu, g_gui, g_language, g_net, g_netmsg, e_log, conbuf;
+  SysUtils, g_basic, g_options, Math, e_res,
+  g_language, g_net, g_netmsg, e_log, conbuf;
 
 const
   configComment = 'generated by doom2d, do not modify';
@@ -158,7 +161,9 @@ begin
   gChatShow := False;
   gConsoleShow := not gConsoleShow;
   InputReady := False;
-  g_Touch_ShowKeyboard(gConsoleShow or gChatShow);
+  {$IFNDEF HEADLESS}
+    g_Touch_ShowKeyboard(gConsoleShow or gChatShow);
+  {$ENDIF}
 end;
 
 procedure g_Console_Chat_Switch (Team: Boolean = False);
@@ -170,7 +175,9 @@ begin
   InputReady := False;
   Line := '';
   CPos := 1;
-  g_Touch_ShowKeyboard(gConsoleShow or gChatShow);
+  {$IFNDEF HEADLESS}
+    g_Touch_ShowKeyboard(gConsoleShow or gChatShow);
+  {$ENDIF}
 end;
 
 // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks
@@ -864,10 +871,12 @@ begin
   'unbindall':
     for i := 0 to e_MaxInputKeys - 1 do
       g_Console_BindKey(i, '');
+{$IFNDEF HEADLESS}
   'showkeyboard':
     g_Touch_ShowKeyboard(True);
   'hidekeyboard':
     g_Touch_ShowKeyboard(False);
+{$ENDIF}
   'togglemenu':
     begin
       if gConsoleShow then
@@ -1756,15 +1765,23 @@ begin
 end;
 
 function BindsAllowed (key: Integer): Boolean;
+  var grab, active: Boolean;
 begin
   Result := False;
-  if (not g_GUIGrabInput) and (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then
+  {$IFDEF HEADLESS}
+    grab := False;
+    active := False;
+  {$ELSE}
+    grab := g_GUIGrabInput;
+    active := g_ActiveWindow <> nil;
+  {$ENDIF}
+  if (not grab) and (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then
   begin
     if gChatShow then
       Result := g_Console_MatchBind(key, 'togglemenu') or
                 g_Console_MatchBind(key, 'showkeyboard') or
                 g_Console_MatchBind(key, 'hidekeyboard')
-    else if gConsoleShow or (g_ActiveWindow <> nil) or (gGameSettings.GameType = GT_NONE) then
+    else if gConsoleShow or active or (gGameSettings.GameType = GT_NONE) then
       Result := g_Console_MatchBind(key, 'togglemenu') or
                 g_Console_MatchBind(key, 'toggleconsole') or
                 g_Console_MatchBind(key, 'showkeyboard') or
@@ -1792,9 +1809,14 @@ begin
 end;
 
 procedure g_Console_ProcessBindRepeat (key: Integer);
-  var i: Integer;
+  var i: Integer; active: Boolean;
 begin
-  if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+  {$IFDEF HEADLESS}
+    active := False;
+  {$ELSE}
+    active := g_ActiveWindow <> nil;
+  {$ENDIF}
+  if gConsoleShow or gChatShow or active then
   begin
     KeyPress(key); // key repeat in menus and shit
     Exit;
index fcd73a7bb8147add3027353f37401c4ea3791c8d..0123ecd695f4fbcd8769477f23d9c9529a1125ed 100644 (file)
@@ -17,12 +17,15 @@ unit g_game;
 
 interface
 
-uses
-  SysUtils, Classes,
-  MAPDEF,
-  g_base, g_basic, g_player, g_res_downloader,
-  g_sound, g_gui, utils, md5, mempool, xprofiler,
-  g_touch, g_weapons;
+  uses
+    {$IFNDEF HEADLESS}
+      g_gui, g_touch,
+    {$ENDIF}
+    SysUtils, Classes, MAPDEF,
+    g_base, g_basic, g_player, g_res_downloader,
+    g_sound, utils, md5, mempool, xprofiler,
+    g_weapons
+  ;
 
 type
   TGameSettings = record
@@ -110,7 +113,9 @@ function  g_Game_GetNextMap(): String;
 procedure g_Game_NextLevel();
 procedure g_Game_Pause(Enable: Boolean);
 procedure g_Game_HolmesPause(Enable: Boolean);
-procedure g_Game_InGameMenu(Show: Boolean);
+{$IFNDEF HEADLESS}
+  procedure g_Game_InGameMenu(Show: Boolean);
+{$ENDIF}
 function  g_Game_IsWatchedPlayer(UID: Word): Boolean;
 function  g_Game_IsWatchedTeam(Team: Byte): Boolean;
 procedure g_Game_Message(Msg: String; Time: Word);
@@ -149,7 +154,10 @@ function GetActivePlayerID_Next(Skip: Integer = -1): Integer;
 procedure SortGameStat(var stat: TPlayerStatArray);
 
 procedure KeyPress (K: Word);
-procedure CharPress (C: AnsiChar);
+
+{$IFNDEF HEADLESS}
+  procedure CharPress (C: AnsiChar);
+{$ENDIF}
 
 { procedure SetWinPause(Enable: Boolean); }
 
@@ -172,8 +180,6 @@ const
   GM_COOP = 4;
   GM_SINGLE = 5;
 
-  MESSAGE_DIKEY = WM_USER + 1;
-
   EXIT_QUIT            = 1;
   EXIT_SIMPLE          = 2;
   EXIT_RESTART         = 3;
@@ -440,15 +446,15 @@ uses
     g_holmes,
   {$ENDIF}
   {$IFNDEF HEADLESS}
-    r_render,
+    r_render, g_menu, r_playermodel, g_system,
   {$ENDIF}
-  e_res, g_window, g_menu,
+  e_res, g_window,
   e_input, e_log, g_console, g_items, g_map, g_panel,
   g_playermodel, g_gfx, g_options, Math,
   g_triggers, g_monsters, e_sound, CONFIG,
   g_language, g_net, g_phys,
   ENet, e_msg, g_netmsg, g_netmaster,
-  sfs, wadreader, g_system, r_playermodel;
+  sfs, wadreader;
 
   var
     charbuff: packed array [0..15] of AnsiChar = (
@@ -772,6 +778,7 @@ begin
 {$ENDIF}
 end;
 
+{$IFNDEF HEADLESS}
 procedure CharPress (C: AnsiChar);
 var
   Msg: g_gui.TMessage;
@@ -794,6 +801,7 @@ begin
     Cheat();
   end;
 end;
+{$ENDIF}
 
 
 // ////////////////////////////////////////////////////////////////////////// //
@@ -1230,7 +1238,10 @@ begin
   MessageText := '';
 
   EndingGameCounter := 0;
+
+{$IFNDEF HEADLESS}
   g_ActiveWindow := nil;
+{$ENDIF}
 
   gLMSRespawn := LMS_RESPAWN_NONE;
   gLMSRespawnTime := 0;
@@ -1239,35 +1250,37 @@ begin
     EXIT_SIMPLE: // Выход через меню или конец теста
       begin
         g_Game_Free();
-
         if gMapOnce  then
-          begin // Это был тест
-            g_Game_Quit();
-          end
+        begin // Это был тест
+          g_Game_Quit();
+        end
         else
-          begin // Выход в главное меню
-            gMusic.SetByName('MUSIC_MENU');
-            gMusic.Play();
-            if gState <> STATE_SLIST then
-            begin
-              g_GUI_ShowWindow('MainMenu');
-              gState := STATE_MENU;
-            end else
+        begin // Выход в главное меню
+{$IFDEF HEADLESS}
+          gState := STATE_MENU; // ???
+{$ELSE}
+          gMusic.SetByName('MUSIC_MENU');
+          gMusic.Play();
+          if gState <> STATE_SLIST then
+          begin
+            g_GUI_ShowWindow('MainMenu');
+            gState := STATE_MENU;
+          end else
+          begin
+            // Обновляем список серверов
+            slReturnPressed := True;
+            if g_Net_Slist_Fetch(slCurrent) then
             begin
-              // Обновляем список серверов
-              slReturnPressed := True;
-              if g_Net_Slist_Fetch(slCurrent) then
-              begin
-                if slCurrent = nil then
-                  slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
-              end
-              else
-                slWaitStr := _lc[I_NET_SLIST_ERROR];
-              g_Serverlist_GenerateTable(slCurrent, slTable);
-            end;
-
-            g_Game_ExecuteEvent('ongameend');
+              if slCurrent = nil then
+                slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
+            end
+            else
+              slWaitStr := _lc[I_NET_SLIST_ERROR];
+            g_Serverlist_GenerateTable(slCurrent, slTable);
           end;
+{$ENDIF}
+          g_Game_ExecuteEvent('ongameend');
+        end;
       end;
 
     EXIT_RESTART: // Начать уровень сначала
@@ -1637,6 +1650,7 @@ begin
     end
   end;
 
+{$IFNDEF HEADLESS}
   // HACK: add dynlight here
   if gwin_k8_enable_light_experiments then
   begin
@@ -1651,6 +1665,7 @@ begin
   end;
 
   if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
+{$ENDIF}
 end;
 
 // HACK: don't have a "key was pressed" function
@@ -1673,12 +1688,14 @@ begin
 end;
 
 procedure g_Game_Update();
-var
-  Msg: g_gui.TMessage;
-  Time: Int64;
-  a: Byte;
-  w: Word;
-  i, b: Integer;
+  var
+    {$IFNDEF HEADLESS}
+      Msg: g_gui.TMessage;
+      w: Word;
+    {$ENDIF}
+    Time: Int64;
+    a: Byte;
+    i, b: Integer;
 
   function sendMonsPos (mon: TMonster): Boolean;
   begin
@@ -1765,7 +1782,9 @@ begin
               e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
             )
             and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
             and (g_ActiveWindow = nil)
+{$ENDIF}
           )
           or (g_Game_IsNet and ((gInterTime > gInterEndTime) or ((gInterReadyCount >= NetClientCount) and (NetClientCount > 0))))
         )
@@ -1784,9 +1803,11 @@ begin
               begin
               // Выход в главное меню:
                 g_Game_Free;
+{$IFNDEF HEADLESS}
                 g_GUI_ShowWindow('MainMenu');
                 gMusic.SetByName('MUSIC_MENU');
                 gMusic.Play();
+{$ENDIF}
                 gState := STATE_MENU;
               end else
               begin
@@ -1812,7 +1833,9 @@ begin
             e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
           )
           and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
           and (g_ActiveWindow = nil)
+{$ENDIF}
         )
         then
         begin
@@ -1947,7 +1970,11 @@ begin
     // Обрабатываем клавиши игроков:
       if gPlayer1 <> nil then gPlayer1.ReleaseKeys();
       if gPlayer2 <> nil then gPlayer2.ReleaseKeys();
+{$IFDEF HEADLESS}
+      if (not gConsoleShow) and (not gChatShow) then
+{$ELSE}
       if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+{$ENDIF}
       begin
         ProcessPlayerControls(gPlayer1, 0, P1MoveButton);
         ProcessPlayerControls(gPlayer2, 1, P2MoveButton);
@@ -1960,8 +1987,12 @@ begin
     end; // if server
 
   // Наблюдатель
-    if (gPlayer1 = nil) and (gPlayer2 = nil) and
-       (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+    if (gPlayer1 = nil) and (gPlayer2 = nil)
+      and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
+      and (g_ActiveWindow = nil)
+{$ENDIF}
+    then
     begin
       if not gSpectKeyPress then
       begin
@@ -2205,6 +2236,7 @@ begin
   end; // if gameOn ...
 
 // Активно окно интерфейса - передаем клавиши ему:
+{$IFNDEF HEADLESS}
   if g_ActiveWindow <> nil then
   begin
     w := e_GetFirstKeyPressed();
@@ -2237,9 +2269,7 @@ begin
       //e_WriteLog('Read language file', MSG_NOTIFY);
       //g_Language_Load(DataDir + gLanguage + '.txt');
       g_Language_Set(gLanguage);
-{$IFNDEF HEADLESS}
       g_Menu_Reset();
-{$ENDIF}
       gLanguageChange := False;
     end;
   end;
@@ -2252,6 +2282,7 @@ begin
   begin
     KeyPress(IK_F10);
   end;
+{$ENDIF} // NOT HEADLESS
 
   Time := GetTickCount64() {div 1000};
 
@@ -2472,7 +2503,10 @@ begin
     g_Game_DeleteTestMap();
 
   gExit := EXIT_QUIT;
-  sys_RequestQuit;
+
+  {$IFNDEF HEADLESS}
+    sys_RequestQuit;
+  {$ENDIF}
 end;
 
 procedure g_Game_FreeData();
@@ -3295,7 +3329,9 @@ begin
       g_Player_ResetAll(Force or gLastMap, gGameSettings.GameType = GT_SINGLE);
 
       gState := STATE_NONE;
-      g_ActiveWindow := nil;
+      {$IFNDEF HEADLESS}
+        g_ActiveWindow := nil;
+      {$ENDIF}
       gGameOn := True;
 
       DisableCheats();
@@ -4526,8 +4562,12 @@ begin
   chstr := '';
   if cmd = 'pause' then
   begin
-    if (g_ActiveWindow = nil) then
+    {$IFNDEF HEADLESS}
+      if (g_ActiveWindow = nil) then
+        g_Game_Pause(not gPauseMain);
+    {$ELSE}
       g_Game_Pause(not gPauseMain);
+    {$ENDIF}
   end
   else if cmd = 'endgame' then
     gExit := EXIT_SIMPLE
@@ -5769,6 +5809,7 @@ begin
 end;
 {$ENDIF}
 
+{$IFNDEF HEADLESS}
 procedure g_Game_InGameMenu(Show: Boolean);
 begin
   if (g_ActiveWindow = nil) and Show then
@@ -5799,6 +5840,7 @@ begin
         g_Game_Pause(False);
     end;
 end;
+{$ENDIF}
 
 procedure g_Game_Pause (Enable: Boolean);
 var
@@ -6247,7 +6289,9 @@ begin
     PBarWasHere := false;
   end;
 
-  g_ActiveWindow := nil;
+  {$IFNDEF HEADLESS}
+    g_ActiveWindow := nil;
+  {$ENDIF}
 
   ProcessLoading(true);
 end;
index 960ba747cc4f083b5b29019809632ec9242b54cf..4bf8f7ceebdb91b961738448a90ae1a195f78053 100644 (file)
@@ -75,6 +75,8 @@ const
   WM_CHAR    = 102;
   WM_USER    = 110;
 
+  MESSAGE_DIKEY = WM_USER + 1;
+
 type
   TMessage = record
     Msg: DWORD;
index f7b553c4151c9f394aef8865c6038255c979f070..1b05ddd7a5bbdd92bbf285bedb7051bc492ee85e 100644 (file)
@@ -655,7 +655,7 @@ procedure g_Language_Dump(fileName: String);
 implementation
 
 uses
-  SysUtils, g_gui, g_basic, e_log, e_input;
+  SysUtils, {g_gui,} g_basic, e_log, e_input;
 
 const
   g_lang_default: Array [TStrings_Locale] of Array [1..3] of String = (
index 9690b745bd93ac05cfde1b9b75fbb2dfa25cda33..3301dd4c61263cdd719bb977c4bf813637f42f86 100644 (file)
@@ -521,9 +521,12 @@ var
 implementation
 
 uses
+  {$IFNDEF HEADLESS}
+    g_menu,
+  {$ENDIF}
   e_log, g_sound, g_gfx, g_player, g_game,
   g_weapons, g_triggers, g_items, g_options,
-  g_console, g_map, Math, g_menu, wadreader,
+  g_console, g_map, Math, wadreader,
   g_language, g_netmsg, idpool, utils, xstreams;
 
 
index 98ca2ab33d8b0d31f15a1e6880f2301d576c5807..19623af29b35bd11ab9f8174a569c3d54ac413d1 100644 (file)
@@ -256,7 +256,7 @@ uses
   SysUtils,
   e_input, e_res, g_options,
   g_nethandler, g_netmsg, g_netmaster, g_player, g_window, g_console,
-  g_game, g_language, g_weapons, ctypes, g_system, g_map;
+  g_game, g_language, g_weapons, ctypes, g_map;
 
 const
   FILE_CHUNK_SIZE = 8192;
index 56dec596971af747214515d3d6de09d737355e15..ae0b0de1e796fc2be6bcfb77c2ab7953b7ac8514 100644 (file)
@@ -176,9 +176,12 @@ function GetTimerMS (): Int64;
 implementation
 
 uses
+  {$IFNDEF HEADLESS}
+    g_gui, g_menu, r_game, g_system,
+  {$ENDIF}
   e_input, e_log, g_net, g_console,
-  g_map, g_game, g_sound, g_gui, g_menu, g_options, g_language, g_basic, r_game,
-  wadreader, g_system, utils, hashtable;
+  g_map, g_game, g_sound, g_options, g_language, g_basic,
+  wadreader, utils, hashtable;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
@@ -1742,7 +1745,11 @@ begin
   if gConsoleShow or gChatShow then
     Exit;
 
-  qm := sys_HandleInput(); // this updates kbd
+  {$IFDEF HEADLESS}
+    qm := True;
+  {$ELSE}
+    qm := sys_HandleInput(); // this updates kbd
+  {$ENDIF}
 
   if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) or
      e_KeyPressed(JOY0_JUMP) or e_KeyPressed(JOY1_JUMP) or
@@ -1751,10 +1758,12 @@ begin
     SL := nil;
     ST := nil;
     gState := STATE_MENU;
+{$IFNDEF HEADLESS}
     g_GUI_ShowWindow('MainMenu');
     g_GUI_ShowWindow('NetGameMenu');
     g_GUI_ShowWindow('NetClientMenu');
     g_Sound_PlayEx(WINDOW_CLOSESOUND);
+{$ENDIF}
     Exit;
   end;
 
@@ -1774,8 +1783,10 @@ begin
     begin
       slWaitStr := _lc[I_NET_SLIST_WAIT];
 
+{$IFNDEF HEADLESS}
       r_Game_Draw;
       sys_Repaint;
+{$ENDIF}
 
       if g_Net_Slist_Fetch(SL) then
       begin
@@ -1803,10 +1814,14 @@ begin
       Srv := GetServerFromTable(slSelection, SL, ST);
       if Srv.Password then
       begin
+{$IFNDEF HEADLESS}
         PromptIP := Srv.IP;
         PromptPort := Srv.Port;
+{$ENDIF}
         gState := STATE_MENU;
+{$IFNDEF HEADLESS}
         g_GUI_ShowWindow('ClientPasswordMenu');
+{$ENDIF}
         SL := nil;
         ST := nil;
         slReturnPressed := True;
index da87a4a0bdb417fbe47d265c6c92c3bd47104478..816673a180455a7289cd40b3332b97b40a39cad7 100644 (file)
@@ -276,9 +276,12 @@ function IsValidFilePath(const S: String): Boolean;
 implementation
 
 uses
+  {$IFNDEF HEADLESS}
+    g_gui,
+  {$ENDIF}
   Math, ENet, e_input, e_log, g_base, g_basic,
   g_textures, g_gfx, g_sound, g_console, g_options,
-  g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
+  g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys,
   g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
 
 const
@@ -2940,7 +2943,11 @@ begin
   kByte := 0;
   Predict := NetPredictSelf; // and (not NetGotKeys);
 
+{$IFDEF HEADLESS}
+  if (not gConsoleShow) and (not gChatShow) then
+{$ELSE}
   if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+{$ENDIF}
   begin
     strafeDir := P1MoveButton shr 4;
     P1MoveButton := P1MoveButton and $0F;
index 836f06d68fb25113e8e994bcd269d823a191ed59..cc7cba15f28a0a86839d30f40ac03d0f281308b2 100644 (file)
@@ -121,7 +121,7 @@ uses
   {$ENDIF}
   e_log, e_input, g_console, g_sound, g_gfx, g_player, Math,
   g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game,
-  g_items, wadreader, g_touch, envvars, g_system;
+  g_items, wadreader, envvars;
 
   var
     machine: Integer;
index 80f38b7691245f5a45b8a80687aa63c0fb3d0cfc..39848acaefdc2055d3fc784bfb19b84cd180958b 100644 (file)
@@ -628,10 +628,10 @@ uses
     g_holmes,
   {$ENDIF}
   {$IFNDEF HEADLESS}
-    r_render,
+    r_render, g_menu,
   {$ENDIF}
   e_log, g_map, g_items, g_console, g_gfx, Math,
-  g_options, g_triggers, g_menu, g_game, g_grid, e_res,
+  g_options, g_triggers, g_game, g_grid, e_res,
   wadreader, g_monsters, CONFIG, g_language,
   g_net, g_netmsg,
   utils, xstreams;
index 142401547a3c6b77d9d01bacd8b1bb13f2b74fde..1d1fca781779cccd2b76e08cc34ab2af6a458046 100644 (file)
@@ -135,6 +135,8 @@ function  g_PlayerModel_Get(ModelName: String): TPlayerModel;
 function  g_PlayerModel_GetGibs (ModelID: Integer; var Gibs: TGibsArray): Boolean;
 function  g_PlayerModel_GetIndex (ModelName: String): Integer;
 
+procedure g_PlayerModel_LoadFake (ModelName, FileName: String);
+
 (* --- private data --- *)
 
   type
@@ -295,6 +297,16 @@ end;
     end;
   end;
 
+  procedure g_PlayerModel_LoadFake (ModelName, FileName: String);
+    var id: Integer;
+  begin
+    SetLength(PlayerModelsArray, Length(PlayerModelsArray) + 1);
+    id := High(PlayerModelsArray);
+    PlayerModelsArray[id].Name := ModelName;
+    PlayerModelsArray[id].HaveWeapon := False;
+    PlayerModelsArray[id].FileName := FileName;
+  end;
+
 function g_PlayerModel_Load(FileName: string): Boolean;
 var
   ID: DWORD;
index 63de883338008a7f57c01742c4cf8eae7c5bf960..fcf4b4226b3946a18c3ec4bbf0134f31c1c2096b 100644 (file)
@@ -23,14 +23,20 @@ implementation
 
   uses
     {$IFNDEF HEADLESS}
-      r_render,
+      r_render, g_system,
     {$ENDIF}
-    e_sound, g_system, g_net
+    e_sound, g_net
   ;
 
   procedure ProcessLoading (forceUpdate: Boolean = False);
+    var update: Boolean;
   begin
-    if sys_HandleInput() = False then
+    {$IFDEF HEADLESS}
+      update := True;
+    {$ELSE}
+      update := sys_HandleInput() = False;
+    {$ENDIF}
+    if update then
     begin
       {$IFNDEF HEADLESS}
         r_Render_DrawLoading(forceUpdate);