Changeset 149
- Timestamp:
- Nov 13, 2017, 12:17:04 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r148 r149 1636 1636 1637 1637 destructor TUnitMove.Destroy; 1638 var1639 LastState: Boolean;1640 1638 begin 1641 1639 CellFrom := nil; 1642 1640 CellTo := nil; 1643 if Assigned(List) then begin 1644 // To remove itself from list we need disable owning to not be called twice 1645 try 1646 LastState := List.FreeObjects; 1647 List.FreeObjects := False; 1648 List.Remove(Self); 1649 finally 1650 List.FreeObjects := LastState; 1651 end; 1652 end; 1641 List := nil; 1653 1642 inherited Destroy; 1654 1643 end; … … 1887 1876 begin 1888 1877 for I := MovesFrom.Count - 1 downto 0 do 1889 TUnitMove(MovesFrom[I]). Free;1878 TUnitMove(MovesFrom[I]).List.Remove(TUnitMove(MovesFrom[I])); 1890 1879 FreeAndNil(MovesFrom); 1891 1880 for I := MovesTo.Count - 1 downto 0 do 1892 TUnitMove(MovesTo[I]). Free;1881 TUnitMove(MovesTo[I]).List.Remove(TUnitMove(MovesTo[I])); 1893 1882 FreeAndNil(MovesTo); 1894 1883 for I := Links.Count - 1 downto 0 do … … 2307 2296 // Fallback 2308 2297 for I := MovesTo.Count - 1 downto 0 do 2309 TUnitMove(MovesTo[I]).Free;2298 Player.Moves.Remove(MovesTo[I]); 2310 2299 for I := 0 to Neighbors.Count - 1 do 2311 2300 if (TCell(Neighbors[I]).Player = Player) and (AttackersCount(TCell(Neighbors[I])) = 0) then begin … … 2342 2331 if ssShift in ShiftState then begin 2343 2332 // Make maximum unit move without confirmation dialog 2344 for I := SelectedCell.MovesFrom.Count - 1 downto 0 do 2345 TUnitMove(SelectedCell.MovesFrom[I]).Free; 2333 for I := SelectedCell.MovesFrom.Count - 1 downto 0 do begin 2334 Player.Moves.Remove(SelectedCell.MovesFrom[I]); 2335 end; 2346 2336 Game.CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power, False); 2347 2337 SelectedCell := nil; … … 2351 2341 // move all power to new selected cell 2352 2342 for I := SelectedCell.MovesFrom.Count - 1 downto 0 do 2353 TUnitMove(SelectedCell.MovesFrom[I]).Free;2343 Player.Moves.Remove(SelectedCell.MovesFrom[I]); 2354 2344 UnitMove := Game.CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power, False); 2355 2345 if Assigned(UnitMove) then … … 2620 2610 var 2621 2611 NewMove: TUnitMove; 2622 I: Integer;2623 2612 CountOnce: Integer; 2624 2613 CountRepeat: Integer; 2625 2614 Confirm: Boolean; 2626 2615 begin 2627 I := 0;2628 2616 Confirm := True; 2629 2617 Result := Moves.SearchByFromTo(CellFrom, CellTo); … … 2643 2631 if Assigned(Result) then begin 2644 2632 // Already have such move 2645 if (CountOnce = 0) and (CountRepeat = 0) then Moves.Delete(I) 2646 else begin 2633 if (CountOnce = 0) and (CountRepeat = 0) then begin 2634 Result.List.Remove(Result); 2635 end else begin 2647 2636 Result.CountOnce := CountOnce; 2648 2637 Result.CountRepeat := CountRepeat; … … 2903 2892 2904 2893 List := TCells.Create; 2905 List.FreeObjects := False; 2906 Map.Cells.GetCellsWithWeight(List, Round(LongestDistance * 0.6), Round(LongestDistance * 0.8)); 2907 StartCell := List[Random(List.Count)]; 2908 FreeAndNil(List); 2894 try 2895 List.FreeObjects := False; 2896 Map.Cells.GetCellsWithWeight(List, Round(LongestDistance * 0.6), Round(LongestDistance * 0.8)); 2897 StartCell := List[Random(List.Count)]; 2898 finally 2899 FreeAndNil(List); 2900 end; 2909 2901 end; 2910 2902 end;
Note:
See TracChangeset
for help on using the changeset viewer.