Changeset 146
- Timestamp:
- Nov 12, 2017, 1:57:59 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r145 r146 6 6 7 7 uses 8 Classes, SysUtils, ExtCtrls, Graphics, Contnrs,XMLConf, XMLRead, XMLWrite,8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, 9 9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf, fgl; 10 10 … … 80 80 { TCells } 81 81 82 TCells = class(T ObjectList)82 TCells = class(TFPGObjectList<TCell>) 83 83 Map: TMap; 84 84 procedure FixRefId; … … 103 103 { TCellLinks } 104 104 105 TCellLinks = class(T ObjectList)105 TCellLinks = class(TFPGObjectList<TCellLink>) 106 106 Map: TMap; 107 107 function FindByCells(Cell1, Cell2: TCell): TCellLink; … … 159 159 end; 160 160 161 TMapAreas = class(T ObjectList)161 TMapAreas = class(TFPGObjectList<TMapArea>) 162 162 end; 163 163 … … 222 222 { TPlayerCells } 223 223 224 TPlayerCells = class(T ObjectList)224 TPlayerCells = class(TFPGObjectList<TPlayerCell>) 225 225 Map: TPlayerMap; 226 226 function SearchCell(Cell: TCell): TPlayerCell; … … 256 256 { TGameTurnStats } 257 257 258 TGameTurnStats = class(T ObjectList)258 TGameTurnStats = class(TFPGObjectList<TGameTurnStat>) 259 259 procedure LoadFromNode(Node: TDOMNode); 260 260 procedure SaveToNode(Node: TDOMNode); … … 303 303 TComputer = class 304 304 Game: TGame; 305 Targets: TObjectList;305 //Targets: TFPGObjectList<TPlayer>; 306 306 CellProcessDirection: Boolean; 307 307 procedure AttackNeutral; … … 318 318 { TPlayers } 319 319 320 TPlayers = class(T ObjectList)320 TPlayers = class(TFPGObjectList<TPlayer>) 321 321 Game: TGame; 322 322 NewPlayerId: Integer; … … 352 352 { TUnitMoves } 353 353 354 TUnitMoves = class(T ObjectList)354 TUnitMoves = class(TFPGObjectList<TUnitMove>) 355 355 Game: TGame; 356 356 procedure LoadFromNode(Node: TDOMNode); … … 377 377 { TClients } 378 378 379 TClients = class(T ObjectList)379 TClients = class(TFPGObjectList<TClient>) 380 380 Game: TGame; 381 381 procedure New(Name: string); … … 695 695 begin 696 696 Cells := TCells.Create; 697 Cells. OwnsObjects := False;697 Cells.FreeObjects := False; 698 698 end; 699 699 … … 713 713 // To remove itself from list we need disable owning to not be called twice 714 714 try 715 LastState := Map.CellLinks. OwnsObjects;716 Map.CellLinks. OwnsObjects := False;715 LastState := Map.CellLinks.FreeObjects; 716 Map.CellLinks.FreeObjects := False; 717 717 Map.CellLinks.Remove(Self); 718 718 finally 719 Map.CellLinks. OwnsObjects := LastState;719 Map.CellLinks.FreeObjects := LastState; 720 720 end; 721 721 end; … … 799 799 begin 800 800 Cells := TCells.Create; 801 Cells. OwnsObjects := False;801 Cells.FreeObjects := False; 802 802 end; 803 803 … … 1610 1610 // To remove itself from list we need disable owning to not be called twice 1611 1611 try 1612 LastState := List. OwnsObjects;1613 List. OwnsObjects := False;1612 LastState := List.FreeObjects; 1613 List.FreeObjects := False; 1614 1614 List.Remove(Self); 1615 1615 finally 1616 List. OwnsObjects := LastState;1616 List.FreeObjects := LastState; 1617 1617 end; 1618 1618 end; … … 1823 1823 Player := nil; 1824 1824 Neighbors := TCells.Create; 1825 Neighbors. OwnsObjects := False;1825 Neighbors.FreeObjects := False; 1826 1826 MovesFrom := TUnitMoves.Create; 1827 MovesFrom. OwnsObjects := False;1827 MovesFrom.FreeObjects := False; 1828 1828 MovesTo := TUnitMoves.Create; 1829 MovesTo. OwnsObjects := False;1829 MovesTo.FreeObjects := False; 1830 1830 Links := TCellLinks.Create; 1831 Links. OwnsObjects := False;1831 Links.FreeObjects := False; 1832 1832 end; 1833 1833 … … 1956 1956 end; 1957 1957 1958 function CellCompare( Item1, Item2: Pointer): Integer;1959 begin 1960 if TCell(Item1).Power > TCell(Item2).Power then Result := 11961 else if TCell(Item1).Power < TCell(Item2).Power then Result := -11958 function CellCompare(const Item1, Item2: TCell): Integer; 1959 begin 1960 if Item1.Power > Item2.Power then Result := 1 1961 else if Item1.Power < Item2.Power then Result := -1 1962 1962 else Result := 0; 1963 1963 end; 1964 1964 1965 function CellCompareDescending( Item1, Item2: Pointer): Integer;1966 begin 1967 if TCell(Item1).Power > TCell(Item2).Power then Result := -11968 else if TCell(Item1).Power < TCell(Item2).Power then Result := 11965 function CellCompareDescending(const Item1, Item2: TCell): Integer; 1966 begin 1967 if Item1.Power > Item2.Power then Result := -1 1968 else if Item1.Power < Item2.Power then Result := 1 1969 1969 else Result := 0; 1970 1970 end; … … 1985 1985 AllCells := Game.Map.Cells; 1986 1986 TargetCells := TCells.Create; 1987 TargetCells. OwnsObjects := False;1987 TargetCells.FreeObjects := False; 1988 1988 1989 1989 // Get list of all attack target cells … … 2046 2046 AllCells := Game.Map.Cells; 2047 2047 TargetCells := TCells.Create; 2048 TargetCells. OwnsObjects := False;2048 TargetCells.FreeObjects := False; 2049 2049 2050 2050 // Get list of all attack target cells … … 2113 2113 AllCells := Game.Map.Cells; 2114 2114 TargetCells := TCells.Create; 2115 TargetCells. OwnsObjects := False;2115 TargetCells.FreeObjects := False; 2116 2116 NewTargetCells := TCells.Create; 2117 NewTargetCells. OwnsObjects := False;2117 NewTargetCells.FreeObjects := False; 2118 2118 2119 2119 // Get list of all enemy border cells … … 2177 2177 TargetCells := NewTargetCells; 2178 2178 NewTargetCells := TCells.Create; 2179 NewTargetCells. OwnsObjects := False;2179 NewTargetCells.FreeObjects := False; 2180 2180 end; 2181 2181 … … 2218 2218 begin 2219 2219 BorderCells := TCells.Create; 2220 BorderCells. OwnsObjects := False;2220 BorderCells.FreeObjects := False; 2221 2221 AllCells := Game.Map.Cells; 2222 2222 … … 2656 2656 Result := nil; 2657 2657 NewList := TCells.Create; 2658 NewList. OwnsObjects := False;2658 NewList.FreeObjects := False; 2659 2659 NewListVoid := TCells.Create; 2660 NewListVoid. OwnsObjects := False;2660 NewListVoid.FreeObjects := False; 2661 2661 2662 2662 for C := 0 to List.Count - 1 do … … 2723 2723 begin 2724 2724 List := TCells.Create; 2725 List. OwnsObjects := False;2725 List.FreeObjects := False; 2726 2726 2727 2727 BorderList := TCells.Create; 2728 BorderList. OwnsObjects := False;2728 BorderList.FreeObjects := False; 2729 2729 2730 2730 // Build area bridges
Note:
See TracChangeset
for help on using the changeset viewer.