-/*
+/*
* Copyright (C) 2003 Robert Kooima
*
* NEVERBALL is free software; you can redistribute it and/or modify
int i;
const struct level *l;
char states[MAXLVL + 1];
-
+
if ((fout = fopen(config_user(s->user_scores), "w")))
{
for (i = 0; i < s->count; i++)
}
states[s->count] = '\0';
fprintf(fout, "%s\n",states);
-
+
put_score(fout, &s->time_score);
put_score(fout, &s->coin_score);
if ((fin = fopen(fn, "r")))
{
- res = ((fscanf(fin, "%s\n", states) == 1) &&
+ res = ((fscanf(fin, "%s\n", states) == 1) &&
(strlen(states) == s->count));
for (i = 0; i < s->count && res; i++)
{
{
level_v[i].is_locked = 0;
level_v[i].is_completed = 1;
- }
+ }
else if (states[i] == 'O')
{
level_v[i].is_locked = 0;
else
res = 0;
}
-
+
res = res &&
get_score(fin, &s->time_score) &&
get_score(fin, &s->coin_score);
-
+
for (i = 0; i < s->count && res; i++)
{
l = &level_v[i];
fclose(fin);
}
-
+
if (!res && errno != ENOENT)
{
fprintf(stderr, _("Error while loading user high-score file '%s': "),
FILE *fin;
char buf[MAXSTR];
int res = 0;
-
+
/* Open the datafile */
fin = fopen(filename, "r");
memset(s, 0, sizeof(struct set));
/* Set some sane values in case the scores hs is missing. */
-
+
score_init_hs(&s->time_score, 359999, 0);
score_init_hs(&s->coin_score, 359999, 0);
-
+
/* Load set metadata */
-
+
strcpy(s->file, filename);
if ((res = fgets(buf, MAXSTR, fin) != NULL))
strcpy(s->name, chomp(buf));
if (res && (res = fgets(buf, MAXSTR, fin) != NULL))
strcpy(s->shot, chomp(buf));
if (res && (res = fgets(buf, MAXSTR, fin) != NULL))
- sscanf(buf, "%d %d %d %d %d %d",
+ sscanf(buf, "%d %d %d %d %d %d",
&s->time_score.timer[0],
&s->time_score.timer[1],
&s->time_score.timer[2],
strcat(s->user_scores, s->setname);
/* Count levels levels. */
-
+
s->count = 0;
while (s->count < MAXLVL && (fscanf(fin, "%s", buf) == 1))
s->count++;
-
+
/* Close the file, since it's no more needed */
-
+
fclose(fin);
/* Load the levels states (stored in the user highscore file) */
int res;
current_set = NULL;
-
+
count = 0;
if ((fin = fopen(config_data(SET_FILE), "r")))
set = &(set_v[count]);
/* clean the set data */
-
+
res = (fgets(filename, MAXSTR, fin) != NULL);
if (res)
{
int i = 0, res;
int nb = 1, bnb = 1;
-
+
fin = fopen(current_set->file, "r");
assert(fin != NULL);
-
+
res = 1;
/* Skip the five first lines */
struct level *l = &level_v[lg->level->number];
lg->time_rank = score_time_insert(&l->time_score, player, timer, coins);
-
+
if (lg->mode == MODE_CHALLENGE || lg->mode == MODE_NORMAL)
lg->goal_rank = score_time_insert(&l->goal_score, player, timer, coins);
else
}
static struct level *next_normal_level(int i)
-/* Return the next normal level (starting for i)
+/* Return the next normal level (starting for i)
* Return NULL if there is not a such level */
{
for (i++; i < current_set->count; i++)
}
void set_finish_level(struct level_game *lg, const char *player)
-/* Inform the set that a level is finished.
+/* Inform the set that a level is finished.
* Update next_level and score rank fields */
{
struct set *s = current_set;
if (game_init(&level_v[i], 0, 0))
{
+ int shadow;
+
+ if ((shadow = config_get_d(CONFIG_SHADOW)))
+ config_set_d(CONFIG_SHADOW, 0);
+
/* Render the level and grab the screen. */
config_clear();
image_snap(filename, config_get_d(CONFIG_WIDTH),
config_get_d(CONFIG_HEIGHT));
+
+ if (shadow)
+ config_set_d(CONFIG_SHADOW, 1);
}
}