mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Move fallback name logic out of platform_get_username
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user