From: Ketmar Dark Date: Sat, 2 Sep 2017 00:32:43 +0000 (+0300) Subject: loading game now properly fixes enabled/disabled state for proxy X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=17c43bf44dcda54fa7d87e278357c803eb3eea2f;p=d2df-sdl.git loading game now properly fixes enabled/disabled state for proxy --- diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 049868c..17ad2fc 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -685,13 +685,13 @@ end; // ////////////////////////////////////////////////////////////////////////// // function TBodyGridBase.getProxyEnabled (pid: TBodyProxyId): Boolean; inline; begin - if (pid >= 0) then result := ((mProxies[pid].mTag and TagDisabled) = 0) else result := false; + if (pid >= 0) and (pid < Length(mProxies)) then result := ((mProxies[pid].mTag and TagDisabled) = 0) else result := false; end; procedure TBodyGridBase.setProxyEnabled (pid: TBodyProxyId; val: Boolean); inline; begin - if (pid >= 0) then + if (pid >= 0) and (pid < Length(mProxies)) then begin if val then begin @@ -707,7 +707,7 @@ end; function TBodyGridBase.getProxyById (idx: TBodyProxyId): PBodyProxyRec; inline; begin - if (idx >= 0) and (idx < High(mProxies)) then result := @mProxies[idx] else result := nil; + if (idx >= 0) and (idx < Length(mProxies)) then result := @mProxies[idx] else result := nil; end; diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index 3c95a56..7e6a135 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -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,7 +439,7 @@ begin end; -procedure TPanel.positionChanged (); +procedure TPanel.positionChanged (); inline; begin if (proxyId >= 0) then mapGrid.moveBody(proxyId, X, Y); end; @@ -784,7 +784,8 @@ begin Mem.ReadInt(mMovingEnd.Y); Mem.ReadBoolean(mMovingActive); - if (proxyId >= 0) then mapGrid.moveBody(proxyId, X, Y); + positionChanged(); + mapGrid.proxyEnabled[proxyId] := FEnabled; end; end.