mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-30 18:09:09 +00:00
Change: remove the ability to control "max spectators" (#9466)
Soon we will make "join game" join the game as spectator first, so limiting the amount of spectators makes no sense anymore in that context. Not sure it ever did make sense.
This commit is contained in:
@@ -126,7 +126,6 @@ void FillStaticNetworkServerGameInfo()
|
||||
_network_game_info.start_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
|
||||
_network_game_info.clients_max = _settings_client.network.max_clients;
|
||||
_network_game_info.companies_max = _settings_client.network.max_companies;
|
||||
_network_game_info.spectators_max = _settings_client.network.max_spectators;
|
||||
_network_game_info.map_width = MapSizeX();
|
||||
_network_game_info.map_height = MapSizeY();
|
||||
_network_game_info.landscape = _settings_game.game_creation.landscape;
|
||||
@@ -234,7 +233,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
|
||||
/* NETWORK_GAME_INFO_VERSION = 2 */
|
||||
p->Send_uint8 (info->companies_max);
|
||||
p->Send_uint8 (info->companies_on);
|
||||
p->Send_uint8 (info->spectators_max);
|
||||
p->Send_uint8 (info->clients_max); // Used to be max-spectators
|
||||
|
||||
/* NETWORK_GAME_INFO_VERSION = 1 */
|
||||
p->Send_string(info->server_name);
|
||||
@@ -331,7 +330,7 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo
|
||||
case 2:
|
||||
info->companies_max = p->Recv_uint8 ();
|
||||
info->companies_on = p->Recv_uint8 ();
|
||||
info->spectators_max = p->Recv_uint8 ();
|
||||
p->Recv_uint8(); // Used to contain max-spectators.
|
||||
FALLTHROUGH;
|
||||
|
||||
case 1:
|
||||
|
@@ -105,7 +105,6 @@ struct NetworkServerGameInfo {
|
||||
byte companies_on; ///< How many started companies do we have
|
||||
byte companies_max; ///< Max companies allowed on server
|
||||
byte spectators_on; ///< How many spectators do we have?
|
||||
byte spectators_max; ///< Max spectators allowed on server
|
||||
byte landscape; ///< The used landscape
|
||||
int gamescript_version; ///< Version of the gamescript.
|
||||
std::string gamescript_name; ///< Name of the gamescript.
|
||||
|
@@ -314,8 +314,6 @@ static std::string _password_server_id;
|
||||
|
||||
/** Maximum number of companies of the currently joined server. */
|
||||
static uint8 _network_server_max_companies;
|
||||
/** Maximum number of spectators of the currently joined server. */
|
||||
static uint8 _network_server_max_spectators;
|
||||
|
||||
/** Information about the game to join to. */
|
||||
NetworkJoinInfo _network_join;
|
||||
@@ -1189,7 +1187,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(P
|
||||
if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
_network_server_max_companies = p->Recv_uint8();
|
||||
_network_server_max_spectators = p->Recv_uint8();
|
||||
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
@@ -1406,12 +1403,3 @@ bool NetworkMaxCompaniesReached()
|
||||
{
|
||||
return Company::GetNumItems() >= (_network_server ? _settings_client.network.max_companies : _network_server_max_companies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if max_spectatos has been reached on the server (local check only).
|
||||
* @return true if the max value has been reached or exceeded, false otherwise.
|
||||
*/
|
||||
bool NetworkMaxSpectatorsReached()
|
||||
{
|
||||
return NetworkSpectatorCount() >= (_network_server ? _settings_client.network.max_spectators : _network_server_max_spectators);
|
||||
}
|
||||
|
@@ -60,7 +60,6 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const
|
||||
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
||||
bool NetworkCompanyIsPassworded(CompanyID company_id);
|
||||
bool NetworkMaxCompaniesReached();
|
||||
bool NetworkMaxSpectatorsReached();
|
||||
void NetworkPrintClients();
|
||||
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
|
||||
|
||||
|
@@ -1033,10 +1033,6 @@ struct NetworkStartServerWindow : public Window {
|
||||
case WID_NSS_COMPANIES_TXT:
|
||||
SetDParam(0, _settings_client.network.max_companies);
|
||||
break;
|
||||
|
||||
case WID_NSS_SPECTATORS_TXT:
|
||||
SetDParam(0, _settings_client.network.max_spectators);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1079,7 +1075,6 @@ struct NetworkStartServerWindow : public Window {
|
||||
|
||||
case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU: // Click on up/down button for number of clients
|
||||
case WID_NSS_COMPANIES_BTND: case WID_NSS_COMPANIES_BTNU: // Click on up/down button for number of companies
|
||||
case WID_NSS_SPECTATORS_BTND: case WID_NSS_SPECTATORS_BTNU: // Click on up/down button for number of spectators
|
||||
/* Don't allow too fast scrolling. */
|
||||
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
|
||||
this->HandleButtonClick(widget);
|
||||
@@ -1092,9 +1087,6 @@ struct NetworkStartServerWindow : public Window {
|
||||
case WID_NSS_COMPANIES_BTND: case WID_NSS_COMPANIES_BTNU:
|
||||
_settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - WID_NSS_COMPANIES_TXT, 1, MAX_COMPANIES);
|
||||
break;
|
||||
case WID_NSS_SPECTATORS_BTND: case WID_NSS_SPECTATORS_BTNU:
|
||||
_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - WID_NSS_SPECTATORS_TXT, 0, MAX_CLIENTS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_left_button_clicked = false;
|
||||
@@ -1112,12 +1104,6 @@ struct NetworkStartServerWindow : public Window {
|
||||
ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, 3, this, CS_NUMERAL, QSF_NONE);
|
||||
break;
|
||||
|
||||
case WID_NSS_SPECTATORS_TXT: // Click on number of spectators
|
||||
this->widget_id = WID_NSS_SPECTATORS_TXT;
|
||||
SetDParam(0, _settings_client.network.max_spectators);
|
||||
ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, 4, this, CS_NUMERAL, QSF_NONE);
|
||||
break;
|
||||
|
||||
case WID_NSS_GENERATE_GAME: // Start game
|
||||
if (!CheckServerName()) return;
|
||||
_is_network_server = true;
|
||||
@@ -1172,7 +1158,7 @@ struct NetworkStartServerWindow : public Window {
|
||||
|
||||
void OnTimeout() override
|
||||
{
|
||||
static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WID_NSS_SPECTATORS_BTND, WID_NSS_SPECTATORS_BTNU, WIDGET_LIST_END};
|
||||
static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WIDGET_LIST_END};
|
||||
for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
|
||||
if (this->IsWidgetLowered(*widget)) {
|
||||
this->RaiseWidget(*widget);
|
||||
@@ -1194,7 +1180,6 @@ struct NetworkStartServerWindow : public Window {
|
||||
default: NOT_REACHED();
|
||||
case WID_NSS_CLIENTS_TXT: _settings_client.network.max_clients = Clamp(value, 2, MAX_CLIENTS); break;
|
||||
case WID_NSS_COMPANIES_TXT: _settings_client.network.max_companies = Clamp(value, 1, MAX_COMPANIES); break;
|
||||
case WID_NSS_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1246,15 +1231,6 @@ static const NWidgetPart _nested_network_start_server_window_widgets[] = {
|
||||
NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, STR_NULL),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SPECTATORS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
|
||||
NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* 'generate game' and 'load game' buttons */
|
||||
@@ -1369,8 +1345,6 @@ struct NetworkLobbyWindow : public Window {
|
||||
this->SetWidgetDisabledState(WID_NL_JOIN, this->company == INVALID_COMPANY || GetLobbyCompanyInfo(this->company)->ai);
|
||||
/* Cannot start new company if there are too many. */
|
||||
this->SetWidgetDisabledState(WID_NL_NEW, gi->companies_on >= gi->companies_max);
|
||||
/* Cannot spectate if there are too many spectators. */
|
||||
this->SetWidgetDisabledState(WID_NL_SPECTATE, gi->spectators_on >= gi->spectators_max);
|
||||
|
||||
this->vscroll->SetCount(gi->companies_on);
|
||||
|
||||
|
@@ -820,7 +820,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendConfigUpdate()
|
||||
Packet *p = new Packet(PACKET_SERVER_CONFIG_UPDATE);
|
||||
|
||||
p->Send_uint8(_settings_client.network.max_companies);
|
||||
p->Send_uint8(_settings_client.network.max_spectators);
|
||||
this->SendPacket(p);
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
@@ -890,9 +889,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
||||
}
|
||||
break;
|
||||
case COMPANY_SPECTATOR: // Spectator
|
||||
if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
|
||||
return this->SendError(NETWORK_ERROR_FULL);
|
||||
}
|
||||
break;
|
||||
default: // Join another company (companies 1-8 (index 0-7))
|
||||
if (!Company::IsValidHumanID(playas)) {
|
||||
|
Reference in New Issue
Block a user