Changeset - r25881:988fc42507a5
[Not reviewed]
master
0 4 0
Patric Stout - 3 years ago 2021-08-14 08:19:40
truebrain@openttd.org
Add: synchronize server name to clients and display in Online Players GUI (#9472)
4 files changed with 17 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/network/network_client.cpp
Show inline comments
 
@@ -314,6 +314,8 @@ static std::string _password_server_id;
 

	
 
/** Maximum number of companies of the currently joined server. */
 
static uint8 _network_server_max_companies;
 
/** The current name of the server you are on. */
 
std::string _network_server_name;
 

	
 
/** Information about the game to join to. */
 
NetworkJoinInfo _network_join;
 
@@ -1187,6 +1189,7 @@ NetworkRecvStatus ClientNetworkGameSocke
 
	if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 

	
 
	_network_server_max_companies = p->Recv_uint8();
 
	_network_server_name = p->Recv_string(NETWORK_NAME_LENGTH);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
src/network/network_gui.cpp
Show inline comments
 
@@ -1601,14 +1601,14 @@ static const NWidgetPart _nested_client_
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_SELECTION, INVALID_COLOUR, WID_CL_SERVER_SELECTOR),
 
			NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER, STR_NULL), SetPadding(4, 4, 0, 4), SetPIP(0, 2, 0),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
 
					NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalTextLines(1, 0), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER_NAME, STR_NULL),
 
					NWidget(NWID_SPACER), SetMinimalSize(10, 0),
 
					NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_SERVER_NAME), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_TOOLTIP), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
					NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_CL_SERVER_NAME_EDIT), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NETWORK_CLIENT_LIST_SERVER_NAME_EDIT_TOOLTIP),
 
				EndContainer(),
 
		NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER, STR_NULL), SetPadding(4, 4, 0, 4), SetPIP(0, 2, 0),
 
			NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
 
				NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalTextLines(1, 0), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER_NAME, STR_NULL),
 
				NWidget(NWID_SPACER), SetMinimalSize(10, 0),
 
				NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_SERVER_NAME), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_TOOLTIP), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_CL_SERVER_NAME_EDIT), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NETWORK_CLIENT_LIST_SERVER_NAME_EDIT_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_SELECTION, INVALID_COLOUR, WID_CL_SERVER_SELECTOR),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
 
					NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalTextLines(1, 0), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER_VISIBILITY, STR_NULL),
 
					NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0), SetResize(1, 0),
 
@@ -2017,6 +2017,7 @@ public:
 

	
 
		/* Currently server information is not sync'd to clients, so we cannot show it on clients. */
 
		this->GetWidget<NWidgetStacked>(WID_CL_SERVER_SELECTOR)->SetDisplayedPlane(_network_server ? 0 : SZSP_HORIZONTAL);
 
		this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server);
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
@@ -2051,7 +2052,7 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_CL_SERVER_NAME:
 
				SetDParamStr(0, _settings_client.network.server_name);
 
				SetDParamStr(0, _network_server ? _settings_client.network.server_name : _network_server_name);
 
				break;
 

	
 
			case WID_CL_SERVER_VISIBILITY:
src/network/network_internal.h
Show inline comments
 
@@ -86,6 +86,9 @@ extern uint32 _network_join_bytes_total;
 
extern ConnectionType _network_server_connection_type;
 
extern std::string _network_server_invite_code;
 

	
 
/* Variable available for clients. */
 
extern std::string _network_server_name;
 

	
 
extern uint8 _network_reconnect;
 

	
 
extern CompanyMask _network_company_passworded;
src/network/network_server.cpp
Show inline comments
 
@@ -820,6 +820,7 @@ NetworkRecvStatus ServerNetworkGameSocke
 
	Packet *p = new Packet(PACKET_SERVER_CONFIG_UPDATE);
 

	
 
	p->Send_uint8(_settings_client.network.max_companies);
 
	p->Send_string(_settings_client.network.server_name);
 
	this->SendPacket(p);
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
0 comments (0 inline, 0 general)