From: Holger Schemel Date: Mon, 20 Aug 2018 09:30:59 +0000 (+0200) Subject: improved handling network protocol version mismatch X-Git-Tag: 4.1.1.0~67 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2b062aac2defaf49659459125225c82c309ba0f5;p=rocksndiamonds.git improved handling network protocol version mismatch In case of different network protocol versions at network client and server, show an error message and disable networking instead of aborting the program with a "fatal error" style message. --- diff --git a/src/network.c b/src/network.c index f5148cd4..b0a6a0ee 100644 --- a/src/network.c +++ b/src/network.c @@ -48,6 +48,8 @@ static byte readbuffer[MAX_BUFFER_SIZE], writbuffer[MAX_BUFFER_SIZE]; static byte *buffer = realbuffer + 4; static int nread = 0, nwrite = 0; static boolean stop_network_game = FALSE; +static boolean stop_network_client = FALSE; +static char stop_network_client_message[MAX_OUTPUT_LINESIZE + 1]; static void DrawNetworkTextExt(char *message, int font_nr, boolean initialize) { @@ -430,9 +432,15 @@ void SendToServer_MovePlayer(byte player_action) static void Handle_OP_BAD_PROTOCOL_VERSION() { Error(ERR_WARN, "protocol version mismatch"); - Error(ERR_EXIT, "server expects %d.%d.x instead of %d.%d.%d", + Error(ERR_WARN, "server expects %d.%d.x instead of %d.%d.%d", buffer[2], buffer[3], PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, PROTOCOL_VERSION_3); + + sprintf(stop_network_client_message, "Network protocol version mismatch! Server expects version %d.%d.x instead of %d.%d.%d!", + buffer[2], buffer[3], + PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, PROTOCOL_VERSION_3); + + stop_network_client = TRUE; } static void Handle_OP_YOUR_NUMBER() @@ -826,6 +834,9 @@ static char *HandleNetworkingPackets() nread += num_bytes; HandleNetworkingMessages(); + + if (stop_network_client) + return stop_network_client_message; } return NULL;