Skip to content

Commit

Permalink
Fix: server shutdown and newgame packets should be stable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rubidium42 committed Mar 25, 2024
1 parent 4751179 commit 8e12bd3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/network/core/tcp_game.h
Expand Up @@ -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. */
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8e12bd3

Please sign in to comment.