Changeset 409 for tags/1.4.0/Game.pas


Ignore:
Timestamp:
Jan 8, 2025, 11:01:27 AM (34 hours ago)
Author:
chronos
Message:

Merged revision(s) 403-408 from trunk:

  • Added: Cover image.
  • Fixed: Crash on cyclic map new move creation.
  • Modified: TView class moved into separate unit.
  • Added: French translation.
  • Fixed: Do not stop running game on Quit action.
  • Fixed: Cell cities were not correctly stored the saved game.
  • Fixed: ItemList references were loaded by item index instead of item id.
  • Fixed: Wrong default map image path initialization.
Location:
tags/1.4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/1.4.0

  • tags/1.4.0/Game.pas

    r401 r409  
    5858    procedure InitDefaultPlayers;
    5959    procedure WinObjectiveMapPrepare;
     60    procedure BuildCity(Cell: TCell);
    6061  public
    6162    GameSystem: TGameSystem;
     
    342343  with Cell do begin
    343344    if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then begin
    344       Building := Buildings.AddItem('City');
    345       Building.Kind := GameSystem.BuildingKinds.FindBySpecialType(stCity);
     345      BuildCity(Cell);
    346346    end;
    347347  end;
     
    369369          StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)];
    370370
    371         if CityEnabled then begin
    372           StartCell.Building := Buildings.AddItem('City');
    373           StartCell.Building.Kind := GameSystem.BuildingKinds.FindBySpecialType(stCity);
    374         end;
     371        if CityEnabled then BuildCity(StartCell);
    375372        StartCell.Player := Player;
    376373        if GameSystem.UnitKinds.Count > 0 then begin
     
    497494end;
    498495
     496procedure TGame.BuildCity(Cell: TCell);
     497var
     498  CityBuildingKind: TBuildingKind;
     499begin
     500  CityBuildingKind := GameSystem.BuildingKinds.FindBySpecialType(stCity);
     501  if not Assigned(CityBuildingKind) then begin
     502    CityBuildingKind := GameSystem.BuildingKinds.AddItem('City');
     503    CityBuildingKind.SpecialType := stCity;
     504  end;
     505  if not Assigned(Cell.Building) then begin
     506    Cell.Building := Buildings.AddItem('City');
     507    Cell.Building.Kind := CityBuildingKind;
     508    Cell.Building.Game := Self;
     509  end;
     510end;
     511
    499512procedure TGame.Assign(Source: TGame);
    500513begin
     
    502515  DevelMode := Source.DevelMode;
    503516  Players.Assign(Source.Players);
     517  Buildings.Assign(Source.Buildings);
    504518  MapType := Source.MapType;
    505519  Map.Assign(Source.Map);
     
    647661        Units.LoadFromNode(NewNode);
    648662
     663      NewNode := FindNode('Buildings');
     664      if Assigned(NewNode) then
     665        Buildings.LoadFromNode(NewNode);
     666
    649667      Map.Cells.FixRefId;
    650668      Units.FixRefId;
     
    697715      Units.RecalculateItemsId;
    698716      Players.RecalculateItemsId;
     717      Buildings.RecalculateItemsId;
    699718
    700719      NewNode := OwnerDocument.CreateElement('GameSystem');
     
    713732      AppendChild(NewNode);
    714733      Units.SaveToNode(NewNode);
     734
     735      NewNode := OwnerDocument.CreateElement('Buildings');
     736      AppendChild(NewNode);
     737      Buildings.SaveToNode(NewNode);
    715738    end;
    716739    if ExtractFileDir(FileName) <> '' then
     
    955978  Map.Clear;
    956979  Units.Clear;
     980  Buildings.Clear;
    957981end;
    958982
Note: See TracChangeset for help on using the changeset viewer.