Changeset 345


Ignore:
Timestamp:
Dec 23, 2024, 11:25:36 AM (4 hours ago)
Author:
chronos
Message:
  • Modified: Improved test cases.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GameSystem.pas

    r344 r345  
    143143    (UnitsSplitMerge = GameSystem.UnitsSplitMerge) and
    144144    (EmptyCellsNeutral = GameSystem.EmptyCellsNeutral) and
    145     (PreferedMapType = GameSystem.PreferedMapType); // and
    146     //(UnitKinds.Assign(GameSystem.UnitKinds) and
    147     //(BuildingKinds.Assign(GameSystem.BuildingKinds) and
    148     //(Nations.Assign(GameSystem.Nations);
     145    (PreferedMapType = GameSystem.PreferedMapType) and
     146    UnitKinds.Compare(GameSystem.UnitKinds) and
     147    BuildingKinds.Compare(GameSystem.BuildingKinds) and
     148    Nations.Compare(GameSystem.Nations);
    149149end;
    150150
  • trunk/Geometry.pas

    r317 r345  
    9696    constructor Create(const Points: TPointArray); overload;
    9797    constructor Create(const Rect: TGRect<T>); overload;
     98    function Compare(Polygon: TGPolygon<T>): Boolean;
    9899    procedure Move(P: T);
    99100    function GetRect: TGRect<T>;
     
    239240  Self.Points[2] := Rect.P2;
    240241  Self.Points[3] := T.Create(Rect.P1.X, Rect.P2.Y);
     242end;
     243
     244function TGPolygon<T>.Compare(Polygon: TGPolygon<T>): Boolean;
     245var
     246  I: Integer;
     247begin
     248  Result := Length(Points) = Length(Polygon.Points);
     249  if not Result then Exit;
     250  for I := 0 to Length(Points) - 1 do
     251    if Points[I] <> Polygon.Points[I] then begin
     252      Result := False;
     253      Break;
     254    end;
    241255end;
    242256
  • trunk/ItemList.pas

    r344 r345  
    253253end;
    254254
    255 function TItemList<T>.QueryInterface(constref iid: tguid; out obj): longint;
     255function TItemList<T>.QueryInterface(constref iid: tguid; out obj): LongInt;
    256256  stdcall;
    257257begin
    258 end;
    259 
    260 function TItemList<T>._AddRef: Longint; stdcall;
    261 begin
    262 end;
    263 
    264 function TItemList<T>._Release: Longint; stdcall;
    265 begin
     258  Result := 0;
     259end;
     260
     261function TItemList<T>._AddRef: LongInt; stdcall;
     262begin
     263  Result := 0;
     264end;
     265
     266function TItemList<T>._Release: LongInt; stdcall;
     267begin
     268  Result := 0;
    266269end;
    267270
  • trunk/Map.pas

    r343 r345  
    4848    Extra: TExtraType;
    4949    OneUnitId: Integer; // Temporary value
     50    function Compare(Cell: TCell): Boolean;
    5051    procedure ConnectTo(Cell: TCell);
    5152    procedure DisconnectFrom(Cell: TCell);
     
    8081    procedure LoadFromNode(Node: TDOMNode);
    8182    procedure SaveToNode(Node: TDOMNode);
     83    function Compare(Cells: TCells): Boolean;
    8284    procedure ClearMark;
    8385    procedure ClearWeight;
     
    409411end;
    410412
     413function TCells.Compare(Cells: TCells): Boolean;
     414var
     415  I: Integer;
     416begin
     417  Result := True;
     418  for I := 0 to Count - 1 do
     419  with Items[I] do begin
     420    if not Items[I].Compare(Cells[I]) then begin
     421      Result := False;
     422      Break;
     423    end;
     424  end;
     425end;
     426
    411427procedure TCells.ClearMark;
    412428var
     
    543559function TMap.Compare(Map: TMap): Boolean;
    544560begin
    545   Result := True;
     561  Result := (MaxPower = Map.MaxPower) and
     562    (Cyclic = Map.Cyclic) and
     563    (Size = Map.Size) and
     564    (DefaultCellSize = Map.DefaultCellSize) and
     565    (Shape = Map.Shape) and
     566    Cells.Compare(Map.Cells);
    546567end;
    547568
     
    942963end;
    943964
     965function TCell.Compare(Cell: TCell): Boolean;
     966begin
     967  Result := (Id = Cell.Id) and
     968    (PosPx = Cell.PosPx) and
     969    (Terrain = Cell.Terrain) and
     970    Polygon.Compare(Cell.Polygon) and
     971    (Player = Cell.Player) and
     972    (Mark = Cell.Mark) and
     973    (Extra = Cell.Extra);
     974end;
     975
    944976procedure TCell.ConnectTo(Cell: TCell);
    945977begin
Note: See TracChangeset for help on using the changeset viewer.