Changeset 203 for trunk/UGameClient.pas
- Timestamp:
- May 18, 2018, 12:54:37 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGameClient.pas
r202 r203 6 6 7 7 uses 8 Classes, SysUtils, UGame, Forms, fgl, UGameProtocol, UGameServer ;8 Classes, SysUtils, UGame, Forms, fgl, UGameProtocol, UGameServer, UCommThread; 9 9 10 10 type … … 22 22 FOnReceive: TCommandEvent; 23 23 FOnMove: TMoveEvent; 24 FOnTurnStart: TNotifyEvent; 25 CommThread: TCommThread; 24 26 procedure SetActive(AValue: Boolean); 25 27 procedure SetControlPlayer(AValue: TPlayer); … … 28 30 procedure PlayerMove(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer; 29 31 Update: Boolean; var Confirm: Boolean); 32 procedure SetOnMove(AValue: TMoveEvent); 30 33 protected 31 34 procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); virtual; … … 45 48 property Game: TGame read FGame write SetGame; 46 49 property Form: TForm read FForm write SetForm; 47 property OnMove: TMoveEvent read FOnMove write FOnMove;50 property OnMove: TMoveEvent read FOnMove write SetOnMove; 48 51 property OnReceive: TCommandEvent read FOnReceive write FOnReceive; 49 52 property OnChange: TNotifyEvent read FOnChange write FOnChange; 53 property OnTurnStart: TNotifyEvent read FOnTurnStart write FOnTurnStart; 50 54 property Active: Boolean read FActive write SetActive; 51 55 end; … … 113 117 end; 114 118 119 procedure TClient.SetOnMove(AValue: TMoveEvent); 120 begin 121 //if FOnMove = AValue then Exit; 122 FOnMove := AValue; 123 end; 124 115 125 procedure TClient.ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); 116 126 begin … … 120 130 procedure TClient.DoTurnStart(Sender: TObject); 121 131 begin 122 132 if Assigned(FOnTurnStart) then 133 FOnTurnStart(Self); 123 134 end; 124 135 … … 139 150 begin 140 151 if FActive = AValue then Exit; 152 if FActive then begin 153 case ConnectType of 154 ctLocal: begin 155 CommThread.Active := False; 156 CommThread.Ext.Disconnect; 157 CommThread.Pin.Disconnect; 158 end; 159 end; 160 end; 141 161 FActive := AValue; 142 162 if FActive then begin 143 163 case ConnectType of 144 164 ctLocal: if LocalServer.Active then begin 165 CommThread.Active := True; 166 CommThread.Pin.Connect(Protocol.Pin); 145 167 ServerClient := LocalServer.GetNewServerClient; 146 168 ServerClient.Player := ControlPlayer; 147 ServerClient.Protocol.Pin.Connect( Protocol.Pin);169 ServerClient.Protocol.Pin.Connect(CommThread.Ext); 148 170 end else raise Exception.Create('Local server is not active'); 149 171 //ctNetwork: ; … … 162 184 constructor TClient.Create; 163 185 begin 186 CommThread := TCommThread.Create(nil); 164 187 FControlPlayer := nil; 165 188 View := TView.Create; … … 173 196 FreeAndNil(View); 174 197 FreeAndNil(Protocol); 198 FreeAndNil(CommThread); 175 199 inherited Destroy; 176 200 end;
Note:
See TracChangeset
for help on using the changeset viewer.