void set_rename_player(int score_rank, int times_rank, const char *player) { struct set *s = SET_GET(sets, curr); SAFECPY(s->coin_score.player[score_rank], player); SAFECPY(s->time_score.player[times_rank], player); }
int hole_load(int h, const char *filename) { struct s_base base; if (filename != hole_v[h].file) { /* Note filename if it came from elsewhere. */ SAFECPY(hole_v[h].file, filename); } if (sol_load_meta(&base, filename)) { int i; for (i = 0; i < base.dc; i++) { const char *k = base.av + base.dv[i].ai; const char *v = base.av + base.dv[i].aj; if (strcmp("grad", k) == 0) SAFECPY(hole_v[h].back, v); else if (strcmp("par", k) == 0) hole_v[h].par = atoi(v); else if (strcmp("song", k) == 0) SAFECPY(hole_v[h].song, v); } score_v[h][0] = hole_v[h].par; sol_free_base(&base); return 1; } return 0; }
/* * Convert a system path into a VFS path. */ const char *fs_resolve(const char *system) { static char path[MAXSTR]; const char *p; /* * PhysicsFS will claim a file doesn't exist if its path uses a * directory separator other than a forward slash, even if that * separator is valid for the system. We'll oblige. */ SAFECPY(path, system); path_normalize(path); if (fs_exists(path)) return path; /* Chop off directories until we have a match. */ p = path; while ((p = path_next_sep(p))) { /* Skip separator. */ p += 1; if (fs_exists(p)) return p; } return NULL; }
static int get_score(fs_file fp, struct score *s) { char line[MAXSTR]; int i; for (i = RANK_HARD; i <= RANK_EASY; i++) { int n = -1; if (!fs_gets(line, sizeof (line), fp)) return 0; strip_newline(line); if (sscanf(line, "%d %d %n", &s->timer[i], &s->coins[i], &n) < 2) return 0; if (n < 0) return 0; SAFECPY(s->player[i], line + n); } return 1; }
static void set_load_levels(void) { static const char *roman[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", "XXIII", "XXIV", "XXV" }; struct set *s = SET_GET(sets, curr); int regular = 1, bonus = 1; int i; for (i = 0; i < s->count; i++) { struct level *l = &level_v[i]; level_load(s->level_name_v[i], l); l->number = i; if (l->is_bonus) SAFECPY(l->name, roman[bonus++]); else sprintf(l->name, "%02d", regular++); l->is_locked = (i > 0); l->is_completed = 0; if (i > 0) level_v[i - 1].next = l; } }
int goto_name(struct state *ok, struct state *cancel, unsigned int back) { SAFECPY(player, config_get_s(CONFIG_PLAYER)); ok_state = ok; cancel_state = cancel; draw_back = back; return goto_state(&st_name); }
static const char *theme_path(const char *name, const char *file) { static char path[MAXSTR]; if ((name && *name) && (file && *file)) { SAFECPY(path, "gui/"); SAFECAT(path, name); SAFECAT(path, "/"); SAFECAT(path, file); return path; } return ""; }
static void snapshot_prep(const char *path) { if (path && *path) SAFECPY(snapshot_path, path); }
static int set_load(struct set *s, const char *filename) { fs_file fin; char *scores, *level_name; /* Skip "Misc" set when not in dev mode. */ if (strcmp(filename, SET_MISC) == 0 && !config_cheat()) return 0; fin = fs_open(filename, "r"); if (!fin) { log_printf("Failure to load set file %s\n", filename); //senquack - added error reporting: log_printf(fs_error()); return 0; } memset(s, 0, sizeof (struct set)); /* Set some sane values in case the scores are missing. */ score_init_hs(&s->time_score, 359999, 0); score_init_hs(&s->coin_score, 359999, 0); SAFECPY(s->file, filename); if (read_line(&s->name, fin) && read_line(&s->desc, fin) && read_line(&s->id, fin) && read_line(&s->shot, fin) && read_line(&scores, fin)) { sscanf(scores, "%d %d %d %d %d %d", &s->time_score.timer[RANK_HARD], &s->time_score.timer[RANK_MEDM], &s->time_score.timer[RANK_EASY], &s->coin_score.coins[RANK_HARD], &s->coin_score.coins[RANK_MEDM], &s->coin_score.coins[RANK_EASY]); free(scores); s->user_scores = concat_string("Scores/", s->id, ".txt", NULL); s->cheat_scores = concat_string("Scores/", s->id, "-cheat.txt", NULL); s->count = 0; while (s->count < MAXLVL && read_line(&level_name, fin)) { s->level_name_v[s->count] = level_name; s->count++; } fs_close(fin); return 1; } free(s->name); free(s->desc); free(s->id); free(s->shot); fs_close(fin); return 0; }