Changeset 185 for trunk/UGameServer.pas
- Timestamp:
- Feb 12, 2018, 3:08:27 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.