DEADSOFTWARE

correctly freeing dynrecords; as a consequence, no more memory leaks in custom game...
[d2df-sdl.git] / src / game / g_panel.pas
index 3c95a56ffe7f3b07724ad060b99a995f7fad3c26..94e7b877488b8963eb05bbcb924d0161fe7a7bf4 100644 (file)
@@ -93,7 +93,7 @@ type
     procedure   SaveState(var Mem: TBinMemoryWriter);
     procedure   LoadState(var Mem: TBinMemoryReader);
 
-    procedure positionChanged ();
+    procedure positionChanged (); inline;
 
     function isGBack (): Boolean; inline; // gRenderBackgrounds
     function isGStep (): Boolean; inline; // gSteps
@@ -439,9 +439,21 @@ begin
 end;
 
 
-procedure TPanel.positionChanged ();
+procedure TPanel.positionChanged (); inline;
+var
+  px, py, pw, ph: Integer;
 begin
-  if (proxyId >= 0) then mapGrid.moveBody(proxyId, X, Y);
+  if (proxyId >= 0) then
+  begin
+    monsGrid.getBodyDims(proxyId, px, py, pw, ph);
+    if (px <> x) or (py <> y) or (pw <> Width) or (ph <> Height) then
+    begin
+      g_Mark(px, py, pw, ph, MARK_WALL, false);
+      if (pw <> Width) or (ph <> Height) then mapGrid.moveResizeBody(proxyId, X, Y, Width, Height)
+      else mapGrid.moveBody(proxyId, X, Y);
+      g_Mark(X, Y, Width, Height, MARK_WALL);
+    end;
+  end;
 end;
 
 
@@ -552,10 +564,10 @@ begin
          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;
     // awake particles
-    g_Mark(X, Y, Width, Height, MARK_WALL, false);
+    //g_Mark(X, Y, Width, Height, MARK_WALL, false);
     X := nx;
     Y := ny;
-    g_Mark(nx, ny, Width, Height, MARK_WALL);
+    //g_Mark(nx, ny, Width, Height, MARK_WALL);
     // fix grid
     positionChanged();
     // notify moved monsters about their movement
@@ -784,7 +796,8 @@ begin
   Mem.ReadInt(mMovingEnd.Y);
   Mem.ReadBoolean(mMovingActive);
 
-  if (proxyId >= 0) then mapGrid.moveBody(proxyId, X, Y);
+  positionChanged();
+  //mapGrid.proxyEnabled[proxyId] := FEnabled; // done in g_map.pas
 end;
 
 end.