mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 10:51:58 -05:00
Merge pull request #5777 from Keatzee/fix-4301
Fix #4301: Remove leading/trailing whitespace from playername
This commit is contained in:
commit
52372b7429
4 changed files with 14 additions and 9 deletions
|
@ -10,6 +10,7 @@
|
|||
- Fix: [#5920] Placing guest spawn doesn't do anything every 3rd click
|
||||
- Fix: [#5939] Crash when importing 'Six Flags Santa Fe'.
|
||||
- Improved: The land tool buttons can now be held down to increase/decrease size.
|
||||
- Improved: [#4301] Leading and trailing whitespace in player name is now removed.
|
||||
- Improved: [#5859] OpenGL rendering performance
|
||||
- Improved: [#5863] Switching drawing engines no longer requires the application to restart.
|
||||
|
||||
|
|
|
@ -347,18 +347,22 @@ namespace Config
|
|||
{
|
||||
// If the `player_name` setting is missing or equal to the empty string
|
||||
// use the logged-in user's username instead
|
||||
utf8* playerName = reader->GetCString("player_name", "");
|
||||
if (String::IsNullOrEmpty(playerName))
|
||||
auto playerName = reader->GetString("player_name", "");
|
||||
if (playerName.empty())
|
||||
{
|
||||
playerName = String::Duplicate(platform_get_username());
|
||||
if (playerName == nullptr)
|
||||
playerName = String::ToStd(platform_get_username());
|
||||
if (playerName.empty())
|
||||
{
|
||||
playerName = String::Duplicate("Player");
|
||||
playerName = "Player";
|
||||
}
|
||||
}
|
||||
|
||||
// Trim any whitespace before or after the player's name,
|
||||
// to avoid people pretending to be someone else
|
||||
playerName = String::Trim(playerName);
|
||||
|
||||
auto model = &gConfigNetwork;
|
||||
model->player_name = playerName;
|
||||
model->player_name = String::Duplicate(playerName);
|
||||
model->default_port = reader->GetSint32("default_port", NETWORK_DEFAULT_PORT);
|
||||
model->listen_address = reader->GetCString("listen_address", "");
|
||||
model->default_password = reader->GetCString("default_password", nullptr);
|
||||
|
|
|
@ -1478,7 +1478,7 @@ NetworkPlayer* Network::AddPlayer(const utf8 *name, const std::string &keyhash)
|
|||
if (networkUser == nullptr) {
|
||||
player->Group = GetDefaultGroup();
|
||||
if (!String::IsNullOrEmpty(name)) {
|
||||
player->SetName(MakePlayerNameUnique(std::string(name)));
|
||||
player->SetName(MakePlayerNameUnique(String::Trim(std::string(name))));
|
||||
}
|
||||
} else {
|
||||
player->Group = networkUser->GroupId.GetValueOrDefault(GetDefaultGroup());
|
||||
|
@ -1488,7 +1488,7 @@ NetworkPlayer* Network::AddPlayer(const utf8 *name, const std::string &keyhash)
|
|||
player = std::unique_ptr<NetworkPlayer>(new NetworkPlayer); // change to make_unique in c++14
|
||||
player->Id = newid;
|
||||
player->Group = GetDefaultGroup();
|
||||
player->SetName(name);
|
||||
player->SetName(String::Trim(std::string(name)));
|
||||
}
|
||||
|
||||
addedplayer = player.get();
|
||||
|
|
|
@ -55,7 +55,7 @@ extern "C" {
|
|||
// This define specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "4"
|
||||
#define NETWORK_STREAM_VERSION "5"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Add table
Reference in a new issue