Subversion Repositories HelenOS

Rev

Rev 4515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4515 Rev 4565
Line 194... Line 194...
194
        scores[i].hs_score = (NUMSPOTS - i) * 200;
194
        scores[i].hs_score = (NUMSPOTS - i) * 200;
195
        scores[i].hs_level = (i + 1 > MAXLEVEL ? MAXLEVEL : i + 1);
195
        scores[i].hs_level = (i + 1 > MAXLEVEL ? MAXLEVEL : i + 1);
196
    }
196
    }
197
}
197
}
198
 
198
 
-
 
199
int loadscores(void)
-
 
200
{
-
 
201
    FILE *f;
-
 
202
    size_t cnt;
-
 
203
    int rc;
-
 
204
 
-
 
205
    f = fopen("/tetris.sco", "rb");
-
 
206
    if (f == NULL)
-
 
207
        return ENOENT;
-
 
208
 
-
 
209
    cnt = fread(scores, sizeof(struct highscore), NUMSPOTS, f);
-
 
210
    rc = fclose(f);
-
 
211
 
-
 
212
    if (cnt != NUMSPOTS || rc != 0)
-
 
213
        return EIO;
-
 
214
 
-
 
215
    return EOK;
-
 
216
}
-
 
217
 
-
 
218
void savescores(void)
-
 
219
{
-
 
220
    FILE *f;
-
 
221
    size_t cnt;
-
 
222
    int rc;
-
 
223
 
-
 
224
    f = fopen("/tetris.sco", "wb");
-
 
225
    cnt = fwrite(scores, sizeof(struct highscore), NUMSPOTS, f);
-
 
226
    rc = fclose(f);
-
 
227
 
-
 
228
    if (cnt != NUMSPOTS || rc != 0)
-
 
229
        printf("Error saving score table\n");
-
 
230
}
-
 
231
 
199
/** @}
232
/** @}
200
 */
233
 */