Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
RACE
Commits
06f7e1cb
Commit
06f7e1cb
authored
Oct 03, 2020
by
Libretro-Admin
Browse files
Cleanups
parent
4cf25e68
Changes
1
Hide whitespace changes
Inline
Side-by-side
state.cpp
View file @
06f7e1cb
...
...
@@ -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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment