From c5684c0c980bb96fd4fd0efae4d48cdeb469c8ff Mon Sep 17 00:00:00 2001
From: DeaDDooMER <deaddoomer@deadsoftware.ru>
Date: Tue, 8 Jun 2021 14:22:49 +0300
Subject: [PATCH] render: remove from render some common types

---
 src/game/Doom2DF.lpr              |  1 +
 src/game/g_base.pas               | 85 +++++++++++++++++++++++++++++++
 src/game/g_game.pas               |  2 +-
 src/game/g_gui.pas                |  2 +-
 src/game/g_map.pas                |  2 +-
 src/game/g_menu.pas               |  2 +-
 src/game/g_monsters.pas           |  2 +-
 src/game/g_netmsg.pas             |  4 +-
 src/game/g_phys.pas               |  3 +-
 src/game/g_player.pas             |  2 +-
 src/game/g_playermodel.pas        |  2 +-
 src/game/g_textures.pas           |  2 +-
 src/game/opengl/r_console.pas     |  2 +-
 src/game/opengl/r_game.pas        |  2 +-
 src/game/opengl/r_gfx.pas         |  2 +-
 src/game/opengl/r_graphics.pas    | 65 +----------------------
 src/game/opengl/r_items.pas       |  2 +-
 src/game/opengl/r_map.pas         |  2 +-
 src/game/opengl/r_monsters.pas    |  2 +-
 src/game/opengl/r_panel.pas       |  2 +-
 src/game/opengl/r_player.pas      |  4 +-
 src/game/opengl/r_playermodel.pas |  2 +-
 src/game/opengl/r_weapons.pas     |  2 +-
 23 files changed, 109 insertions(+), 87 deletions(-)
 create mode 100644 src/game/g_base.pas

diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index c585478..0434ce2 100644
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
@@ -113,6 +113,7 @@ uses
   wadreader in '../shared/wadreader.pas',
   MAPDEF in '../shared/MAPDEF.pas',
   CONFIG in '../shared/CONFIG.pas',
+  g_base in 'g_base.pas',
   g_basic in 'g_basic.pas',
   g_console in 'g_console.pas',
   g_net in 'g_net.pas',
