diff --git a/src/config.c b/src/config.c index f9ae7d5ac9..992a2f29ce 100644 --- a/src/config.c +++ b/src/config.c @@ -375,7 +375,13 @@ void config_set_defaults() destValue->value_uint8 = platform_get_locale_temperature_format(); } else if (strcmp(property->property_name, "player_name") == 0) { - destValue->value_string = _strdup(platform_get_username()); + utf8* username = platform_get_username(); + + if (username) { + destValue->value_string = _strdup(username); + } else { + destValue->value_string = _strdup(language_get_string(STR_PLAYER_DEFAULT_NAME)); + } } else { // Use static default diff --git a/src/platform/posix.c b/src/platform/posix.c index d683164229..850ad1df5a 100644 --- a/src/platform/posix.c +++ b/src/platform/posix.c @@ -33,7 +33,6 @@ #include "../addresses.h" #include "../config.h" #include "../localisation/language.h" -#include "../localisation/string_ids.h" #include "../openrct2.h" #include "../util/util.h" #include "platform.h" @@ -883,7 +882,7 @@ utf8* platform_get_username() { if (pw) { return pw->pw_name; } else { - return language_get_string(STR_PLAYER_DEFAULT_NAME); + return NULL; } } diff --git a/src/platform/windows.c b/src/platform/windows.c index f27e2b563c..31c8fc7fd5 100644 --- a/src/platform/windows.c +++ b/src/platform/windows.c @@ -31,7 +31,6 @@ #include "../addresses.h" #include "../openrct2.h" #include "../localisation/language.h" -#include "../localisation/string_ids.h" #include "../util/util.h" #include "../config.h" #include "platform.h" @@ -982,7 +981,7 @@ utf8* platform_get_username() { DWORD usernameLength = UNLEN + 1; if (!GetUserName(username, &usernameLength)) { - strcpy(username, language_get_string(STR_PLAYER_DEFAULT_NAME)); + return NULL; } return username;