- Timestamp:
- Feb 12, 2018, 3:08:27 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 35 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormChat.pas
r184 r185 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UGame, UGameClient ;9 UGame, UGameClient, SpecializedList; 10 10 11 11 type … … 41 41 42 42 procedure TFormChat.ButtonMessageSendClick(Sender: TObject); 43 var44 TextMessage: TCommandTextMessage;45 43 begin 46 44 if Assigned(Client) then 47 45 with Client do begin 48 TextMessage.Text := EditMessage.Text; 49 Client.Send(cmdTextMessage, @TextMessage, nil); 46 Protocol.SendMessage(EditMessage.Text); 50 47 MemoChat.Lines.Add(Client.Name + ': ' + EditMessage.Text); 51 48 EditMessage.Text := ''; -
trunk/Forms/UFormClient.pas
r184 r185 79 79 CountRepeat: Integer; Update: Boolean; var Confirm: Boolean); 80 80 public 81 property Client: TClient read FClient write SetClient;82 81 procedure LoadConfig(Config: TXmlConfig; Path: string); 83 82 procedure SaveConfig(Config: TXmlConfig; Path: string); 84 83 procedure ReloadView; 85 84 procedure Redraw; 85 property Client: TClient read FClient write SetClient; 86 86 end; 87 87 -
trunk/Languages/xtactics.cs.po
r183 r185 868 868 msgstr "Nulové přiblížení není povoleno" 869 869 870 #: uvarblockserializer.serrorgetvarsize 871 msgid "Error reading variable block size" 872 msgstr "" 873 874 #: uvarblockserializer.smaskedvaluereaderror 875 msgid "Error reading masked variable length block." 876 msgstr "" 877 878 #: uvarblockserializer.sreaderror 879 msgid "Stream read error. Expected length %d, read %d. Source stream size %d." 880 msgstr "" 881 882 #: uvarblockserializer.suint64overflow 883 msgid "64-bit UInt read overflow." 884 msgstr "" 885 -
trunk/Languages/xtactics.po
r183 r185 847 847 msgstr "" 848 848 849 #: uvarblockserializer.serrorgetvarsize 850 msgid "Error reading variable block size" 851 msgstr "" 852 853 #: uvarblockserializer.smaskedvaluereaderror 854 msgid "Error reading masked variable length block." 855 msgstr "" 856 857 #: uvarblockserializer.sreaderror 858 msgid "Stream read error. Expected length %d, read %d. Source stream size %d." 859 msgstr "" 860 861 #: uvarblockserializer.suint64overflow 862 msgid "64-bit UInt read overflow." 863 msgstr "" 864 -
trunk/UCore.pas
r184 r185 8 8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms, 9 9 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; 12 12 13 13 type … … 87 87 AnimationSpeed: Integer; 88 88 AutoSaveEnabled: Boolean; 89 FormClients: TObjectList; // TFormClient 90 //CurrentClient: TClient; 91 LocalClients: TObjectList; // TClient 89 FormClients: TFPGObjectList<TFormClient>; 90 Clients: TClients; 92 91 procedure Spectate(Player: TPlayer); 93 92 procedure UpdateActions; … … 219 218 begin 220 219 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); 223 222 end; 224 223 … … 376 375 begin 377 376 Server := TServer.Create; 377 Clients := TClients.Create; 378 378 Game := TGame.Create; 379 379 Game.OnMoveUpdated := DoMoveUpdated; … … 382 382 Game.OnPlayerChange := DoPlayerChange; 383 383 Server.Game := Game; 384 Clients.Game := Game; 384 385 StoredDimension := TControlDimension.Create; 385 386 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 386 387 ForceDirectories(GetAppConfigDir(False)); 387 FormClients := T ObjectList.Create;388 FormClients := TFPGObjectList<TFormClient>.Create; 388 389 end; 389 390 … … 400 401 FreeAndNil(Server); 401 402 FreeAndNil(Game); 403 FreeAndNil(Clients); 402 404 end; 403 405 … … 447 449 begin 448 450 Form := TFormClient.Create(nil); 449 Form.Client := Server.Clients.New(SSpectator);451 Form.Client := Clients.New(SSpectator); 450 452 //Form.Client.Form := Form; 451 453 //Form.Client.ControlPlayer := Player; … … 456 458 457 459 procedure TCore.StartNewGame; 460 var 461 NewClient: TClient; 462 Player: TPlayer; 458 463 begin 459 464 Game.New; 460 465 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 461 480 Game.DevelMode := DevelMode; 462 481 SelectClient; … … 474 493 begin 475 494 if Assigned(Game.CurrentPlayer) then begin 476 PlayerClient := Server.Clients.SearchPlayer(Game.CurrentPlayer);495 PlayerClient := Clients.SearchPlayer(Game.CurrentPlayer); 477 496 if Assigned(PlayerClient) then FormClient.Client := PlayerClient; 478 497 end; -
trunk/UGame.pas
r184 r185 8 8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms, 9 9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf, fgl, 10 UGeometry ;10 UGeometry, SpecializedList; 11 11 12 12 const … … 407 407 procedure LoadFromNode(Node: TDOMNode); 408 408 procedure SaveToNode(Node: TDOMNode); 409 end;410 411 TCommand = (cmdTextMessage);412 TReceiveEvent = procedure (Command: TCommand; DataIn, DataOut: Pointer);413 TCommandTextMessage = record414 Text: string;415 409 end; 416 410 -
trunk/UGameClient.pas
r184 r185 6 6 7 7 uses 8 Classes, SysUtils, UGame, Forms, fgl ;8 Classes, SysUtils, UGame, Forms, fgl, UGameProtocol; 9 9 10 10 type … … 17 17 FControlPlayer: TPlayer; 18 18 FOnChange: TNotifyEvent; 19 FOnReceive: T ReceiveEvent;19 FOnReceive: TCommandEvent; 20 20 FOnMove: TMoveEvent; 21 21 procedure SetControlPlayer(AValue: TPlayer); … … 24 24 procedure PlayerMove(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer; 25 25 Update: Boolean; var Confirm: Boolean); 26 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 26 27 public 27 28 Name: string; 28 29 View: TView; 30 Protocol: TGameProtocolClient; 29 31 procedure DoChange; 30 procedure Send(Command: TCommand; DataOut, DataIn: Pointer);31 32 constructor Create; 32 33 destructor Destroy; override; … … 35 36 property Form: TForm read FForm write SetForm; 36 37 property OnMove: TMoveEvent read FOnMove write FOnMove; 37 property OnReceive: T ReceiveEvent read FOnReceive write FOnReceive;38 property OnReceive: TCommandEvent read FOnReceive write FOnReceive; 38 39 property OnChange: TNotifyEvent read FOnChange write FOnChange; 39 40 end; … … 101 102 end; 102 103 103 procedure TClient. Send(Command: TCommand; DataOut, DataIn: Pointer);104 procedure TClient.ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 104 105 begin 106 105 107 end; 106 108 … … 126 128 FControlPlayer := nil; 127 129 View := TView.Create; 130 Protocol := TGameProtocolClient.Create; 128 131 end; 129 132 … … 132 135 ControlPlayer := nil; 133 136 FreeAndNil(View); 137 FreeAndNil(Protocol); 134 138 inherited Destroy; 135 139 end; -
trunk/UGameServer.pas
r184 r185 6 6 7 7 uses 8 Classes, SysUtils, UGame, UGameClient, DOM, XMLConf; 8 Classes, SysUtils, UGame, UGameClient, DOM, XMLConf, fgl, SpecializedList, 9 UGameProtocol; 9 10 10 11 type 11 12 TServerMode = (smLocal, smNetworkServer, smNetworkClient); 13 14 { TServerClient } 15 16 TServerClient = class 17 private 18 FOnReceiveCmd: TCommandEvent; 19 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 20 public 21 Game: TGame; 22 Protocol: TGameProtocolServer; 23 procedure DoChange; 24 procedure SendCmd(Command: TCommand; DataOut, DataIn: TStream); 25 property OnReceiveCmd: TCommandEvent read FOnReceiveCmd write 26 FOnReceiveCmd; 27 constructor Create; 28 destructor Destroy; override; 29 end; 30 31 TServerClients = class(TFPGObjectList<TServerClient>) 32 Game: TGame; 33 end; 12 34 13 35 { TServer } … … 24 46 procedure GameStarted(Sender: TObject); 25 47 public 26 Clients: T Clients;48 Clients: TServerClients; 27 49 LocalNetworkAddress: string; 28 50 LocalNetworkPort: Word; … … 42 64 43 65 implementation 66 67 { TServerClient } 68 69 procedure TServerClient.DoChange; 70 begin 71 72 end; 73 74 procedure TServerClient.SendCmd(Command: TCommand; DataOut, DataIn: TStream); 75 begin 76 77 end; 78 79 constructor TServerClient.Create; 80 begin 81 Protocol := TGameProtocolServer.Create; 82 end; 83 84 destructor TServerClient.Destroy; 85 begin 86 Protocol.Free; 87 inherited Destroy; 88 end; 89 90 procedure TServerClient.ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 91 begin 92 if Assigned(FOnReceiveCmd) then 93 FOnReceiveCmd(Command, DataOut, DataIn); 94 end; 44 95 45 96 { TServer } … … 102 153 procedure TServer.DoChange; 103 154 var 104 Client: T Client;155 Client: TServerClient; 105 156 begin 106 157 for Client in Clients do … … 113 164 begin 114 165 for I := 0 to Clients.Count - 1 do 115 with T Client(Clients[I]) do begin116 View.Clear;166 with TServerClient(Clients[I]) do begin 167 //TODO View.Clear; 117 168 end; 118 169 end; … … 142 193 procedure TServer.InitClients; 143 194 var 144 Client: T Client;195 Client: TServerClient; 145 196 Player: TPlayer; 146 197 begin 147 198 Clients.Clear; 148 Clients.New(SSpectator);149 150 for Player in Game.Players do151 with Player do152 if Mode = pmHuman then begin153 Clients.New(Player.Name).ControlPlayer := Player;154 end;155 156 for Client in Clients do157 with Client do begin158 View.Clear;159 View.Zoom := 1;160 if Assigned(ControlPlayer) and Assigned(ControlPlayer.StartCell) then161 View.CenterPlayerCity(ControlPlayer)162 else View.CenterMap;163 end;164 199 end; 165 200 … … 173 208 begin 174 209 FGame := nil; 175 Clients := T Clients.Create;210 Clients := TServerClients.Create; 176 211 end; 177 212 -
trunk/xtactics.lpi
r184 r185 28 28 <SearchPaths> 29 29 <IncludeFiles Value="$(ProjOutDir)"/> 30 <OtherUnitFiles Value="Forms "/>30 <OtherUnitFiles Value="Forms;Packages/PinConnection"/> 31 31 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 32 32 </SearchPaths> … … 65 65 </Item2> 66 66 <SharedMatrixOptions Count="2"> 67 <Item1 ID="257295799247" Targets="Common,CoolTranslator,TemplateGenerics " Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>68 <Item2 ID="262602526292" Targets="Common,CoolTranslator,TemplateGenerics " Modes="Release" Value="-CX -XX -O3"/>67 <Item1 ID="257295799247" Targets="Common,CoolTranslator,TemplateGenerics,CoolStreaming" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/> 68 <Item2 ID="262602526292" Targets="Common,CoolTranslator,TemplateGenerics,CoolStreaming" Modes="Release" Value="-CX -XX -O3"/> 69 69 </SharedMatrixOptions> 70 70 </BuildModes> … … 77 77 </local> 78 78 </RunParams> 79 <RequiredPackages Count=" 6">79 <RequiredPackages Count="7"> 80 80 <Item1> 81 <PackageName Value="TAChartLazarusPkg"/> 81 <PackageName Value="CoolStreaming"/> 82 <DefaultFilename Value="Packages/CoolStreaming/CoolStreaming.lpk" Prefer="True"/> 82 83 </Item1> 83 84 <Item2> 85 <PackageName Value="TAChartLazarusPkg"/> 86 </Item2> 87 <Item3> 84 88 <PackageName Value="TemplateGenerics"/> 85 89 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 86 </Item 2>87 <Item 3>90 </Item3> 91 <Item4> 88 92 <PackageName Value="Common"/> 89 93 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 90 </Item3>91 <Item4>92 <PackageName Value="FCL"/>93 94 </Item4> 94 95 <Item5> 96 <PackageName Value="FCL"/> 97 </Item5> 98 <Item6> 95 99 <PackageName Value="CoolTranslator"/> 96 100 <DefaultFilename Value="Packages/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 97 </Item 5>98 <Item 6>101 </Item6> 102 <Item7> 99 103 <PackageName Value="LCL"/> 100 </Item 6>104 </Item7> 101 105 </RequiredPackages> 102 <Units Count="2 0">106 <Units Count="22"> 103 107 <Unit0> 104 108 <Filename Value="xtactics.lpr"/> … … 219 223 <IsPartOfProject Value="True"/> 220 224 </Unit19> 225 <Unit20> 226 <Filename Value="UGameProtocol.pas"/> 227 <IsPartOfProject Value="True"/> 228 </Unit20> 229 <Unit21> 230 <Filename Value="Packages/PinConnection/UCommPin.pas"/> 231 <IsPartOfProject Value="True"/> 232 </Unit21> 221 233 </Units> 222 234 </ProjectOptions> … … 228 240 <SearchPaths> 229 241 <IncludeFiles Value="$(ProjOutDir)"/> 230 <OtherUnitFiles Value="Forms "/>242 <OtherUnitFiles Value="Forms;Packages/PinConnection"/> 231 243 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 232 244 </SearchPaths> -
trunk/xtactics.lpr
r184 r185 12 12 { you can add units after this }, 13 13 SysUtils, UFormMain, UFormMove, UFormNew, UFormCharts, UFormUnitMoves, 14 UFormChat, UTCP, UServerList, UFormPlayersStats, UGameServer, UGameClient; 14 UFormChat, UTCP, UServerList, UFormPlayersStats, UGameServer, UGameClient, 15 UGameProtocol, CoolStreaming; 15 16 16 17 {$R *.res}
Note:
See TracChangeset
for help on using the changeset viewer.