Changeset 409 for tags/1.4.0/Game.pas
- Timestamp:
- Jan 8, 2025, 11:01:27 AM (34 hours ago)
- Location:
- tags/1.4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/1.4.0
-
tags/1.4.0/Game.pas
r401 r409 58 58 procedure InitDefaultPlayers; 59 59 procedure WinObjectiveMapPrepare; 60 procedure BuildCity(Cell: TCell); 60 61 public 61 62 GameSystem: TGameSystem; … … 342 343 with Cell do begin 343 344 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); 346 346 end; 347 347 end; … … 369 369 StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)]; 370 370 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); 375 372 StartCell.Player := Player; 376 373 if GameSystem.UnitKinds.Count > 0 then begin … … 497 494 end; 498 495 496 procedure TGame.BuildCity(Cell: TCell); 497 var 498 CityBuildingKind: TBuildingKind; 499 begin 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; 510 end; 511 499 512 procedure TGame.Assign(Source: TGame); 500 513 begin … … 502 515 DevelMode := Source.DevelMode; 503 516 Players.Assign(Source.Players); 517 Buildings.Assign(Source.Buildings); 504 518 MapType := Source.MapType; 505 519 Map.Assign(Source.Map); … … 647 661 Units.LoadFromNode(NewNode); 648 662 663 NewNode := FindNode('Buildings'); 664 if Assigned(NewNode) then 665 Buildings.LoadFromNode(NewNode); 666 649 667 Map.Cells.FixRefId; 650 668 Units.FixRefId; … … 697 715 Units.RecalculateItemsId; 698 716 Players.RecalculateItemsId; 717 Buildings.RecalculateItemsId; 699 718 700 719 NewNode := OwnerDocument.CreateElement('GameSystem'); … … 713 732 AppendChild(NewNode); 714 733 Units.SaveToNode(NewNode); 734 735 NewNode := OwnerDocument.CreateElement('Buildings'); 736 AppendChild(NewNode); 737 Buildings.SaveToNode(NewNode); 715 738 end; 716 739 if ExtractFileDir(FileName) <> '' then … … 955 978 Map.Clear; 956 979 Units.Clear; 980 Buildings.Clear; 957 981 end; 958 982
Note:
See TracChangeset
for help on using the changeset viewer.