From e979719019322a78e7fded8fd96130c18cf31972 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 17 Jan 2022 23:15:58 +0300 Subject: [PATCH] server: build headless with completely disabled render, system driver and menus --- src/game/Doom2DF.lpr | 98 ++++++++++++++---------- src/game/g_console.pas | 38 ++++++++-- src/game/g_game.pas | 148 ++++++++++++++++++++++++------------- src/game/g_gui.pas | 2 + src/game/g_language.pas | 2 +- src/game/g_monsters.pas | 5 +- src/game/g_net.pas | 2 +- src/game/g_netmaster.pas | 21 +++++- src/game/g_netmsg.pas | 9 ++- src/game/g_options.pas | 2 +- src/game/g_player.pas | 4 +- src/game/g_playermodel.pas | 12 +++ src/game/g_window.pas | 12 ++- 13 files changed, 245 insertions(+), 110 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 1be6b0c..4a74e66 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -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; diff --git a/src/game/g_console.pas b/src/game/g_console.pas index feef35d..91131d1 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -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; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index fcd73a7..0123ecd 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -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; diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 960ba74..4bf8f7c 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -75,6 +75,8 @@ const WM_CHAR = 102; WM_USER = 110; + MESSAGE_DIKEY = WM_USER + 1; + type TMessage = record Msg: DWORD; diff --git a/src/game/g_language.pas b/src/game/g_language.pas index f7b553c..1b05ddd 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -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 = ( diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 9690b74..3301dd4 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -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; diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 98ca2ab..19623af 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -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; diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 56dec59..ae0b0de 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -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; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index da87a4a..816673a 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -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; diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 836f06d..cc7cba1 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -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; diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 80f38b7..39848ac 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -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; diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 1424015..1d1fca7 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -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; diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 63de883..fcf4b42 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -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); -- 2.29.2