DEADSOFTWARE

system: add option -dDISABLE_SYSTEM
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sat, 29 Jan 2022 18:44:13 +0000 (21:44 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 08:08:51 +0000 (11:08 +0300)
src/game/Doom2DF.lpr
src/game/g_game.pas
src/game/g_netmaster.pas
src/game/g_window.pas
src/game/opengl/r_game.pas
src/game/opengl/r_render.pas
src/game/opengl/r_window.pas
src/shared/a_modes.inc

index 44d23d13850c5a187ea118a7e1b8790f93cec346..4aecd4026ac048917850dca9611028047d7a74df 100644 (file)
@@ -148,17 +148,18 @@ uses
   g_triggers in 'g_triggers.pas',
   g_weapons in 'g_weapons.pas',
   g_window in 'g_window.pas',
-{$IFNDEF HEADLESS}
-  {$IFDEF USE_SYSSTUB}
-    g_system in 'stub/g_system.pas',
-  {$ENDIF}
-  {$IFDEF USE_SDL}
-    g_system in 'sdl/g_system.pas',
-  {$ENDIF}
-  {$IFDEF USE_SDL2}
-    g_system in 'sdl2/g_system.pas',
+
+  {$IFDEF ENABLE_SYSTEM}
+    {$IFDEF USE_SYSSTUB}
+      g_system in 'stub/g_system.pas',
+    {$ENDIF}
+    {$IFDEF USE_SDL}
+      g_system in 'sdl/g_system.pas',
+    {$ENDIF}
+    {$IFDEF USE_SDL2}
+      g_system in 'sdl2/g_system.pas',
+    {$ENDIF}
   {$ENDIF}
-{$ENDIF}
 
 {$IFDEF ENABLE_RENDER}
   {$I ../shared/vampimg.inc}
@@ -266,10 +267,10 @@ var
   Time, Time_Delta: Int64;
   Frame: Int64;
 begin
-  {$IFDEF HEADLESS}
-    Result := False;
-  {$ELSE}
+  {$IFDEF ENABLE_SYSTEM}
     Result := sys_HandleInput();
+  {$ELSE}
+    Result := False;
   {$ENDIF}
 
   Time := GetTickCount64();
@@ -318,10 +319,12 @@ begin
       gLerpFactor := 1.0
     else
       gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0);
-{$IFDEF ENABLE_RENDER}
-    r_Render_Draw;
-    sys_Repaint;
-{$ENDIF}
+    {$IFDEF ENABLE_RENDER}
+      r_Render_Draw;
+    {$ENDIF}
+    {$IFDEF ENABLE_SYSTEM}
+      sys_Repaint;
+    {$ENDIF}
     Frame := Time
   end
   else
@@ -1004,7 +1007,7 @@ end;
     InitPrep;
     e_Input_Initialize;
     InitSound;
-    {$IFNDEF HEADLESS}
+    {$IFDEF ENABLE_SYSTEM}
       sys_Init;
       sys_CharPress := @CharPress; (* install hook *)
       sys_ScreenResize := @ScreenResize; (* install hook *)
@@ -1059,6 +1062,8 @@ end;
     (* g_Touch_Finalize; *)
     {$IFDEF ENABLE_RENDER}
       r_Render_Finalize;
+    {$ENDIF}
+    {$IFDEF ENABLE_SYSTEM}
       sys_Final;
     {$ENDIF}
     g_Console_Finalize;
index 602fa4207f83800a25267accedefe238d58b35af..9fdc66ec54b0d8a657eb8778a784d88d78d79739 100644 (file)
@@ -472,7 +472,7 @@ uses
   {$IFDEF ENABLE_RENDER}
     r_render,
   {$ENDIF}
-  {$IFNDEF HEADLESS}
+  {$IFDEF ENABLE_SYSTEM}
     g_system,
   {$ENDIF}
   e_res, g_window,
@@ -2598,7 +2598,7 @@ begin
 
   gExit := EXIT_QUIT;
 
