Changeset 407 for trunk/Map.pas


Ignore:
Timestamp:
Jan 8, 2025, 10:18:12 AM (38 hours ago)
Author:
chronos
Message:
  • Fixed: Cell cities were not correctly stored the saved game.
  • Fixed: ItemList references were loaded by item index instead of item id.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Map.pas

    r398 r407  
    4848    Extra: TExtraType;
    4949    OneUnitId: Integer; // Temporary value
     50    BuildingId: Integer; // Temporary value
    5051    function Compare(Cell: TCell): Boolean;
    5152    procedure ConnectTo(Cell: TCell);
     
    10641065  end else Player := nil;
    10651066
     1067  if BuildingId <> 0 then begin
     1068    Building := TGame(Map.Game).Buildings.FindById(BuildingId);
     1069    if not Assigned(Building) then
     1070      raise Exception.Create('Referenced building id ' + IntToStr(BuildingId) + ' not found.');
     1071  end else Building := nil;
     1072
    10661073  if OneUnitId <> 0 then begin
    10671074    OneUnit := TGame(Map.Game).Units.FindById(OneUnitId);
     
    10951102  PosPx.Y := ReadInteger(Node, 'PosY', 0);
    10961103  PlayerId := ReadInteger(Node, 'Player', 0);
     1104  BuildingId := ReadInteger(Node, 'Building', 0);
    10971105
    10981106  Node3 := Node.FindNode('Neighbours');
     
    11351143    WriteInteger(Node, 'Player', TPlayer(Player).Id)
    11361144    else WriteInteger(Node, 'Player', 0);
     1145  if Assigned(Building) then
     1146    WriteInteger(Node, 'Building', Building.Id)
     1147    else WriteInteger(Node, 'Building', 0);
    11371148  NewNode := Node.OwnerDocument.CreateElement('Neighbours');
    11381149  Node.AppendChild(NewNode);
Note: See TracChangeset for help on using the changeset viewer.