Changeset 83 for trunk


Ignore:
Timestamp:
Nov 5, 2014, 10:18:38 AM (10 years ago)
Author:
chronos
Message:
  • Fixed: Loading game was not working after Fog of war modifications.
  • Fixed: Show move arrows only for visible area.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r82 r83  
    225225  if OpenDialog1.Execute then begin
    226226    Game.LoadFromFile(OpenDialog1.FileName);
     227    Player := Game.Players.GetFirstHuman;
    227228    LastMapFileName := OpenDialog1.FileName;
    228229    with Core.Game.CurrentPlayer do
  • trunk/UGame.pas

    r82 r83  
    211211
    212212  TPlayerCells = class(TObjectList)
    213 
     213    function SearchCell(Cell: TCell): TPlayerCell;
    214214  end;
    215215
     
    480480end;
    481481
     482{ TPlayerCells }
     483
     484function TPlayerCells.SearchCell(Cell: TCell): TPlayerCell;
     485var
     486  I: Integer;
     487begin
     488  I := 0;
     489  while (I < Count) and (TPlayerCell(Items[I]).MapCell <> Cell) do Inc(I);
     490  if I < Count then Result := TPlayerCell(Items[I])
     491    else Result := nil;
     492end;
     493
    482494{ TPlayerMap }
    483495
     
    554566          else if Player.Game.FogOfWar then begin
    555567            if Cell.InVisibleRange then begin
    556               if not Cell.Explored then begin
    557                 Brush.Color := HalfColor(Cell.MapCell.GetColor);
     568              Brush.Color := Cell.MapCell.GetColor;
     569            end else begin
     570              if Cell.Explored then begin
     571                Brush.Color := $404040;
    558572                CellText := '';
    559               end else Brush.Color := Cell.MapCell.GetColor
    560             end else begin
    561               Brush.Color := clBlack;
    562               CellText := '';
     573              end else begin
     574                Brush.Color := clBlack;
     575                CellText := '';
     576              end;
    563577            end;
    564578          end else Brush.Color := Cell.MapCell.GetColor;
     
    577591      PosFrom := Player.Game.Map.CellToPos(Move.CellFrom);
    578592      PosTo := Player.Game.Map.CellToPos(Move.CellTo);
     593      // In Fog of war mode show only
     594      if Game.FogOfWar and not Cells.SearchCell(Move.CellFrom).InVisibleRange and
     595        not Cells.SearchCell(Move.CellTo).InVisibleRange then
     596        Continue;
    579597      if Move.CountRepeat > 0 then Pen.Width := 2
    580598        else Pen.Width := 1;
     
    21862204var
    21872205  NewNode: TDOMNode;
    2188   Value: Integer;
    21892206  Doc: TXMLDocument;
    2190   Dump: TStringList;
    21912207  RootNode: TDOMNode;
     2208  I: Integer;
    21922209begin
    21932210  Self.FileName := FileName;
     
    22262243
    22272244      Map.Cells.FixRefId;
     2245
     2246      for I := 0 to Players.Count - 1 do begin
     2247        TPlayer(Players[I]).PlayerMap.Update;
     2248        TPlayer(Players[I]).PlayerMap.CheckVisibility;
     2249      end;
    22282250    end;
    22292251  finally
     
    22352257var
    22362258  NewNode: TDOMNode;
    2237   NewNode2: TDOMNode;
    22382259  Doc: TXMLDocument;
    22392260  RootNode: TDOMNode;
     
    23222343  Map.Grow(CurrentPlayer);
    23232344  UpdateRepeatMoves(CurrentPlayer);
    2324   CurrentPlayer.PlayerMap.CheckVisibility;
    23252345  ComputePlayerStats;
    23262346  PrevPlayer := CurrentPlayer;
     
    23352355  end;
    23362356  CheckWinObjective;
     2357  CurrentPlayer.PlayerMap.CheckVisibility;
    23372358  // For computers take view from previous human
    23382359  //if CurrentPlayer.Mode = pmComputer then CurrentPlayer.View.Assign(PrevPlayer.View);
Note: See TracChangeset for help on using the changeset viewer.