Changeset 298 for trunk/UGame.pas


Ignore:
Timestamp:
Jul 10, 2019, 5:35:15 PM (5 years ago)
Author:
chronos
Message:
  • Added: New item list type reference. Used in players for reference to selected nation.
  • Modified: New game players selection migrated to dynamic item/list forms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r294 r298  
    330330  if not GeneratePlayers then Exit;
    331331
    332   for Player in Players do begin
    333     Player.Reset;
    334     Player.StartCell := nil;
    335   end;
    336   I := 0;
    337   for Player in Players do
    338   with Player do begin
     332  for I := 0 to Players.Count - 1 do begin
     333    TPlayer(Players[I]).Reset;
     334    TPlayer(Players[I]).StartCell := nil;
     335  end;
     336  for I := 0 to Players.Count - 1 do
     337  with TPlayer(Players[I]) do begin
     338    Player := TPlayer(Players[I]);
    339339    PlayerMap.Update;
    340340    if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin
     
    342342      if Assigned(Player.StartCell) then begin
    343343        if SymetricMap and (I = 1) then
    344           StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)];
     344          StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(TPlayer(Players[0]).StartCell)];
    345345
    346346        if CityEnabled then begin
     
    358358    InitUnitMoves;
    359359    PlayerMap.CheckVisibility;
    360     Inc(I);
    361360  end;
    362361end;
     
    411410  Player: TPlayer;
    412411  List: TCells;
    413 begin
    414   for Player in Players do
    415   if Assigned(Player.StartCell) then begin
    416     Player.StartCell.Weight := 1;
    417     Player.StartCell.Mark := True;
    418     List := TCells.Create;
    419     List.FreeObjects := False;
    420     List.Add(Player.StartCell);
    421     PropagatePlayerDistance(List);
    422     FreeAndNil(List);
     412  I: Integer;
     413begin
     414  for I := 0 to Players.Count - 1 do begin
     415    Player := TPlayer(Players[I]);
     416    if Assigned(Player.StartCell) then begin
     417      Player.StartCell.Weight := 1;
     418      Player.StartCell.Mark := True;
     419      List := TCells.Create;
     420      List.FreeObjects := False;
     421      List.Add(Player.StartCell);
     422      PropagatePlayerDistance(List);
     423      FreeAndNil(List);
     424    end;
    423425  end;
    424426end;
     
    568570    MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), 5);
    569571    MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99);
     572    GameSystemName := string(GetValue(DOMString(Path + '/GameSystemName'), DOMString('')));
    570573    Players.LoadConfig(Config, Path + '/Players');
    571     GameSystemName := string(GetValue(DOMString(Path + '/GameSystemName'), DOMString('')));
    572574  end;
    573575end;
     
    617619      if Assigned(NewNode) then
    618620        Players.LoadFromNode(NewNode);
    619       if Players.Count > 0 then CurrentPlayer := Players[0]
     621      if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])
    620622        else CurrentPlayer := nil;
    621623
     
    628630
    629631      for I := 0 to Players.Count - 1 do begin
    630         Players[I].PlayerMap.Update;
    631         Players[I].PlayerMap.CheckVisibility;
     632        TPlayer(Players[I]).PlayerMap.Update;
     633        TPlayer(Players[I]).PlayerMap.CheckVisibility;
    632634      end;
    633635      ComputePlayerStats;
     
    700702begin
    701703  for I := 0 to Players.Count - 1 do
    702   with Players[I] do begin
     704  with TPlayer(Players[I]) do begin
    703705    TotalUnits := 0;
    704706    TotalCells := 0;
     
    721723begin
    722724  for I := 0 to Players.Count - 1 do
    723   with Players[I] do begin
     725  with TPlayer(Players[I]) do begin
    724726    NewStat := TGameTurnStat.Create;
    725727    NewStat.DiscoveredCells := TotalDiscovered;
     
    770772      NewPlayerIndex := NewPlayerIndex mod AlivePlayers.Count;
    771773    end;
    772     CurrentPlayer := AlivePlayers[NewPlayerIndex];
     774    CurrentPlayer := TPlayer(AlivePlayers[NewPlayerIndex]);
    773775  finally
    774776    AlivePlayers.Free;
     
    895897  I: Integer;
    896898begin
    897   for I := 0 to Players.Count - 1 do Players[I].Clear;
     899  for I := 0 to Players.Count - 1 do TPlayer(Players[I]).Clear;
    898900  Map.Clear;
    899901end;
     
    922924
    923925  InitPlayers;
    924   if Players.Count > 0 then CurrentPlayer := Players[0]
     926  if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])
    925927    else CurrentPlayer := nil;
    926928
Note: See TracChangeset for help on using the changeset viewer.