| 279 | } |
| 280 | |
| 281 | void Host::ConnectToServer( |
| 282 | const char* server_address, |
| 283 | const uint16_t client_tcp_port, |
| 284 | const uint16_t client_udp_port ) |
| 285 | { |
| 286 | InetAddress address; |
| 287 | if( !InetAddress::Parse( server_address , address ) ) |
| 288 | { |
| 289 | Log::User( "Invalid address." ); |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | if( address.port == 0 ) |
| 294 | address.port= Net::c_default_server_tcp_port; |
| 295 | |
| 296 | Log::User( "Connecting to ", address.ToString(), "." ); |
| 297 | |
| 298 | EnsureClient(); |
| 299 | EnsureNet(); |
| 300 | |
| 301 | ClearBeforeGameStart(); |
| 302 | |
| 303 | auto connection= net_->ConnectToServer( address, client_tcp_port, client_udp_port ); |
| 304 | if( connection == nullptr ) |
| 305 | { |
| 306 | Log::User( "Connection failed." ); |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | client_->SetConnection( connection ); |
| 311 | |
| 312 | if( system_window_ != nullptr ) |
| 313 | system_window_->SetTitle( base_window_title_ + " - multiplayer client" ); |
| 314 | } |
| 315 | |
| 316 | void Host::StartServer( |
| 317 | const unsigned int map_number, |
no test coverage detected