Changeset 258


Ignore:
Timestamp:
Sep 23, 2018, 1:43:52 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Bad cell links in Voronoi map type causing problems on openning saved file.
  • Added: More checks for loaded game file.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/xtactics.cs.po

    r253 r258  
    230230msgstr "Vykonat"
    231231
    232 #: tformmain.astatusbarvisible.caption
    233 msgid "Status bar visible"
    234 msgstr "Viditelná stavová lišta"
    235 
    236232#: tformmain.atoolbarbigicons.caption
    237233msgctxt "tformmain.atoolbarbigicons.caption"
     
    278274msgid "Help"
    279275msgstr "Nápověda"
     276
     277#: tformmain.menuitem22.caption
     278msgctxt "tformmain.menuitem22.caption"
     279msgid "Statusbar visible"
     280msgstr "Viditelná stavová lišta"
    280281
    281282#: tformmain.menuitem8.caption
     
    354355#: tformnew.aplayermodify.caption
    355356msgctxt "tformnew.aplayermodify.caption"
    356 msgid "Modify"
     357msgid "Modify player"
    357358msgstr "Upravit"
    358359
     
    378379msgstr "Odstranit"
    379380
     381#: tformnew.button1.caption
     382msgctxt "tformnew.button1.caption"
     383msgid "Add"
     384msgstr "Přidat"
     385
     386#: tformnew.button2.caption
     387msgctxt "tformnew.button2.caption"
     388msgid "Remove"
     389msgstr "Odstranit"
     390
     391#: tformnew.button3.caption
     392msgctxt "tformnew.button3.caption"
     393msgid "Modify"
     394msgstr "Upravit"
     395
    380396#: tformnew.buttoncancel.caption
    381397msgctxt "tformnew.buttoncancel.caption"
     
    392408msgid "Ok"
    393409msgstr "Ok"
     410
     411#: tformnew.buttonplayeradd.caption
     412msgctxt "tformnew.buttonplayeradd.caption"
     413msgid "Add"
     414msgstr "Přidat"
     415
     416#: tformnew.buttonplayermodify.caption
     417msgctxt "tformnew.buttonplayermodify.caption"
     418msgid "Modify"
     419msgstr "Upravit"
     420
     421#: tformnew.buttonplayerremove.caption
     422msgctxt "tformnew.buttonplayerremove.caption"
     423msgid "Remove"
     424msgstr "Odstranit"
    394425
    395426#: tformnew.caption
     
    10591090msgid "64-bit UInt read overflow."
    10601091msgstr "Přetečení při čtení 64-bit UInt"
    1061 
  • trunk/Languages/xtactics.po

    r250 r258  
    220220msgstr ""
    221221
    222 #: tformmain.astatusbarvisible.caption
    223 msgid "Status bar visible"
    224 msgstr ""
    225 
    226222#: tformmain.atoolbarbigicons.caption
    227223msgctxt "tformmain.atoolbarbigicons.caption"
     
    269265msgstr ""
    270266
     267#: tformmain.menuitem22.caption
     268msgctxt "tformmain.menuitem22.caption"
     269msgid "Statusbar visible"
     270msgstr ""
     271
    271272#: tformmain.menuitem8.caption
    272273msgctxt "tformmain.menuitem8.caption"
     
    342343#: tformnew.aplayermodify.caption
    343344msgctxt "tformnew.aplayermodify.caption"
    344 msgid "Modify"
     345msgid "Modify player"
    345346msgstr ""
    346347
     
    365366msgstr ""
    366367
     368#: tformnew.button1.caption
     369msgctxt "tformnew.button1.caption"
     370msgid "Add"
     371msgstr ""
     372
     373#: tformnew.button2.caption
     374msgctxt "tformnew.button2.caption"
     375msgid "Remove"
     376msgstr ""
     377
     378#: tformnew.button3.caption
     379msgctxt "tformnew.button3.caption"
     380msgid "Modify"
     381msgstr ""
     382
    367383#: tformnew.buttoncancel.caption
    368384msgctxt "TFORMNEW.BUTTONCANCEL.CAPTION"
     
    378394msgctxt "TFORMNEW.BUTTONOK.CAPTION"
    379395msgid "Ok"
     396msgstr ""
     397
     398#: tformnew.buttonplayeradd.caption
     399msgctxt "tformnew.buttonplayeradd.caption"
     400msgid "Add"
     401msgstr ""
     402
     403#: tformnew.buttonplayermodify.caption
     404msgctxt "tformnew.buttonplayermodify.caption"
     405msgid "Modify"
     406msgstr ""
     407
     408#: tformnew.buttonplayerremove.caption
     409msgctxt "tformnew.buttonplayerremove.caption"
     410msgid "Remove"
    380411msgstr ""
    381412
  • trunk/UGeometry.pas

    r248 r258  
    123123
    124124function TypedMod(Numerator, Denominator: Integer): Integer; overload;
    125 function TypedMod(Numerator, Denominator: Single): Single; overload;
     125//function TypedMod(Numerator, Denominator: Single): Single; overload;
    126126function TypedDivide(Divident, Divisor: Integer): Integer; overload;
    127127function TypedDivide(Divident, Divisor: Single): Single; overload;
     
    146146end;
    147147
    148 function TypedMod(Numerator, Denominator: Single): Single; overload;
     148{function TypedMod(Numerator, Denominator: Single): Single; overload;
    149149begin
    150150  //Result := FMod(Numerator, Denominator);
    151 end;
     151end;}
    152152
    153153function TypedDivide(Divident, Divisor: Integer): Integer;
  • trunk/UMap.pas

    r248 r258  
    467467end;
    468468
    469 {procedure TMap.Paint(Canvas: TCanvas; View: TView);
    470 var
    471   I: Integer;
    472   Cell: TCell;
    473   PosFrom, PosTo: TPoint;
    474   Angle: Double;
    475   ArrowCenter: TPoint;
    476   Move: TUnitMove;
    477   CellLink: TCellLink;
    478 begin
    479   with Canvas, View do
    480   try
    481     Lock;
    482 
    483     // Draw cell links
    484     Pen.Color := clBlack;
    485     Pen.Style := psSolid;
    486     Pen.Width := 3;
    487     for CellLink in CellLinks do
    488     with CellLink do begin
    489       if Length(Points) >= 2 then begin
    490         MoveTo(PointToStdPoint(View.CellToCanvasPos(Points[0])));
    491         for I := 1 to Length(Points) - 1 do
    492           LineTo(PointToStdPoint(View.CellToCanvasPos(Points[I])));
    493       end;
    494     end;
    495 
    496     // Draw cells
    497     for Cell in Cells do begin
    498       if (Cell.Terrain <> ttVoid) and Cell.IsVisible(View) then begin
    499         if Assigned(SelectedCell) and (SelectedCell.MapCell = Cell) then
    500           Brush.Color := clGreen
    501           else if Assigned(SelectedCell) and IsCellsNeighbor(SelectedCell.MapCell, Cell) then
    502             Brush.Color := clPurple
    503           else Brush.Color := Cell.GetColor;
    504         //Pen.Color := clBlack;
    505         PaintCell(Canvas, Cell.PosPx, IntToStr(Cell.Power), View, Cell);
    506       end;
    507     end;
    508   finally
    509     Unlock;
    510   end;
    511 end;
    512 }
    513 
    514469function TMap.GetNewCellId: Integer;
    515470begin
     
    647602  Result := Cell.PosPx;
    648603end;
    649 
    650 {procedure TMap.PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView;
    651   Cell: TCell);
    652 var
    653   I: Integer;
    654   TextPos: TPoint;
    655   Points: array of Classes.TPoint;
    656   TextSize: TSize;
    657 begin
    658   if Cell.Extra = etObjectiveTarget then begin
    659     Text := Text + '!';
    660   end;
    661   with Canvas do begin
    662     if Assigned(View.FocusedCell) and (View.FocusedCell.MapCell = Cell) then begin
    663       Pen.Color := clYellow;
    664       Pen.Style := psSolid;
    665       Pen.Width := 1;
    666     end else
    667     if Cell.Terrain = ttCity then begin
    668       // Cannot set clear border as it will display shifted on gtk2
    669       //Pen.Style := psClear;
    670       Pen.Color := clBlack;
    671       Pen.Style := psSolid;
    672       Pen.Width := 3;
    673     end else begin
    674       // Cannot set clear border as it will display shifted on gtk2
    675       //Pen.Style := psClear;
    676       Pen.Color := Brush.Color;
    677       Pen.Style := psSolid;
    678       Pen.Width := 0;
    679     end;
    680     // Transform view
    681     SetLength(Points, Length(Cell.Polygon.Points));
    682     for I := 0 to Length(Points) - 1 do
    683       Points[I] := PointToStdPoint(View.CellToCanvasPos(Cell.Polygon.Points[I]));
    684     Brush.Style := bsSolid;
    685     //Polygon(Points, False, 0, Length(Points));
    686     TCanvasEx.PolygonEx(Canvas, Points, False);
    687     //MoveTo(Points[0].X, Points[0].Y);
    688     //LineTo(Points[1].X, Points[1].Y);
    689 
    690     // Show cell text
    691     if (Cell.Power <> 0) or (Cell.Extra = etObjectiveTarget) then begin
    692       Pen.Style := psSolid;
    693       Font.Color := clWhite;
    694       Brush.Style := bsClear;
    695       Font.Size := Trunc(42 * View.Zoom);
    696       TextPos := View.CellToCanvasPos(Pos);
    697       TextSize := TextExtent(Text);
    698       TCanvasEx.TextOutEx(Canvas, Round(TextPos.X) - TextSize.cx div 2,
    699         Round(TextPos.Y) - TextSize.cy div 2, Text, False);
    700     end;
    701   end;
    702 end;
    703 }
    704604
    705605procedure TMap.ComputePlayerStats;
     
    1010910procedure TCell.ConnectTo(Cell: TCell);
    1011911begin
     912  if Cell = Self then
     913    raise Exception.Create('Can''t connect map cell to itself');
    1012914  // Connect only if already not connected
    1013915  if Neighbors.IndexOf(Cell) < 0 then begin
     
    1068970var
    1069971  I: Integer;
     972  Cell: TCell;
    1070973begin
    1071974  Player := TGame(Map.Game).Players.FindById(PlayerId);
    1072975
    1073976  Neighbors.Count := Length(NeighborsId);
     977  for I := 0 to Length(NeighborsId) - 1 do
     978    Neighbors[I] := nil;
    1074979  for I := 0 to Length(NeighborsId) - 1 do begin
    1075     Neighbors[I] := Map.Cells.FindById(NeighborsId[I]);
     980    Cell := Map.Cells.FindById(NeighborsId[I]);
     981    if not Assigned(Cell) then
     982      raise Exception.Create('Neighbor cell id not found ' + IntToStr(NeighborsId[I]));
     983    if Neighbors.IndexOf(Cell) <> -1 then
     984      raise Exception.Create('Duplicate neighbor cell ' + IntToStr(NeighborsId[I]) + ' found for cell ' + IntToStr(Id));
     985    Neighbors[I] := Cell;
    1076986  end;
    1077987end;
  • trunk/UMapType.pas

    r248 r258  
    489489      for Y := -1 to 1 do
    490490      for X := -1 to 1 do
    491       for J := 0 to Cells.Count - 1 do begin
     491      for J := 0 to Cells.Count - 1 do
     492      if J <> I then begin
    492493        P := Cells[J].Polygon;
    493494        P.Move(TPoint.Create(X * AreaSize.X, Y * AreaSize.Y));
  • trunk/UPlayer.pas

    r248 r258  
    217217
    218218procedure TPlayerCell.LoadFromNode(Node: TDOMNode);
     219var
     220  C: TCell;
     221  CellId: Integer;
    219222begin
    220223  Explored := ReadBoolean(Node, 'Explored', False);
    221   MapCell := TGame(List.Map.Player.Game).Map.Cells.FindById(ReadInteger(Node, 'MapCell', 0));
     224  CellId := ReadInteger(Node, 'MapCell', 0);
     225  C := TGame(List.Map.Player.Game).Map.Cells.FindById(CellId);
     226  if not Assigned(C) then
     227    raise Exception.Create('Cell map not found ' + IntToStr(CellId));
     228  if List.SearchCell(C) <> nil then
     229    raise Exception.Create('Map cell used twice ' + IntToStr(CellId));
     230  MapCell := C;
    222231end;
    223232
    224233procedure TPlayerCell.ConnectTo(Cell: TPlayerCell);
    225234begin
     235  if Cell = Self then
     236    raise Exception.Create('Can''t connect player cell to itself');
    226237  if (Cell.Neighbors.IndexOf(Self) = -1) and
    227   (Neighbors.IndexOf(Cell) = -1) then begin;
     238  (Neighbors.IndexOf(Cell) = -1) then begin
    228239    Cell.Neighbors.Add(Self);
    229240    Neighbors.Add(Cell);
     
    282293begin
    283294  for I := MovesFrom.Count - 1 downto 0 do
    284     TUnitMove(MovesFrom[I]).List.Remove(TUnitMove(MovesFrom[I]));
     295    if TUnitMove(MovesFrom[I]).List.Remove(TUnitMove(MovesFrom[I])) = -1 then
     296      raise Exception.Create('MoveFrom cell remove error');
    285297  FreeAndNil(MovesFrom);
    286298  for I := MovesTo.Count - 1 downto 0 do
    287     TUnitMove(MovesTo[I]).List.Remove(TUnitMove(MovesTo[I]));
     299    if TUnitMove(MovesTo[I]).List.Remove(TUnitMove(MovesTo[I])) = -1 then
     300      raise Exception.Create('MoveTo cell remove error');
    288301  FreeAndNil(MovesTo);
    289302  for I := Neighbors.Count - 1 downto 0 do
     
    672685  if FCellFrom = AValue then Exit;
    673686  if Assigned(AValue) and not Assigned(FCellFrom) then begin
    674     AValue.MovesFrom.Add(Self);
     687    if AValue.MovesFrom.IndexOf(Self) = -1 then
     688      AValue.MovesFrom.Add(Self)
     689      else raise Exception.Create('Unit move already exists');
    675690  end else
    676691  if not Assigned(AValue) and Assigned(FCellFrom) then begin
    677     FCellFrom.MovesFrom.Remove(Self);
     692    if FCellFrom.MovesFrom.IndexOf(Self) <> -1 then
     693      FCellFrom.MovesFrom.Remove(Self)
     694      else raise Exception.Create('Unit move not found');
    678695  end;
    679696  FCellFrom := AValue;
Note: See TracChangeset for help on using the changeset viewer.