From 9dc1fdc3851f86cdc50738fd3d2015e53838ca15 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 23 Mar 2024 19:26:08 +0100 Subject: [PATCH] Cleanup: remove client side password checks when moving to a different company --- src/company_gui.cpp | 7 ------- src/console_cmds.cpp | 9 ++++----- src/network/network_client.cpp | 4 +--- src/network/network_func.h | 2 +- src/widgets/network_widget.h | 1 - 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 0c8e58b055..6a8d1fb043 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2517,9 +2517,6 @@ struct CompanyWindow : Window if (_network_server) { NetworkServerDoMove(CLIENT_ID_SERVER, company); MarkWholeScreenDirty(); - } else if (NetworkCompanyIsPassworded(company)) { - /* ask for the password */ - ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_PASSWORD); } else { /* just send the join command */ NetworkClientRequestMove(company); @@ -2567,10 +2564,6 @@ struct CompanyWindow : Window case WID_C_COMPANY_NAME: Command::Post(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, str); break; - - case WID_C_COMPANY_JOIN: - NetworkClientRequestMove((CompanyID)this->window_number, str); - break; } } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index c9bfa9fde9..c91009766d 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -914,7 +914,7 @@ DEF_CONSOLE_CMD(ConClientNickChange) DEF_CONSOLE_CMD(ConJoinCompany) { if (argc < 2) { - IConsolePrint(CC_HELP, "Request joining another company. Usage: 'join []'."); + IConsolePrint(CC_HELP, "Request joining another company. Usage: 'join '."); IConsolePrint(CC_HELP, "For valid company-id see company list, use 255 for spectator."); return true; } @@ -943,9 +943,8 @@ DEF_CONSOLE_CMD(ConJoinCompany) return true; } - /* Check if the company requires a password */ - if (NetworkCompanyIsPassworded(company_id) && argc < 3) { - IConsolePrint(CC_ERROR, "Company {} requires a password to join.", company_id + 1); + if (!info->CanJoinCompany(company_id)) { + IConsolePrint(CC_ERROR, "You are not allowed to join this company."); return true; } @@ -953,7 +952,7 @@ DEF_CONSOLE_CMD(ConJoinCompany) if (_network_server) { NetworkServerDoMove(CLIENT_ID_SERVER, company_id); } else { - NetworkClientRequestMove(company_id, NetworkCompanyIsPassworded(company_id) ? argv[2] : ""); + NetworkClientRequestMove(company_id); } return true; diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 3ed70a7054..78695d8552 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -1249,10 +1249,8 @@ void NetworkClientSendRcon(const std::string &password, const std::string &comma /** * Notify the server of this client wanting to be moved to another company. * @param company_id id of the company the client wishes to be moved to. - * @param pass the password, is only checked on the server end if a password is needed. - * @return void */ -void NetworkClientRequestMove(CompanyID company_id, [[maybe_unused]] const std::string &pass) +void NetworkClientRequestMove(CompanyID company_id) { MyClient::SendMove(company_id); } diff --git a/src/network/network_func.h b/src/network/network_func.h index 485ecfcdb1..af83a0fa30 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -51,7 +51,7 @@ void NetworkUpdateClientInfo(ClientID client_id); void NetworkClientsToSpectators(CompanyID cid); bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password = ""); void NetworkClientJoinGame(); -void NetworkClientRequestMove(CompanyID company, const std::string &pass = ""); +void NetworkClientRequestMove(CompanyID company); void NetworkClientSendRcon(const std::string &password, const std::string &command); void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data = 0); bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio); diff --git a/src/widgets/network_widget.h b/src/widgets/network_widget.h index 276874f92e..7efbb236eb 100644 --- a/src/widgets/network_widget.h +++ b/src/widgets/network_widget.h @@ -86,7 +86,6 @@ enum ClientListWidgets : WidgetID { WID_CL_CLIENT_NAME_EDIT, ///< Edit button for client name. WID_CL_MATRIX, ///< Company/client list. WID_CL_SCROLLBAR, ///< Scrollbar for company/client list. - WID_CL_COMPANY_JOIN, ///< Used for QueryWindow when a company has a password. WID_CL_CLIENT_COMPANY_COUNT, ///< Count of clients and companies. };