diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 4320a06f66..e14cd060d8 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -333,7 +333,7 @@ protected: * string Name of the company. * string Name of the companies manager. * uint8_t Main company colour. - * bool Company is password protected. + * bool Company is protected. * uint32_t Year the company was inaugurated. * bool Company is an AI. * @param p The packet that was just received. @@ -347,7 +347,7 @@ protected: * string Name of the company. * string Name of the companies manager. * uint8_t Main company colour. - * bool Company is password protected. + * bool Company is protected. * uint8_t Quarters of bankruptcy. * uint8_t Owner of share 1. * uint8_t Owner of share 2. diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index 5b7ef1dfca..c466ceedee 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -83,10 +83,8 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet &p) case PACKET_SERVER_CLIENT_INFO: return this->Receive_SERVER_CLIENT_INFO(p); case PACKET_CLIENT_IDENTIFY: return this->Receive_CLIENT_IDENTIFY(p); case PACKET_SERVER_AUTH_REQUEST: return this->Receive_SERVER_AUTH_REQUEST(p); - case PACKET_SERVER_NEED_COMPANY_PASSWORD: return this->Receive_SERVER_NEED_COMPANY_PASSWORD(p); case PACKET_CLIENT_AUTH_RESPONSE: return this->Receive_CLIENT_AUTH_RESPONSE(p); case PACKET_SERVER_ENABLE_ENCRYPTION: return this->Receive_SERVER_ENABLE_ENCRYPTION(p); - case PACKET_CLIENT_COMPANY_PASSWORD: return this->Receive_CLIENT_COMPANY_PASSWORD(p); case PACKET_SERVER_WELCOME: return this->Receive_SERVER_WELCOME(p); case PACKET_CLIENT_GETMAP: return this->Receive_CLIENT_GETMAP(p); case PACKET_SERVER_WAIT: return this->Receive_SERVER_WAIT(p); @@ -104,7 +102,6 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet &p) case PACKET_CLIENT_CHAT: return this->Receive_CLIENT_CHAT(p); case PACKET_SERVER_CHAT: return this->Receive_SERVER_CHAT(p); case PACKET_SERVER_EXTERNAL_CHAT: return this->Receive_SERVER_EXTERNAL_CHAT(p); - case PACKET_CLIENT_SET_PASSWORD: return this->Receive_CLIENT_SET_PASSWORD(p); case PACKET_CLIENT_SET_NAME: return this->Receive_CLIENT_SET_NAME(p); case PACKET_CLIENT_QUIT: return this->Receive_CLIENT_QUIT(p); case PACKET_CLIENT_ERROR: return this->Receive_CLIENT_ERROR(p); @@ -118,7 +115,6 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet &p) case PACKET_CLIENT_NEWGRFS_CHECKED: return this->Receive_CLIENT_NEWGRFS_CHECKED(p); case PACKET_SERVER_MOVE: return this->Receive_SERVER_MOVE(p); case PACKET_CLIENT_MOVE: return this->Receive_CLIENT_MOVE(p); - case PACKET_SERVER_COMPANY_UPDATE: return this->Receive_SERVER_COMPANY_UPDATE(p); case PACKET_SERVER_CONFIG_UPDATE: return this->Receive_SERVER_CONFIG_UPDATE(p); default: @@ -166,10 +162,8 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_GAME_INFO(Packet &) { NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_CLIENT_INFO); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_IDENTIFY); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_AUTH_REQUEST(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_AUTH_REQUEST); } -NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_NEED_COMPANY_PASSWORD); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_AUTH_RESPONSE(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_AUTH_RESPONSE); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_ENABLE_ENCRYPTION(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_ENABLE_ENCRYPTION); } -NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWORD(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_COMPANY_PASSWORD); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_WELCOME(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_WELCOME); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_GETMAP); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_WAIT(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_WAIT); } @@ -187,7 +181,6 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMMAND(Packet &) { r NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_CHAT); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CHAT(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_CHAT); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_EXTERNAL_CHAT); } -NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_PASSWORD(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_SET_PASSWORD); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_NAME(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_SET_NAME); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_QUIT); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_ERROR); } @@ -201,7 +194,6 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(Packet NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_NEWGRFS_CHECKED); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_MOVE(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_MOVE); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet &) { return this->ReceiveInvalidPacket(PACKET_CLIENT_MOVE); } -NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_COMPANY_UPDATE); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(Packet &) { return this->ReceiveInvalidPacket(PACKET_SERVER_CONFIG_UPDATE); } void NetworkGameSocketHandler::DeferDeletion() diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index d29a17d8e0..5795221a2e 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -71,10 +71,6 @@ enum PacketGameType : uint8_t { PACKET_SERVER_CHECK_NEWGRFS, ///< Server sends NewGRF IDs and MD5 checksums for the client to check. PACKET_CLIENT_NEWGRFS_CHECKED, ///< Client acknowledges that it has all required NewGRFs. - /* Checking the company passwords. */ - PACKET_SERVER_NEED_COMPANY_PASSWORD, ///< Server requests the (hashed) company password. - PACKET_CLIENT_COMPANY_PASSWORD, ///< Client sends the (hashed) company password. - /* The server welcomes the authenticated client and sends information of other clients. */ PACKET_SERVER_WELCOME, ///< Server welcomes you and gives you your #ClientID. PACKET_SERVER_CLIENT_INFO, ///< Server sends you information about a client. @@ -119,9 +115,7 @@ enum PacketGameType : uint8_t { PACKET_SERVER_MOVE, ///< Server tells everyone that someone is moved to another company. /* Configuration updates. */ - PACKET_CLIENT_SET_PASSWORD, ///< A client (re)sets its company's password. PACKET_CLIENT_SET_NAME, ///< A client changes its name. - PACKET_SERVER_COMPANY_UPDATE, ///< Information (password) of a company changed. PACKET_SERVER_CONFIG_UPDATE, ///< Some network configuration important to the client changed. /* A client quitting. */ @@ -225,14 +219,6 @@ protected: */ virtual NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p); - /** - * Indication to the client that the server needs a company password: - * uint32_t Generation seed. - * string Network ID of the server. - * @param p The packet that was just received. - */ - virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet &p); - /** * Send the response to the authentication request: * 32 * uint8_t Public key of the client. @@ -250,19 +236,9 @@ protected: */ virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p); - /** - * Send a password to the server to authorize - * uint8_t Password type (see NetworkPasswordType). - * string The password. - * @param p The packet that was just received. - */ - virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet &p); - /** * The client is joined and ready to receive their map: * uint32_t Own client ID. - * uint32_t Generation seed. - * string Network ID of the server. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p); @@ -402,13 +378,6 @@ protected: */ virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet &p); - /** - * Set the password for the clients current company: - * string The password. - * @param p The packet that was just received. - */ - virtual NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet &p); - /** * Gives the client a new name: * string New name of the client. @@ -498,18 +467,10 @@ protected: /** * Request the server to move this client into another company: * uint8_t ID of the company the client wants to join. - * string Password, if the company is password protected. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet &p); - /** - * Update the clients knowledge of which company is password protected: - * uint16_t Bitwise representation of each company - * @param p The packet that was just received. - */ - virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet &p); - /** * Update the clients knowledge of the max settings: * uint8_t Maximum number of companies allowed. diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 82cebe186e..f2a035cc00 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -328,7 +328,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company SetDParam(0, c->index); p->Send_string(GetString(STR_PRESIDENT_NAME)); p->Send_uint8 (c->colour); - p->Send_bool (NetworkCompanyIsPassworded(c->index)); + p->Send_bool (true); p->Send_uint32(c->inaugurated_year.base()); p->Send_bool (c->is_ai); p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy @@ -353,7 +353,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Compa SetDParam(0, c->index); p->Send_string(GetString(STR_PRESIDENT_NAME)); p->Send_uint8 (c->colour); - p->Send_bool (NetworkCompanyIsPassworded(c->index)); + p->Send_bool (true); p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy this->SendPacket(std::move(p)); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index a6e6f3277b..3ed70a7054 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -313,11 +313,6 @@ ClientNetworkGameSocketHandler * ClientNetworkGameSocketHandler::my_client = nul /** Last frame we performed an ack. */ static uint32_t last_ack_frame; -/** One bit of 'entropy' used to generate a salt for the company passwords. */ -static uint32_t _password_game_seed; -/** The other bit of 'entropy' used to generate a salt for the company passwords. */ -static std::string _password_server_id; - /** Maximum number of companies of the currently joined server. */ static uint8_t _network_server_max_companies; /** The current name of the server you are on. */ @@ -388,20 +383,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendAuthResponse() return NETWORK_RECV_STATUS_OKAY; } -/** - * Set the company password as requested. - * @param password The company password. - */ -NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyPassword(const std::string &password) -{ - Debug(net, 9, "Client::SendCompanyPassword()"); - - auto p = std::make_unique(my_client, PACKET_CLIENT_COMPANY_PASSWORD); - p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _password_game_seed)); - my_client->SendPacket(std::move(p)); - return NETWORK_RECV_STATUS_OKAY; -} - /** Request the map from the server. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap() { @@ -485,21 +466,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendError(NetworkErrorCode err return NETWORK_RECV_STATUS_OKAY; } -/** - * Tell the server that we like to change the password of the company. - * @param password The new password. - */ -NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetPassword(const std::string &password) -{ - Debug(net, 9, "Client::SendSetPassword()"); - - auto p = std::make_unique(my_client, PACKET_CLIENT_SET_PASSWORD); - - p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _password_game_seed)); - my_client->SendPacket(std::move(p)); - return NETWORK_RECV_STATUS_OKAY; -} - /** * Tell the server that we like to change the name of the client. * @param name The new name. @@ -547,15 +513,13 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon(const std::string &pa /** * Ask the server to move us. * @param company The company to move to. - * @param password The password of the company to move to. */ -NetworkRecvStatus ClientNetworkGameSocketHandler::SendMove(CompanyID company, const std::string &password) +NetworkRecvStatus ClientNetworkGameSocketHandler::SendMove(CompanyID company) { Debug(net, 9, "Client::SendMove(): company={}", company); auto p = std::make_unique(my_client, PACKET_CLIENT_MOVE); p->Send_uint8(company); - p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _password_game_seed)); my_client->SendPacket(std::move(p)); return NETWORK_RECV_STATUS_OKAY; } @@ -796,34 +760,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ENABLE_ENCRYPTI return this->SendIdentify(); } -class CompanyPasswordRequest : public NetworkAuthenticationPasswordRequest { - virtual void Reply(const std::string &password) override - { - MyClient::SendCompanyPassword(password); - } -}; - -NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD(Packet &p) -{ - if (this->status < STATUS_ENCRYPTED || this->status >= STATUS_AUTH_COMPANY) return NETWORK_RECV_STATUS_MALFORMED_PACKET; - Debug(net, 9, "Client::status = AUTH_COMPANY"); - this->status = STATUS_AUTH_COMPANY; - - Debug(net, 9, "Client::Receive_SERVER_NEED_COMPANY_PASSWORD()"); - - _password_game_seed = p.Recv_uint32(); - _password_server_id = p.Recv_string(NETWORK_SERVER_ID_LENGTH); - if (this->HasClientQuit()) return NETWORK_RECV_STATUS_MALFORMED_PACKET; - - if (!_network_join.company_password.empty()) { - return SendCompanyPassword(_network_join.company_password); - } - - ShowNetworkNeedPassword(NETWORK_COMPANY_PASSWORD, std::make_shared()); - - return NETWORK_RECV_STATUS_OKAY; -} - NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WELCOME(Packet &p) { if (this->status < STATUS_ENCRYPTED || this->status >= STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET; @@ -834,10 +770,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WELCOME(Packet Debug(net, 9, "Client::Receive_SERVER_WELCOME(): client_id={}", _network_own_client_id); - /* Initialize the password hash salting variables, even if they were previously. */ - _password_game_seed = p.Recv_uint32(); - _password_server_id = p.Recv_string(NETWORK_SERVER_ID_LENGTH); - /* Start receiving the map */ return SendGetMap(); } @@ -1261,17 +1193,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(P return NETWORK_RECV_STATUS_OKAY; } -NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet &) -{ - if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET; - - SetWindowClassesDirty(WC_COMPANY); - - Debug(net, 9, "Client::Receive_SERVER_COMPANY_UPDATE()"); - - return NETWORK_RECV_STATUS_OKAY; -} - /** * Check the connection's state, i.e. is the connection still up? */ @@ -1331,9 +1252,9 @@ void NetworkClientSendRcon(const std::string &password, const std::string &comma * @param pass the password, is only checked on the server end if a password is needed. * @return void */ -void NetworkClientRequestMove(CompanyID company_id, const std::string &pass) +void NetworkClientRequestMove(CompanyID company_id, [[maybe_unused]] const std::string &pass) { - MyClient::SendMove(company_id, pass); + MyClient::SendMove(company_id); } /** @@ -1447,9 +1368,8 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const * Set/Reset company password on the client side. * @param password Password to be set. */ -void NetworkClientSetCompanyPassword(const std::string &password) +void NetworkClientSetCompanyPassword([[maybe_unused]] const std::string &password) { - MyClient::SendSetPassword(password); } /** diff --git a/src/network/network_client.h b/src/network/network_client.h index 8d68b8d8ba..0c2dda37eb 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -27,7 +27,6 @@ private: STATUS_AUTH_GAME, ///< Last action was requesting game (server) password. STATUS_ENCRYPTED, ///< The game authentication has completed and from here on the connection to the server is encrypted. STATUS_NEWGRFS_CHECK, ///< Last action was checking NewGRFs. - STATUS_AUTH_COMPANY, ///< Last action was requesting company password. STATUS_AUTHORIZED, ///< The client is authorized at the server. STATUS_MAP_WAIT, ///< The client is waiting as someone else is downloading the map. STATUS_MAP, ///< The client is downloading the map. @@ -48,7 +47,6 @@ protected: NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet &p) override; NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p) override; NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p) override; - NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet &p) override; NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p) override; NetworkRecvStatus Receive_SERVER_WAIT(Packet &p) override; NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet &p) override; @@ -68,7 +66,6 @@ protected: NetworkRecvStatus Receive_SERVER_RCON(Packet &p) override; NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet &p) override; NetworkRecvStatus Receive_SERVER_MOVE(Packet &p) override; - NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet &p) override; NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet &p) override; static NetworkRecvStatus SendNewGRFsOk(); @@ -90,13 +87,11 @@ public: static NetworkRecvStatus SendAck(); static NetworkRecvStatus SendAuthResponse(); - static NetworkRecvStatus SendCompanyPassword(const std::string &password); static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data); - static NetworkRecvStatus SendSetPassword(const std::string &password); static NetworkRecvStatus SendSetName(const std::string &name); static NetworkRecvStatus SendRCon(const std::string &password, const std::string &command); - static NetworkRecvStatus SendMove(CompanyID company, const std::string &password); + static NetworkRecvStatus SendMove(CompanyID company); static bool IsConnected(); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index b0ff3cf164..11b000d203 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -413,8 +413,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck() this->status = STATUS_NEWGRFS_CHECK; if (_grfconfig == nullptr) { - /* There are no NewGRFs, continue with the company password. */ - return this->SendNeedCompanyPassword(); + /* There are no NewGRFs, so they're welcome. */ + return this->SendWelcome(); } auto p = std::make_unique(this, PACKET_SERVER_CHECK_NEWGRFS, TCP_MTU); @@ -473,39 +473,13 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendEnableEncryption() return NETWORK_RECV_STATUS_OKAY; } -/** Request the company password. */ -NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword() -{ - Debug(net, 9, "client[{}] SendNeedCompanyPassword()", this->client_id); - - /* Invalid packet when status is anything but STATUS_NEWGRFS_CHECK. */ - if (this->status != STATUS_NEWGRFS_CHECK) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET); - - Debug(net, 9, "client[{}] status = AUTH_COMPANY", this->client_id); - this->status = STATUS_AUTH_COMPANY; - - NetworkClientInfo *ci = this->GetInfo(); - if (!Company::IsValidID(ci->client_playas)) { - return this->SendWelcome(); - } - - /* Reset 'lag' counters */ - this->last_frame = this->last_frame_server = _frame_counter; - - auto p = std::make_unique(this, PACKET_SERVER_NEED_COMPANY_PASSWORD); - p->Send_uint32(_settings_game.game_creation.generation_seed); - p->Send_string(_settings_client.network.network_id); - this->SendPacket(std::move(p)); - return NETWORK_RECV_STATUS_OKAY; -} - /** Send the client a welcome message with some basic information. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome() { Debug(net, 9, "client[{}] SendWelcome()", this->client_id); - /* Invalid packet when status is anything but STATUS_AUTH_COMPANY. */ - if (this->status != STATUS_AUTH_COMPANY) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET); + /* Invalid packet when status is anything but STATUS_NEWGRFS_CHECK. */ + if (this->status != STATUS_NEWGRFS_CHECK) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET); Debug(net, 9, "client[{}] status = AUTHORIZED", this->client_id); this->status = STATUS_AUTHORIZED; @@ -517,8 +491,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome() auto p = std::make_unique(this, PACKET_SERVER_WELCOME); p->Send_uint32(this->client_id); - p->Send_uint32(_settings_game.game_creation.generation_seed); - p->Send_string(_settings_client.network.network_id); this->SendPacket(std::move(p)); /* Transmit info about all the active clients */ @@ -840,18 +812,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMove(ClientID client_id, C return NETWORK_RECV_STATUS_OKAY; } -/** Send an update about the company password states. */ -NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyUpdate() -{ - Debug(net, 9, "client[{}] SendCompanyUpdate()", this->client_id); - - auto p = std::make_unique(this, PACKET_SERVER_COMPANY_UPDATE); - - p->Send_uint16(0); - this->SendPacket(std::move(p)); - return NETWORK_RECV_STATUS_OKAY; -} - /** Send an update about the max company/spectator counts. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendConfigUpdate() { @@ -885,7 +845,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED Debug(net, 9, "client[{}] Receive_CLIENT_NEWGRFS_CHECKED()", this->client_id); - return this->SendNeedCompanyPassword(); + return this->SendWelcome(); } NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet &p) @@ -1025,17 +985,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_AUTH_RESPONSE(P return NETWORK_RECV_STATUS_OKAY; } -NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWORD(Packet &) -{ - if (this->status != STATUS_AUTH_COMPANY) { - return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - } - - Debug(net, 9, "client[{}] Receive_CLIENT_COMPANY_PASSWORD()", this->client_id); - - return this->SendWelcome(); -} - NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet &) { /* The client was never joined.. so this is impossible, right? @@ -1096,10 +1045,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet & NetworkAdminClientInfo(this, true); /* also update the new client with our max values */ - this->SendConfigUpdate(); - - /* quickly update the syncing client with company details */ - return this->SendCompanyUpdate(); + return this->SendConfigUpdate(); } /* Wrong status for this packet, give a warning to client, and close connection */ @@ -1464,22 +1410,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet &p) return NETWORK_RECV_STATUS_OKAY; } -NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_SET_PASSWORD(Packet &p) -{ - if (this->status != STATUS_ACTIVE) { - /* Illegal call, return error and ignore the packet */ - return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - } - - Debug(net, 9, "client[{}] Receive_CLIENT_SET_PASSWORD()", this->client_id); - - std::string password = p.Recv_string(NETWORK_PASSWORD_LENGTH); - const NetworkClientInfo *ci = this->GetInfo(); - - NetworkServerSetCompanyPassword(ci->client_playas, password); - return NETWORK_RECV_STATUS_OKAY; -} - NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME(Packet &p) { if (this->status != STATUS_ACTIVE) { @@ -1866,7 +1796,6 @@ void NetworkServer_Tick(bool send_frame) break; case NetworkClientSocket::STATUS_AUTH_GAME: - case NetworkClientSocket::STATUS_AUTH_COMPANY: /* These don't block? */ if (lag > _settings_client.network.max_password_time) { IConsolePrint(CC_WARNING, "Client #{} (IP: {}) is dropped because it took longer than {} ticks to enter the password.", cs->client_id, cs->GetClientIP(), _settings_client.network.max_password_time); @@ -2012,10 +1941,9 @@ void NetworkServerShowStatusToConsole() { static const char * const stat_str[] = { "inactive", - "authorizing (server password)", + "authorizing", "identifing client", "checking NewGRFs", - "authorizing (company password)", "authorized", "waiting", "loading map", @@ -2066,10 +1994,6 @@ void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded) SetWindowClassesDirty(WC_COMPANY); - for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) { - if (cs->status >= NetworkClientSocket::STATUS_PRE_ACTIVE) cs->SendCompanyUpdate(); - } - NetworkAdminCompanyUpdate(Company::GetIfValid(company_id)); } diff --git a/src/network/network_server.h b/src/network/network_server.h index 6b75a123f9..2c91b7cfe1 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -30,13 +30,11 @@ protected: NetworkRecvStatus Receive_CLIENT_IDENTIFY(Packet &p) override; NetworkRecvStatus Receive_CLIENT_GAME_INFO(Packet &p) override; NetworkRecvStatus Receive_CLIENT_AUTH_RESPONSE(Packet &p) override; - NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet &p) override; NetworkRecvStatus Receive_CLIENT_GETMAP(Packet &p) override; NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet &p) override; NetworkRecvStatus Receive_CLIENT_ACK(Packet &p) override; NetworkRecvStatus Receive_CLIENT_COMMAND(Packet &p) override; NetworkRecvStatus Receive_CLIENT_CHAT(Packet &p) override; - NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet &p) override; NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet &p) override; NetworkRecvStatus Receive_CLIENT_QUIT(Packet &p) override; NetworkRecvStatus Receive_CLIENT_ERROR(Packet &p) override; @@ -49,7 +47,6 @@ protected: NetworkRecvStatus SendWelcome(); NetworkRecvStatus SendAuthRequest(); NetworkRecvStatus SendEnableEncryption(); - NetworkRecvStatus SendNeedCompanyPassword(); public: /** Status of a client */ @@ -58,7 +55,6 @@ public: STATUS_AUTH_GAME, ///< The client is authorizing with game (server) password. STATUS_IDENTIFY, ///< The client is identifying itself. STATUS_NEWGRFS_CHECK, ///< The client is checking NewGRFs. - STATUS_AUTH_COMPANY, ///< The client is authorizing with company password. STATUS_AUTHORIZED, ///< The client is authorized. STATUS_MAP_WAIT, ///< The client is waiting as someone else is downloading the map. STATUS_MAP, ///< The client is downloading the map. @@ -104,7 +100,6 @@ public: NetworkRecvStatus SendFrame(); NetworkRecvStatus SendSync(); NetworkRecvStatus SendCommand(const CommandPacket &cp); - NetworkRecvStatus SendCompanyUpdate(); NetworkRecvStatus SendConfigUpdate(); static void Send();