Changeset 399


Ignore:
Timestamp:
Jan 6, 2025, 10:48:55 AM (3 days ago)
Author:
chronos
Message:
  • Fixed: Wrong players and units id recalculation during game save causing bad references.
  • Modified: Set new created players as computer.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Game.pas

    r398 r399  
    695695      WriteInteger(RootNode, 'CurrentPlayer', CurrentPlayer.Id);
    696696
     697      Units.RecalculateItemsId;
     698      Players.RecalculateItemsId;
     699
    697700      NewNode := OwnerDocument.CreateElement('GameSystem');
    698701      AppendChild(NewNode);
  • trunk/Packages/Common/ItemList.pas

    r391 r399  
    133133    FBaseItemList: TBaseItemList;
    134134    procedure RecalculateNewId(Reset: Boolean);
    135     procedure RecalculateItemsId;
    136135    function BaseGetItem(Index: SizeInt): TItem;
    137136    procedure BaseSetItem(Index: SizeInt; AValue: TItem);
     
    145144  public
    146145    NewId: Integer;
     146    procedure RecalculateItemsId;
    147147    function CreateItem(Name: string = ''): T; virtual;
    148148    function IncrementName(Name: string): string;
     
    265265  NewNode2: TDOMNode;
    266266begin
    267   RecalculateItemsId;
    268267  for I := 0 to Count - 1 do
    269268  with TItem(Items[I]) do begin
  • trunk/Player.pas

    r398 r399  
    558558  Result := inherited;
    559559  Result.Game := Game;
     560  Result.Mode := pmComputer;
     561  Result.Agressivity := caMedium;
    560562  Result.Color := GetUnusedColor;
    561563end;
  • trunk/Units.pas

    r398 r399  
    114114  NewNode2: TDOMNode;
    115115begin
    116   RecalculateItemsId;
    117116  for I := 0 to Count - 1 do
    118117  with Items[I] do begin
Note: See TracChangeset for help on using the changeset viewer.