#include "tape.h"
#include "joystick.h"
+#define MAX_LINE_LEN 1000
+
+static char *getGlobalDataDir()
+{
+ return GAME_DIR;
+}
+
+static char *getUserDataDir()
+{
+ static char *userdata_dir = NULL;
+
+ if (!userdata_dir)
+ {
+ char *home_dir = getHomeDir();
+ char *data_dir = USERDATA_DIRECTORY;
+
+ userdata_dir = checked_malloc(strlen(home_dir) + strlen(data_dir) + 2);
+ sprintf(userdata_dir, "%s/%s", home_dir, data_dir);
+ }
+
+ return userdata_dir;
+}
+
+static char *getSetupDir()
+{
+ return getUserDataDir();
+}
+
+static char *getTapeDir(char *level_subdir)
+{
+ static char *tape_dir = NULL;
+ char *data_dir = getUserDataDir();
+ char *tape_subdir = TAPES_DIRECTORY;
+
+ if (tape_dir)
+ free(tape_dir);
+
+ tape_dir = checked_malloc(strlen(data_dir) + strlen(tape_subdir) +
+ strlen(level_subdir) + 3);
+ sprintf(tape_dir, "%s/%s%s%s", data_dir, tape_subdir,
+ (strlen(level_subdir) > 0 ? "/" : ""), level_subdir);
+
+ return tape_dir;
+}
+
+static char *getScoreDir(char *level_subdir)
+{
+ static char *score_dir = NULL;
+ char *data_dir = getGlobalDataDir();
+ char *score_subdir = SCORES_DIRECTORY;
+
+ if (score_dir)
+ free(score_dir);
+
+ score_dir = checked_malloc(strlen(data_dir) + strlen(score_subdir) +
+ strlen(level_subdir) + 3);
+ sprintf(score_dir, "%s/%s%s%s", data_dir, score_subdir,
+ (strlen(level_subdir) > 0 ? "/" : ""), level_subdir);
+
+ return score_dir;
+}
+
+static void createDirectory(char *dir, char *text)
+{
+ if (access(dir, F_OK) != 0)
+ if (mkdir(dir, USERDATA_DIR_MODE) != 0)
+ Error(ERR_WARN, "cannot create %s directory '%s'", text, dir);
+}
+
+static void InitUserDataDirectory()
+{
+ createDirectory(getUserDataDir(), "user data");
+}
+
+static void InitTapeDirectory(char *level_subdir)
+{
+ createDirectory(getTapeDir(""), "main tape");
+ createDirectory(getTapeDir(level_subdir), "level tape");
+}
+
+static void InitScoreDirectory(char *level_subdir)
+{
+ createDirectory(getScoreDir(""), "main score");
+ createDirectory(getScoreDir(level_subdir), "level score");
+}
+
boolean LoadLevelInfo()
{
int i;
char cookie[MAX_FILENAME_LEN];
FILE *file;
- sprintf(filename,"%s/%s",level_directory,LEVDIR_FILENAME);
+ sprintf(filename, "%s/%s", options.level_directory, LEVDIR_FILENAME);
- if (!(file=fopen(filename,"r")))
+ if (!(file = fopen(filename, "r")))
{
Error(ERR_WARN, "cannot read level info '%s'", filename);
return(FALSE);
}
- fscanf(file,"%s\n",cookie);
- if (strcmp(cookie,LEVELDIR_COOKIE)) /* ungültiges Format? */
+ fscanf(file, "%s\n", cookie);
+ if (strcmp(cookie, LEVELDIR_COOKIE))
{
Error(ERR_WARN, "wrong format of level info file");
fclose(file);
num_leveldirs = 0;
leveldir_nr = 0;
- for(i=0;i<MAX_LEVDIR_ENTRIES;i++)
+ for(i=0; i<MAX_LEVDIR_ENTRIES; i++)
{
- fscanf(file,"%s",leveldir[i].filename);
- fscanf(file,"%s",leveldir[i].name);
- fscanf(file,"%d",&leveldir[i].levels);
- fscanf(file,"%d",&leveldir[i].readonly);
+ fscanf(file, "%s", leveldir[i].filename);
+ fscanf(file, "%s", leveldir[i].name);
+ fscanf(file, "%d", &leveldir[i].levels);
+ fscanf(file, "%d", &leveldir[i].readonly);
if (feof(file))
break;
void LoadLevel(int level_nr)
{
- int i,x,y;
+ int i, x, y;
char filename[MAX_FILENAME_LEN];
char cookie[MAX_FILENAME_LEN];
FILE *file;
- sprintf(filename,"%s/%s/%d",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
+ sprintf(filename, "%s/%s/%d",
+ options.level_directory, leveldir[leveldir_nr].filename, level_nr);
- if (!(file = fopen(filename,"r")))
+ if (!(file = fopen(filename, "r")))
Error(ERR_WARN, "cannot read level '%s' - creating new level", filename);
else
{
- fgets(cookie,LEVEL_COOKIE_LEN,file);
+ fgets(cookie, LEVEL_COOKIE_LEN, file);
fgetc(file);
- if (strcmp(cookie,LEVEL_COOKIE)) /* ungültiges Format? */
+ if (strcmp(cookie,LEVEL_COOKIE))
{
Error(ERR_WARN, "wrong format of level file '%s'", filename);
fclose(file);
level.time = (fgetc(file)<<8) | fgetc(file);
level.edelsteine = (fgetc(file)<<8) | fgetc(file);
- for(i=0;i<MAX_LEVNAMLEN;i++)
+ for(i=0; i<MAX_LEVNAMLEN; i++)
level.name[i] = fgetc(file);
level.name[MAX_LEVNAMLEN-1] = 0;
- for(i=0;i<MAX_LEVSCORE_ENTRIES;i++)
+ for(i=0; i<MAX_LEVSCORE_ENTRIES; i++)
level.score[i] = fgetc(file);
- for(i=0;i<4;i++)
- for(y=0;y<3;y++)
- for(x=0;x<3;x++)
+ for(i=0; i<4; i++)
+ for(y=0; y<3; y++)
+ for(x=0; x<3; x++)
level.mampfer_inhalt[i][x][y] = fgetc(file);
level.tempo_amoebe = fgetc(file);
level.dauer_sieb = fgetc(file);
level.dauer_ablenk = fgetc(file);
level.amoebe_inhalt = fgetc(file);
- for(i=0;i<NUM_FREE_LVHD_BYTES;i++) /* Rest frei / Headergröße 80 Bytes */
+ for(i=0; i<NUM_FREE_LVHD_BYTES; i++) /* Rest frei / Headergröße 80 Bytes */
fgetc(file);
- for(y=0;y<MAX_LEV_FIELDY;y++)
- for(x=0;x<MAX_LEV_FIELDX;x++)
+ for(y=0; y<MAX_LEV_FIELDY; y++)
+ for(x=0; x<MAX_LEV_FIELDX; x++)
Feld[x][y] = Ur[x][y] = EL_ERDREICH;
- for(y=0;y<lev_fieldy;y++)
- for(x=0;x<lev_fieldx;x++)
+ for(y=0; y<lev_fieldy; y++)
+ for(x=0; x<lev_fieldx; x++)
Feld[x][y] = Ur[x][y] = fgetc(file);
fclose(file);
- if (level.time<=10) /* Mindestspieldauer */
+ if (level.time <= 10) /* Mindestspieldauer */
level.time = 10;
}
else
level.time = 100;
level.edelsteine = 0;
- strncpy(level.name,"Nameless Level",MAX_LEVNAMLEN-1);
- for(i=0;i<MAX_LEVSCORE_ENTRIES;i++)
+ strcpy(level.name, "Nameless Level");
+ for(i=0; i<MAX_LEVSCORE_ENTRIES; i++)
level.score[i] = 10;
- for(i=0;i<4;i++)
- for(y=0;y<3;y++)
- for(x=0;x<3;x++)
+ for(i=0; i<4; i++)
+ for(y=0; y<3; y++)
+ for(x=0; x<3; x++)
level.mampfer_inhalt[i][x][y] = EL_FELSBROCKEN;
level.tempo_amoebe = 10;
level.dauer_sieb = 10;
level.dauer_ablenk = 10;
level.amoebe_inhalt = EL_DIAMANT;
- for(y=0;y<STD_LEV_FIELDY;y++)
- for(x=0;x<STD_LEV_FIELDX;x++)
+ for(y=0; y<STD_LEV_FIELDY; y++)
+ for(x=0; x<STD_LEV_FIELDX; x++)
Feld[x][y] = Ur[x][y] = EL_ERDREICH;
Feld[0][0] = Ur[0][0] = EL_SPIELFIGUR;
Feld[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] =
void SaveLevel(int level_nr)
{
- int i,x,y;
+ int i, x, y;
char filename[MAX_FILENAME_LEN];
FILE *file;
- sprintf(filename,"%s/%s/%d",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
+ sprintf(filename, "%s/%s/%d",
+ options.level_directory, leveldir[leveldir_nr].filename, level_nr);
- if (!(file=fopen(filename,"w")))
+ if (!(file = fopen(filename, "w")))
{
Error(ERR_WARN, "cannot save level file '%s'", filename);
return;
}
fputs(LEVEL_COOKIE,file); /* Formatkennung */
- fputc(0x0a,file);
-
- fputc(level.fieldx,file);
- fputc(level.fieldy,file);
- fputc(level.time / 256,file);
- fputc(level.time % 256,file);
- fputc(level.edelsteine / 256,file);
- fputc(level.edelsteine % 256,file);
-
- for(i=0;i<MAX_LEVNAMLEN;i++)
- fputc(level.name[i],file);
- for(i=0;i<MAX_LEVSCORE_ENTRIES;i++)
- fputc(level.score[i],file);
- for(i=0;i<4;i++)
- for(y=0;y<3;y++)
- for(x=0;x<3;x++)
- fputc(level.mampfer_inhalt[i][x][y],file);
- fputc(level.tempo_amoebe,file);
- fputc(level.dauer_sieb,file);
- fputc(level.dauer_ablenk,file);
- fputc(level.amoebe_inhalt,file);
-
- for(i=0;i<NUM_FREE_LVHD_BYTES;i++) /* Rest frei / Headergröße 80 Bytes */
- fputc(0,file);
-
- for(y=0;y<lev_fieldy;y++)
- for(x=0;x<lev_fieldx;x++)
- fputc(Ur[x][y],file);
+ fputc(0x0a, file);
+
+ fputc(level.fieldx, file);
+ fputc(level.fieldy, file);
+ fputc(level.time / 256, file);
+ fputc(level.time % 256, file);
+ fputc(level.edelsteine / 256, file);
+ fputc(level.edelsteine % 256, file);
+
+ for(i=0; i<MAX_LEVNAMLEN; i++)
+ fputc(level.name[i], file);
+ for(i=0; i<MAX_LEVSCORE_ENTRIES; i++)
+ fputc(level.score[i], file);
+ for(i=0; i<4; i++)
+ for(y=0; y<3; y++)
+ for(x=0; x<3; x++)
+ fputc(level.mampfer_inhalt[i][x][y], file);
+ fputc(level.tempo_amoebe, file);
+ fputc(level.dauer_sieb, file);
+ fputc(level.dauer_ablenk, file);
+ fputc(level.amoebe_inhalt, file);
+
+ for(i=0; i<NUM_FREE_LVHD_BYTES; i++) /* Rest frei / Headergröße 80 Bytes */
+ fputc(0, file);
+
+ for(y=0; y<lev_fieldy; y++)
+ for(x=0; x<lev_fieldx; x++)
+ fputc(Ur[x][y], file);
fclose(file);
chmod(filename, LEVEL_PERMS);
}
-void LoadLevelTape(int level_nr)
+void LoadTape(int level_nr)
{
int i;
char filename[MAX_FILENAME_LEN];
FILE *file;
boolean levelrec_10 = FALSE;
-#ifndef MSDOS
- sprintf(filename,"%s/%s/%d.tape",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
-#else
- sprintf(filename,"%s/%s/%d.tap",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
-#endif
+ sprintf(filename, "%s/%d.%s",
+ getTapeDir(leveldir[leveldir_nr].filename),
+ level_nr, TAPEFILE_EXTENSION);
- if ((file=fopen(filename,"r")))
+ if ((file = fopen(filename, "r")))
{
- fgets(cookie,LEVELREC_COOKIE_LEN,file);
+ fgets(cookie, LEVELREC_COOKIE_LEN, file);
fgetc(file);
- if (!strcmp(cookie,LEVELREC_COOKIE_10)) /* old 1.0 tape format */
+ if (!strcmp(cookie, LEVELREC_COOKIE_10)) /* old 1.0 tape format */
levelrec_10 = TRUE;
- else if (strcmp(cookie,LEVELREC_COOKIE)) /* unknown tape format */
+ else if (strcmp(cookie, LEVELREC_COOKIE)) /* unknown tape format */
{
Error(ERR_WARN, "wrong format of level recording file '%s'", filename);
fclose(file);
tape.playing = FALSE;
tape.pausing = FALSE;
- for(i=0;i<tape.length;i++)
+ for(i=0; i<tape.length; i++)
{
int j;
tape.length_seconds = GetTapeLength();
}
-void SaveLevelTape(int level_nr)
+void SaveTape(int level_nr)
{
int i;
char filename[MAX_FILENAME_LEN];
FILE *file;
boolean new_tape = TRUE;
-#ifndef MSDOS
- sprintf(filename,"%s/%s/%d.tape",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
-#else
- sprintf(filename,"%s/%s/%d.tap",
- level_directory,leveldir[leveldir_nr].filename,level_nr);
-#endif
+ sprintf(filename, "%s/%d.%s",
+ getTapeDir(leveldir[leveldir_nr].filename),
+ level_nr, TAPEFILE_EXTENSION);
+
+ InitTapeDirectory(leveldir[leveldir_nr].filename);
/* Testen, ob bereits eine Aufnahme existiert */
- if ((file=fopen(filename,"r")))
+ if ((file = fopen(filename, "r")))
{
new_tape = FALSE;
fclose(file);
- if (!Request("Replace old tape ?",REQ_ASK))
+ if (!Request("Replace old tape ?", REQ_ASK))
return;
}
- if (!(file=fopen(filename,"w")))
+ if (!(file = fopen(filename, "w")))
{
Error(ERR_WARN, "cannot save level recording file '%s'", filename);
return;
}
- fputs(LEVELREC_COOKIE,file); /* Formatkennung */
- fputc(0x0a,file);
+ fputs(LEVELREC_COOKIE, file); /* Formatkennung */
+ fputc(0x0a, file);
fputc((tape.random_seed >> 24) & 0xff,file);
fputc((tape.random_seed >> 16) & 0xff,file);
fputc((tape.length >> 8) & 0xff,file);
fputc((tape.length >> 0) & 0xff,file);
- for(i=0;i<tape.length;i++)
+ for(i=0; i<tape.length; i++)
{
int j;
for(j=0; j<MAX_PLAYERS; j++)
- fputc(tape.pos[i].action[j],file);
+ fputc(tape.pos[i].action[j], file);
- fputc(tape.pos[i].delay,file);
+ fputc(tape.pos[i].delay, file);
}
fclose(file);
Request("tape saved !",REQ_CONFIRM);
}
-boolean CreateNewScoreFile()
+void LoadScore(int level_nr)
{
- int i,j,k;
+ int i;
char filename[MAX_FILENAME_LEN];
- char empty_alias[MAX_NAMELEN];
+ char cookie[MAX_FILENAME_LEN];
+ char line[MAX_LINE_LEN];
+ char *line_ptr;
FILE *file;
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME);
-
- if (!(file=fopen(filename,"w")))
- return(FALSE);
-
- for(i=0;i<MAX_NAMELEN;i++)
- empty_alias[i] = 0;
- strncpy(empty_alias,EMPTY_ALIAS,MAX_NAMELEN-1);
-
- fputs(SCORE_COOKIE,file); /* Formatkennung */
- for(i=0;i<leveldir[leveldir_nr].levels;i++)
+ /* start with empty score table */
+ for(i=0; i<MAX_SCORE_ENTRIES; i++)
{
- for(j=0;j<MAX_SCORE_ENTRIES;j++)
- {
- for(k=0;k<MAX_NAMELEN;k++)
- fputc(empty_alias[k],file);
- fputc(0,file);
- fputc(0,file);
- }
+ strcpy(highscore[i].Name, EMPTY_ALIAS);
+ highscore[i].Score = 0;
}
- fclose(file);
- chmod(filename, SCORE_PERMS);
- return(TRUE);
-}
+ sprintf(filename, "%s/%d.%s",
+ getScoreDir(leveldir[leveldir_nr].filename),
+ level_nr, SCOREFILE_EXTENSION);
-void LoadScore(int level_nr)
-{
- int i,j;
- char filename[MAX_FILENAME_LEN];
- char cookie[MAX_FILENAME_LEN];
- FILE *file;
+ if (!(file = fopen(filename, "r")))
+ return;
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME);
+ fgets(cookie, SCORE_COOKIE_LEN, file);
- if (!(file = fopen(filename,"r")))
+ if (strcmp(cookie, SCORE_COOKIE) != 0)
{
- if (!CreateNewScoreFile())
- Error(ERR_WARN, "cannot create score file '%s'", filename);
- else if (!(file = fopen(filename,"r")))
- Error(ERR_WARN, "cannot read score for level %d", level_nr);
+ Error(ERR_WARN, "wrong format of score file '%s'", filename);
+ fclose(file);
+ return;
}
- if (file)
+ for(i=0; i<MAX_SCORE_ENTRIES; i++)
{
- fgets(cookie,SCORE_COOKIE_LEN,file);
- if (strcmp(cookie,SCORE_COOKIE)) /* ungültiges Format? */
- {
- Error(ERR_WARN, "wrong format of score file '%s'", filename);
- fclose(file);
- file = NULL;
- }
- }
+ fscanf(file, "%d", &highscore[i].Score);
+ fgets(line, MAX_LINE_LEN, file);
- if (file)
- {
- fseek(file,
- SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
- SEEK_SET);
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
- {
- for(j=0;j<MAX_NAMELEN;j++)
- highscore[i].Name[j] = fgetc(file);
- highscore[i].Score = (fgetc(file)<<8) | fgetc(file);
- }
- fclose(file);
- }
- else
- {
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
+ if (line[strlen(line)-1] == '\n')
+ line[strlen(line)-1] = '\0';
+
+ for (line_ptr = line; *line_ptr; line_ptr++)
{
- strcpy(highscore[i].Name,EMPTY_ALIAS);
- highscore[i].Score = 0;
+ 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';
+ break;
+ }
}
}
+
+ fclose(file);
}
void SaveScore(int level_nr)
{
- int i,j;
+ int i;
char filename[MAX_FILENAME_LEN];
FILE *file;
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME);
+ sprintf(filename, "%s/%d.%s",
+ getScoreDir(leveldir[leveldir_nr].filename),
+ level_nr, SCOREFILE_EXTENSION);
+
+ InitScoreDirectory(leveldir[leveldir_nr].filename);
- if (!(file=fopen(filename,"r+")))
+ if (!(file = fopen(filename, "w")))
{
Error(ERR_WARN, "cannot save score for level %d", level_nr);
return;
}
- fseek(file,
- SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
- SEEK_SET);
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
- {
- for(j=0;j<MAX_NAMELEN;j++)
- fputc(highscore[i].Name[j],file);
- fputc(highscore[i].Score / 256,file);
- fputc(highscore[i].Score % 256,file);
- }
+ fprintf(file, "%s\n\n", SCORE_COOKIE);
+
+ for(i=0; i<MAX_SCORE_ENTRIES; i++)
+ fprintf(file, "%d %s\n", highscore[i].Score, highscore[i].Name);
+
fclose(file);
-}
-#define MAX_LINE_LEN 1000
+ chmod(filename, SCORE_PERMS);
+}
#define TOKEN_STR_FILE_IDENTIFIER "file_identifier"
#define TOKEN_STR_LAST_LEVEL_SERIES "last_level_series"
#define SETUP_TOKEN_FADING 8
#define SETUP_TOKEN_AUTORECORD 9
#define SETUP_TOKEN_QUICK_DOORS 10
-#define SETUP_TOKEN_ALIAS_NAME 11
-
-#define SETUP_TOKEN_USE_JOYSTICK 12
-#define SETUP_TOKEN_JOY_DEVICE_NAME 13
-#define SETUP_TOKEN_JOY_XLEFT 14
-#define SETUP_TOKEN_JOY_XMIDDLE 15
-#define SETUP_TOKEN_JOY_XRIGHT 16
-#define SETUP_TOKEN_JOY_YUPPER 17
-#define SETUP_TOKEN_JOY_YMIDDLE 18
-#define SETUP_TOKEN_JOY_YLOWER 19
-#define SETUP_TOKEN_JOY_SNAP 20
-#define SETUP_TOKEN_JOY_BOMB 21
-#define SETUP_TOKEN_KEY_LEFT 22
-#define SETUP_TOKEN_KEY_RIGHT 23
-#define SETUP_TOKEN_KEY_UP 24
-#define SETUP_TOKEN_KEY_DOWN 25
-#define SETUP_TOKEN_KEY_SNAP 26
-#define SETUP_TOKEN_KEY_BOMB 27
-
-#define NUM_SETUP_TOKENS 28
+#define SETUP_TOKEN_TEAM_MODE 11
+#define SETUP_TOKEN_ALIAS_NAME 12
+
+#define SETUP_TOKEN_USE_JOYSTICK 13
+#define SETUP_TOKEN_JOY_DEVICE_NAME 14
+#define SETUP_TOKEN_JOY_XLEFT 15
+#define SETUP_TOKEN_JOY_XMIDDLE 16
+#define SETUP_TOKEN_JOY_XRIGHT 17
+#define SETUP_TOKEN_JOY_YUPPER 18
+#define SETUP_TOKEN_JOY_YMIDDLE 19
+#define SETUP_TOKEN_JOY_YLOWER 20
+#define SETUP_TOKEN_JOY_SNAP 21
+#define SETUP_TOKEN_JOY_BOMB 22
+#define SETUP_TOKEN_KEY_LEFT 23
+#define SETUP_TOKEN_KEY_RIGHT 24
+#define SETUP_TOKEN_KEY_UP 25
+#define SETUP_TOKEN_KEY_DOWN 26
+#define SETUP_TOKEN_KEY_SNAP 27
+#define SETUP_TOKEN_KEY_BOMB 28
+
+#define NUM_SETUP_TOKENS 29
#define FIRST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_SOUND
#define LAST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_ALIAS_NAME
{ TYPE_SWITCH, &si.fading, "screen_fading" },
{ TYPE_SWITCH, &si.autorecord, "automatic_tape_recording" },
{ TYPE_SWITCH, &si.quick_doors, "quick_doors" },
+ { TYPE_SWITCH, &si.team_mode, "team_mode" },
{ TYPE_STRING, &si.alias_name, "alias_name" },
/* for each player: */
si->autorecord = FALSE;
si->quick_doors = FALSE;
- strncpy(si->login_name, GetLoginName(), MAX_NAMELEN-1);
+ strncpy(si->login_name, getLoginName(), MAX_NAMELEN-1);
si->login_name[MAX_NAMELEN-1] = '\0';
- strncpy(si->alias_name, GetLoginName(), MAX_NAMELEN-1);
+ strncpy(si->alias_name, getLoginName(), MAX_NAMELEN-1);
si->alias_name[MAX_NAMELEN-1] = '\0';
for (i=0; i<MAX_PLAYERS; i++)
/* always start with reliable default setup values */
setSetupInfoToDefaults(&setup);
- sprintf(filename, "%s/%s", SETUP_PATH, SETUP_FILENAME);
+ sprintf(filename, "%s/%s", getSetupDir(), SETUP_FILENAME);
setup_file_list = loadSetupFileList(filename);
char filename[MAX_FILENAME_LEN];
FILE *file;
- sprintf(filename, "%s/%s", SETUP_PATH, SETUP_FILENAME);
+ sprintf(filename, "%s/%s", getSetupDir(), SETUP_FILENAME);
+
+ InitUserDataDirectory();
if (!(file = fopen(filename, "w")))
{
leveldir_nr = 0;
level_nr = 0;
- sprintf(filename, "%s/%s", SETUP_PATH, LEVELSETUP_FILENAME);
+ sprintf(filename, "%s/%s", getSetupDir(), LEVELSETUP_FILENAME);
if (level_setup_list)
freeSetupFileList(level_setup_list);
setTokenValue(level_setup_list,
leveldir[leveldir_nr].filename, int2str(level_nr, 0));
- sprintf(filename, "%s/%s", SETUP_PATH, LEVELSETUP_FILENAME);
+ sprintf(filename, "%s/%s", getSetupDir(), LEVELSETUP_FILENAME);
+
+ InitUserDataDirectory();
if (!(file = fopen(filename, "w")))
{