DEADSOFTWARE

hackfix for video resolution change (still not working right, see commit text)
[d2df-sdl.git] / src / game / g_game.pas
index 29348b28c45600e074df7fe18b3dced0bbaa2b61..918a94714df9f810469a5204a8e83d817fac5074 100644 (file)
@@ -313,6 +313,8 @@ var
   gUseChatSounds: Boolean = True;
   gChatSounds: Array of TChatSound;
 
+  g_dbg_ignore_bounds: Boolean = false;
+
   // move button values:
   // bits 0-1: l/r state:
   //   0: neither left, nor right pressed
@@ -1984,6 +1986,7 @@ begin
       e_WriteLog('Changing resolution', TMsgType.Notify);
       g_Game_ChangeResolution(gRC_Width, gRC_Height, gRC_FullScreen, gRC_Maximized);
       gResolutionChange := False;
+      g_ActiveWindow := nil;
     end;
 
   // Íóæíî ñìåíèòü ÿçûê:
@@ -3250,7 +3253,7 @@ begin
   px := p.GameX + PLAYER_RECT_CX;
   py := p.GameY + PLAYER_RECT_CY+p.Obj.slopeUpLeft;
 
-  if (g_dbg_scale = 1.0) then
+  if (g_dbg_scale = 1.0) and (not g_dbg_ignore_bounds) then
   begin
     if (px > (gPlayerScreenSize.X div 2)) then a := -px+(gPlayerScreenSize.X div 2) else a := 0;
     if (py > (gPlayerScreenSize.Y div 2)) then b := -py+(gPlayerScreenSize.Y div 2) else b := 0;
@@ -3328,6 +3331,16 @@ begin
   //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
   fixViewportForScale();
   //conwritefln('     (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
+  if (g_dbg_scale <> 1.0) and (not g_dbg_ignore_bounds) then
+  begin
+    if (sX+sWidth > gMapInfo.Width) then sX := gMapInfo.Width-sWidth;
+    if (sY+sHeight > gMapInfo.Height) then sY := gMapInfo.Height-sHeight;
+    if (sX < 0) then sX := 0;
+    if (sY < 0) then sY := 0;
+
+    if (gBackSize.X <= gPlayerScreenSize.X) or (gMapInfo.Width <= sWidth) then c := 0 else c := trunc((gBackSize.X-gPlayerScreenSize.X)*sX/(gMapInfo.Width-sWidth));
+    if (gBackSize.Y <= gPlayerScreenSize.Y) or (gMapInfo.Height <= sHeight) then d := 0 else d := trunc((gBackSize.Y-gPlayerScreenSize.Y)*sY/(gMapInfo.Height-sHeight));
+  end;
   p.viewPortX := sX;
   p.viewPortY := sY;
   p.viewPortW := sWidth;
@@ -3752,7 +3765,7 @@ begin
   g_PlayerModel_FreeData();
   g_Texture_DeleteAll();
   g_Frames_DeleteAll();
-  g_Menu_Free();
+  //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
 
   if NetInitDone then g_Net_Free;
 
@@ -4194,6 +4207,10 @@ begin
     gPlayer2.Name := gPlayer2Settings.Name;
   end;
 
+  g_Game_SetLoadingText(_lc[I_LOAD_HOST], 0, False);
+  if NetForwardPorts then
+    g_Game_SetLoadingText(_lc[I_LOAD_PORTS], 0, False);
+
 // Ñòàðòóåì ñåðâåð
   if not g_Net_Host(IPAddr, Port, NetMaxClients) then
   begin
@@ -7526,7 +7543,9 @@ begin
 
   conRegVar('dbg_holmes', @g_holmes_enabled, 'enable/disable Holmes', 'Holmes', true);
 
-  conRegVar('dbg_scale', @g_dbg_scale, 0.01, 100.0, 'experimental deBUG scale mode', '',  false);
+  conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds, 'ignore level bounds', '',  false);
+
+  conRegVar('r_scale', @g_dbg_scale, 0.01, 100.0, 'render scale', '',  false);
 
   conRegVar('light_enabled', @gwin_k8_enable_light_experiments, 'enable/disable dynamic lighting', 'lighting');
   conRegVar('light_player_halo', @g_playerLight, 'enable/disable player halo', 'player light halo');