diff --git a/src/game/g_base.pas b/src/game/g_base.pas
new file mode 100644
index 0000000..238d69e
--- /dev/null
+++ b/src/game/g_base.pas
@@ -0,0 +1,85 @@
+(* Copyright (C)  Doom 2D: Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
+unit g_base;
+
+interface
+
+  type
+    TMirrorType = (None, Horizontal, Vertical);
+    TBlending = (None, Blend, Filter, Invert);
+
+    TPoint2i = record
+      X, Y: Integer;
+    end;
+
+    TPoint2f = record
+      X, Y: Double;
+    end;
+
+    TRect = record
+      Left, Top, Right, Bottom: Integer;
+    end;
+
+    TRectWH = record
+      X, Y: Integer;
+      Width, Height: Word;
+    end;
+
+    TRGB = packed record
+      R, G, B: Byte;
+    end;
+
+    PPoint2f = ^TPoint2f;
+    PRect = ^TRect;
+    PRectWH = ^TRectWH;
+
+  function _RGB (Red, Green, Blue: Byte): TRGB;
+  function _Point (X, Y: Integer): TPoint2i;
+  function _Rect (X, Y: Integer; Width, Height: Word): TRectWH;
+  function _TRect (L, T, R, B: LongInt): TRect;
+
+implementation
+
+  function _RGB (Red, Green, Blue: Byte): TRGB;
+  begin
+    Result.R := Red;
+    Result.G := Green;
+    Result.B := Blue;
+  end;
+
+  function _Point (X, Y: Integer): TPoint2i;
+  begin
+    Result.X := X;
+    Result.Y := Y;
+  end;
+
+  function _Rect (X, Y: Integer; Width, Height: Word): TRectWH;
+  begin
+    Result.X := X;
+    Result.Y := Y;
+    Result.Width := Width;
+    Result.Height := Height;
+  end;
+
+  function _TRect (L, T, R, B: LongInt): TRect;
+  begin
+    Result.Top := T;
+    Result.Left := L;
+    Result.Right := R;
+    Result.Bottom := B;
+  end;
+
+end.
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 4c0871c..534dfea 100644
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
@@ -20,7 +20,7 @@ interface
 uses
   SysUtils, Classes,
   MAPDEF,
-  g_basic, g_player, r_graphics, g_res_downloader,
+  g_base, g_basic, g_player, r_graphics, g_res_downloader,
   g_sound, g_gui, utils, md5, mempool, xprofiler,
   g_touch, g_weapons;
 
diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas
index 1acdf1b..8e45c5d 100644
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
@@ -19,7 +19,7 @@ interface
 
 uses
   {$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
-  r_graphics, e_input, e_log, g_playermodel, g_basic, g_touch, MAPDEF, utils;
+  g_base, r_graphics, e_input, e_log, g_playermodel, g_basic, g_touch, MAPDEF, utils;
 
 const
   MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255);
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 9459c10..a6e1dab 100644
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
@@ -20,7 +20,7 @@ interface
 
 uses
   SysUtils, Classes, mempool,
-  r_graphics, g_basic, MAPDEF, g_textures,
+  g_base, r_graphics, g_basic, MAPDEF, g_textures,
   g_phys, utils, g_panel, g_grid, md5, binheap, xprofiler, xparser, xdynrec;
 
 type
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index c086cb0..4ae82a2 100644
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
@@ -44,7 +44,7 @@ implementation
 
 uses
   g_gui, g_textures, r_graphics, g_main, g_window, g_game, g_map,
-  g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
+  g_base, g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
   e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
   MAPDEF, Math, g_saveload,
   e_texture, g_language, e_res,
diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas
index 13ab23e..f858d12 100644
--- a/src/game/g_monsters.pas
+++ b/src/game/g_monsters.pas
@@ -23,7 +23,7 @@ uses
   SysUtils, Classes,
   mempool,
   MAPDEF,
-  g_basic, r_graphics, g_phys, g_textures, g_grid,
+  g_base, g_basic, g_phys, g_textures, g_grid,
   g_saveload, g_panel, xprofiler;
 
 const
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 772bda8..b5edf0a 100644
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
@@ -276,8 +276,8 @@ function IsValidFilePath(const S: String): Boolean;
 implementation
 
 uses
-  Math, ENet, e_input, r_graphics, e_log,
-  g_textures, g_gfx, g_sound, g_console, g_basic, g_options, g_main,
+  Math, ENet, e_input, e_log, g_base, g_basic,
+  g_textures, g_gfx, g_sound, g_console, g_options, g_main,
   g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
   g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
 
diff --git a/src/game/g_phys.pas b/src/game/g_phys.pas
index 81bdb78..6919979 100644
--- a/src/game/g_phys.pas
+++ b/src/game/g_phys.pas
@@ -17,8 +17,7 @@ unit g_phys;
 
 interface
 
-uses
-  r_graphics;
+  uses g_base;
 
 type
   PObj = ^TObj;
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 551b9c6..e2e9e97 100644
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
@@ -21,7 +21,7 @@ interface
 uses
   SysUtils, Classes,
   {$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
-  r_graphics, g_playermodel, g_basic, g_textures,
+  g_base, g_playermodel, g_basic, g_textures,
   g_weapons, g_phys, g_sound, g_saveload, MAPDEF,
   g_panel;
 
diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas
index a436aa1..9b018cb 100644
--- a/src/game/g_playermodel.pas
+++ b/src/game/g_playermodel.pas
@@ -19,7 +19,7 @@ unit g_playermodel;
 interface
 
 uses
-  MAPDEF, g_textures, g_basic, g_weapons, r_graphics, utils, g_gfx,
+  MAPDEF, g_textures, g_base, g_basic, g_weapons, r_graphics, utils, g_gfx,
   ImagingTypes, Imaging, ImagingUtility;
 
 const
diff --git a/src/game/g_textures.pas b/src/game/g_textures.pas
index b8ebfa0..6417fa9 100644
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
@@ -20,7 +20,7 @@ interface
 uses
   SysUtils, Classes,
   {$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
-  r_graphics, MAPDEF, ImagingTypes, Imaging, ImagingUtility;
+  g_base, r_graphics, MAPDEF, ImagingTypes, Imaging, ImagingUtility;
 
 type
   TLevelTexture = record
diff --git a/src/game/opengl/r_console.pas b/src/game/opengl/r_console.pas
index 3904841..e7a0b6a 100644
--- a/src/game/opengl/r_console.pas
+++ b/src/game/opengl/r_console.pas
@@ -27,7 +27,7 @@ implementation
     SysUtils, Classes, Math,
     e_log, r_graphics,
     conbuf,
-    g_main, g_console, g_game, g_menu, g_textures
+    g_base, g_main, g_console, g_game, g_menu, g_textures
   ;
 
 (* ====== Console ====== *)
diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas
index ca85e9e..6260d48 100644
--- a/src/game/opengl/r_game.pas
+++ b/src/game/opengl/r_game.pas
@@ -29,7 +29,7 @@ implementation
     g_holmes,
 {$ENDIF}
     SysUtils, Classes, Math,
-    r_graphics,
+    g_base, r_graphics,
     g_system, g_touch,
     MAPDEF, xprofiler, utils, wadreader,
     g_textures, e_input, e_sound,
diff --git a/src/game/opengl/r_gfx.pas b/src/game/opengl/r_gfx.pas
index f15a802..955bdec 100644
--- a/src/game/opengl/r_gfx.pas
+++ b/src/game/opengl/r_gfx.pas
@@ -25,7 +25,7 @@ implementation
     {$INCLUDE ../nogl/noGLuses.inc}
     SysUtils, Classes, Math,
     utils,
-    r_graphics,
+    g_base, r_graphics,
     g_game,
     g_gfx
   ;
diff --git a/src/game/opengl/r_graphics.pas b/src/game/opengl/r_graphics.pas
index b16bd6f..5bd4aee 100644
--- a/src/game/opengl/r_graphics.pas
+++ b/src/game/opengl/r_graphics.pas
@@ -22,39 +22,11 @@ uses
   {$IFDEF USE_SDL2}
     SDL2,
   {$ENDIF}
-  SysUtils, Classes, Math, e_log, e_texture,
+  SysUtils, Classes, Math, e_log, e_texture, g_base,
   MAPDEF, ImagingTypes, Imaging, ImagingUtility;
 
 type
-  TMirrorType=(None, Horizontal, Vertical);
-  TBlending=(None, Blend, Filter, Invert);
-
-  TPoint2i = record
-    X, Y: Integer;
-  end;
-
-  TPoint2f = record
-    X, Y: Double;
-  end;
-
-  TRect = record
-    Left, Top, Right, Bottom: Integer;
-  end;
-
-  TRectWH = record
-   X, Y: Integer;
-   Width, Height: Word;
-  end;
-
-  TRGB = packed record
-   R, G, B: Byte;
-  end;
-
   PDFPoint = ^TDFPoint;
-  PPoint2f = ^TPoint2f;
-  PRect = ^TRect;
-  PRectWH = ^TRectWH;
-
 
 //------------------------------------------------------------------
 // прототипы функций
@@ -143,11 +115,6 @@ procedure e_SetGamma(win: PSDL_Window;Gamma: Byte);
 
 procedure e_MakeScreenshot(st: TStream; Width, Height: Word);
 
-function _RGB(Red, Green, Blue: Byte): TRGB;
-function _Point(X, Y: Integer): TPoint2i;
-function _Rect(X, Y: Integer; Width, Height: Word): TRectWH;
-function _TRect(L, T, R, B: LongInt): TRect;
-
 //function e_getTextGLId (ID: DWORD): GLuint;
 
 var
@@ -1943,36 +1910,6 @@ begin
  e_TextureFonts := nil;
 end;
 
-function _RGB(Red, Green, Blue: Byte): TRGB;
-begin
- Result.R := Red;
- Result.G := Green;
- Result.B := Blue;
-end;
-
-function _Point(X, Y: Integer): TPoint2i;
-begin
- Result.X := X;
- Result.Y := Y;
-end;
-
-function _Rect(X, Y: Integer; Width, Height: Word): TRectWH;
-begin
- Result.X := X;
- Result.Y := Y;
- Result.Width := Width;
- Result.Height := Height;
-end;
-
-function _TRect(L, T, R, B: LongInt): TRect;
-begin
- Result.Top := T;
- Result.Left := L;
- Result.Right := R;
- Result.Bottom := B;
-end;
-
-
 procedure e_MakeScreenshot (st: TStream; Width, Height: Word);
 var
   pixels, obuf, scln, ps, pd: PByte;
diff --git a/src/game/opengl/r_items.pas b/src/game/opengl/r_items.pas
index 19599f0..6e3dfee 100644
--- a/src/game/opengl/r_items.pas
+++ b/src/game/opengl/r_items.pas
@@ -26,7 +26,7 @@ implementation
     SysUtils, Classes, Math,
     r_graphics,
     MAPDEF,
-    g_basic, g_game,
+    g_base, g_basic, g_game,
     g_items
   ;
 
diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas
index 12f3137..ef75c14 100644
--- a/src/game/opengl/r_map.pas
+++ b/src/game/opengl/r_map.pas
@@ -31,7 +31,7 @@ implementation
     {$INCLUDE ../nogl/noGLuses.inc}
     SysUtils, Classes, Math,
     r_graphics,
-    g_basic, g_game, g_options,
+    g_base, g_basic, g_game, g_options,
     g_panel, g_map,
     r_panel
   ;
diff --git a/src/game/opengl/r_monsters.pas b/src/game/opengl/r_monsters.pas
index 9d65d47..45f8dd3 100644
--- a/src/game/opengl/r_monsters.pas
+++ b/src/game/opengl/r_monsters.pas
@@ -26,7 +26,7 @@ implementation
     SysUtils, Classes, Math,
     r_graphics,
     MAPDEF,
-    g_basic, g_game, g_phys,
+    g_base, g_basic, g_game, g_phys,
     g_monsters
   ;
 
diff --git a/src/game/opengl/r_panel.pas b/src/game/opengl/r_panel.pas
index a2ba6e0..e9d92de 100644
--- a/src/game/opengl/r_panel.pas
+++ b/src/game/opengl/r_panel.pas
@@ -28,7 +28,7 @@ implementation
     {$INCLUDE ../nogl/noGLuses.inc}
     SysUtils, Classes, Math,
     r_graphics,
-    g_basic, g_textures
+    g_base, g_basic, g_textures
   ;
 
   // TODO: remove WITH operator
diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas
index 96dfa92..bb25f29 100644
--- a/src/game/opengl/r_player.pas
+++ b/src/game/opengl/r_player.pas
@@ -17,7 +17,7 @@ unit r_player;
 
 interface
 
-  uses g_player, r_graphics; // TPlayer, TRGB
+  uses g_player, g_base; // TPlayer, TRGB
 
   procedure r_Player_DrawAll;
   procedure r_Player_DrawDebug (p: TPlayer);
@@ -46,7 +46,7 @@ implementation
 {$IFDEF ENABLE_HOLMES}
     g_holmes,
 {$ENDIF}
-    r_playermodel
+    r_playermodel, r_graphics
   ;
 
   procedure r_Player_DrawAll;
diff --git a/src/game/opengl/r_playermodel.pas b/src/game/opengl/r_playermodel.pas
index b11ac28..9b0f244 100644
--- a/src/game/opengl/r_playermodel.pas
+++ b/src/game/opengl/r_playermodel.pas
@@ -29,7 +29,7 @@ implementation
     SysUtils, Classes, Math,
     MAPDEF,
     r_graphics,
-    g_basic, g_map, g_weapons, g_textures, g_main
+    g_base, g_basic, g_map, g_weapons, g_textures, g_main
   ;
 
   const
diff --git a/src/game/opengl/r_weapons.pas b/src/game/opengl/r_weapons.pas
index 974d744..38882f1 100644
--- a/src/game/opengl/r_weapons.pas
+++ b/src/game/opengl/r_weapons.pas
@@ -25,7 +25,7 @@ implementation
     SysUtils, Classes, Math,
     MAPDEF,
     r_graphics,
-    g_basic, g_game,
+    g_base, g_basic, g_game,
     g_weapons
   ;
 
-- 
2.29.2