mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-08 07:21:53 +00:00
Fix: Treat closing network relay window as a choice of "No".
Issue ConnectFailure when closing the window if the relay request is considered unhandled.
This commit is contained in:
parent
f379b31e28
commit
bdcf6b6acd
@ -648,7 +648,7 @@ void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(const std::string &
|
||||
*/
|
||||
void ClientNetworkCoordinatorSocketHandler::CloseTurnHandler(const std::string &token)
|
||||
{
|
||||
CloseWindowByClass(WC_NETWORK_ASK_RELAY);
|
||||
CloseWindowByClass(WC_NETWORK_ASK_RELAY, NRWCD_HANDLED);
|
||||
|
||||
auto turn_it = this->turn_handlers.find(token);
|
||||
if (turn_it == this->turn_handlers.end()) return;
|
||||
|
@ -2413,6 +2413,12 @@ struct NetworkAskRelayWindow : public Window {
|
||||
this->InitNested(0);
|
||||
}
|
||||
|
||||
void Close(int data = 0) override
|
||||
{
|
||||
if (data == NRWCD_UNHANDLED) _network_coordinator_client.ConnectFailure(this->token, 0);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
if (widget == WID_NAR_TEXT) {
|
||||
@ -2452,18 +2458,18 @@ struct NetworkAskRelayWindow : public Window {
|
||||
switch (widget) {
|
||||
case WID_NAR_NO:
|
||||
_network_coordinator_client.ConnectFailure(this->token, 0);
|
||||
this->Close();
|
||||
this->Close(NRWCD_HANDLED);
|
||||
break;
|
||||
|
||||
case WID_NAR_YES_ONCE:
|
||||
_network_coordinator_client.StartTurnConnection(this->token);
|
||||
this->Close();
|
||||
this->Close(NRWCD_HANDLED);
|
||||
break;
|
||||
|
||||
case WID_NAR_YES_ALWAYS:
|
||||
_settings_client.network.use_relay_service = URS_ALLOW;
|
||||
_network_coordinator_client.StartTurnConnection(this->token);
|
||||
this->Close();
|
||||
this->Close(NRWCD_HANDLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2499,7 +2505,7 @@ static WindowDesc _network_ask_relay_desc(
|
||||
*/
|
||||
void ShowNetworkAskRelay(const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token)
|
||||
{
|
||||
CloseWindowByClass(WC_NETWORK_ASK_RELAY);
|
||||
CloseWindowByClass(WC_NETWORK_ASK_RELAY, NRWCD_HANDLED);
|
||||
|
||||
Window *parent = GetMainWindow();
|
||||
new NetworkAskRelayWindow(&_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token);
|
||||
|
@ -39,5 +39,9 @@ struct NetworkCompanyInfo : NetworkCompanyStats {
|
||||
std::string clients; ///< The clients that control this company (Name1, name2, ..)
|
||||
};
|
||||
|
||||
enum NetworkRelayWindowCloseData {
|
||||
NRWCD_UNHANDLED = 0, ///< Relay request is unhandled.
|
||||
NRWCD_HANDLED = 1, ///< Relay request is handled, either by user or by timeout.
|
||||
};
|
||||
|
||||
#endif /* NETWORK_GUI_H */
|
||||
|
Loading…
Reference in New Issue
Block a user