Changeset - r25198:a701a159e9ab
[Not reviewed]
master
0 16 0
Patric Stout - 3 years ago 2021-04-20 14:51:15
truebrain@openttd.org
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.
16 files changed with 5 insertions and 157 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2070,46 +2070,6 @@ STR_NETWORK_START_SERVER_LANGUAGE_TOOLTI
 

	
 
STR_NETWORK_START_SERVER_NEW_GAME_NAME_OSKTITLE                 :{BLACK}Enter a name for the network game
 

	
 
# Network game languages
 
############ Leave those lines in this order!!
 
STR_NETWORK_LANG_ANY                                            :Any
 
STR_NETWORK_LANG_ENGLISH                                        :English
 
STR_NETWORK_LANG_GERMAN                                         :German
 
STR_NETWORK_LANG_FRENCH                                         :French
 
STR_NETWORK_LANG_BRAZILIAN                                      :Brazilian
 
STR_NETWORK_LANG_BULGARIAN                                      :Bulgarian
 
STR_NETWORK_LANG_CHINESE                                        :Chinese
 
STR_NETWORK_LANG_CZECH                                          :Czech
 
STR_NETWORK_LANG_DANISH                                         :Danish
 
STR_NETWORK_LANG_DUTCH                                          :Dutch
 
STR_NETWORK_LANG_ESPERANTO                                      :Esperanto
 
STR_NETWORK_LANG_FINNISH                                        :Finnish
 
STR_NETWORK_LANG_HUNGARIAN                                      :Hungarian
 
STR_NETWORK_LANG_ICELANDIC                                      :Icelandic
 
STR_NETWORK_LANG_ITALIAN                                        :Italian
 
STR_NETWORK_LANG_JAPANESE                                       :Japanese
 
STR_NETWORK_LANG_KOREAN                                         :Korean
 
STR_NETWORK_LANG_LITHUANIAN                                     :Lithuanian
 
STR_NETWORK_LANG_NORWEGIAN                                      :Norwegian
 
STR_NETWORK_LANG_POLISH                                         :Polish
 
STR_NETWORK_LANG_PORTUGUESE                                     :Portuguese
 
STR_NETWORK_LANG_ROMANIAN                                       :Romanian
 
STR_NETWORK_LANG_RUSSIAN                                        :Russian
 
STR_NETWORK_LANG_SLOVAK                                         :Slovak
 
STR_NETWORK_LANG_SLOVENIAN                                      :Slovenian
 
STR_NETWORK_LANG_SPANISH                                        :Spanish
 
STR_NETWORK_LANG_SWEDISH                                        :Swedish
 
STR_NETWORK_LANG_TURKISH                                        :Turkish
 
STR_NETWORK_LANG_UKRAINIAN                                      :Ukrainian
 
STR_NETWORK_LANG_AFRIKAANS                                      :Afrikaans
 
STR_NETWORK_LANG_CROATIAN                                       :Croatian
 
STR_NETWORK_LANG_CATALAN                                        :Catalan
 
STR_NETWORK_LANG_ESTONIAN                                       :Estonian
 
STR_NETWORK_LANG_GALICIAN                                       :Galician
 
STR_NETWORK_LANG_GREEK                                          :Greek
 
STR_NETWORK_LANG_LATVIAN                                        :Latvian
 
############ End of leave-in-this-order
 

	
 
# Network game lobby
 
STR_NETWORK_GAME_LOBBY_CAPTION                                  :{WHITE}Multiplayer game lobby
 

	
src/network/core/config.h
Show inline comments
 
@@ -57,8 +57,6 @@ static const uint NETWORK_GRF_NAME_LENGT
 
 */
 
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
src/network/core/game.h
Show inline comments
 
@@ -42,7 +42,6 @@ struct NetworkGameInfo : NetworkServerGa
 
	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
src/network/core/udp.cpp
Show inline comments
 
