Changeset - r25908:0d803b199db7
[Not reviewed]
master
0 5 0
Patric Stout - 3 years ago 2021-08-18 10:06:14
truebrain@openttd.org
Fix #9492: show for what server a relay session is being created (#9494)

Currently it says "the server" which is a bit ambigious. Be more
specific.
5 files changed with 31 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2163,7 +2163,7 @@ STR_NETWORK_CLIENT_LIST_ASK_COMPANY_RESE
 
STR_NETWORK_CLIENT_LIST_ASK_COMPANY_UNLOCK                      :{YELLOW}Are you sure you want to reset the password of company '{COMPANY}'?
 

	
 
STR_NETWORK_ASK_RELAY_CAPTION                                   :{WHITE}Use relay?
 
STR_NETWORK_ASK_RELAY_TEXT                                      :{YELLOW}Failed to establish a connection between you and the server.{}Would you like to relay this session via '{RAW_STRING}'?
 
STR_NETWORK_ASK_RELAY_TEXT                                      :{YELLOW}Failed to establish a connection between you and server '{RAW_STRING}'.{}Would you like to relay this session via '{RAW_STRING}'?
 
STR_NETWORK_ASK_RELAY_NO                                        :{BLACK}No
 
STR_NETWORK_ASK_RELAY_YES_ONCE                                  :{BLACK}Yes, this once
 
STR_NETWORK_ASK_RELAY_YES_ALWAYS                                :{BLACK}Yes, don't ask again
src/network/network_coordinator.cpp
Show inline comments
 
@@ -279,7 +279,7 @@ bool ClientNetworkCoordinatorSocketHandl
 
	}
 

	
 
	/* Now store it based on the token. */
 
	this->connecter[token] = connecter_pre_it->second;
 
	this->connecter[token] = {invite_code, connecter_pre_it->second};
 
	this->connecter_pre.erase(connecter_pre_it);
 

	
 
	return true;
 
@@ -378,16 +378,24 @@ bool ClientNetworkCoordinatorSocketHandl
 
		this->game_connecter = nullptr;
 
	}
 

	
 
	Debug(misc, 0, "{}", ticket);
 
	this->turn_handlers[token] = ClientNetworkTurnSocketHandler::Turn(token, tracking_number, ticket, connection_string);
 

	
 
	if (!_network_server) {
 
		auto connecter_it = this->connecter.find(token);
 
		if (connecter_it == this->connecter.end()) {
 
			/* Make sure we are still interested in connecting to this server. */
 
			this->ConnectFailure(token, 0);
 
			return true;
 
		}
 

	
 
		switch (_settings_client.network.use_relay_service) {
 
			case URS_NEVER:
 
				this->ConnectFailure(token, 0);
 
				break;
 

	
 
			case URS_ASK:
 
				ShowNetworkAskRelay(connection_string, token);
 
				ShowNetworkAskRelay(connecter_it->second.first, connection_string, token);
 
				break;
 

	
 
			case URS_ALLOW:
 
@@ -579,7 +587,7 @@ void ClientNetworkCoordinatorSocketHandl
 
		 * processes of connecting us. */
 
		auto connecter_it = this->connecter.find(token);
 
		if (connecter_it != this->connecter.end()) {
 
			connecter_it->second->SetConnected(sock);
 
			connecter_it->second.second->SetConnected(sock);
 
			this->connecter.erase(connecter_it);
 
		}
 
	}
 
@@ -665,7 +673,7 @@ void ClientNetworkCoordinatorSocketHandl
 
	/* Close the caller of the connection attempt. */
 
	auto connecter_it = this->connecter.find(token);
 
	if (connecter_it != this->connecter.end()) {
 
		connecter_it->second->SetFailure();
 
		connecter_it->second.second->SetFailure();
 
		this->connecter.erase(connecter_it);
 
	}
 
}
 
