Add: allow setting your server visibility to "invite-only" (#9434)
In this mode you do register to the Game Coordinator, but your server will not show up in the public server listing. You can give your friends the invite code of the server with which they can join.
This commit is contained in:
@@ -94,8 +94,8 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_ERROR(Packet *p)
|
||||
SetDParamStr(0, detail);
|
||||
ShowErrorMessage(STR_NETWORK_ERROR_COORDINATOR_REGISTRATION_FAILED, STR_JUST_RAW_STRING, WL_ERROR);
|
||||
|
||||
/* To prevent that we constantly try to reconnect, switch to private game. */
|
||||
_settings_client.network.server_advertise = false;
|
||||
/* To prevent that we constantly try to reconnect, switch to local game. */
|
||||
_settings_client.network.server_game_type = SERVER_GAME_TYPE_LOCAL;
|
||||
|
||||
this->CloseConnection();
|
||||
return false;
|
||||
@@ -153,9 +153,18 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK(Packet *p)
|
||||
default: connection_type = "Unknown"; break; // Should never happen, but don't fail if it does.
|
||||
}
|
||||
|
||||
std::string game_type;
|
||||
switch (_settings_client.network.server_game_type) {
|
||||
case SERVER_GAME_TYPE_INVITE_ONLY: game_type = "Invite only"; break;
|
||||
case SERVER_GAME_TYPE_PUBLIC: game_type = "Public"; break;
|
||||
|
||||
case SERVER_GAME_TYPE_LOCAL: // Impossible to register local servers.
|
||||
default: game_type = "Unknown"; break; // Should never happen, but don't fail if it does.
|
||||
}
|
||||
|
||||
Debug(net, 3, "----------------------------------------");
|
||||
Debug(net, 3, "Your server is now registered with the Game Coordinator:");
|
||||
Debug(net, 3, " Game type: Public");
|
||||
Debug(net, 3, " Game type: {}", game_type);
|
||||
Debug(net, 3, " Connection type: {}", connection_type);
|
||||
Debug(net, 3, " Invite code: {}", _network_server_invite_code);
|
||||
Debug(net, 3, "----------------------------------------");
|
||||
@@ -298,7 +307,7 @@ void ClientNetworkCoordinatorSocketHandler::Register()
|
||||
|
||||
Packet *p = new Packet(PACKET_COORDINATOR_SERVER_REGISTER);
|
||||
p->Send_uint8(NETWORK_COORDINATOR_VERSION);
|
||||
p->Send_uint8(SERVER_GAME_TYPE_PUBLIC);
|
||||
p->Send_uint8(_settings_client.network.server_game_type);
|
||||
p->Send_uint16(_settings_client.network.server_port);
|
||||
if (_settings_client.network.server_invite_code.empty() || _settings_client.network.server_invite_code_secret.empty()) {
|
||||
p->Send_string("");
|
||||
@@ -467,7 +476,7 @@ void ClientNetworkCoordinatorSocketHandler::CloseAllTokens()
|
||||
void ClientNetworkCoordinatorSocketHandler::SendReceive()
|
||||
{
|
||||
/* Private games are not listed via the Game Coordinator. */
|
||||
if (_network_server && !_settings_client.network.server_advertise) {
|
||||
if (_network_server && _settings_client.network.server_game_type == SERVER_GAME_TYPE_LOCAL) {
|
||||
if (this->sock != INVALID_SOCKET) {
|
||||
this->CloseConnection();
|
||||
}
|
||||
|
Reference in New Issue
Block a user