DEADSOFTWARE

game: disable gibs for server
[d2df-sdl.git] / src / game / Doom2DF.lpr
index b66ba3b6535bfe364524b3c3247bbcc6f1bc08ea..dc4d79c504668d79d9390852d02425f4f1825cf5 100644 (file)
@@ -123,11 +123,14 @@ uses
   g_res_downloader in 'g_res_downloader.pas',
   g_grid in 'g_grid.pas',
   g_game in 'g_game.pas',
-  g_gfx in 'g_gfx.pas',
-  g_gui in 'g_gui.pas',
+  {$IFDEF ENABLE_GFX}
+    g_gfx in 'g_gfx.pas',
+  {$ENDIF}
+  {$IFDEF ENABLE_GIBS}
+    g_gibs in 'g_gibs.pas',
+  {$ENDIF}
   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,34 +142,46 @@ 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',
+  {$ENDIF}
+  {$IFDEF USE_SDL}
+    g_system in 'sdl/g_system.pas',
+  {$ENDIF}
+  {$IFDEF USE_SDL2}
+    g_system in 'sdl2/g_system.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',
-  r_gfx in 'opengl/r_gfx.pas',
+  {$IFDEF ENABLE_GFX}
+    r_gfx in 'opengl/r_gfx.pas',
+  {$ENDIF}
   r_graphics in 'opengl/r_graphics.pas',
   r_items in 'opengl/r_items.pas',
   r_map in 'opengl/r_map.pas',
   r_monsters in 'opengl/r_monsters.pas',
   r_netmaster in 'opengl/r_netmaster.pas',
-  r_panel in 'opengl/r_panel.pas',
   r_player in 'opengl/r_player.pas',
   r_playermodel in 'opengl/r_playermodel.pas',
+  r_render in 'opengl/r_render.pas',
   r_texture in 'opengl/r_texture.pas',
+  r_textures in 'opengl/r_textures.pas',
   r_weapons in 'opengl/r_weapons.pas',
   r_window in 'opengl/r_window.pas',
-  r_render in 'opengl/r_render.pas',
+  {$IFDEF ENABLE_TOUCH}
+    r_touch in 'opengl/r_touch.pas',
+  {$ENDIF}
+  {$IFDEF ENABLE_MENU}
+    g_gui in 'g_gui.pas',
+    g_menu in 'g_menu.pas',
+  {$ENDIF}
+{$ENDIF}
 
 {$IFDEF USE_FMOD}
   fmod in '../lib/FMOD/fmod.pas',
@@ -200,7 +215,6 @@ uses
   fui_flexlay in '../flexui/fui_flexlay.pas',
   fui_ctls in '../flexui/fui_ctls.pas',
 {$ENDIF}
-  {$I ../shared/vampimg.inc}
 
   SysUtils, Classes;
 
@@ -216,11 +230,7 @@ uses
     binPath: AnsiString = '';
     forceBinDir: Boolean = False;
 
-    wLoadingQuit: Boolean = false;
-    Time, Time_Delta, Time_Old: Int64;
-    Frame: Int64;
-    flag: Boolean = false;
-
+    Time_Old: Int64;
     NoSound: Boolean;
 
 procedure Update ();
@@ -232,6 +242,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();
@@ -240,10 +253,17 @@ end;
 function ProcessMessage (): Boolean;
 var
   i, t: Integer;
+  flag: Boolean;
+  Time, Time_Delta: Int64;
+  Frame: Int64;
 begin
-  result := sys_HandleInput();
+  {$IFDEF HEADLESS}
+    Result := False;
+  {$ELSE}
+    Result := sys_HandleInput();
+  {$ENDIF}
 
-  Time := sys_GetTicks();
+  Time := GetTickCount64();
   Time_Delta := Time-Time_Old;
 
   flag := false;
@@ -269,12 +289,6 @@ begin
   g_Map_ProfilersEnd();
   g_Mons_ProfilersEnd();
 
-  if wLoadingQuit then
-  begin
-    g_Game_Free();
-    g_Game_Quit();
-  end;
-
   if (gExit = EXIT_QUIT) then
   begin
     result := true;
