Changeset 191


Ignore:
Timestamp:
May 1, 2018, 10:16:08 AM (7 years ago)
Author:
chronos
Message:
  • Fixed: Clients initialization if game is loaded from file.
  • Fixed: Removed compilation warnings.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r185 r191  
    155155procedure TCore.LoadConfig;
    156156begin
    157   RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
     157  RegistryContext := TRegistryContext.Create(HKEY_CURRENT_USER, DefaultRegKey);
    158158  PersistentForm.RegistryContext := RegistryContext;
    159159  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
     
    415415
    416416procedure TCore.LoadGame(FileName: string);
     417var
     418  Player: TPlayer;
     419  NewClient: TClient;
    417420begin
    418421  Game.LoadFromFile(FileName);
    419   Server.InitClients;
    420   SelectClient;
    421   LastOpenedList1.AddItem(FileName);
    422   with FormClient.Client do
    423     View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0),
    424       TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height));
    425   FormClient.AZoomAll.Execute;
    426   RedrawClients;
    427   UpdateOtherForms;
    428 end;
    429 
    430 procedure TCore.RedrawClients;
    431 var
    432   Form: TFormClient;
    433 begin
    434   for Form in FormClients do
    435     Form.Redraw;
    436   FormClient.Redraw;
    437 end;
    438 
    439 procedure TCore.UpdateOtherForms;
    440 begin
    441   if Assigned(FormCharts) and FormCharts.Visible then FormCharts.Redraw;
    442   if Assigned(FormUnitMoves) and FormUnitMoves.Visible then FormUnitMoves.ReloadList;
    443   if Assigned(FormPlayersStats) and FormPlayersStats.Visible then FormPlayersStats.ReloadList;
    444 end;
    445 
    446 procedure TCore.Spectate(Player: TPlayer);
    447 var
    448   Form: TFormClient;
    449 begin
    450   Form := TFormClient.Create(nil);
    451   Form.Client := Clients.New(SSpectator);
    452   //Form.Client.Form := Form;
    453   //Form.Client.ControlPlayer := Player;
    454   Form.AZoomAll.Execute;
    455   Form.Show;
    456   FormClients.Add(Form);
    457 end;
    458 
    459 procedure TCore.StartNewGame;
    460 var
    461   NewClient: TClient;
    462   Player: TPlayer;
    463 begin
    464   Game.New;
    465422  Server.InitClients;
    466423
     
    478435  end;
    479436
     437  SelectClient;
     438  LastOpenedList1.AddItem(FileName);
     439  with FormClient.Client do
     440    View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0),
     441      TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height));
     442  FormClient.AZoomAll.Execute;
     443  RedrawClients;
     444  UpdateOtherForms;
     445end;
     446
     447procedure TCore.RedrawClients;
     448var
     449  Form: TFormClient;
     450begin
     451  for Form in FormClients do
     452    Form.Redraw;
     453  FormClient.Redraw;
     454end;
     455
     456procedure TCore.UpdateOtherForms;
     457begin
     458  if Assigned(FormCharts) and FormCharts.Visible then FormCharts.Redraw;
     459  if Assigned(FormUnitMoves) and FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     460  if Assigned(FormPlayersStats) and FormPlayersStats.Visible then FormPlayersStats.ReloadList;
     461end;
     462
     463procedure TCore.Spectate(Player: TPlayer);
     464var
     465  Form: TFormClient;
     466begin
     467  Form := TFormClient.Create(nil);
     468  Form.Client := Clients.New(SSpectator);
     469  //Form.Client.Form := Form;
     470  //Form.Client.ControlPlayer := Player;
     471  Form.AZoomAll.Execute;
     472  Form.Show;
     473  FormClients.Add(Form);
     474end;
     475
     476procedure TCore.StartNewGame;
     477var
     478  NewClient: TClient;
     479  Player: TPlayer;
     480begin
     481  Game.New;
     482  Server.InitClients;
     483
     484  // Create local clients for human players
     485  for Player in Game.Players do
     486  with Player do
     487  if Mode = pmHuman then begin
     488    NewClient := Clients.New(Name);
     489    NewClient.ControlPlayer := Player;
     490    NewClient.View.Clear;
     491    NewClient.View.Zoom := 1;
     492    if Assigned(NewClient.ControlPlayer.StartCell) then
     493      NewClient.View.CenterPlayerCity(NewClient.ControlPlayer)
     494      else NewClient.View.CenterMap;
     495  end;
     496
    480497  Game.DevelMode := DevelMode;
    481498  SelectClient;
  • trunk/UGame.pas

    r185 r191  
    88  Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms,
    99  DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf, fgl,
    10   UGeometry, SpecializedList;
     10  UGeometry;
    1111
    1212const
     
    14671467      if Power < MaxPower then begin
    14681468        // Increase units count
    1469         if Game.GrowAmount = gaByOne then Addition := 1
    1470           else if Game.GrowAmount = gaBySquareRoot then begin
    1471             Addition := Trunc(Sqrt(Power));
    1472             if Addition = 0 then Addition := 1;
    1473           end;
     1469        Addition := 0;
     1470        if Game.GrowAmount = gaByOne then begin
     1471          Addition := 1;
     1472        end else
     1473        if Game.GrowAmount = gaBySquareRoot then begin
     1474          Addition := Trunc(Sqrt(Power));
     1475          if Addition = 0 then Addition := 1;
     1476        end;
    14741477        Power := Min(Power + Addition, MaxPower);
    14751478      end else
  • trunk/UGameServer.pas

    r185 r191  
    192192
    193193procedure TServer.InitClients;
    194 var
    195   Client: TServerClient;
    196   Player: TPlayer;
    197194begin
    198195  Clients.Clear;
Note: See TracChangeset for help on using the changeset viewer.