Move fallback name logic out of platform_get_username

This commit is contained in:
Alexander Overvoorde 2016-02-12 00:31:23 +01:00
parent 65f25f8340
commit 05c1aabc39
3 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;