@@ -685,7 +693,7 @@ void ClientNetworkCoordinatorSocketHandl
 
	for (auto &[token, it] : this->connecter) {
 
		this->CloseStunHandler(token);
 
		this->CloseTurnHandler(token);
 
		it->SetFailure();
 
		it.second->SetFailure();
 

	
 
		/* Inform the Game Coordinator he can stop trying to connect us to the server. */
 
		this->ConnectFailure(token, 0);
src/network/network_coordinator.h
Show inline comments
 
@@ -54,7 +54,7 @@
 
class ClientNetworkCoordinatorSocketHandler : public NetworkCoordinatorSocketHandler {
 
private:
 
	std::chrono::steady_clock::time_point next_update; ///< When to send the next update (if server and public).
 
	std::map<std::string, TCPServerConnecter *> connecter; ///< Based on tokens, the current connecters that are pending.
 
	std::map<std::string, std::pair<std::string, TCPServerConnecter *>> connecter; ///< Based on tokens, the current (invite-code, connecter) that are pending.
 
	std::map<std::string, TCPServerConnecter *> connecter_pre; ///< Based on invite codes, the current connecters that are pending.
 
	std::map<std::string, std::map<int, std::unique_ptr<ClientNetworkStunSocketHandler>>> stun_handlers; ///< All pending STUN handlers, stored by token:family.
 
	std::map<std::string, std::unique_ptr<ClientNetworkTurnSocketHandler>> turn_handlers; ///< Pending TURN handler (if any), stored by token.
src/network/network_gui.cpp
Show inline comments
 
@@ -2361,13 +2361,18 @@ void ShowNetworkCompanyPasswordWindow(Wi
 
}
 

	
 
/**
 
 * Window used for asking the user if he is okay using a TURN server.
 
 * Window used for asking the user if he is okay using a relay server.
 
 */
 
struct NetworkAskRelayWindow : public Window {
 
	std::string connection_string; ///< The TURN server we want to connect to.
 
	std::string token;             ///< The token for this connection.
 
	std::string server_connection_string; ///< The game server we want to connect to.
 
	std::string relay_connection_string;  ///< The relay server we want to connect to.
 
	std::string token;                    ///< The token for this connection.
 

	
 
	NetworkAskRelayWindow(WindowDesc *desc, Window *parent, const std::string &connection_string, const std::string &token) : Window(desc), connection_string(connection_string), token(token)
 
	NetworkAskRelayWindow(WindowDesc *desc, Window *parent, const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token) :
 
		Window(desc),
 
		server_connection_string(server_connection_string),
 
		relay_connection_string(relay_connection_string),
 
		token(token)
 
	{
 
		this->parent = parent;
 
		this->InitNested(0);
 
@@ -2400,7 +2405,8 @@ struct NetworkAskRelayWindow : public Wi
 
	{
 
		switch (widget) {
 
			case WID_NAR_TEXT:
 
				SetDParamStr(0, this->connection_string);
 
				SetDParamStr(0, this->server_connection_string);
 
				SetDParamStr(1, this->relay_connection_string);
 
				break;
 
		}
 
	}
 
@@ -2451,13 +2457,14 @@ static WindowDesc _network_ask_relay_des
 

	
 
/**
 
 * Show a modal confirmation window with "no" / "yes, once" / "yes, always" buttons.
 
 * @param connection_string The relay server we want to connect to.
 
 * @param server_connection_string The game server we want to connect to.
 
 * @param relay_connection_string The relay server we want to connect to.
 
 * @param token The token for this connection.
 
 */
 
void ShowNetworkAskRelay(const std::string &connection_string, const std::string &token)
 
void ShowNetworkAskRelay(const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token)
 
{
 
	CloseWindowByClass(WC_NETWORK_ASK_RELAY);
 

	
 
	Window *parent = FindWindowById(WC_MAIN_WINDOW, 0);
 
	new NetworkAskRelayWindow(&_network_ask_relay_desc, parent, connection_string, token);
 
	new NetworkAskRelayWindow(&_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token);
 
}
src/network/network_gui.h
Show inline comments
 
@@ -23,6 +23,7 @@ void ShowJoinStatusWindow();
 
void ShowNetworkGameWindow();
 
void ShowClientList();
 
void ShowNetworkCompanyPasswordWindow(Window *parent);
 
void ShowNetworkAskRelay(const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token);
 

	
 

	
 
/** Company information stored at the client side */
 
@@ -37,6 +38,5 @@ struct NetworkCompanyInfo : NetworkCompa
 
	std::string clients;      ///< The clients that control this company (Name1, name2, ..)
 
};
 

	
 
void ShowNetworkAskRelay(const std::string &connection_string, const std::string &token);
 

	
 
#endif /* NETWORK_GUI_H */
0 comments (0 inline, 0 general)