Changeset 316 for trunk/UPlayer.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/UPlayer.pas

    r315 r316  
    11unit UPlayer;
    22
    3 {$mode delphi}
    4 
    53interface
    64
    75uses
    8   Classes, SysUtils, Graphics, UMap, DOM, fgl, XMLConf, XML, Math,
    9   UGeometry, UUnit, UNation, UItemList;
     6  Classes, SysUtils, Graphics, UMap, DOM, Generics.Collections, Generics.Defaults,
     7  XMLConf, XML, Math, UGeometry, UUnit, UNation, UItemList;
    108
    119type
     
    3836  { TPlayerCells }
    3937
    40   TPlayerCells = class(TFPGObjectList<TPlayerCell>)
     38  TPlayerCells = class(TObjectList<TPlayerCell>)
    4139    Map: TPlayerMap;
    4240    function FindByCellId(Id: Integer): TPlayerCell;
     
    8482  { TGameTurnStats }
    8583
    86   TGameTurnStats = class(TFPGObjectList<TGameTurnStat>)
     84  TGameTurnStats = class(TObjectList<TGameTurnStat>)
    8785    procedure LoadFromNode(Node: TDOMNode);
    8886    procedure SaveToNode(Node: TDOMNode);
     
    192190  { TUnitMoves }
    193191
    194   TUnitMoves = class(TFPGObjectList<TUnitMove>)
     192  TUnitMoves = class(TObjectList<TUnitMove>)
    195193    Game: TObject; //TGame;
    196194    Player: TPlayer;
     
    200198  end;
    201199
    202 function CellCompare(const Item1, Item2: TPlayerCell): Integer;
    203 function CellCompareDescending(const Item1, Item2: TPlayerCell): Integer;
     200function CellCompare(constref Item1, Item2: TPlayerCell): Integer;
     201function CellCompareDescending(constref Item1, Item2: TPlayerCell): Integer;
    204202
    205203
     
    225223  SDefensive = 'Defensive';
    226224
    227 function ComparePointer(const Item1, Item2: Integer): Integer;
     225function ComparePointer(constref Item1, Item2: Integer): Integer;
    228226begin
    229227  Result := -CompareValue(Item1, Item2);
     
    311309begin
    312310  MovesFrom := TUnitMoves.Create;
    313   MovesFrom.FreeObjects := False;
     311  MovesFrom.OwnsObjects := False;
    314312  MovesTo := TUnitMoves.Create;
    315   MovesTo.FreeObjects := False;
     313  MovesTo.OwnsObjects := False;
    316314  Neighbors := TPlayerCells.Create;
    317   Neighbors.FreeObjects := False;
     315  Neighbors.OwnsObjects := False;
    318316end;
    319317
     
    334332      raise Exception.Create(SCellRemoveNeighborError);
    335333  FreeAndNil(Neighbors);
    336   inherited Destroy;
     334  inherited;
    337335end;
    338336
     
    480478begin
    481479  FreeAndNil(Cells);
    482   inherited Destroy;
     480  inherited;
    483481end;
    484482
     
    718716  CellTo := nil;
    719717  List := nil;
    720   inherited Destroy;
     718  inherited;
    721719end;
    722720
     
    864862  S: string;
    865863  I: Integer;
    866   AttackRolls: TFPGList<Integer>;
    867   DefendRolls: TFPGList<Integer>;
    868 begin
    869   AttackRolls := TFPGList<Integer>.Create;
    870   DefendRolls := TFPGList<Integer>.Create;
     864  AttackRolls: TList<Integer>;
     865  DefendRolls: TList<Integer>;
     866begin
     867  AttackRolls := TList<Integer>.Create;
     868  DefendRolls := TList<Integer>.Create;
    871869  if AttackPower < 1 then
    872870    raise Exception.Create(SAttackerPowerPositive);
     
    884882      AttackRolls[I] := Random(7);
    885883    end;
    886     AttackRolls.Sort(ComparePointer);
     884    AttackRolls.Sort(TComparer<Integer>.Construct(ComparePointer));
    887885    S := 'Att:';
    888886    for I := 0 to AttackerDiceCount - 1 do
     
    892890      DefendRolls[I] := Random(7);
    893891    end;
    894     DefendRolls.Sort(ComparePointer);
     892    DefendRolls.Sort(TComparer<Integer>.Construct(ComparePointer));
    895893    S := S + ' Def:';
    896894    for I := 0 to DefenderDiceCount - 1 do
     
    905903end;
    906904
    907 function CellCompare(const Item1, Item2: TPlayerCell): Integer;
     905function CellCompare(constref Item1, Item2: TPlayerCell): Integer;
    908906var
    909907  Stack1, Stack2: Integer;
     
    918916end;
    919917
    920 function CellCompareDescending(const Item1, Item2: TPlayerCell): Integer;
     918function CellCompareDescending(constref Item1, Item2: TPlayerCell): Integer;
    921919var
    922920  Stack1, Stack2: Integer;
Note: See TracChangeset for help on using the changeset viewer.