-  {$IFNDEF HEADLESS}
+  {$IFDEF ENABLE_SYSTEM}
     sys_RequestQuit;
   {$ENDIF}
 end;
index 29e60e73f9862c57bf127c44824b5e66316a2636..2774b4498bea81b779896b976e8f609682cb9bb5 100644 (file)
@@ -182,7 +182,7 @@ uses
   {$IFDEF ENABLE_RENDER}
     r_render,
   {$ENDIF}
-  {$IFNDEF HEADLESS}
+  {$IFDEF ENABLE_SYSTEM}
     g_system,
   {$ENDIF}
   e_input, e_log, g_net, g_console,
@@ -1752,10 +1752,10 @@ begin
   if gConsoleShow or gChatShow then
     Exit;
 
-  {$IFDEF HEADLESS}
-    qm := True;
-  {$ELSE}
+  {$IFDEF ENABLE_SYSTEM}
     qm := sys_HandleInput(); // this updates kbd
+  {$ELSE}
+    qm := True;
   {$ENDIF}
 
   if qm or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) or
@@ -1793,7 +1793,7 @@ begin
       {$IFDEF ENABLE_RENDER}
         r_Render_Draw;
       {$ENDIF}
-      {$IFNDEF HEADLESS}
+      {$IFDEF ENABLE_SYSTEM}
         sys_Repaint;
       {$ENDIF}
 
index ab211a961557b09ee4cdb772a5b2a8124201dfe2..2b20517baa9466c43bc29df4d79a2d95326665d8 100644 (file)
@@ -25,7 +25,7 @@ implementation
     {$IFDEF ENABLE_RENDER}
       r_render,
     {$ENDIF}
-    {$IFNDEF HEADLESS}
+    {$IFDEF ENABLE_SYSTEM}
       g_system,
     {$ENDIF}
     e_sound, g_net
@@ -34,10 +34,10 @@ implementation
   procedure ProcessLoading (forceUpdate: Boolean = False);
     var update: Boolean;
   begin
-    {$IFDEF HEADLESS}
-      update := True;
-    {$ELSE}
+    {$IFDEF ENABLE_SYSTEM}
       update := sys_HandleInput() = False;
+    {$ELSE}
+      update := True;
     {$ENDIF}
     if update then
     begin
index 9387ca4323de812b76de4d07976ed79d95e22a0e..672ceb45df3df36fdcb9658cb80bb21a1dc8adee 100644 (file)
@@ -50,9 +50,11 @@ implementation
     {$IFDEF ENABLE_CORPSES}
       g_corpses,
     {$ENDIF}
+    {$IFDEF ENABLE_SYSTEM}
+      g_system,
+    {$ENDIF}
     SysUtils, Classes, Math,
     g_base, g_basic, r_graphics,
-    g_system,
     MAPDEF, xprofiler, utils, wadreader, CONFIG,
     e_input, e_sound,
     g_language, g_console, g_triggers, g_player, g_options, g_monsters, g_map, g_panel,
@@ -575,7 +577,9 @@ var
 begin
   e_TextureFontGetSize(gStdFont, ww2, hh2);
 
-  sys_HandleInput;
+  {$IFDEF ENABLE_SYSTEM}
+    sys_HandleInput;
+  {$ENDIF}
 
   if g_Console_Action(ACTION_SCORES) then
   begin
index 6c3729fb2a5596f69f23700ebaf1e47c5c3fb469..ffb1c4d53018c6a22c6ba48882fbe74420974338 100644 (file)
@@ -61,8 +61,11 @@ implementation
     {$IFDEF ENABLE_GFX}
       r_gfx,
     {$ENDIF}
+    {$IFDEF ENABLE_SYSTEM}
+      g_system,
+    {$ENDIF}
     SysUtils, Classes, Math,
-    e_log, g_system, utils,
+    e_log, utils,
     g_game, g_options, g_console,
     r_window, r_graphics, r_console, r_playermodel, r_textures, r_animations,
     r_weapons, r_items, r_monsters, r_map, r_player, r_game
@@ -237,8 +240,10 @@ implementation
 
   procedure r_Render_Initialize;
   begin
