From 3f9f9afcc6f00317e2cac5512e88ca538ff9b903 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 47ffeb2..44d23d1 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', @@ -251,7 +251,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(); @@ -318,7 +318,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} @@ -977,7 +977,7 @@ end; procedure ScreenResize (w, h: Integer); begin - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Resize(w, h); {$IFDEF ENABLE_HOLMES} fuiScrWdt := w; @@ -1014,7 +1014,7 @@ end; g_Console_Initialize; // TODO move load configs here g_Language_Set(gLanguage); - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Initialize; {$ENDIF} DebugOptions; @@ -1023,11 +1023,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} @@ -1048,7 +1048,7 @@ end; g_GUI_Destroy; g_Menu_Free; {$ENDIF} - {$IFNDEF HEADLESS} + {$IFDEF ENABLE_RENDER} r_Render_Free; {$ENDIF} {$IFDEF ENABLE_HOLMES} @@ -1057,7 +1057,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 38b4088..602fa42 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -132,7 +132,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); @@ -469,8 +469,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, @@ -3453,7 +3456,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; @@ -5919,8 +5922,8 @@ begin end else if cmd = 'screenshot' then begin - {$IFNDEF HEADLESS} - g_TakeScreenShot() + {$IFDEF ENABLE_RENDER} + g_TakeScreenShot; {$ENDIF} end else if (cmd = 'weapnext') or (cmd = 'weapprev') then @@ -6205,7 +6208,7 @@ begin g_Game_Free(); g_Game_Quit(); end; -{$IFNDEF HEADLESS} +{$IFDEF ENABLE_RENDER} 'r_reset': r_Render_Apply; {$ENDIF} @@ -6254,7 +6257,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 5dbe785..29e60e7 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, @@ -1787,10 +1790,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 HEADLESS} + 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 200435b..ea2aea5 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -572,7 +572,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 6d08b18..ab211a9 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 97e346e..08cb80e 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} @@ -408,10 +408,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 7936319..9596f5b 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