summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-07-14 21:23:44 +0200
committerGitHub <noreply@github.com>2021-07-14 21:23:44 +0200
commitc921f6d81794223590abc4ced95daba0b91e4767 (patch)
tree7d929eafb0c225ba74baca4633838a79be5b3c33 /src/network/core
parent333cba6a619d8d99a2508e5cb9cd1cc72c4360d1 (diff)
downloadopenttd-c921f6d81794223590abc4ced95daba0b91e4767.tar.xz
Add: inform clients what game-script a server is running (#9441)
Co-authored-by: The Dude <thedude@novapolis.net>
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/config.h2
-rw-r--r--src/network/core/game_info.cpp13
-rw-r--r--src/network/core/game_info.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 06df93140..757556993 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -45,7 +45,7 @@ static const uint16 TCP_MTU = 32767; ///< Numbe
static const uint16 COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility
static const byte NETWORK_GAME_ADMIN_VERSION = 1; ///< What version of the admin network do we use?
-static const byte NETWORK_GAME_INFO_VERSION = 4; ///< What version of game-info do we use?
+static const byte NETWORK_GAME_INFO_VERSION = 5; ///< What version of game-info do we use?
static const byte NETWORK_COMPANY_INFO_VERSION = 6; ///< What version of company info is this?
static const byte NETWORK_COORDINATOR_VERSION = 2; ///< What version of game-coordinator-protocol do we use?
diff --git a/src/network/core/game_info.cpp b/src/network/core/game_info.cpp
index 17f00c5f5..32b8fdb75 100644
--- a/src/network/core/game_info.cpp
+++ b/src/network/core/game_info.cpp
@@ -16,6 +16,8 @@
#include "../../date_func.h"
#include "../../debug.h"
#include "../../map_func.h"
+#include "../../game/game.hpp"
+#include "../../game/game_info.hpp"
#include "../../settings_type.h"
#include "../../string_func.h"
#include "../../rev.h"
@@ -195,6 +197,11 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info)
/* Update the documentation in game_info.h on changes
* to the NetworkGameInfo wire-protocol! */
+ /* NETWORK_GAME_INFO_VERSION = 5 */
+ GameInfo *game_info = Game::GetInfo();
+ p->Send_uint32(game_info == nullptr ? -1 : (uint32)game_info->GetVersion());
+ p->Send_string(game_info == nullptr ? "" : game_info->GetName());
+
/* NETWORK_GAME_INFO_VERSION = 4 */
{
/* Only send the GRF Identification (GRF_ID and MD5 checksum) of
@@ -260,6 +267,12 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info)
* to the NetworkGameInfo wire-protocol! */
switch (game_info_version) {
+ case 5: {
+ info->gamescript_version = (int)p->Recv_uint32();
+ info->gamescript_name = p->Recv_string(NETWORK_NAME_LENGTH);
+ FALLTHROUGH;
+ }
+
case 4: {
GRFConfig **dst = &info->grfconfig;
uint i;
diff --git a/src/network/core/game_info.h b/src/network/core/game_info.h
index 1ea77ae77..8d9824b18 100644
--- a/src/network/core/game_info.h
+++ b/src/network/core/game_info.h
@@ -76,6 +76,8 @@ struct NetworkServerGameInfo {
byte spectators_on; ///< How many spectators do we have?
byte spectators_max; ///< Max spectators allowed on server
byte landscape; ///< The used landscape
+ int gamescript_version; ///< Version of the gamescript.
+ std::string gamescript_name; ///< Name of the gamescript.
};
/**