Changeset 176 for trunk/UGame.pas
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 8 8 backup 9 9 xtactics.exe 10 *.lrj
-
- Property svn:ignore
-
trunk/UGame.pas
r171 r176 30 30 TMapArea = class; 31 31 TClient = class; 32 TServer = class; 32 33 33 34 TTerrainType = (ttVoid, ttNormal, ttCity); … … 430 431 Game: TGame; 431 432 procedure New(Name: string); 433 constructor Create(FreeObjects: Boolean = True); 432 434 end; 433 435 … … 460 462 procedure SetRunning(AValue: Boolean); 461 463 procedure BuildTerrain; 462 procedure InitClients;463 464 procedure SelectPlayerStartCell(Player: TPlayer); 464 465 procedure CalculatePlayersDistance; … … 466 467 procedure InitDefaultPlayersSetting; 467 468 public 469 Server: TServer; 468 470 DevelMode: Boolean; 469 471 Players: TPlayers; 470 472 PlayersSetting: TPlayers; 471 Clients: TClients;472 473 Map: TMap; 473 474 MapImageFileName: string; … … 511 512 end; 512 513 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 513 529 var 514 530 PlayerModeText: array[TPlayerMode] of string; … … 617 633 NewClient.Name := Name; 618 634 Add(NewClient); 635 end; 636 637 constructor TClients.Create(FreeObjects: Boolean = True); 638 begin 639 Game := nil; 640 inherited; 619 641 end; 620 642 … … 2906 2928 end else begin 2907 2929 FRunning := AValue; 2908 for I := 0 to Clients.Count - 1 do2909 with TClient( Clients[I]) do begin2930 for I := 0 to Server.Clients.Count - 1 do 2931 with TClient(Server.Clients[I]) do begin 2910 2932 View.Clear; 2911 2933 end; … … 3098 3120 end; 3099 3121 3100 procedure TGame.InitClients; 3122 procedure TServer.SetGame(AValue: TGame); 3123 var 3124 I: Integer; 3125 begin 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; 3131 end; 3132 3133 procedure TServer.InitClients; 3101 3134 var 3102 3135 Client: TClient; … … 3106 3139 Clients.New('Spectator'); 3107 3140 3108 for Player in Players do3141 for Player in Game.Players do 3109 3142 with Player do 3110 3143 if Mode = pmHuman then begin … … 3121 3154 else View.CenterMap; 3122 3155 end; 3156 end; 3157 3158 procedure TServer.Clear; 3159 begin 3160 Clients.Clear; 3161 Game.Clear; 3162 end; 3163 3164 constructor TServer.Create; 3165 begin 3166 FGame := nil; 3167 Clients := TClients.Create; 3168 end; 3169 3170 destructor TServer.Destroy; 3171 begin 3172 FreeAndNil(Clients); 3173 inherited Destroy; 3123 3174 end; 3124 3175 … … 3300 3351 else CurrentPlayer := nil; 3301 3352 3302 InitClients;3303 3353 Map.Cells.FixRefId; 3304 3354 … … 3484 3534 PlayersSetting := TPlayers.Create; 3485 3535 PlayersSetting.Game := Self; 3486 Clients := TClients.Create;3487 Clients.Game := Self;3488 3536 3489 3537 MapImageFileName := 'Images/Maps/WorldMap.png'; … … 3501 3549 destructor TGame.Destroy; 3502 3550 begin 3503 FreeAndNil(Clients);3504 3551 FreeAndNil(PlayersSetting); 3505 3552 FreeAndNil(Players); … … 3510 3557 procedure TGame.Clear; 3511 3558 begin 3512 Clients.Clear;3513 3559 Players.Clear; 3514 3560 Map.Clear; … … 3558 3604 else CurrentPlayer := nil; 3559 3605 3560 InitClients;3561 3606 ComputePlayerStats; 3562 3607 end;
Note:
See TracChangeset
for help on using the changeset viewer.