Change to more reliable way to access username on posix

This commit is contained in:
Alexander Overvoorde 2016-02-10 21:58:06 +01:00
parent 75b072d266
commit 4f0fc1065b
1 changed files with 3 additions and 4 deletions

View File

@ -43,7 +43,6 @@
#include <time.h>
#include <fts.h>
#include <sys/file.h>
#include <unistd.h>
// The name of the mutex used to prevent multiple instances of the game from running
#define SINGLE_INSTANCE_MUTEX_NAME "openrct2.lock"
@ -878,10 +877,10 @@ datetime64 platform_get_datetime_now_utc()
}
utf8* platform_get_username() {
char* username = getlogin();
struct passwd* pw = getpwuid(getuid());
if (username) {
return username;
if (pw) {
return pw->pw_name;
} else {
return "Player";
}