X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=000992012cb38657d255a7f4e9bdd9f6d34644fb;hb=bb33b871657d1af6beda881e33b536512815aa9b;hp=34c53f77c97c76deb60b5cf7c1cfc0b993dc8d17;hpb=20e58eb6573a45a41c25958e17e8d9c20f738edc;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index 34c53f77..00099201 100644 --- a/src/files.c +++ b/src/files.c @@ -116,11 +116,6 @@ static void SaveUserLevelInfo(); /* for 'InitUserLevelDir()' */ static char *getSetupLine(char *, int); /* for 'SaveUserLevelInfo()' */ -static char *getGlobalDataDir() -{ - return GAME_DIR; -} - char *getUserDataDir() { static char *userdata_dir = NULL; @@ -178,7 +173,7 @@ static char *getTapeDir(char *level_subdir) static char *getScoreDir(char *level_subdir) { static char *score_dir = NULL; - char *data_dir = getGlobalDataDir(); + char *data_dir = options.rw_base_directory; char *score_subdir = SCORES_DIRECTORY; if (score_dir) @@ -832,15 +827,15 @@ void LoadScore(int level_nr) fscanf(file, "%d", &highscore[i].Score); fgets(line, MAX_LINE_LEN, file); - if (line[strlen(line)-1] == '\n') - line[strlen(line)-1] = '\0'; + if (line[strlen(line) - 1] == '\n') + line[strlen(line) - 1] = '\0'; for (line_ptr = line; *line_ptr; line_ptr++) { if (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0') { - strncpy(highscore[i].Name, line_ptr, MAX_NAMELEN - 1); - highscore[i].Name[MAX_NAMELEN - 1] = '\0'; + strncpy(highscore[i].Name, line_ptr, MAX_PLAYER_NAME_LEN); + highscore[i].Name[MAX_PLAYER_NAME_LEN] = '\0'; break; } } @@ -1577,11 +1572,11 @@ void LoadSetup() freeSetupFileList(setup_file_list); /* needed to work around problems with fixed length strings */ - if (strlen(setup.player_name) >= MAX_NAMELEN) - setup.player_name[MAX_NAMELEN - 1] = '\0'; - else if (strlen(setup.player_name) < MAX_NAMELEN - 1) + if (strlen(setup.player_name) > MAX_PLAYER_NAME_LEN) + setup.player_name[MAX_PLAYER_NAME_LEN] = '\0'; + else if (strlen(setup.player_name) < MAX_PLAYER_NAME_LEN) { - char *new_name = checked_malloc(MAX_NAMELEN); + char *new_name = checked_malloc(MAX_PLAYER_NAME_LEN + 1); strcpy(new_name, setup.player_name); free(setup.player_name);