From 8e12bd35aed324feefe5e0e275eaaa48f10abdbb Mon Sep 17 00:00:00 2001 From: Rubidium Date: Mon, 25 Mar 2024 21:59:04 +0100 Subject: [PATCH] Fix: server shutdown and newgame packets should be stable The server sends shutdown and newgame (reboot) packets to any connected client. This can be useful, so you can tell clients that are trying to join that the server is restarting. However, that means that packets can be sent before a version check has been done. So, these packets should be in the stable packet range instead of the one that is unstable and guarded by a version check. --- src/network/core/tcp_game.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index a381f6aa3b..24cb9c941c 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -24,10 +24,9 @@ */ enum PacketGameType : uint8_t { /* - * These first four pair of packets (thus eight in - * total) must remain in this order for backward - * and forward compatibility between clients that - * are trying to join directly. + * These first ten packets must remain in this order for backward and forward compatibility + * between clients that are trying to join directly. These packets can be received and/or sent + * by the server before the server has processed the 'join' packet from the client. */ /* Packets sent by socket accepting code without ever constructing a client socket instance. */ @@ -46,6 +45,10 @@ enum PacketGameType : uint8_t { PACKET_SERVER_GAME_INFO, ///< Information about the server. PACKET_CLIENT_GAME_INFO, ///< Request information about the server. + /* A server quitting this game. */ + PACKET_SERVER_NEWGAME, ///< The server is preparing to start a new game. + PACKET_SERVER_SHUTDOWN, ///< The server is shutting down. + /* * Packets after here assume that the client * and server are running the same version. As @@ -121,10 +124,6 @@ enum PacketGameType : uint8_t { PACKET_SERVER_COMPANY_UPDATE, ///< Information (password) of a company changed. PACKET_SERVER_CONFIG_UPDATE, ///< Some network configuration important to the client changed. - /* A server quitting this game. */ - PACKET_SERVER_NEWGAME, ///< The server is preparing to start a new game. - PACKET_SERVER_SHUTDOWN, ///< The server is shutting down. - /* A client quitting. */ PACKET_CLIENT_QUIT, ///< A client tells the server it is going to quit. PACKET_SERVER_QUIT, ///< A server tells that a client has quit.