DEADSOFTWARE

"dbg_scale" debug variable
[d2df-sdl.git] / src / game / g_panel.pas
index 3b2830e634d471e3eb0796b37b5d504cf50ea1e8..f1aa0078ede8d0e6d64e1ff1a680348d859f1409 100644 (file)
@@ -120,7 +120,7 @@ type
 implementation
 
 uses
-  SysUtils, g_basic, g_map, g_game, e_graphics,
+  SysUtils, g_basic, g_map, g_game, g_gfx, e_graphics,
   g_console, g_language, g_monsters, g_player, e_log, GL;
 
 const
@@ -303,7 +303,7 @@ var
 begin
   if {Enabled and} (FCurTexture >= 0) and
      (Width > 0) and (Height > 0) and (FAlpha < 255) and
-     (g_dbg_scale_05 or g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)) then
+     ((g_dbg_scale <> 1.0) or g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)) then
   begin
     if FTextureIDs[FCurTexture].Anim then
       begin // Àíèìèðîâàííàÿ òåêñòóðà
@@ -501,18 +501,25 @@ begin
     monMoveListUsed := 0;
     nx := X+mMovingSpeed.X;
     ny := Y+mMovingSpeed.Y;
+    // move monsters on lifts
     g_Mons_ForEachAt(X, Y-1, Width, 1, monMove);
+    // push monsters
     g_Mons_ForEachAt(nx, ny, Width, Height, monPush);
+    // move and push players
     for f := 0 to High(gPlayers) do plrMove(gPlayers[f]);
+    // reverse moving direction, if necessary
          if (mMovingSpeed.X < 0) and (nx <= mMovingStart.X) then mMovingSpeed.X := -mMovingSpeed.X
     else if (mMovingSpeed.X > 0) and (nx >= mMovingEnd.X) then mMovingSpeed.X := -mMovingSpeed.X;
          if (mMovingSpeed.Y < 0) and (ny <= mMovingStart.Y) then mMovingSpeed.Y := -mMovingSpeed.Y
     else if (mMovingSpeed.Y > 0) and (ny >= mMovingEnd.Y) then mMovingSpeed.Y := -mMovingSpeed.Y;
-    //!!!g_Mark(X, Y, Width, Height, MARK_FREE);
+    // awake particles
+    g_Mark(X, Y, Width, Height, MARK_WALL, false);
     X := nx;
     Y := ny;
-    //!!!g_Mark(X, Y, Width, Height, MARK_WALL);
+    g_Mark(nx, ny, Width, Height, MARK_WALL);
+    // fix grid
     if (proxyId >= 0) then mapGrid.moveBody(proxyId, nx, ny);
+    // notify moved monsters about their movement
     for f := 0 to monMoveListUsed-1 do monMoveList[f].positionChanged();
   end;
 end;
@@ -653,8 +660,8 @@ var
   sig: DWORD;
   anim: Boolean;
 begin
-  if (not SaveIt) or (Mem = nil) then
-    Exit;
+  if (Mem = nil) then exit;
+  //if not SaveIt then exit;
 
 // Ñèãíàòóðà ïàíåëè:
   sig := PANEL_SIGNATURE; // 'PANL'
@@ -695,9 +702,10 @@ procedure TPanel.LoadState(var Mem: TBinMemoryReader);
 var
   sig: DWORD;
   anim: Boolean;
+  //ox, oy: Integer;
 begin
-  if (not SaveIt) or (Mem = nil) then
-    Exit;
+  if (Mem = nil) then exit;
+  //if not SaveIt then exit;
 
 // Ñèãíàòóðà ïàíåëè:
   Mem.ReadDWORD(sig);
@@ -712,8 +720,11 @@ begin
 // Íîìåð òåêóùåé òåêñòóðû:
   Mem.ReadInt(FCurTexture);
 // Êîîðäû
+  //ox := FX;
+  //oy := FY;
   Mem.ReadInt(FX);
   Mem.ReadInt(FY);
+  //e_LogWritefln('panel %s(%s): old=(%s,%s); new=(%s,%s); delta=(%s,%s)', [arrIdx, proxyId, ox, oy, FX, FY, FX-ox, FY-oy]);
 // Àíèìèðîâàííàÿ ëè òåêóùàÿ òåêñòóðà:
   Mem.ReadBoolean(anim);
 // Åñëè äà - çàãðóæàåì àíèìàöèþ:
@@ -733,6 +744,8 @@ begin
   Mem.ReadInt(mMovingEnd.X);
   Mem.ReadInt(mMovingEnd.Y);
   Mem.ReadBoolean(mMovingActive);
+
+  if (proxyId >= 0) then mapGrid.moveBody(proxyId, X, Y);
 end;
 
 end.