* Functions to help ReceivePacket/SendPacket a bit * A socket can make errors. When that happens this handles what to do. * For clients: close connection and drop back to main-menu * For servers: close connection and that is it * @return the new status */
| 38 | * @return the new status |
| 39 | */ |
| 40 | NetworkRecvStatus NetworkGameSocketHandler::CloseConnection(bool) |
| 41 | { |
| 42 | /* Clients drop back to the main menu */ |
| 43 | if (!_network_server && _networking) { |
| 44 | ClientNetworkEmergencySave(); |
| 45 | _switch_mode = SM_MENU; |
| 46 | _networking = false; |
| 47 | ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_LOSTCONNECTION), {}, WL_CRITICAL); |
| 48 | |
| 49 | return this->CloseConnection(NETWORK_RECV_STATUS_CLIENT_QUIT); |
| 50 | } |
| 51 | |
| 52 | return this->CloseConnection(NETWORK_RECV_STATUS_CONNECTION_LOST); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | /** |
no test coverage detected