|
|
|
@ -326,13 +326,8 @@ static uint8 _network_server_max_companies;
|
|
|
|
|
/** Maximum number of spectators of the currently joined server. */
|
|
|
|
|
static uint8 _network_server_max_spectators;
|
|
|
|
|
|
|
|
|
|
/** Who would we like to join as. */
|
|
|
|
|
CompanyID _network_join_as;
|
|
|
|
|
|
|
|
|
|
/** Login password from -p argument */
|
|
|
|
|
const char *_network_join_server_password = nullptr;
|
|
|
|
|
/** Company password from -P argument */
|
|
|
|
|
const char *_network_join_company_password = nullptr;
|
|
|
|
|
/** Information about the game to join to. */
|
|
|
|
|
NetworkJoinInfo _network_join;
|
|
|
|
|
|
|
|
|
|
/** Make sure the server ID length is the same as a md5 hash. */
|
|
|
|
|
static_assert(NETWORK_SERVER_ID_LENGTH == 16 * 2 + 1);
|
|
|
|
@ -372,7 +367,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin()
|
|
|
|
|
p->Send_string(GetNetworkRevisionString());
|
|
|
|
|
p->Send_uint32(_openttd_newgrf_version);
|
|
|
|
|
p->Send_string(_settings_client.network.client_name); // Client name
|
|
|
|
|
p->Send_uint8 (_network_join_as); // PlayAs
|
|
|
|
|
p->Send_uint8 (_network_join.company); // PlayAs
|
|
|
|
|
p->Send_uint8 (0); // Used to be language
|
|
|
|
|
my_client->SendPacket(p);
|
|
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
|
@ -804,7 +799,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEED_GAME_PASSW
|
|
|
|
|
if (this->status < STATUS_JOIN || this->status >= STATUS_AUTH_GAME) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
|
|
|
|
this->status = STATUS_AUTH_GAME;
|
|
|
|
|
|
|
|
|
|
const char *password = _network_join_server_password;
|
|
|
|
|
const char *password = _network_join.server_password;
|
|
|
|
|
if (!StrEmpty(password)) {
|
|
|
|
|
return SendGamePassword(password);
|
|
|
|
|
}
|
|
|
|
@ -823,7 +818,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PA
|
|
|
|
|
p->Recv_string(_password_server_id, sizeof(_password_server_id));
|
|
|
|
|
if (this->HasClientQuit()) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
|
|
|
|
|
|
|
|
|
const char *password = _network_join_company_password;
|
|
|
|
|
const char *password = _network_join.company_password;
|
|
|
|
|
if (!StrEmpty(password)) {
|
|
|
|
|
return SendCompanyPassword(password);
|
|
|
|
|
}
|
|
|
|
@ -945,10 +940,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
|
|
|
|
|
|
|
|
|
/* New company/spectator (invalid company) or company we want to join is not active
|
|
|
|
|
* Switch local company to spectator and await the server's judgement */
|
|
|
|
|
if (_network_join_as == COMPANY_NEW_COMPANY || !Company::IsValidID(_network_join_as)) {
|
|
|
|
|
if (_network_join.company == COMPANY_NEW_COMPANY || !Company::IsValidID(_network_join.company)) {
|
|
|
|
|
SetLocalCompany(COMPANY_SPECTATOR);
|
|
|
|
|
|
|
|
|
|
if (_network_join_as != COMPANY_SPECTATOR) {
|
|
|
|
|
if (_network_join.company != COMPANY_SPECTATOR) {
|
|
|
|
|
/* We have arrived and ready to start playing; send a command to make a new company;
|
|
|
|
|
* the server will give us a client-id and let us in */
|
|
|
|
|
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
|
|
|
|
@ -957,7 +952,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* take control over an existing company */
|
|
|
|
|
SetLocalCompany(_network_join_as);
|
|
|
|
|
SetLocalCompany(_network_join.company);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
|
|