90 lines
1.4 KiB
C++
90 lines
1.4 KiB
C++
#include "../include/saves.h"
|
|
#include <cstdlib>
|
|
#include <stdio.h>
|
|
|
|
|
|
static const char *filepath= "OutRun.sav";
|
|
static const char *filepara= "OutRun.prm";
|
|
bool saveexist;
|
|
bool paraexist;
|
|
unsigned int sizeoffile;
|
|
|
|
|
|
extern BestRanking HallOfFame[10][5];
|
|
extern Parameters PlayerPara[1];
|
|
|
|
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 );
|
|
}
|
|
|
|
void is_param_existing( void )
|
|
{
|
|
FILE *file = fopen( filepara, "r" );
|
|
|
|
if (file==NULL)
|
|
{
|
|
paraexist = false;
|
|
}
|
|
else
|
|
{
|
|
fclose( file );
|
|
paraexist = true;
|
|
}
|
|
}
|
|
|
|
|
|
void saveparameters( void )
|
|
{
|
|
sizeoffile = sizeof( PlayerPara );
|
|
|
|
FILE *file = fopen( filepara, "w" );
|
|
fwrite( PlayerPara, sizeoffile, 1, file );
|
|
|
|
fclose( file );
|
|
}
|
|
|
|
|
|
void loadparameters( void )
|
|
{
|
|
sizeoffile = sizeof( PlayerPara );
|
|
|
|
FILE *file = fopen( filepara, "r" );
|
|
fread( PlayerPara, sizeoffile, 1, file );
|
|
|
|
fclose( file );
|
|
}
|
|
|