Changeset 360


Ignore:
Timestamp:
Dec 31, 2024, 11:46:43 AM (7 days ago)
Author:
chronos
Message:
  • Fixed: Store current player information to game save to be able to continue with different player.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r354 r360  
    275275
    276276procedure TCore.SelectClient;
    277 var
    278   FirstHuman: TPlayer;
    279 begin
    280   FirstHuman := Game.Players.GetFirstHuman;
    281   if Assigned(FirstHuman) then FormMain.FormClient.Client := TClientGUI(LocalClients.SearchPlayer(FirstHuman))
    282     else begin
    283       FormMain.FormClient.Client := TClientGUI(LocalClients.New(SSpectator));
    284       FormMain.FormClient.Client.LocalServer := Server;
    285       FormMain.FormClient.Client.ConnectType := ctLocal;
    286       FormMain.FormClient.Client.Active := True;
    287       FormMain.FormClient.AZoomAll.Execute;
    288     end;
     277begin
     278  if not Assigned(Game.CurrentPlayer) then
     279    Game.CurrentPlayer := Game.Players.GetFirstHuman;
     280  if Assigned(Game.CurrentPlayer) then begin
     281    FormMain.FormClient.Client := TClientGUI(LocalClients.SearchPlayer(Game.CurrentPlayer));
     282  end else begin
     283    FormMain.FormClient.Client := TClientGUI(LocalClients.New(SSpectator));
     284    FormMain.FormClient.Client.LocalServer := Server;
     285    FormMain.FormClient.Client.ConnectType := ctLocal;
     286    FormMain.FormClient.Client.Active := True;
     287    FormMain.FormClient.AZoomAll.Execute;
     288  end;
    289289end;
    290290
  • trunk/Game.pas

    r354 r360  
    633633      if Assigned(NewNode) then
    634634        Players.LoadFromNode(NewNode);
    635       if Players.Count > 0 then CurrentPlayer := Players[0]
    636         else CurrentPlayer := nil;
     635      CurrentPlayer := Players.FindById(ReadInteger(RootNode, 'CurrentPlayer', -1));
     636
     637      if not Assigned(CurrentPlayer) and (Players.Count > 0) then CurrentPlayer := Players[0];
    637638
    638639      NewNode := FindNode('Units');
     
    685686      WriteInteger(RootNode, 'StayAliveForDefinedTurns', StayAliveForDefinedTurns);
    686687      WriteBoolean(RootNode, 'Running', Running);
     688      WriteInteger(RootNode, 'CurrentPlayer', CurrentPlayer.Id);
    687689
    688690      NewNode := OwnerDocument.CreateElement('GameSystem');
Note: See TracChangeset for help on using the changeset viewer.