else if (CASE("goal"))
{
l->goal = atoi(v);
- l->coin_score.coins[2] = l->goal;
+ l->score.most_coins.coins[2] = l->goal;
}
else if (CASE("time"))
{
l->time = atoi(v);
- l->time_score.timer[2] = l->time;
- l->goal_score.timer[2] = l->time;
+ l->score.best_times.timer[2] = l->time;
+ l->score.unlock_goal.timer[2] = l->time;
}
else if (CASE("time_hs"))
sscanf(v, "%d %d",
- &l->time_score.timer[0],
- &l->time_score.timer[1]);
+ &l->score.best_times.timer[0],
+ &l->score.best_times.timer[1]);
else if (CASE("goal_hs"))
sscanf(v, "%d %d",
- &l->goal_score.timer[0],
- &l->goal_score.timer[1]);
+ &l->score.unlock_goal.timer[0],
+ &l->score.unlock_goal.timer[1]);
else if (CASE("coin_hs"))
sscanf(v, "%d %d",
- &l->coin_score.coins[0],
- &l->coin_score.coins[1]);
- else if (CASE("levelname"))
- strcpy(l->name, v);
+ &l->score.most_coins.coins[0],
+ &l->score.most_coins.coins[1]);
else if (CASE("version"))
- l->version = atoi(v);
+ strcpy(l->version, v);
else if (CASE("author"))
strcpy(l->author, v);
else if (CASE("special"))
strcpy(level->file, filename);
/* Init hs with default values */
- score_init_hs(&level->time_score, 59999, 0);
- score_init_hs(&level->goal_score, 59999, 0);
- score_init_hs(&level->coin_score, 59999, 0);
+ score_init_hs(&level->score.best_times, 59999, 0);
+ score_init_hs(&level->score.unlock_goal, 59999, 0);
+ score_init_hs(&level->score.most_coins, 59999, 0);
/* Compute money and default max money */
money = 0;
for (i = 0; i < sol.cc; i++)
money += sol.cv[i].n;
- level->coin_score.coins[0] = money;
+ level->score.most_coins.coins[0] = money;
/* Scan sol metadata */
if (sol.ac > 0)
else if (t[2] c t[1]) \
t[1] = (t[0] + t[2]) / 2
- HOP(level->time_score.timer, <=);
- HOP(level->goal_score.timer, <=);
- HOP(level->coin_score.coins, >=);
+ HOP(level->score.best_times.timer, <=);
+ HOP(level->score.unlock_goal.timer, <=);
+ HOP(level->score.most_coins.coins, >=);
sol_free(&sol);
/*---------------------------------------------------------------------------*/
void level_dump_info(const struct level *l)
-/* This function dumps the info of a demo structure
- * It's only a function for debugging, no need of I18N */
{
printf("filename: %s\n"
- "name: %s\n"
- "version: %d\n"
+ "version: %s\n"
"author: %s\n"
"time limit: %d\n"
"goal count: %d\n"
"gradiant: %s\n"
"screenshot: %s\n"
"song: %s\n",
- l->file, l->name, l->version, l->author,
- l->time, l->goal,
- l->time_score.timer[0],
- l->time_score.timer[1],
- l->time_score.timer[2],
- l->goal_score.timer[0],
- l->goal_score.timer[1],
- l->goal_score.timer[2],
- l->coin_score.coins[0],
- l->coin_score.coins[1],
- l->coin_score.coins[2],
- l->message, l->back, l->grad, l->shot, l->song);
+ l->file,
+ l->version,
+ l->author,
+ l->time,
+ l->goal,
+ l->score.best_times.timer[0],
+ l->score.best_times.timer[1],
+ l->score.best_times.timer[2],
+ l->score.unlock_goal.timer[0],
+ l->score.unlock_goal.timer[1],
+ l->score.unlock_goal.timer[2],
+ l->score.most_coins.coins[0],
+ l->score.most_coins.coins[1],
+ l->score.most_coins.coins[2],
+ l->message,
+ l->back,
+ l->grad,
+ l->shot,
+ l->song);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-/* A score structure */
-
struct score
{
- char player[NSCORE + 1][MAXNAM]; /* player name */
- int timer[NSCORE + 1]; /* time elapsed */
- int coins[NSCORE + 1]; /* coins collected */
+ char player[NSCORE + 1][MAXNAM];
+
+ int timer [NSCORE + 1]; /* Time elapsed */
+ int coins [NSCORE + 1]; /* Coins collected */
};
void score_init_hs(struct score *, int, int);
/*---------------------------------------------------------------------------*/
-/* A simple level */
-
struct level
{
- /* Level identity */
+ char file[PATHMAX];
+ char back[PATHMAX];
+ char grad[PATHMAX];
+ char shot[PATHMAX];
+ char song[PATHMAX];
- char file[MAXSTR]; /* sol main file */
- char name[MAXSTR]; /* the level name */
- int version; /* the level version */
- char author[MAXSTR]; /* the author */
+ char message[MAXSTR];
- /* Time and goal information */
+ char version[MAXSTR];
+ char author[MAXSTR];
- int time; /* time limit */
- int goal; /* coins needed */
+ int time; /* Time limit */
+ int goal; /* Coins needed */
- struct score time_score; /* "best time" score */
- struct score goal_score; /* "unlock goal" score */
- struct score coin_score; /* "most coin" score */
+ struct
+ {
+ struct score best_times;
+ struct score unlock_goal;
+ struct score most_coins;
+ }
+ score;
- /* Regarding set information */
+ /* Set information. */
- struct set *set; /* set (NULL in single mode) */
- int number; /* level number in the set */
- char numbername[3]; /* string representation of the number (eg. B1) */
- int is_locked; /* Is the level unplayable */
- int is_bonus; /* Is the level an extra-bonus level? */
- int is_completed; /* Is the level goal terminated? */
- int is_last; /* Is the level the last of the set? */
+ struct set *set;
- /* Other metadata (files are relative the data file) */
+ int number;
+ char repr[3]; /* String representation of the number (eg. "B1") */
- char message[MAXSTR]; /* intro message */
- char back[MAXSTR]; /* sol background file */
- char grad[MAXSTR]; /* gradiant backgound image */
- char shot[MAXSTR]; /* screenshot image */
- char song[MAXSTR]; /* song file */
+ int is_locked;
+ int is_bonus;
+ int is_completed;
};
int level_load(const char *, struct level *);
for (i = 0; i < s->count; i++)
{
l = &level_v[i];
- put_score(fout, &l->time_score);
- put_score(fout, &l->goal_score);
- put_score(fout, &l->coin_score);
+ put_score(fout, &l->score.best_times);
+ put_score(fout, &l->score.unlock_goal);
+ put_score(fout, &l->score.most_coins);
}
fclose(fout);
for (i = 0; i < s->count && res; i++)
{
l = &level_v[i];
- res = get_score(fin, &l->time_score) &&
- get_score(fin, &l->goal_score) &&
- get_score(fin, &l->coin_score);
+ res = get_score(fin, &l->score.best_times) &&
+ get_score(fin, &l->score.unlock_goal) &&
+ get_score(fin, &l->score.most_coins);
}
fclose(fin);
l->set = current_set;
l->number = i;
if (l->is_bonus)
- sprintf(l->numbername, _("B%d"), bnb++);
+ sprintf(l->repr, _("B%d"), bnb++);
else
- sprintf(l->numbername, "%02d", nb++);
+ sprintf(l->repr, "%02d", nb++);
l->is_locked = 1;
l->is_completed = 0;
}
int coins = lg->coins;
struct level *l = &level_v[lg->level->number];
- lg->time_rank = score_time_insert(&l->time_score, player, timer, coins);
+ lg->time_rank = score_time_insert(&l->score.best_times,
+ player, timer, coins);
if (lg->mode == MODE_CHALLENGE || lg->mode == MODE_NORMAL)
- lg->goal_rank = score_time_insert(&l->goal_score, player, timer, coins);
+ lg->goal_rank = score_time_insert(&l->score.unlock_goal,
+ player, timer, coins);
else
lg->goal_rank = 3;
- lg->coin_rank = score_coin_insert(&l->coin_score, player, timer, coins);
+ lg->coin_rank = score_coin_insert(&l->score.most_coins,
+ player, timer, coins);
return (lg->time_rank < 3 || lg->goal_rank < 3 || lg->coin_rank < 3);
}
#define UPDATE(i, x) (strncpy((x).player[(i)], player, MAXNAM))
struct set *s = current_set;
struct level *l = &level_v[lg->level->number];
- UPDATE(lg->time_rank, l->time_score);
- UPDATE(lg->goal_rank, l->goal_score);
- UPDATE(lg->coin_rank, l->coin_score);
+ UPDATE(lg->time_rank, l->score.best_times);
+ UPDATE(lg->goal_rank, l->score.unlock_goal);
+ UPDATE(lg->coin_rank, l->score.most_coins);
UPDATE(lg->score_rank, s->coin_score);
UPDATE(lg->times_rank, s->time_score);
set_store_hs();
}
else if ((jd = gui_hstack(id)))
{
- ln = lg->level->numbername;
+ ln = lg->level->repr;
b = lg->level->is_bonus;
textcol1 = b ? gui_wht : 0;
textcol2 = b ? gui_grn : 0;
if (state == GAME_GOAL)
{
- set_most_coins(&l->coin_score, lg->coin_rank);
+ set_most_coins(&l->score.most_coins, lg->coin_rank);
if (mode == MODE_CHALLENGE || mode == MODE_NORMAL)
- set_best_times(&l->goal_score, lg->goal_rank, 1);
+ set_best_times(&l->score.unlock_goal, lg->goal_rank, 1);
else
- set_best_times(&l->time_score, lg->time_rank, 0);
+ set_best_times(&l->score.best_times, lg->time_rank, 0);
}
config_clr_grab();
else
fore = back = gui_gry;
- jd = gui_label(id, l->numbername, GUI_SML, GUI_ALL, back, fore);
+ jd = gui_label(id, l->repr, GUI_SML, GUI_ALL, back, fore);
gui_active(jd, i, 0);
}
{
gui_set_image(shot_id, l->shot);
- set_most_coins(&l->coin_score, -1);
+ set_most_coins(&l->score.most_coins, -1);
if (config_get_d(CONFIG_MODE) == MODE_PRACTICE)
{
- set_best_times(&l->time_score, -1, 0);
+ set_best_times(&l->score.best_times, -1, 0);
if (l->is_bonus)
gui_set_label(status_id,
_("Play this bonus level in practice mode"));
}
else
{
- set_best_times(&l->goal_score, -1, 1);
+ set_best_times(&l->score.unlock_goal, -1, 1);
if (l->is_bonus)
gui_set_label(status_id,
_("Play this bonus level in normal mode"));