Changeset 185 for trunk/UCore.pas


Ignore:
Timestamp:
Feb 12, 2018, 3:08:27 PM (7 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r184 r185  
    88  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms,
    99  UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator,
    10   URegistry, ULastOpenedList, Registry, Menus, UGeometry, Contnrs, UFormClient,
    11   UGameServer, UGameClient;
     10  URegistry, ULastOpenedList, Registry, Menus, UGeometry, UFormClient,
     11  UGameServer, UGameClient, fgl;
    1212
    1313type
     
    8787    AnimationSpeed: Integer;
    8888    AutoSaveEnabled: Boolean;
    89     FormClients: TObjectList; // TFormClient
    90     //CurrentClient: TClient;
    91     LocalClients: TObjectList; // TClient
     89    FormClients: TFPGObjectList<TFormClient>;
     90    Clients: TClients;
    9291    procedure Spectate(Player: TPlayer);
    9392    procedure UpdateActions;
     
    219218begin
    220219  FirstHuman := Game.Players.GetFirstHuman;
    221   if Assigned(FirstHuman) then FormClient.Client := Server.Clients.SearchPlayer(FirstHuman)
    222     else FormClient.Client := TClient(Server.Clients.First);
     220  if Assigned(FirstHuman) then FormClient.Client := Clients.SearchPlayer(FirstHuman)
     221    else FormClient.Client := TClient(Clients.First);
    223222end;
    224223
     
    376375begin
    377376  Server := TServer.Create;
     377  Clients := TClients.Create;
    378378  Game := TGame.Create;
    379379  Game.OnMoveUpdated := DoMoveUpdated;
     
    382382  Game.OnPlayerChange := DoPlayerChange;
    383383  Server.Game := Game;
     384  Clients.Game := Game;
    384385  StoredDimension := TControlDimension.Create;
    385386  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
    386387  ForceDirectories(GetAppConfigDir(False));
    387   FormClients := TObjectList.Create;
     388  FormClients := TFPGObjectList<TFormClient>.Create;
    388389end;
    389390
     
    400401  FreeAndNil(Server);
    401402  FreeAndNil(Game);
     403  FreeAndNil(Clients);
    402404end;
    403405
     
    447449begin
    448450  Form := TFormClient.Create(nil);
    449   Form.Client := Server.Clients.New(SSpectator);
     451  Form.Client := Clients.New(SSpectator);
    450452  //Form.Client.Form := Form;
    451453  //Form.Client.ControlPlayer := Player;
     
    456458
    457459procedure TCore.StartNewGame;
     460var
     461  NewClient: TClient;
     462  Player: TPlayer;
    458463begin
    459464  Game.New;
    460465  Server.InitClients;
     466
     467  // Create local clients for human players
     468  for Player in Game.Players do
     469  with Player do
     470  if Mode = pmHuman then begin
     471    NewClient := Clients.New(Name);
     472    NewClient.ControlPlayer := Player;
     473    NewClient.View.Clear;
     474    NewClient.View.Zoom := 1;
     475    if Assigned(NewClient.ControlPlayer.StartCell) then
     476      NewClient.View.CenterPlayerCity(NewClient.ControlPlayer)
     477      else NewClient.View.CenterMap;
     478  end;
     479
    461480  Game.DevelMode := DevelMode;
    462481  SelectClient;
     
    474493begin
    475494  if Assigned(Game.CurrentPlayer) then begin
    476     PlayerClient := Server.Clients.SearchPlayer(Game.CurrentPlayer);
     495    PlayerClient := Clients.SearchPlayer(Game.CurrentPlayer);
    477496    if Assigned(PlayerClient) then FormClient.Client := PlayerClient;
    478497  end;
Note: See TracChangeset for help on using the changeset viewer.