Changeset 222 for trunk


Ignore:
Timestamp:
Jul 13, 2018, 11:13:12 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Computer was affecting player cells by its cell moves.
  • Added: Additional consistency checks.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.pas

    r221 r222  
    477477      Client.View.FocusedCell := Cell;
    478478      StatusBar1.Panels[0].Text := '[' + IntToStr(Cell.PosPx.X) + ', ' + IntToStr(Cell.PosPx.Y) +
    479         '] (' + IntToStr(Cell.MovesFrom.Count) + ', ' + IntToStr(Cell.MovesTo.Count) + ')';
     479        '] (' + IntToStr(Cell.MovesFrom.Count) + ', ' + IntToStr(Cell.MovesTo.Count) + ') ' + IntToStr(Cell.Id);
    480480    end else begin
    481481      Client.View.FocusedCell := nil;
  • trunk/Forms/UFormMain.lfm

    r221 r222  
    55  Width = 775
    66  Caption = 'xTactics'
    7   ClientHeight = 596
     7  ClientHeight = 587
    88  ClientWidth = 775
    9   DesignTimePPI = 120
     9  DesignTimePPI = 144
    1010  Menu = MainMenu1
    1111  OnClose = FormClose
     
    1414  OnKeyUp = FormKeyUp
    1515  OnShow = FormShow
    16   LCLVersion = '1.8.2.0'
     16  LCLVersion = '1.8.4.0'
    1717  WindowState = wsMaximized
    1818  object ToolBar1: TToolBar
     
    7878  object PanelMain: TPanel
    7979    Left = 0
    80     Height = 556
     80    Height = 547
    8181    Top = 40
    8282    Width = 775
     
    192192    Interval = 20
    193193    OnTimer = Timer1Timer
    194     left = 154
     194    left = 128
    195195    top = 263
    196196  end
  • trunk/Languages/xtactics.cs.po

    r221 r222  
    10391039msgid "64-bit UInt read overflow."
    10401040msgstr "Přetečení při čtení 64-bit UInt"
     1041
  • trunk/UClientAI.pas

    r213 r222  
    6060      CanAttack := 0;
    6161      for NeighborCell in Neighbors do
    62       if NeighborCell.Player = Game.CurrentPlayer then begin
     62      if NeighborCell.Player = ControlPlayer then begin
    6363        Inc(CanAttack);
    6464      end;
     
    7777      TotalPower := 0;
    7878      for NeighborCell in Neighbors do
    79       if NeighborCell.Player = Game.CurrentPlayer then
     79      if NeighborCell.Player = ControlPlayer then
    8080        TotalPower := TotalPower + NeighborCell.GetAvialPower;
    8181
     
    8484        TotalAttackPower := 0;
    8585        for NeighborCell in Neighbors do
    86         if NeighborCell.Player = Game.CurrentPlayer then begin
     86        if NeighborCell.Player = ControlPlayer then begin
    8787          // Use only necessary power
    8888          AttackPower := Power - TotalAttackPower + AttackDiff;
     
    109109  NeighborCell: TCell;
    110110begin
    111   if ControlPlayer.Defensive then Exit;
     111if ControlPlayer.Defensive then Exit;
    112112
    113113  AllCells := Game.Map.Cells;
     
    188188  for C := 0 to AllCells.Count - 1 do
    189189  with AllCells[C] do begin
    190     if (Player <> Game.CurrentPlayer) and (Player <> nil) and (Terrain <> ttVoid) then begin
     190    if (Player <> ControlPlayer) and (Player <> nil) and (Terrain <> ttVoid) then begin
    191191      CanAttack := 0;
    192192      for I := 0 to Neighbors.Count - 1 do
    193       if ((Neighbors[I].Player = Game.CurrentPlayer) or
     193      if ((Neighbors[I].Player = ControlPlayer) or
    194194      (Neighbors[I].Player = nil)) and (Neighbors[I].Terrain <> ttVoid) then begin
    195195        Inc(CanAttack);
     
    218218      for I := 0 to Neighbors.Count - 1 do begin
    219219        if (Neighbors[I].Terrain <> ttVoid) and (not Neighbors[I].Mark) then begin
    220           if (TargetCells[C].Player = Game.CurrentPlayer) and
    221           (Neighbors[I].Player = Game.CurrentPlayer) then begin
     220          if (TargetCells[C].Player = ControlPlayer) and
     221          (Neighbors[I].Player = ControlPlayer) then begin
    222222            // Do not take units from front line
    223223            Cells2 := Neighbors[I].Neighbors;
    224224            CanAttack := 0;
    225225            for J := 0 to Cells2.Count - 1 do
    226             if ((Cells2[J].Player <> Game.CurrentPlayer) or (Cells2[J].Player = nil))
     226            if ((Cells2[J].Player <> ControlPlayer) or (Cells2[J].Player = nil))
    227227            and (Cells2[J].Terrain <> ttVoid) then begin
    228228              Inc(CanAttack);
     
    292292  for C := 0 to AllCells.Count - 1 do
    293293  with AllCells[C] do begin
    294     if (Terrain <> ttVoid) and (Player = Game.CurrentPlayer)  then begin
     294    if (Terrain <> ttVoid) and (Player = ControlPlayer)  then begin
    295295      if AttackersCount(AllCells[C]) > 0 then
    296296        BorderCells.Add(AllCells[C]);
     
    305305    EnemyPower := 0;
    306306    for I := 0 to Neighbors.Count - 1 do
    307     if (Neighbors[I].Player <> Game.CurrentPlayer) and (Neighbors[I].Player <> nil) then begin
     307    if (Neighbors[I].Player <> ControlPlayer) and (Neighbors[I].Player <> nil) then begin
    308308      Inc(EnemyPower, Neighbors[I].Power);
    309309    end;
     
    329329  Result := 0;
    330330  for I := 0 to Cell.Neighbors.Count - 1 do
    331   if (Cell.Neighbors[I].Player <> Game.CurrentPlayer) and
     331  if (Cell.Neighbors[I].Player <> ControlPlayer) and
    332332    (Cell.Neighbors[I].Player <> nil) then begin
    333333      Inc(Result);
  • trunk/UCore.lfm

    r221 r222  
    33  OnDestroy = DataModuleDestroy
    44  OldCreateOrder = False
    5   Height = 676
    6   HorizontalOffset = 353
    7   VerticalOffset = 312
    8   Width = 1048
    9   PPI = 120
     5  Height = 811
     6  HorizontalOffset = 424
     7  VerticalOffset = 374
     8  Width = 1258
     9  PPI = 144
    1010  object ActionListMain: TActionList
    1111    Images = ImageListSmall
    12     left = 114
    13     top = 50
     12    left = 137
     13    top = 60
    1414    object AExit: TAction
    1515      Caption = 'Exit'
     
    105105  end
    106106  object ImageListSmall: TImageList
    107     left = 655
    108     top = 350
     107    left = 786
     108    top = 420
    109109    Bitmap = {
    110110      4C690C00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1
     
    498498    POFilesFolder = 'Languages'
    499499    OnTranslate = CoolTranslator1Translate
    500     left = 114
    501     top = 363
     500    left = 137
     501    top = 436
    502502  end
    503503  object ImageListLarge: TImageList
    504504    Height = 32
    505505    Width = 32
    506     left = 655
    507     top = 238
     506    left = 786
     507    top = 286
    508508    Bitmap = {
    509509      4C690C0000002000000020000000000000000000000000000000E2AA4B36E2A9
     
    20502050    RootName = 'CONFIG'
    20512051    ReadOnly = False
    2052     left = 114
    2053     top = 463
     2052    left = 137
     2053    top = 556
    20542054  end
    20552055  object OpenDialog1: TOpenDialog
    20562056    DefaultExt = '.xtmap'
    2057     left = 938
    2058     top = 243
     2057    left = 1126
     2058    top = 292
    20592059  end
    20602060  object SaveDialog1: TSaveDialog
    20612061    DefaultExt = '.xtmap'
    2062     left = 938
    2063     top = 138
     2062    left = 1126
     2063    top = 166
    20642064  end
    20652065  object ApplicationInfo: TApplicationInfo
     
    20742074    AuthorsName = 'Chronos'
    20752075    AppName = 'xTactics'
    2076     ReleaseDate = 43263
     2076    ReleaseDate = 43293
    20772077    RegistryKey = '\Software\xTactics'
    20782078    RegistryRoot = rrKeyCurrentUser
    20792079    License = 'CC0'
    2080     left = 114
    2081     top = 150
     2080    left = 137
     2081    top = 180
    20822082  end
    20832083  object PersistentForm: TPersistentForm
    20842084    MinVisiblePart = 50
    20852085    EntireVisible = False
    2086     left = 650
    2087     top = 500
     2086    left = 780
     2087    top = 600
    20882088  end
    20892089  object ScaleDPI1: TScaleDPI
    20902090    AutoDetect = False
    2091     left = 113
    2092     top = 563
     2091    left = 136
     2092    top = 676
    20932093  end
    20942094  object LastOpenedList1: TLastOpenedList
    20952095    MaxCount = 10
    20962096    OnChange = LastOpenedList1Change
    2097     left = 114
    2098     top = 250
     2097    left = 137
     2098    top = 300
    20992099  end
    21002100end
  • trunk/UGame.pas

    r220 r222  
    3838  private
    3939    FArea: TMapArea;
     40    FId: Integer;
    4041    FMap: TMap;
    4142    FPower: Integer;
    4243    procedure SetArea(AValue: TMapArea);
     44    procedure SetId(AValue: Integer);
    4345    procedure SetPower(AValue: Integer);
    4446  public
    45     Id: Integer;
    4647    PosPx: TPoint;
    4748    Polygon: TPolygon;
     
    5859    Links: TCellLinks;
    5960    Extra: TExtraType;
     61    property Id: Integer read FId write SetId;
    6062    procedure ConnectTo(Cell: TCell);
    6163    procedure DisconnectFrom(Cell: TCell);
     
    226228    procedure CreateLinks;
    227229    procedure Clear;
     230    procedure CheckCells;
    228231    constructor Create; virtual;
    229232    destructor Destroy; override;
     
    16881691end;
    16891692
     1693procedure TMap.CheckCells;
     1694var
     1695  I: Integer;
     1696  J: Integer;
     1697begin
     1698  for I := 0 to Cells.Count - 1 do begin
     1699    for J := I + 1 to Cells.Count - 1 do begin
     1700      if (Cells[I].Id = Cells[J].Id) then
     1701        raise Exception.Create('Duplicate cells ID ' + IntToStr(I) + ' ' + IntToStr(J));
     1702      if (Cells[I].PosPx = Cells[J].PosPx) then
     1703        raise Exception.Create('Duplicate cells position ' + IntToStr(I) + ' ' + IntToStr(J));
     1704    end;
     1705  end;
     1706end;
     1707
    16901708constructor TMap.Create;
    16911709begin
     
    18891907  FArea := AValue;
    18901908  if Assigned(FArea) then FArea.Cells.Add(Self);
     1909end;
     1910
     1911procedure TCell.SetId(AValue: Integer);
     1912begin
     1913  if FId = AValue then Exit;
     1914  FId := AValue;
    18911915end;
    18921916
     
    20372061constructor TCell.Create;
    20382062begin
     2063  FId := -1;
    20392064  Player := nil;
    20402065  Neighbors := TCells.Create;
     
    24512476  Confirm: Boolean;
    24522477begin
     2478  if CellFrom.Player <> Self then
     2479    raise Exception.Create('Can''t set move of other player.');
    24532480  Confirm := True;
    24542481  Result := Moves.SearchByFromTo(CellFrom, CellTo);
     
    27492776  I: Integer;
    27502777begin
     2778  if AttackCount < 0 then raise Exception.Create('Attack power needs to be possitive' + IntToStr(AttackCount));
    27512779  if AttackCount = 0 then begin
    27522780    Result := 0;
    27532781    Exit;
    27542782  end;
     2783  if DefendCount < 0 then raise Exception.Create('Defend power needs to be possitive but is ' + IntToStr(DefendCount));
    27552784  if DefendCount = 0 then begin
    27562785    Result := 1;
     
    31873216  NewPlayerIndex: Integer;
    31883217begin
     3218  {$IFDEF DEBUG}
     3219  Map.CheckCells;
     3220  {$ENDIF}
     3221
    31893222  // Finalize current player
    31903223  CurrentPlayer.MoveAll;
  • trunk/xtactics.lpr

    r203 r222  
    1111  CoolTranslator, TemplateGenerics
    1212  { you can add units after this },
    13   SysUtils, UFormMain, CoolStreaming, UFormServer, UClientAI, UGameConnection;
     13  SysUtils, UFormMain, CoolStreaming;
    1414
    1515{$R *.res}
Note: See TracChangeset for help on using the changeset viewer.