@@ -200,7 +200,7 @@ void NetworkUDPSocketHandler::SendNetwor
 
	/* 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::ReceiveNet
 
		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::ReceiveNet
 
			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;
 
	}
 
}
 

	
src/network/network_admin.cpp
Show inline comments
 
@@ -238,7 +238,7 @@ NetworkRecvStatus ServerNetworkAdminSock
 
	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);
 

	
src/network/network_base.h
Show inline comments
 
@@ -23,7 +23,6 @@ extern NetworkClientInfoPool _networkcli
 
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
 

	
src/network/network_client.cpp
Show inline comments
 
@@ -362,7 +362,7 @@ NetworkRecvStatus ClientNetworkGameSocke
 
	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;
 
}
src/network/network_gui.cpp
Show inline comments
 
@@ -56,20 +56,6 @@ static const StringID _connection_types_
 
	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
 
			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
 
				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
 
			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
 
					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(),
src/network/network_internal.h
Show inline comments
 
@@ -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;
src/network/network_server.cpp
Show inline comments
 
@@ -910,7 +910,6 @@ NetworkRecvStatus ServerNetworkGameSocke
 

	
 
	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 ServerNetworkGameSocke
 

	
 
	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 ServerNetworkGameSocke
 
	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 */
src/network/network_udp.cpp
Show inline comments
 
@@ -176,7 +176,6 @@ void ServerNetworkUDPSocketHandler::Rece
 
	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();
src/settings_type.h
Show inline comments
 
@@ -280,7 +280,6 @@ struct NetworkSettings {
 
	uint8  max_spectators;                                ///< maximum amount of spectators
 
	Year   restart_game_year;                             ///< year the server restarts
 
	uint8  min_active_clients;                            ///< minimum amount of active clients to unpause the game
 
	uint8  server_lang;                                   ///< language of the server
 
	bool   reload_cfg;                                    ///< reload the config file before restarting
 
	char   last_host[NETWORK_HOSTNAME_LENGTH];            ///< IP address of the last joined server
 
	uint16 last_port;                                     ///< port of the last joined server
src/strings.cpp
Show inline comments
 
@@ -1695,8 +1695,6 @@ static char *GetSpecialNameString(char *
 
	NOT_REACHED();
 
}
 

	
 
extern void SortNetworkLanguages();
 

	
 
/**
 
 * Check whether the header is a valid header for OpenTTD.
 
 * @return true iff the header is deemed valid.
 
@@ -1813,7 +1811,6 @@ bool ReadLanguagePack(const LanguageMeta
 
	InitializeSortedCargoSpecs();
 
	SortIndustryTypes();
 
	BuildIndustriesLegend();
 
	SortNetworkLanguages();
 
	BuildContentTypeStringList();
 
	InvalidateWindowClassesData(WC_BUILD_VEHICLE);      // Build vehicle window.
 
	InvalidateWindowClassesData(WC_TRAINS_LIST);        // Train group window.
src/table/gameopt_settings.ini
Show inline comments
 
@@ -19,7 +19,6 @@ static const char *_climates = "temperat
 
static const char *_autosave_interval = "off|monthly|quarterly|half year|yearly";
 
static const char *_roadsides = "left|right";
 
static const char *_savegame_date = "long|short|iso";
 
static const char *_server_langs = "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN";
 
static const char *_osk_activation = "disabled|double|single|immediately";
 
static const char *_settings_profiles = "easy|medium|hard";
 
static const char *_news_display = "off|summarized|full";
src/table/settings.ini
Show inline comments
 
@@ -4061,16 +4061,6 @@ def      = 0
 
min      = 0
 
max      = MAX_CLIENTS
 

	
 
[SDTC_OMANY]
 
var      = network.server_lang
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 0
 
max      = 35
 
full     = _server_langs
 
cat      = SC_BASIC
 

	
 
[SDTC_BOOL]
 
var      = network.reload_cfg
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
src/widgets/network_widget.h
Show inline comments
 
@@ -71,9 +71,6 @@ enum NetworkStartServerWidgets {
 
	WID_NSS_SPECTATORS_TXT,    ///< 'Max spectators' text.
 
	WID_NSS_SPECTATORS_BTNU,   ///< 'Max spectators' uparrow.
 

	
 
	WID_NSS_LANGUAGE_LABEL,    ///< Label for 'language spoken'.
 
	WID_NSS_LANGUAGE_BTN,      ///< 'Language spoken' droplist button.
 

	
 
	WID_NSS_GENERATE_GAME,     ///< New game button.
 
	WID_NSS_LOAD_GAME,         ///< Load game button.
 
	WID_NSS_PLAY_SCENARIO,     ///< Play scenario button.
0 comments (0 inline, 0 general)