summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-04-20 16:51:15 +0200
committerPatric Stout <github@truebrain.nl>2021-04-20 17:24:38 +0200
commit05612d60ae0af94b9313d5a8b78ebf58a3eeab66 (patch)
tree6f84698665d5931520d41ef23117e4013c575e10 /src/network
parentf4bd3fff5ebfdd7c58ccaf23977b8447c740b48a (diff)
downloadopenttd-05612d60ae0af94b9313d5a8b78ebf58a3eeab66.tar.xz
Remove: "language" field from server/client
The original idea was that people could find a server they could talk in their native language on. This isn't really used in that way. There are several reasons for removing this: - the client also sends his "language" to the server, but nothing is doing anything with this. - flags are a bad way to represent languages, and over the years we had several (rightfully) complaints about this. - most servers have their language set to "All", and prefix the servername with the language it is about. This is a much more efficient way to do the same. All in all, this feature should go back to the drawing board. Maybe it could work in another form, but this form is not it.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/config.h2
-rw-r--r--src/network/core/game.h1
-rw-r--r--src/network/core/udp.cpp7
-rw-r--r--src/network/network_admin.cpp2
-rw-r--r--src/network/network_base.h1
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_gui.cpp44
-rw-r--r--src/network/network_internal.h41
-rw-r--r--src/network/network_server.cpp3
-rw-r--r--src/network/network_udp.cpp1
10 files changed, 5 insertions, 99 deletions
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 3488b1ff2..1483419ea 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -57,8 +57,6 @@ static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum l
*/
static const uint NETWORK_MAX_GRF_COUNT = 62;
-static const uint NETWORK_NUM_LANGUAGES = 36; ///< Number of known languages (to the network protocol) + 1 for 'any'.
-
/**
* The number of landscapes in OpenTTD.
* This number must be equal to NUM_LANDSCAPE, but as this number is used
diff --git a/src/network/core/game.h b/src/network/core/game.h
index 0a10cfb1f..29eca418f 100644
--- a/src/network/core/game.h
+++ b/src/network/core/game.h
@@ -42,7 +42,6 @@ struct NetworkGameInfo : NetworkServerGameInfo {
bool compatible; ///< Can we connect to this server or not? (based on server_revision _and_ grf_match
bool use_password; ///< Is this server passworded?
byte game_info_version; ///< Version of the game info
- byte server_lang; ///< Language of the server (we should make a nice table for this)
byte clients_max; ///< Max clients allowed on server
byte companies_on; ///< How many started companies do we have
byte companies_max; ///< Max companies allowed on server
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 985c8fa72..72fec49e1 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -200,7 +200,7 @@ void NetworkUDPSocketHandler::SendNetworkGameInfo(Packet *p, const NetworkGameIn
/* NETWORK_GAME_INFO_VERSION = 1 */
p->Send_string(info->server_name);
p->Send_string(info->server_revision);
- p->Send_uint8 (info->server_lang);
+ p->Send_uint8 (0); // Used to be server-lang.
p->Send_bool (info->use_password);
p->Send_uint8 (info->clients_max);
p->Send_uint8 (info->clients_on);
@@ -266,7 +266,7 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo
case 1:
p->Recv_string(info->server_name, sizeof(info->server_name));
p->Recv_string(info->server_revision, sizeof(info->server_revision));
- info->server_lang = p->Recv_uint8 ();
+ p->Recv_uint8 (); // Used to contain server-lang.
info->use_password = p->Recv_bool ();
info->clients_max = p->Recv_uint8 ();
info->clients_on = p->Recv_uint8 ();
@@ -281,8 +281,7 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo
info->map_set = p->Recv_uint8 ();
info->dedicated = p->Recv_bool ();
- if (info->server_lang >= NETWORK_NUM_LANGUAGES) info->server_lang = 0;
- if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
+ if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
}
}
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 825acfed1..fa97b7e57 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -238,7 +238,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkC
p->Send_uint32(ci->client_id);
p->Send_string(cs == nullptr ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
p->Send_string(ci->client_name);
- p->Send_uint8 (ci->client_lang);
+ p->Send_uint8 (0); // Used to be language
p->Send_uint32(ci->join_date);
p->Send_uint8 (ci->client_playas);
diff --git a/src/network/network_base.h b/src/network/network_base.h
index cbb7e88f2..15f410dbc 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -23,7 +23,6 @@ extern NetworkClientInfoPool _networkclientinfo_pool;
struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
ClientID client_id; ///< Client identifier (same as ClientState->client_id)
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< Name of the client
- byte client_lang; ///< The language of the client
CompanyID client_playas; ///< As which company is this client playing (CompanyID)
Date join_date; ///< Gamedate the client has joined
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index cd1904269..5858859cb 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -362,7 +362,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin()
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 (NETLANG_ANY); // Language
+ p->Send_uint8 (0); // Used to be language
my_client->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;
}
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 591a45ae9..78b0d9dfc 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -56,20 +56,6 @@ static const StringID _connection_types_dropdown[] = {
INVALID_STRING_ID
};
-static std::vector<StringID> _language_dropdown;
-
-void SortNetworkLanguages()
-{
- /* Init the strings */
- if (_language_dropdown.empty()) {
- for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown.emplace_back(STR_NETWORK_LANG_ANY + i);
- _language_dropdown.emplace_back(INVALID_STRING_ID);
- }
-
- /* Sort the strings (we don't move 'any' and the 'invalid' one) */
- std::sort(_language_dropdown.begin() + 1, _language_dropdown.end() - 1, StringIDSorter);
-}
-
/**
* Update the network new window because a new server is
* found on the network.
@@ -430,9 +416,6 @@ protected:
/* draw red or green icon, depending on compatibility with server */
DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset + 1);
-
- /* draw flag according to server language */
- DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + this->flag_offset, y + (this->resize.step_height - GetSpriteSize(SPR_FLAGS_BASE + cur_item->info.server_lang).height) / 2);
}
}
@@ -638,10 +621,6 @@ public:
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CLIENTS);
y += FONT_HEIGHT_NORMAL;
- SetDParam(0, STR_NETWORK_LANG_ANY + sel->info.server_lang);
- DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANGUAGE); // server language
- y += FONT_HEIGHT_NORMAL;
-
SetDParam(0, STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE + sel->info.map_set);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
y += FONT_HEIGHT_NORMAL;
@@ -1054,10 +1033,6 @@ struct NetworkStartServerWindow : public Window {
case WID_NSS_SPECTATORS_TXT:
SetDParam(0, _settings_client.network.max_spectators);
break;
-
- case WID_NSS_LANGUAGE_BTN:
- SetDParam(0, STR_NETWORK_LANG_ANY + _settings_client.network.server_lang);
- break;
}
}
@@ -1139,18 +1114,6 @@ struct NetworkStartServerWindow : public Window {
ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, 4, this, CS_NUMERAL, QSF_NONE);
break;
- case WID_NSS_LANGUAGE_BTN: { // Language
- uint sel = 0;
- for (uint i = 0; i < _language_dropdown.size() - 1; i++) {
- if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
- sel = i;
- break;
- }
- }
- ShowDropDownMenu(this, _language_dropdown.data(), sel, WID_NSS_LANGUAGE_BTN, 0, 0);
- break;
- }
-
case WID_NSS_GENERATE_GAME: // Start game
_is_network_server = true;
if (_ctrl_pressed) {
@@ -1183,9 +1146,6 @@ struct NetworkStartServerWindow : public Window {
case WID_NSS_CONNTYPE_BTN:
_settings_client.network.server_advertise = (index != 0);
break;
- case WID_NSS_LANGUAGE_BTN:
- _settings_client.network.server_lang = _language_dropdown[index] - STR_NETWORK_LANG_ANY;
- break;
default:
NOT_REACHED();
}
@@ -1253,10 +1213,6 @@ static const NWidgetPart _nested_network_start_server_window_widgets[] = {
NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_CONNTYPE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_ADVERTISED_TOOLTIP),
EndContainer(),
NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
- NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_LANGUAGE_SPOKEN, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_LANGUAGE_TOOLTIP),
- EndContainer(),
- NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
NWidget(NWID_SPACER), SetFill(1, 1),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_SETPWD), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SET_PASSWORD, STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP),
EndContainer(),
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index 290922f38..352416320 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -62,47 +62,6 @@ enum NetworkJoinStatus {
NETWORK_JOIN_STATUS_END,
};
-/** Language ids for server_lang and client_lang. Do NOT modify the order. */
-enum NetworkLanguage {
- NETLANG_ANY = 0,
- NETLANG_ENGLISH,
- NETLANG_GERMAN,
- NETLANG_FRENCH,
- NETLANG_BRAZILIAN,
- NETLANG_BULGARIAN,
- NETLANG_CHINESE,
- NETLANG_CZECH,
- NETLANG_DANISH,
- NETLANG_DUTCH,
- NETLANG_ESPERANTO,
- NETLANG_FINNISH,
- NETLANG_HUNGARIAN,
- NETLANG_ICELANDIC,
- NETLANG_ITALIAN,
- NETLANG_JAPANESE,
- NETLANG_KOREAN,
- NETLANG_LITHUANIAN,
- NETLANG_NORWEGIAN,
- NETLANG_POLISH,
- NETLANG_PORTUGUESE,
- NETLANG_ROMANIAN,
- NETLANG_RUSSIAN,
- NETLANG_SLOVAK,
- NETLANG_SLOVENIAN,
- NETLANG_SPANISH,
- NETLANG_SWEDISH,
- NETLANG_TURKISH,
- NETLANG_UKRAINIAN,
- NETLANG_AFRIKAANS,
- NETLANG_CROATIAN,
- NETLANG_CATALAN,
- NETLANG_ESTONIAN,
- NETLANG_GALICIAN,
- NETLANG_GREEK,
- NETLANG_LATVIAN,
- NETLANG_COUNT
-};
-
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
extern uint32 _frame_counter_max; // To where we may go with our clients
extern uint32 _frame_counter;
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 86885d598..552171027 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -910,7 +910,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
char name[NETWORK_CLIENT_NAME_LENGTH];
CompanyID playas;
- NetworkLanguage client_lang;
char client_revision[NETWORK_REVISION_LENGTH];
p->Recv_string(client_revision, sizeof(client_revision));
@@ -924,7 +923,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
p->Recv_string(name, sizeof(name));
playas = (Owner)p->Recv_uint8();
- client_lang = (NetworkLanguage)p->Recv_uint8();
if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
@@ -961,7 +959,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
ci->join_date = _date;
strecpy(ci->client_name, name, lastof(ci->client_name));
ci->client_playas = playas;
- ci->client_lang = client_lang;
DEBUG(desync, 1, "client: %08x; %02x; %02x; %02x", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
/* Make sure companies to which people try to join are not autocleaned */
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 5b150c45a..46a21fc87 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -176,7 +176,6 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, Networ
ngi.clients_on = _network_game_info.clients_on;
ngi.start_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
- ngi.server_lang = _settings_client.network.server_lang;
ngi.use_password = !StrEmpty(_settings_client.network.server_password);
ngi.clients_max = _settings_client.network.max_clients;
ngi.companies_on = (byte)Company::GetNumItems();