254 _switch_mode = SM_MENU; |
254 _switch_mode = SM_MENU; |
255 NetworkCloseClient(cs); |
255 NetworkCloseClient(cs); |
256 _networking = false; |
256 _networking = false; |
257 } |
257 } |
258 |
258 |
|
259 /** Retrieve a string representation of an internal error number |
|
260 * @param buf buffer where the error message will be stored |
|
261 * @param err NetworkErrorCode (integer) |
|
262 * @return returns a pointer to the error message (buf) */ |
|
263 char *GetNetworkErrorMsg(char *buf, NetworkErrorCode err) |
|
264 { |
|
265 /* List of possible network errors, used by |
|
266 * PACKET_SERVER_ERROR and PACKET_CLIENT_ERROR */ |
|
267 static const StringID network_error_strings[] = { |
|
268 STR_NETWORK_ERR_CLIENT_GENERAL, |
|
269 STR_NETWORK_ERR_CLIENT_DESYNC, |
|
270 STR_NETWORK_ERR_CLIENT_SAVEGAME, |
|
271 STR_NETWORK_ERR_CLIENT_CONNECTION_LOST, |
|
272 STR_NETWORK_ERR_CLIENT_PROTOCOL_ERROR, |
|
273 STR_NETWORK_ERR_CLIENT_NOT_AUTHORIZED, |
|
274 STR_NETWORK_ERR_CLIENT_NOT_EXPECTED, |
|
275 STR_NETWORK_ERR_CLIENT_WRONG_REVISION, |
|
276 STR_NETWORK_ERR_CLIENT_NAME_IN_USE, |
|
277 STR_NETWORK_ERR_CLIENT_WRONG_PASSWORD, |
|
278 STR_NETWORK_ERR_CLIENT_PLAYER_MISMATCH, |
|
279 STR_NETWORK_ERR_CLIENT_KICKED, |
|
280 STR_NETWORK_ERR_CLIENT_CHEATER, |
|
281 STR_NETWORK_ERR_CLIENT_SERVER_FULL, |
|
282 }; |
|
283 |
|
284 if (err >= lengthof(network_error_strings)) err = 0; |
|
285 |
|
286 return GetString(buf, network_error_strings[err]); |
|
287 } |
|
288 |
259 // Find all IP-aliases for this host |
289 // Find all IP-aliases for this host |
260 static void NetworkFindIPs(void) |
290 static void NetworkFindIPs(void) |
261 { |
291 { |
262 int i, last; |
292 int i, last; |
263 |
293 |
522 char client_name[NETWORK_NAME_LENGTH]; |
552 char client_name[NETWORK_NAME_LENGTH]; |
523 NetworkClientState *new_cs; |
553 NetworkClientState *new_cs; |
524 |
554 |
525 NetworkGetClientName(client_name, sizeof(client_name), cs); |
555 NetworkGetClientName(client_name, sizeof(client_name), cs); |
526 |
556 |
527 GetString(str, STR_NETWORK_ERR_CLIENT_GENERAL + errorno); |
557 GetNetworkErrorMsg(str, errorno); |
528 |
558 |
529 NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str); |
559 NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str); |
530 |
560 |
531 // Inform other clients of this... strange leaving ;) |
561 // Inform other clients of this... strange leaving ;) |
532 FOR_ALL_CLIENTS(new_cs) { |
562 FOR_ALL_CLIENTS(new_cs) { |