mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: cascade through SendNeedGame/CompanyPassword functions, instead of duplicating logic for determining whether to call these functions
This commit is contained in:
parent
8add0bf8ec
commit
794f12dc24
@ -423,6 +423,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
|
|||||||
/** Request the game password. */
|
/** Request the game password. */
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
||||||
{
|
{
|
||||||
|
if (_settings_client.network.server_password.empty()) {
|
||||||
|
/* Do not actually need a game password, continue with the company password. */
|
||||||
|
return this->SendNeedCompanyPassword();
|
||||||
|
}
|
||||||
|
|
||||||
Debug(net, 9, "client[{}] SendNeedGamePassword()", this->client_id);
|
Debug(net, 9, "client[{}] SendNeedGamePassword()", this->client_id);
|
||||||
|
|
||||||
/* Invalid packet when status is STATUS_AUTH_GAME or higher */
|
/* Invalid packet when status is STATUS_AUTH_GAME or higher */
|
||||||
@ -441,6 +446,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
|||||||
/** Request the company password. */
|
/** Request the company password. */
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
||||||
{
|
{
|
||||||
|
NetworkClientInfo *ci = this->GetInfo();
|
||||||
|
if (!Company::IsValidID(ci->client_playas) || _network_company_states[ci->client_playas].password.empty()) {
|
||||||
|
return this->SendWelcome();
|
||||||
|
}
|
||||||
|
|
||||||
Debug(net, 9, "client[{}] SendNeedCompanyPassword()", this->client_id);
|
Debug(net, 9, "client[{}] SendNeedCompanyPassword()", this->client_id);
|
||||||
|
|
||||||
/* Invalid packet when status is STATUS_AUTH_COMPANY or higher */
|
/* Invalid packet when status is STATUS_AUTH_COMPANY or higher */
|
||||||
@ -845,20 +855,9 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED
|
|||||||
|
|
||||||
Debug(net, 9, "client[{}] Receive_CLIENT_NEWGRFS_CHECKED()", this->client_id);
|
Debug(net, 9, "client[{}] Receive_CLIENT_NEWGRFS_CHECKED()", this->client_id);
|
||||||
|
|
||||||
NetworkClientInfo *ci = this->GetInfo();
|
|
||||||
|
|
||||||
/* We now want a password from the client else we do not allow them in! */
|
|
||||||
if (!_settings_client.network.server_password.empty()) {
|
|
||||||
return this->SendNeedGamePassword();
|
return this->SendNeedGamePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Company::IsValidID(ci->client_playas) && !_network_company_states[ci->client_playas].password.empty()) {
|
|
||||||
return this->SendNeedCompanyPassword();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->SendWelcome();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
||||||
{
|
{
|
||||||
if (this->status != STATUS_INACTIVE) {
|
if (this->status != STATUS_INACTIVE) {
|
||||||
@ -930,8 +929,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
|||||||
this->status = STATUS_NEWGRFS_CHECK;
|
this->status = STATUS_NEWGRFS_CHECK;
|
||||||
|
|
||||||
if (_grfconfig == nullptr) {
|
if (_grfconfig == nullptr) {
|
||||||
/* Behave as if we received PACKET_CLIENT_NEWGRFS_CHECKED */
|
/* Continue asking for the game password. */
|
||||||
return this->Receive_CLIENT_NEWGRFS_CHECKED(nullptr);
|
return this->SendNeedGamePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->SendNewGRFCheck();
|
return this->SendNewGRFCheck();
|
||||||
@ -954,15 +953,9 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GAME_PASSWORD(P
|
|||||||
return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
|
return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetworkClientInfo *ci = this->GetInfo();
|
|
||||||
if (Company::IsValidID(ci->client_playas) && !_network_company_states[ci->client_playas].password.empty()) {
|
|
||||||
return this->SendNeedCompanyPassword();
|
return this->SendNeedCompanyPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Valid password, allow user */
|
|
||||||
return this->SendWelcome();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWORD(Packet *p)
|
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWORD(Packet *p)
|
||||||
{
|
{
|
||||||
if (this->status != STATUS_AUTH_COMPANY) {
|
if (this->status != STATUS_AUTH_COMPANY) {
|
||||||
|
Loading…
Reference in New Issue
Block a user