MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CloseConnection

Method CloseConnection

src/network/core/tcp_game.cpp:40–53  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

38 * @return the new status
39 */
40NetworkRecvStatus 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/**

Callers 1

HandlePacketMethod · 0.95

Calls 3

ShowErrorMessageFunction · 0.85
GetEncodedStringFunction · 0.50

Tested by

no test coverage detected