OutRun/src/src/saves.cc

51 lines
774 B
C++

#include "../include/saves.h"
#include <gint/std/stdlib.h>
#include <stdio.h>
static const char *filepath= "OutRun.sav";
bool saveexist;
unsigned int sizeoffile;
extern BestRanking HallOfFame[10][5];
void is_save_existing( void )
{
FILE *file = fopen( filepath, "r" );
if (file==NULL)
{
saveexist = false;
}
else
{
fclose( file );
saveexist = true;
}
}
void saveprogress( void )
{
sizeoffile = sizeof( HallOfFame );
FILE *file = fopen( filepath, "w" );
fwrite( HallOfFame, sizeoffile, 1, file );
fclose( file );
}
void loadprogress( void )
{
sizeoffile = sizeof( HallOfFame );
FILE *file = fopen( filepath, "r" );
fread( HallOfFame, sizeoffile, 1, file );
fclose( file );
}