@@ -295,12 +309,14 @@ begin
       gLerpFactor := 1.0
     else
       gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0);
-    r_Game_Draw;
+{$IFNDEF HEADLESS}
+    r_Render_Draw;
     sys_Repaint;
+{$ENDIF}
     Frame := Time
   end
   else
-    sys_Delay(1);
+    Sleep(1);
 
   e_SoundUpdate();
 end;
@@ -322,19 +338,21 @@ begin
     Inc(idx);
     //if arg = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
     if arg = '--jah' then g_profile_history_size := 100;
-    if arg = '--no-particles' then gpart_dbg_enabled := false;
     if arg = '--no-los' then gmon_dbg_los_enabled := false;
 
     if arg = '--profile-render' then g_profile_frame_draw := true;
     if arg = '--profile-coldet' then g_profile_collision := true;
     if arg = '--profile-los' then g_profile_los := true;
 
-    if arg = '--no-part-phys' then gpart_dbg_phys_enabled := false;
-    if arg = '--no-part-physics' then gpart_dbg_phys_enabled := false;
-    if arg = '--no-particles-phys' then gpart_dbg_phys_enabled := false;
-    if arg = '--no-particles-physics' then gpart_dbg_phys_enabled := false;
-    if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
-    if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
+    {$IFDEF ENABLE_GFX}
+      if arg = '--no-particles' then gpart_dbg_enabled := false;
+      if arg = '--no-part-phys' then gpart_dbg_phys_enabled := false;
+      if arg = '--no-part-physics' then gpart_dbg_phys_enabled := false;
+      if arg = '--no-particles-phys' then gpart_dbg_phys_enabled := false;
+      if arg = '--no-particles-physics' then gpart_dbg_phys_enabled := false;
+      if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
+      if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
+    {$ENDIF}
 
     if arg = '--debug-input' then g_dbg_input := True;
 
@@ -916,19 +934,22 @@ end;
 
   procedure ScreenResize (w, h: Integer);
   begin
-    r_Render_Resize(w, h);
-    {$IFDEF ENABLE_HOLMES}
-      fuiScrWdt := w;
-      fuiScrHgt := h;
-    {$ENDIF}
-    g_Game_SetupScreenSize;
-    {$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 *)
+        {$IFDEF ENABLE_MENU}
+          g_Menu_Reset;
+        {$ENDIF}
+      {$ENDIF}
+      //g_Game_ClearLoading;
+      {$IFDEF ENABLE_HOLMES}
+        if assigned(oglInitCB) then oglInitCB;
+      {$ENDIF}
     {$ENDIF}
   end;
 
@@ -940,49 +961,63 @@ 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;
+    {$ENDIF}
     DebugOptions;
     g_Net_InitLowLevel;
     // TODO init serverlist
     {$IFDEF ENABLE_HOLMES}
       InitHolmes;
     {$ENDIF}
+    {$IFDEF HEADLESS}
+      g_PlayerModel_LoadFake('doomer', 'doomer.wad');
+    {$ELSE}
+      g_PlayerModel_LoadAll;
+      r_Render_Load;
+    {$ENDIF}
     g_Game_Init;
-    {$IFNDEF HEADLESS}
+    {$IFDEF ENABLE_MENU}
       g_Menu_Init;
       g_GUI_Init;
     {$ENDIF}
     g_Game_Process_Params;
     // TODO reload GAME textures
     g_Console_Init; // welcome message
-    {$IFNDEF HEADLESS}
+    {$IFDEF ENABLE_MENU}
       if (not gGameOn) and gAskLanguage then
         g_Menu_AskLanguage;
     {$ENDIF}
-    Time_Old := sys_GetTicks();
+    Time_Old := GetTickCount64();
     while not ProcessMessage() do begin end;
     g_Console_WriteGameConfig;
-    {$IFNDEF HEADLESS}
+    {$IFDEF ENABLE_MENU}
       g_GUI_Destroy;
       g_Menu_Free;
     {$ENDIF}
+    {$IFNDEF HEADLESS}
+      r_Render_Free;
+    {$ENDIF}
     {$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;