Changeset 176


Ignore:
Timestamp:
Jan 30, 2018, 6:36:50 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Clients moved to TServer class.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        88backup
        99xtactics.exe
         10*.lrj
  • trunk/UCore.lfm

    r160 r176  
    33  OnDestroy = DataModuleDestroy
    44  OldCreateOrder = False
    5   Height = 542
    6   HorizontalOffset = 565
    7   VerticalOffset = 329
    8   Width = 752
     5  Height = 678
     6  HorizontalOffset = 706
     7  VerticalOffset = 352
     8  Width = 940
     9  PPI = 120
    910  object ActionList1: TActionList
    1011    Images = ImageListSmall
    11     left = 72
    12     top = 32
     12    left = 90
     13    top = 40
    1314    object AGameNew: TAction
    1415      Caption = 'New'
     
    8485  end
    8586  object ImageListSmall: TImageList
    86     left = 419
    87     top = 224
     87    left = 524
     88    top = 280
    8889    Bitmap = {
    8990      4C690C00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1
     
    477478    POFilesFolder = 'Languages'
    478479    OnTranslate = CoolTranslator1Translate
    479     left = 73
    480     top = 232
     480    left = 91
     481    top = 290
    481482  end
    482483  object ImageListLarge: TImageList
    483484    Height = 32
    484485    Width = 32
    485     left = 419
    486     top = 152
     486    left = 524
     487    top = 190
    487488    Bitmap = {
    488489      4C690C0000002000000020000000000000000000000000000000E2AA4B36E2A9
     
    20292030    RootName = 'CONFIG'
    20302031    ReadOnly = False
    2031     left = 73
    2032     top = 296
     2032    left = 91
     2033    top = 370
    20332034  end
    20342035  object OpenDialog1: TOpenDialog
    20352036    DefaultExt = '.xtmap'
    2036     left = 600
    2037     top = 155
     2037    left = 750
     2038    top = 194
    20382039  end
    20392040  object SaveDialog1: TSaveDialog
    20402041    DefaultExt = '.xtmap'
    2041     left = 600
    2042     top = 88
     2042    left = 750
     2043    top = 110
    20432044  end
    20442045  object ApplicationInfo: TApplicationInfo
     
    20572058    RegistryRoot = rrKeyCurrentUser
    20582059    License = 'CC0'
    2059     left = 73
    2060     top = 96
     2060    left = 91
     2061    top = 120
    20612062  end
    20622063  object PersistentForm: TPersistentForm
    20632064    MinVisiblePart = 50
    20642065    EntireVisible = False
    2065     left = 416
    2066     top = 320
     2066    left = 520
     2067    top = 400
    20672068  end
    20682069  object ScaleDPI1: TScaleDPI
    20692070    AutoDetect = False
    2070     left = 72
    2071     top = 360
     2071    left = 90
     2072    top = 450
    20722073  end
    20732074  object LastOpenedList1: TLastOpenedList
    20742075    MaxCount = 10
    20752076    OnChange = LastOpenedList1Change
    2076     left = 73
    2077     top = 160
     2077    left = 91
     2078    top = 200
    20782079  end
    20792080end
  • trunk/UCore.pas

    r174 r176  
    7878  public
    7979    Game: TGame;
     80    Server: TServer;
    8081    UseSingleView: Boolean;
    8182    DevelMode: Boolean;
     
    247248  FirstHuman := Game.Players.GetFirstHuman;
    248249  if Assigned(FirstHuman) then CurrentClient := FirstHuman.Client
    249     else CurrentClient := TClient(Game.Clients.First);
     250    else CurrentClient := TClient(Server.Clients.First);
    250251end;
    251252
     
    384385procedure TCore.DataModuleCreate(Sender: TObject);
    385386begin
     387  Server := TServer.Create;
    386388  Game := TGame.Create;
    387389  Game.OnMove := DoOnMove;
     
    390392  Game.OnNewTurn := GameNewTurnExecute;
    391393  Game.OnPlayerChange := DoPlayerChange;
     394  Game.Server := Server;
     395  Server.Game := Game;
    392396  StoredDimension := TControlDimension.Create;
    393397  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
     
    400404  Game.SaveConfig(XMLConfig1, 'Game');
    401405  SaveConfig;
     406  FreeAndNil(Server);
    402407  FreeAndNil(Game);
    403408end;
     
    416421begin
    417422  Game.LoadFromFile(FileName);
     423  Server.InitClients;
    418424  SelectClient;
    419425  LastOpenedList1.AddItem(FileName);
     
    430436begin
    431437  Game.New;
     438  Server.InitClients;
    432439  Game.DevelMode := DevelMode;
    433440  SelectClient;
  • trunk/UGame.pas

    r171 r176  
    3030  TMapArea = class;
    3131  TClient = class;
     32  TServer = class;
    3233
    3334  TTerrainType = (ttVoid, ttNormal, ttCity);
     
    430431    Game: TGame;
    431432    procedure New(Name: string);
     433    constructor Create(FreeObjects: Boolean = True);
    432434  end;
    433435
     
    460462    procedure SetRunning(AValue: Boolean);
    461463    procedure BuildTerrain;
    462     procedure InitClients;
    463464    procedure SelectPlayerStartCell(Player: TPlayer);
    464465    procedure CalculatePlayersDistance;
     
    466467    procedure InitDefaultPlayersSetting;
    467468  public
     469    Server: TServer;
    468470    DevelMode: Boolean;
    469471    Players: TPlayers;
    470472    PlayersSetting: TPlayers;
    471     Clients: TClients;
    472473    Map: TMap;
    473474    MapImageFileName: string;
     
    511512  end;
    512513
     514  { TServer }
     515
     516  TServer = class
     517  private
     518    FGame: TGame;
     519    procedure SetGame(AValue: TGame);
     520  public
     521    Clients: TClients;
     522    procedure InitClients;
     523    procedure Clear;
     524    constructor Create;
     525    destructor Destroy; override;
     526    property Game: TGame read FGame write SetGame;
     527  end;
     528
    513529var
    514530  PlayerModeText: array[TPlayerMode] of string;
     
    617633  NewClient.Name := Name;
    618634  Add(NewClient);
     635end;
     636
     637constructor TClients.Create(FreeObjects: Boolean = True);
     638begin
     639  Game := nil;
     640  inherited;
    619641end;
    620642
     
    29062928  end else begin
    29072929    FRunning := AValue;
    2908     for I := 0 to Clients.Count - 1 do
    2909     with TClient(Clients[I]) do begin
     2930    for I := 0 to Server.Clients.Count - 1 do
     2931    with TClient(Server.Clients[I]) do begin
    29102932      View.Clear;
    29112933    end;
     
    30983120end;
    30993121
    3100 procedure TGame.InitClients;
     3122procedure TServer.SetGame(AValue: TGame);
     3123var
     3124  I: Integer;
     3125begin
     3126  if FGame = AValue then Exit;
     3127  FGame := AValue;
     3128  for I := 0 to Clients.Count - 1 do
     3129    Clients[I].Game := FGame;
     3130  Clients.Game := Game;
     3131end;
     3132
     3133procedure TServer.InitClients;
    31013134var
    31023135  Client: TClient;
     
    31063139  Clients.New('Spectator');
    31073140
    3108   for Player in Players do
     3141  for Player in Game.Players do
    31093142  with Player do
    31103143  if Mode = pmHuman then begin
     
    31213154      else View.CenterMap;
    31223155  end;
     3156end;
     3157
     3158procedure TServer.Clear;
     3159begin
     3160  Clients.Clear;
     3161  Game.Clear;
     3162end;
     3163
     3164constructor TServer.Create;
     3165begin
     3166  FGame := nil;
     3167  Clients := TClients.Create;
     3168end;
     3169
     3170destructor TServer.Destroy;
     3171begin
     3172  FreeAndNil(Clients);
     3173  inherited Destroy;
    31233174end;
    31243175
     
    33003351        else CurrentPlayer := nil;
    33013352
    3302       InitClients;
    33033353      Map.Cells.FixRefId;
    33043354
     
    34843534  PlayersSetting := TPlayers.Create;
    34853535  PlayersSetting.Game := Self;
    3486   Clients := TClients.Create;
    3487   Clients.Game := Self;
    34883536
    34893537  MapImageFileName := 'Images/Maps/WorldMap.png';
     
    35013549destructor TGame.Destroy;
    35023550begin
    3503   FreeAndNil(Clients);
    35043551  FreeAndNil(PlayersSetting);
    35053552  FreeAndNil(Players);
     
    35103557procedure TGame.Clear;
    35113558begin
    3512   Clients.Clear;
    35133559  Players.Clear;
    35143560  Map.Clear;
     
    35583604    else CurrentPlayer := nil;
    35593605
    3560   InitClients;
    35613606  ComputePlayerStats;
    35623607end;
Note: See TracChangeset for help on using the changeset viewer.