-    if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
-      raise Exception.Create('Failed to set videomode on startup.');
+    {$IFDEF ENABLE_SYSTEM}
+      if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
+        raise Exception.Create('Failed to set videomode on startup.');
+    {$ENDIF}
     LoadGL;
     r_Window_Initialize;
     r_Console_Init;
@@ -301,11 +306,13 @@ implementation
 
   procedure r_Render_Apply;
   begin
-    if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then
-      e_LogWriteln('resolution changed')
-    else
-      e_LogWriteln('resolution not changed');
-    sys_EnableVSync(gVSync)
+    {$IFDEF ENABLE_SYSTEM}
+      if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then
+        e_LogWriteln('resolution changed')
+      else
+        e_LogWriteln('resolution not changed');
+      sys_EnableVSync(gVSync)
+    {$ENDIF}
   end;
 
   function r_Render_WriteScreenShot (filename: String): Boolean;
index 9b7100f4ea05ff642754341043a7cf188f0d8a8d..3e4075fe0d615bbdb1ccae719632740f48cc4060 100644 (file)
@@ -23,9 +23,12 @@ implementation
 
   uses
     {$INCLUDE ../nogl/noGLuses.inc}
+    {$IFDEF ENABLE_SYSTEM}
+      g_system,
+    {$ENDIF}
     SysUtils, Classes,
     e_log, utils,
-    r_graphics, r_game, r_console, g_system,
+    r_graphics, r_game, r_console,
     g_options, g_game, g_console,
     xprofiler
   ;
@@ -61,7 +64,9 @@ implementation
         e_SetViewPort(0, 0, gWinSizeX, gWinSizeY);
         e_BlitFramebuffer(gWinSizeX, gWinSizeY);
 
-        sys_Repaint;
+        {$IFDEF ENABLE_SYSTEM}
+          sys_Repaint;
+        {$ENDIF}
         prevLoadingUpdateTime := getTimeMilli();
       end;
     end;
index 9596f5bab7fb31a3642d6bfc1080bf46c482839b..c500a34f89b2eb6a2ff38a03335ed2734f29c95b 100644 (file)
     {$UNDEF ENABLE_RENDER}
     {$DEFINE DISABLE_RENDER}
   {$ENDIF}
+  {$IFDEF ENABLE_SYSTEM}
+    {$WARNING System in headless mode has no sense. Disabled.}
+    {$UNDEF ENABLE_SYSTEM}
+    {$DEFINE DISABLE_SYSTEM}
+  {$ENDIF}
 {$ENDIF}
 
 {$IF DEFINED(ENABLE_MENU) AND DEFINED(DISABLE_MENU)}
   {$ENDIF}
 {$ENDIF}
 
+{$IF DEFINED(ENABLE_SYSTEM) AND DEFINED(DISABLE_SYSTEM)}
+  {$ERROR Select ENABLE_SYSTEM or DISABLE_SYSTEM}
+{$ELSEIF NOT DEFINED(ENABLE_SYSTEM) AND NOT DEFINED(DISABLE_SYSTEM)}
+  // default ENABLE/DISABLE system driver
+  {$IFDEF HEADLESS}
+    {$DEFINE DISABLE_SYSTEM}
+  {$ELSE}
+    {$DEFINE ENABLE_SYSTEM}
+  {$ENDIF}
+{$ENDIF}
+
 {$IF DEFINED(USE_SYSSTUB)}
   {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)}
     {$ERROR Only one system driver must be selected!}
     {$ERROR Holmes supported only with desktop OpenGL}
   {$ENDIF}
 {$ENDIF}
+
+{$IFDEF ENABLE_MENU}
+  {$IFDEF DISABLE_RENDER}
+    {$FATAL Render driver required for current menu implementation}
+  {$ENDIF}
+{$ENDIF}
+
+{$IFDEF ENABLE_TOUCH}
+  {$IFDEF DISABLE_SYSTEM}
+    {$FATAL System driver required for current touch implementation}
+  {$ENDIF}
+{$ENDIF}