Changeset 180 for trunk/UGame.pas
- Timestamp:
- Feb 8, 2018, 5:32:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r179 r180 6 6 7 7 uses 8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, 8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms, 9 9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf, fgl, 10 10 UGeometry, UGameSocket; … … 421 421 FGame: TGame; 422 422 FControlPlayer: TPlayer; 423 FOnChange: TNotifyEvent; 423 424 FOnReceive: TReceiveEvent; 424 425 procedure SetControlPlayer(AValue: TPlayer); 425 426 procedure SetGame(AValue: TGame); 427 procedure DoChange; 426 428 public 429 Form: TForm; 427 430 Name: string; 428 431 View: TView; … … 434 437 property Game: TGame read FGame write SetGame; 435 438 property OnReceive: TReceiveEvent read FOnReceive write FOnReceive; 439 property OnChange: TNotifyEvent read FOnChange write FOnChange; 436 440 end; 437 441 … … 440 444 TClients = class(TFPGObjectList<TClient>) 441 445 Game: TGame; 442 procedure New(Name: string);446 function New(Name: string): TClient; 443 447 constructor Create(FreeObjects: Boolean = True); 444 448 end; … … 534 538 procedure SetGame(AValue: TGame); 535 539 procedure SetServerMode(AValue: TServerMode); 540 procedure DoChange; 536 541 public 537 542 Clients: TClients; … … 565 570 resourcestring 566 571 SPlayer = 'Player'; 572 SSpectator = 'Spectator'; 567 573 568 574 … … 650 656 { TClients } 651 657 652 procedure TClients.New(Name: string); 653 var 654 NewClient: TClient; 655 begin 656 NewClient := TClient.Create; 657 NewClient.Game := Game; 658 NewClient.Name := Name; 659 Add(NewClient); 658 function TClients.New(Name: string): TClient; 659 begin 660 Result := TClient.Create; 661 Result.Game := Game; 662 Result.Name := Name; 663 Add(Result); 660 664 end; 661 665 … … 673 677 FGame := AValue; 674 678 View.Game := AValue; 679 end; 680 681 procedure TClient.DoChange; 682 begin 683 if Assigned(FOnChange) then 684 FOnChange(Self); 675 685 end; 676 686 … … 3201 3211 end; 3202 3212 3213 procedure TServer.DoChange; 3214 var 3215 Client: TClient; 3216 begin 3217 for Client in Clients do 3218 Client.DoChange; 3219 end; 3220 3203 3221 procedure TServer.LoadConfig(Config: TXmlConfig; Path: string); 3204 3222 begin … … 3229 3247 begin 3230 3248 Clients.Clear; 3231 Clients.New( 'Spectator');3249 Clients.New(SSpectator); 3232 3250 3233 3251 for Player in Game.Players do 3234 3252 with Player do 3235 3253 if Mode = pmHuman then begin 3236 Clients.New(Player.Name); 3237 Player.Client := TClient(Clients.Last); 3254 Player.Client := Clients.New(Player.Name); 3238 3255 end; 3239 3256 … … 3586 3603 // For computers take view from previous human 3587 3604 //if CurrentPlayer.Mode = pmComputer then CurrentPlayer.View.Assign(PrevPlayer.View); 3605 Server.DoChange; 3588 3606 end; 3589 3607
Note:
See TracChangeset
for help on using the changeset viewer.