--- src/attractmanager.c.orig 2019-01-31 01:36:24.130902037 +0100 +++ src/attractmanager.c 2019-01-31 01:40:17.155922935 +0100 @@ -31,10 +31,29 @@ static HiScore hiScore; -#define PREF_FILE "noiz2sa.prf" +#define PREF_FILE pref_file_path() #define DEFAULT_HISCORE 100000 #define DEFAULT_SCENE_HISCORE 10000 +static const char* pref_file_path(void) { + static int initialized = 0; + char file_path[256] = { '\0', }; + + if (!initialized) { + const char *homedir = getenv("HOME"); + if (homedir) { + strcat(file_path, homedir); + strcat(file_path, "/.noiz2sa.prf"); + } else { + strcat(file_path, "/tmp/noiz2sa.prf"); + } + + initialized = 1; + } + + return file_path; +} + static void initHiScore() { int i, j; for ( i=0 ; i