Changeset 316 for trunk/UMap.pas


Ignore:
Timestamp:
Jun 19, 2024, 11:53:06 PM (4 months ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMap.pas

    r315 r316  
    11unit UMap;
    22
    3 {$mode delphi}
    4 
    53interface
    64
    75uses
    8   Classes, SysUtils, Graphics, ExtCtrls, UGeometry, DOM, fgl, UBuilding,
    9   XML, UUnit;
     6  Classes, SysUtils, Graphics, ExtCtrls, UGeometry, DOM, Generics.Collections,
     7  Generics.Defaults, UBuilding, XML, UUnit;
    108
    119const
     
    7876  { TCells }
    7977
    80   TCells = class(TFPGObjectList<TCell>)
     78  TCells = class(TObjectList<TCell>)
    8179    Map: TMap;
    8280    procedure FixRefId;
     
    105103  { TCellLinks }
    106104
    107   TCellLinks = class(TFPGObjectList<TCellLink>)
     105  TCellLinks = class(TObjectList<TCellLink>)
    108106    Map: TMap;
    109107    function FindByCells(Cell1, Cell2: TCell): TCellLink;
     
    136134  end;
    137135
    138   TMapAreas = class(TFPGObjectList<TMapArea>)
     136  TMapAreas = class(TObjectList<TMapArea>)
    139137  end;
    140138
     
    239237begin
    240238  Cells := TCells.Create;
    241   Cells.FreeObjects := False;
     239  Cells.OwnsObjects := False;
    242240end;
    243241
     
    253251  end;
    254252  FreeAndNil(Cells);
    255   inherited Destroy;
     253  inherited;
    256254end;
    257255
     
    336334begin
    337335  Cells := TCells.Create;
    338   Cells.FreeObjects := False;
     336  Cells.OwnsObjects := False;
    339337end;
    340338
     
    342340begin
    343341  FreeAndNil(Cells);
    344   inherited Destroy;
     342  inherited;
    345343end;
    346344
     
    456454end;
    457455
    458 function CompareCellAngle(const C1, C2: TCell): Integer;
     456function CompareCellAngle(constref C1, C2: TCell): Integer;
    459457begin
    460458  if C1.Angle < C2.Angle then Result := -1
     
    472470      NeighborCell.Angle := TLine.Create(Cell.PosPx, NeighborCell.PosPx).GetAngle;
    473471
    474     Cell.Neighbors.Sort(CompareCellAngle);
     472    Cell.Neighbors.Sort(TComparer<TCell>.Construct(CompareCellAngle));
    475473  end;
    476474end;
     
    770768  FreeAndNil(Image);
    771769  FreeAndNil(Cells);
    772   inherited Destroy;
     770  inherited;
    773771end;
    774772
     
    803801  Result := nil;
    804802  NewList := TCells.Create;
    805   NewList.FreeObjects := False;
     803  NewList.OwnsObjects := False;
    806804  NewListVoid := TCells.Create;
    807   NewListVoid.FreeObjects := False;
     805  NewListVoid.OwnsObjects := False;
    808806
    809807  for C := 0 to List.Count - 1 do
     
    845843begin
    846844  List := TCells.Create;
    847   List.FreeObjects := False;
     845  List.OwnsObjects := False;
    848846
    849847  BorderList := TCells.Create;
    850   BorderList.FreeObjects := False;
     848  BorderList.OwnsObjects := False;
    851849
    852850  // Build area bridges
     
    11331131  Player := nil;
    11341132  Neighbors := TCells.Create;
    1135   Neighbors.FreeObjects := False;
     1133  Neighbors.OwnsObjects := False;
    11361134  Links := TCellLinks.Create;
    1137   Links.FreeObjects := False;
     1135  Links.OwnsObjects := False;
    11381136end;
    11391137
     
    11501148      raise Exception.Create(SCellRemoveNeighborError);
    11511149  FreeAndNil(Neighbors);
    1152   inherited Destroy;
     1150  inherited;
    11531151end;
    11541152
Note: See TracChangeset for help on using the changeset viewer.