Changeset 171 for trunk/UMap.pas


Ignore:
Timestamp:
Nov 23, 2017, 7:05:37 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Use specialized TPointF type from generic class.
  • Modified: Part of fixes for Voronoi map generation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMap.pas

    r170 r171  
    66
    77uses
    8   Classes, SysUtils, UGame, XMLRead, XMLWrite, DOM, Contnrs, UGeometryClasses,
    9   UGeometry;
     8  Classes, SysUtils, UGame, XMLRead, XMLWrite, DOM, UGeometryClasses,
     9  UGeometry, fgl;
    1010
    1111type
     
    6464function THexMap.GetHexagonPolygon(Pos: TPoint; Size: TPoint): TPolygon;
    6565var
    66   Shift: TFloatPoint;
    67 begin
    68   Shift := FloatPoint(0.5 * cos(30 / 180 * Pi), 0.5 * sin(30 / 180 * Pi));
     66  Shift: TPointF;
     67begin
     68  Shift := TPointF.Create(0.5 * cos(30 / 180 * Pi), 0.5 * sin(30 / 180 * Pi));
    6969  SetLength(Result.Points, 6);
    7070  Result.Points[0] := TPoint.Create(Trunc(Pos.X + 0 * Size.X), Trunc(Pos.Y - 0.5 * Size.Y));
     
    246246end;
    247247
    248 function CompareDistanceReverse(C1, C2: Pointer): Integer;
    249 begin
    250   if TCellsDistance(C1).Distance > TCellsDistance(C2).Distance then Result := -1
    251   else if TCellsDistance(C1).Distance < TCellsDistance(C2).Distance then Result := 1
     248function CompareDistanceReverse(const C1, C2: TCellsDistance): Integer;
     249begin
     250  if C1.Distance > C2.Distance then Result := -1
     251  else if C1.Distance < C2.Distance then Result := 1
    252252  else Result := 0;
    253253end;
     
    258258  I1, I2: Integer;
    259259  NewCell: TCell;
    260   CellsDistance: TObjectList; // TObjectList<TCellsDistance>
     260  CellsDistance: TFPGObjectList<TCellsDistance>;
    261261  NewCellDist: TCellsDistance;
    262   SelectedCells: TObjectList; // TObjectList<TCellsDistance>
     262  SelectedCells: TFPGObjectList<TCellsDistance>;
    263263  I, J: Integer;
    264264  Intersected: Boolean;
     
    312312
    313313  // Calculate distance between all cells
    314   CellsDistance := TObjectList.Create;
     314  CellsDistance := TFPGObjectList<TCellsDistance>.Create;
    315315  for I1 := 1 to Cells.Count - 1 do
    316316  for I2 := I1 + 1 to Cells.Count - 1 do begin
     
    324324
    325325  // Keep shortest non-intersected cell pairs
    326   SelectedCells := TObjectList.Create;
    327   SelectedCells.OwnsObjects := False;
     326  SelectedCells := TFPGObjectList<TCellsDistance>.Create;
     327  SelectedCells.FreeObjects := False;
    328328  I := CellsDistance.Count - 1;
    329329  while I >= 0 do begin
Note: See TracChangeset for help on using the changeset viewer.