Commit 06f7e1cb authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 4cf25e68
......@@ -347,59 +347,6 @@ static int state_restore_0x10(FILE *stream)
return 1;
}
static int state_store_file(FILE *stream)
{
/* Set version & ROM signature information */
struct race_state_header rsh;
rsh.state_version = CURRENT_SAVE_STATE_VERSION;
memcpy(rsh.rom_signature, mainrom, sizeof(rsh.rom_signature));
/* Initialize state data */
race_state_t rs;
if (!state_store(&rs))
return 0;
/* Write to file */
if (fwrite(&rsh, sizeof(rsh), 1, stream) < 1)
return 0;
if (fwrite(&rs, sizeof(rs), 1, stream) < 1)
return 0;
return 1;
}
static int state_restore_file(FILE *stream)
{
/* Note current position (in case of compatibility rewinds */
long read_pos = ftell(stream);
/* Read header */
struct race_state_header rsh;
if (fread(&rsh, sizeof(rsh), 1, stream) < 1)
return 0;
/* Verify state version */
if (rsh.state_version == 0x10)
{
fseek(stream, read_pos, SEEK_SET); /* Rewind and load old format */
return state_restore_0x10(stream);
}
else if (rsh.state_version != CURRENT_SAVE_STATE_VERSION)
return 0; /* Unsupported version */
/* Verify ROM signature */
if (memcmp(mainrom, rsh.rom_signature, sizeof(rsh.rom_signature)) != 0)
return 0;
/* Read state data */
race_state_t rs;
if (fread(&rs, sizeof(rs), 1, stream) < 1)
return 0;
/* Restore state */
return state_restore(&rs);
}
int state_store_mem(void *state)
{
return state_store((race_state_t*)state);
......@@ -414,16 +361,3 @@ int state_get_size(void)
{
return sizeof(race_state_t);
}
int state_store(char* filename)
{
FILE *stream;
if (!(stream = fopen(filename, "w")))
return 0;
int status = state_store_file(stream);
fclose(stream);
return status;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment