From d197a2da28970b16c06f8fbbbca3a9c7080b7988 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 | 151 ++++++++++++++++++++++++------------- 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, 247 insertions(+), 111 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index baaa8af..cad717d 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; @@ -232,7 +236,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(); @@ -245,7 +251,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; @@ -293,8 +303,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 @@ -948,18 +960,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; @@ -971,24 +985,32 @@ end; InitPrep; e_Input_Initialize; InitSound; - 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; @@ -1007,16 +1029,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 fee5196..514c69e 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -102,9 +102,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, g_weapons, + SysUtils, g_basic, g_options, Math, e_res, + g_language, g_net, g_netmsg, e_log, conbuf, g_weapons, Keyboard; const @@ -162,7 +165,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); @@ -174,7 +179,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 @@ -868,10 +875,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 @@ -1842,15 +1851,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 @@ -1878,9 +1895,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 36c4899..62866c0 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 @@ -115,7 +118,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); @@ -154,7 +159,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); } @@ -177,8 +185,6 @@ const GM_COOP = 4; GM_SINGLE = 5; - MESSAGE_DIKEY = WM_USER + 1; - EXIT_QUIT = 1; EXIT_SIMPLE = 2; EXIT_RESTART = 3; @@ -449,15 +455,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 = ( @@ -781,6 +787,7 @@ begin {$ENDIF} end; +{$IFNDEF HEADLESS} procedure CharPress (C: AnsiChar); var Msg: g_gui.TMessage; @@ -803,6 +810,7 @@ begin Cheat(); end; end; +{$ENDIF} // ////////////////////////////////////////////////////////////////////////// // @@ -1251,7 +1259,10 @@ begin MessageText := ''; EndingGameCounter := 0; + +{$IFNDEF HEADLESS} g_ActiveWindow := nil; +{$ENDIF} gLMSRespawn := LMS_RESPAWN_NONE; gLMSRespawnTime := 0; @@ -1260,35 +1271,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: // Начать уровень сначала @@ -1662,6 +1675,7 @@ begin end end; +{$IFNDEF HEADLESS} // HACK: add dynlight here if gwin_k8_enable_light_experiments then begin @@ -1676,6 +1690,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 @@ -1698,12 +1713,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 @@ -1800,7 +1817,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)))) ) @@ -1819,9 +1838,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 @@ -1847,7 +1868,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 @@ -1981,7 +2004,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); @@ -1994,8 +2021,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 @@ -2249,6 +2280,7 @@ begin end; // if gameOn ... // Активно окно интерфейса - передаем клавиши ему: +{$IFNDEF HEADLESS} if g_ActiveWindow <> nil then begin w := e_GetFirstKeyPressed(); @@ -2281,9 +2313,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; @@ -2296,6 +2326,7 @@ begin begin KeyPress(IK_F10); end; +{$ENDIF} // NOT HEADLESS Time := GetTickCount64() {div 1000}; @@ -2516,7 +2547,10 @@ begin g_Game_DeleteTestMap(); gExit := EXIT_QUIT; - sys_RequestQuit; + + {$IFNDEF HEADLESS} + sys_RequestQuit; + {$ENDIF} end; procedure g_Game_FreeData(); @@ -3372,7 +3406,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(); @@ -4830,8 +4866,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 @@ -6148,6 +6188,7 @@ begin end; {$ENDIF} +{$IFNDEF HEADLESS} procedure g_Game_InGameMenu(Show: Boolean); begin if (g_ActiveWindow = nil) and Show then @@ -6178,6 +6219,7 @@ begin g_Game_Pause(False); end; end; +{$ENDIF} procedure g_Game_Pause (Enable: Boolean); var @@ -6626,8 +6668,11 @@ begin PBarWasHere := false; end; - g_ActiveWindow := nil; - ProcessLoading(True); + {$IFNDEF HEADLESS} + g_ActiveWindow := nil; + {$ENDIF} + + ProcessLoading(true); end; procedure g_Game_StepLoading(Value: Integer = -1); diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index ff77e88..5da0d5a 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 a75db11..c392db9 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -681,7 +681,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 b97e48d..d31219c 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 96f6790..ab13a28 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -270,7 +270,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 1484f6b..a95fa0a 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; // ////////////////////////////////////////////////////////////////////////// // @@ -1743,7 +1746,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 @@ -1752,10 +1759,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; @@ -1775,8 +1784,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 @@ -1804,10 +1815,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 2e6d0a4..bc7f7c9 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -284,9 +284,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 @@ -3170,7 +3173,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 dc45df4..aba2764 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -120,7 +120,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 2e9afdc..56199ce 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -652,10 +652,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 2cbc4a7..6d08b18 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