DEADSOFTWARE

gl: force camera at map center when screen larger than map
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Thu, 29 Dec 2022 01:10:16 +0000 (04:10 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:08:44 +0000 (12:08 +0300)
src/game/renders/opengl/r_map.pas

index 6b54fa3a4273f1fd738451366082640d45f38eee..eb7321773680c186524226d53fe4553c0c88f757 100644 (file)
@@ -1398,13 +1398,18 @@ implementation
     (* camera bounds *)
     if g_dbg_ignore_bounds = false then
     begin
-      if cx + cw > gMapInfo.Width then
-        cx := gMapInfo.Width - cw;
-      if cy + ch > gMapInfo.Height then
-        cy := gMapInfo.Height - ch;
-      if cx < 0 then
+      if w > gMapInfo.Width then
+        cx := gMapInfo.Width div 2 - w div 2
+      else if cx + cw > gMapInfo.Width then
+        cx := gMapInfo.Width - cw
+      else if cx < 0 then
         cx := 0;
-      if cy < 0 then
+
+      if h > gMapInfo.Height then
+        cy := gMapInfo.Height div 2 - h div 2
+      else if cy + ch > gMapInfo.Height then
+        cy := gMapInfo.Height - ch
+      else if cy < 0 then
         cy := 0;
     end;