Changeset - r25824:08d7cb74dd5d
[Not reviewed]
master
0 5 0
Patric Stout - 3 years ago 2021-07-14 19:23:44
truebrain@openttd.org
Add: inform clients what game-script a server is running (#9441)

Co-authored-by: The Dude <thedude@novapolis.net>
5 files changed with 24 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2033,6 +2033,7 @@ STR_NETWORK_SERVER_LIST_SERVER_VERSION  
 
STR_NETWORK_SERVER_LIST_SERVER_ADDRESS                          :{SILVER}Server address: {WHITE}{RAW_STRING}
 
STR_NETWORK_SERVER_LIST_START_DATE                              :{SILVER}Start date: {WHITE}{DATE_SHORT}
 
STR_NETWORK_SERVER_LIST_CURRENT_DATE                            :{SILVER}Current date: {WHITE}{DATE_SHORT}
 
STR_NETWORK_SERVER_LIST_GAMESCRIPT                              :{SILVER}Game Script: {WHITE}{RAW_STRING} (v{NUM})
 
STR_NETWORK_SERVER_LIST_PASSWORD                                :{SILVER}Password protected!
 
STR_NETWORK_SERVER_LIST_SERVER_OFFLINE                          :{SILVER}SERVER OFFLINE
 
STR_NETWORK_SERVER_LIST_SERVER_FULL                             :{SILVER}SERVER FULL
src/network/core/config.h
Show inline comments
 
@@ -45,7 +45,7 @@ static const uint16 TCP_MTU             
 
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?
 

	
src/network/core/game_info.cpp
Show inline comments
 
@@ -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,
 
	/* 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 *
 
	 * 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;
src/network/core/game_info.h
Show inline comments
 
@@ -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.
 
};
 

	
 
/**
src/network/network_gui.cpp
Show inline comments
 
@@ -675,6 +675,13 @@ public:
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
 
			y += FONT_HEIGHT_NORMAL;
 

	
 
			if (sel->info.gamescript_version != -1) {
 
				SetDParamStr(0, sel->info.gamescript_name);
 
				SetDParam(1, sel->info.gamescript_version);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_GAMESCRIPT); // gamescript name and version
 
				y += FONT_HEIGHT_NORMAL;
 
			}
 

	
 
			y += WD_PAR_VSEP_NORMAL;
 

	
 
			if (!sel->info.compatible) {
0 comments (0 inline, 0 general)