From bb931202515154fd56edaa5657d0f69f1cce0e75 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 29 Jan 2022 20:53:01 +0300 Subject: [PATCH] render: add option -dDISABLE_RENDER --- src/game/Doom2DF.lpr | 20 ++++++++++---------- src/game/g_game.pas | 17 ++++++++++------- src/game/g_gfx.pas | 4 ++-- src/game/g_gibs.pas | 4 ++-- src/game/g_netmaster.pas | 15 ++++++++++----- src/game/g_player.pas | 2 +- src/game/g_window.pas | 7 +++++-- src/game/sdl2/g_system.pas | 14 ++++++++++---- src/shared/a_modes.inc | 16 ++++++++++++++++ 9 files changed, 66 insertions(+), 33 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 28e3b62..e7999c5 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -160,7 +160,7 @@ uses {$ENDIF} {$ENDIF} -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} {$I ../shared/vampimg.inc} r_animations in 'opengl/r_animations.pas', r_console in 'opengl/r_console.pas', @@ -248,7 +248,7 @@ begin if (NetMode = NET_SERVER) then g_Net_Host_Update() else if (NetMode = NET_CLIENT) then g_Net_Client_Update(); // think -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} r_Render_Update; {$ENDIF} g_Game_Update(); @@ -315,7 +315,7 @@ begin gLerpFactor := 1.0 else gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0); -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} r_Render_Draw; sys_Repaint; {$ENDIF} @@ -940,7 +940,7 @@ end; procedure ScreenResize (w, h: Integer); begin - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Resize(w, h); {$IFDEF ENABLE_HOLMES} fuiScrWdt := w; @@ -977,7 +977,7 @@ end; g_Console_Initialize; // TODO move load configs here g_Language_Set(gLanguage); - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Initialize; {$ENDIF} DebugOptions; @@ -986,11 +986,11 @@ end; {$IFDEF ENABLE_HOLMES} InitHolmes; {$ENDIF} - {$IFDEF HEADLESS} - g_PlayerModel_LoadFake('doomer', 'doomer.wad'); - {$ELSE} + {$IFDEF ENABLE_RENDER} g_PlayerModel_LoadAll; r_Render_Load; + {$ELSE} + g_PlayerModel_LoadFake('doomer', 'doomer.wad'); {$ENDIF} g_Game_Init; {$IFDEF ENABLE_MENU} @@ -1011,7 +1011,7 @@ end; g_GUI_Destroy; g_Menu_Free; {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Free; {$ENDIF} {$IFDEF ENABLE_HOLMES} @@ -1020,7 +1020,7 @@ end; g_Net_Slist_ShutdownAll; g_Net_DeinitLowLevel; (* g_Touch_Finalize; *) - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Finalize; sys_Final; {$ENDIF} diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 6812d51..69c1240 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -127,7 +127,7 @@ procedure g_Game_Announce_KillCombo(Param: Integer); procedure g_Game_Announce_BodyKill(SpawnerUID: Word); procedure g_Game_StartVote(Command, Initiator: string); procedure g_Game_CheckVote; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} procedure g_TakeScreenShot(Filename: string = ''); {$ENDIF} procedure g_FatalError(Text: String); @@ -460,8 +460,11 @@ uses {$IFDEF ENABLE_CORPSES} g_corpses, {$ENDIF} + {$IFDEF ENABLE_RENDER} + r_render, + {$ENDIF} {$IFNDEF HEADLESS} - r_render, g_system, + g_system, {$ENDIF} e_res, g_window, e_input, e_log, g_console, g_items, g_map, g_panel, @@ -3376,7 +3379,7 @@ begin begin //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName); result := g_Map_Load(NewWAD+':\'+ResName); - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_LoadTextures; {$ENDIF} end; @@ -5587,8 +5590,8 @@ begin end else if cmd = 'screenshot' then begin - {$IFNDEF HEADLESS} - g_TakeScreenShot() + {$IFDEF ENABLE_RENDER} + g_TakeScreenShot; {$ENDIF} end else if cmd = 'weapon' then @@ -5826,7 +5829,7 @@ begin g_Game_Free(); g_Game_Quit(); end; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} 'r_reset': r_Render_Apply; {$ENDIF} @@ -5875,7 +5878,7 @@ begin end; end; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} procedure g_TakeScreenShot(Filename: string = ''); var t: TDateTime; dir, date, name: String; begin diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index 224faee..9cc665c 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -148,7 +148,7 @@ function awmIsSetHolmes (x, y: Integer): Boolean; inline; implementation uses - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} g_map, g_panel, Math, utils, @@ -176,7 +176,7 @@ var procedure g_GFX_QueueEffect (AnimType, X, Y: Integer); begin - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_QueueEffect(AnimType, X, Y) {$ENDIF} end; diff --git a/src/game/g_gibs.pas b/src/game/g_gibs.pas index 8041264..d190384 100644 --- a/src/game/g_gibs.pas +++ b/src/game/g_gibs.pas @@ -55,7 +55,7 @@ implementation {$IFDEF ENABLE_GFX} g_gfx, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} g_playermodel, g_options, g_game @@ -160,7 +160,7 @@ implementation Color := fColor; alive := True; g_Obj_Init(@Obj); - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} Obj.Rect := r_Render_GetGibRect(ModelID, GibID); {$ELSE} Obj.Rect.X := 16; diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 12d926f..e708c13 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -179,8 +179,11 @@ uses {$IFDEF ENABLE_MENU} g_gui, g_menu, {$ENDIF} + {$IFDEF ENABLE_RENDER} + r_render, + {$ENDIF} {$IFNDEF HEADLESS} - r_render, g_system, + g_system, {$ENDIF} e_input, e_log, g_net, g_console, g_map, g_game, g_sound, g_options, g_language, g_basic, @@ -1786,10 +1789,12 @@ begin begin slWaitStr := _lc[I_NET_SLIST_WAIT]; -{$IFNDEF HEADLESS} - r_Render_Draw; - sys_Repaint; -{$ENDIF} + {$IFDEF ENABLE_RENDER} + r_Render_Draw; + {$ENDIF} + {$IFNDEF HEALESS} + sys_Repaint; + {$ENDIF} if g_Net_Slist_Fetch(SL) then begin diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 991b0d8..4967d75 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -547,7 +547,7 @@ uses {$IFDEF ENABLE_MENU} g_menu, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} {$IFDEF ENABLE_GFX} diff --git a/src/game/g_window.pas b/src/game/g_window.pas index fcf4b42..027f409 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -22,8 +22,11 @@ interface implementation uses + {$IFDEF ENABLE_RENDER} + r_render, + {$ENDIF} {$IFNDEF HEADLESS} - r_render, g_system, + g_system, {$ENDIF} e_sound, g_net ; @@ -38,7 +41,7 @@ implementation {$ENDIF} if update then begin - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_DrawLoading(forceUpdate); {$ENDIF} e_SoundUpdate(); diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index abfbfb3..74e8d03 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -48,7 +48,7 @@ implementation {$IFDEF ENABLE_HOLMES} sdlcarcass, {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_render, {$ENDIF} {$IFDEF ENABLE_MENU} @@ -407,10 +407,16 @@ implementation x, y, i, finger: Integer; function IntersectControl(ctl, xx, yy: Integer): Boolean; - var x, y, w, h: Integer; founded: Boolean; + {$IFDEF ENABLE_RENDER} + var x, y, w, h: Integer; founded: Boolean; + {$ENDIF} begin - r_Render_GetKeyRect(ctl, x, y, w, h, founded); - result := founded and (xx >= x) and (yy >= y) and (xx <= x + w) and (yy <= y + h); + {$IFDEF ENABLE_RENDER} + r_Render_GetKeyRect(ctl, x, y, w, h, founded); + Result := founded and (xx >= x) and (yy >= y) and (xx <= x + w) and (yy <= y + h); + {$ELSE} + Result := False + {$ENDIF} end; procedure KeyUp (finger, i: Integer); diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc index 6789e6e..d018fa0 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -135,6 +135,11 @@ {$UNDEF ENABLE_CORPSES} {$DEFINE DISABLE_CORPSES} {$ENDIF} + {$IFDEF ENABLE_RENDER} + {$WARNING Render in headless mode has no sense. Disabled.} + {$UNDEF ENABLE_RENDER} + {$DEFINE DISABLE_RENDER} + {$ENDIF} {$ENDIF} {$IF DEFINED(ENABLE_MENU) AND DEFINED(DISABLE_MENU)} @@ -203,6 +208,17 @@ {$ENDIF} {$ENDIF} +{$IF DEFINED(ENABLE_RENDER) AND DEFINED(DISABLE_RENDER)} + {$ERROR Select ENABLE_RENDER or DISABLE_RENDER} +{$ELSEIF NOT DEFINED(ENABLE_RENDER) AND NOT DEFINED(DISABLE_RENDER)} + // default ENABLE/DISABLE render + {$IFDEF HEADLESS} + {$DEFINE DISABLE_RENDER} + {$ELSE} + {$DEFINE ENABLE_RENDER} + {$ENDIF} +{$ENDIF} + {$IF DEFINED(USE_SYSSTUB)} {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)} {$ERROR Only one system driver must be selected!} -- 2.29.2