Changeset 316 for trunk/UClientAI.pas


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

Legend:

Unmodified
Added
Removed
  • trunk/UClientAI.pas

    r274 r316  
    11unit UClientAI;
    22
    3 {$mode delphi}
    4 
    53interface
    64
    75uses
    8   Classes, SysUtils, UGameClient, UGame, Math, UPlayer, UMap;
     6  Classes, SysUtils, UGameClient, UGame, Math, UPlayer, UMap, Generics.Defaults;
    97
    108type
     
    5351  AllCells := ControlPlayer.PlayerMap.Cells;
    5452  TargetCells := TPlayerCells.Create;
    55   TargetCells.FreeObjects := False;
     53  TargetCells.OwnsObjects := False;
    5654
    5755  // Get list of all attack target cells
     
    7068  // Sort ascending to attack cells with lower power first
    7169  // Low power cells are better for expanding our territory
    72   TargetCells.Sort(CellCompare);
     70  TargetCells.Sort(TComparer<TPlayerCell>.Construct(CellCompare));
    7371
    7472  for Cell in TargetCells do
     
    113111  DefendCount: Integer;
    114112begin
    115 if ControlPlayer.Defensive then Exit;
     113  if ControlPlayer.Defensive then Exit;
    116114
    117115  AllCells := ControlPlayer.PlayerMap.Cells;
    118116  TargetCells := TPlayerCells.Create;
    119   TargetCells.FreeObjects := False;
     117  TargetCells.OwnsObjects := False;
    120118
    121119  // Get list of all attack target cells
     
    134132  // Sort descending to attack cells with higher power first
    135133  // Higher power enemy cells can grow faster and is more dangerous
    136   TargetCells.Sort(CellCompareDescending);
     134  TargetCells.Sort(TComparer<TPlayerCell>.Construct(CellCompareDescending));
    137135
    138136  for TargetCell in TargetCells do begin
     
    188186  AllCells := ControlPlayer.PlayerMap.Cells;
    189187  TargetCells := TPlayerCells.Create;
    190   TargetCells.FreeObjects := False;
     188  TargetCells.OwnsObjects := False;
    191189  NewTargetCells := TPlayerCells.Create;
    192   NewTargetCells.FreeObjects := False;
     190  NewTargetCells.OwnsObjects := False;
    193191
    194192  // Get list of all enemy border cells
     
    252250    TargetCells := NewTargetCells;
    253251    NewTargetCells := TPlayerCells.Create;
    254     NewTargetCells.FreeObjects := False;
     252    NewTargetCells.OwnsObjects := False;
    255253  end;
    256254
     
    293291begin
    294292  BorderCells := TPlayerCells.Create;
    295   BorderCells.FreeObjects := False;
     293  BorderCells.OwnsObjects := False;
    296294  AllCells := ControlPlayer.PlayerMap.Cells;
    297295
Note: See TracChangeset for help on using the changeset viewer.