mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Use CORE_CTL_RETRO_SERIALIZE_SIZE everywhere
This commit is contained in:
parent
a4bfd9046c
commit
57d19b21b5
@ -840,6 +840,7 @@ static void event_load_state(const char *path, char *s, size_t len)
|
||||
|
||||
static void event_main_state(unsigned cmd)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
char msg[128] = {0};
|
||||
global_t *global = global_get_ptr();
|
||||
@ -854,7 +855,9 @@ static void event_main_state(unsigned cmd)
|
||||
else
|
||||
strlcpy(path, global->name.savestate, sizeof(path));
|
||||
|
||||
if (core.retro_serialize_size())
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
if (info.size)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
|
14
movie.c
14
movie.c
@ -22,6 +22,7 @@
|
||||
#include <retro_endianness.h>
|
||||
|
||||
#include "movie.h"
|
||||
#include "libretro_version_1.h"
|
||||
#include "content.h"
|
||||
#include "general.h"
|
||||
#include "msg_hash.h"
|
||||
@ -103,6 +104,8 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
|
||||
if (state_size)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
|
||||
handle->state = (uint8_t*)malloc(state_size);
|
||||
handle->state_size = state_size;
|
||||
if (!handle->state)
|
||||
@ -114,7 +117,9 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (core.retro_serialize_size() == state_size)
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
if (info.size == state_size)
|
||||
core.retro_unserialize(handle->state, state_size);
|
||||
else
|
||||
RARCH_WARN("Movie format seems to have a different serializer version. Will most likely fail.\n");
|
||||
@ -127,6 +132,7 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
|
||||
static bool init_record(bsv_movie_t *handle, const char *path)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
uint32_t state_size;
|
||||
uint32_t header[4] = {0};
|
||||
uint32_t *content_crc_ptr = NULL;
|
||||
@ -144,7 +150,11 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
||||
* BSV1 in a HEX editor, big-endian. */
|
||||
header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);
|
||||
header[CRC_INDEX] = swap_if_big32(*content_crc_ptr);
|
||||
state_size = core.retro_serialize_size();
|
||||
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
state_size = info.size;
|
||||
|
||||
header[STATE_SIZE_INDEX] = swap_if_big32(state_size);
|
||||
|
||||
fwrite(header, 4, sizeof(uint32_t), handle->file);
|
||||
|
@ -62,14 +62,17 @@ bool np_send_nickname(netplay_t *netplay, int fd)
|
||||
|
||||
uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
uint32_t *content_crc_ptr;
|
||||
uint32_t *header, bsv_header[4] = {0};
|
||||
size_t serialize_size = core.retro_serialize_size();
|
||||
size_t header_size = sizeof(bsv_header) + serialize_size;
|
||||
size_t serialize_size, header_size;
|
||||
|
||||
*size = header_size;
|
||||
|
||||
header = (uint32_t*)malloc(header_size);
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
serialize_size = info.size;
|
||||
header_size = sizeof(bsv_header) + serialize_size;
|
||||
*size = header_size;
|
||||
header = (uint32_t*)malloc(header_size);
|
||||
if (!header)
|
||||
return NULL;
|
||||
|
||||
@ -92,6 +95,7 @@ uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic)
|
||||
|
||||
bool np_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
uint32_t *content_crc_ptr;
|
||||
uint32_t in_crc, in_magic, in_state_size;
|
||||
uint32_t in_bsv = swap_if_little32(header[MAGIC_INDEX]);
|
||||
@ -121,11 +125,13 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||
return false;
|
||||
}
|
||||
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
in_state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
||||
if (in_state_size != core.retro_serialize_size())
|
||||
if (in_state_size != info.size)
|
||||
{
|
||||
RARCH_ERR("Serialization size mismatch, got 0x%x, expected 0x%x.\n",
|
||||
(unsigned)in_state_size, (unsigned)core.retro_serialize_size());
|
||||
(unsigned)in_state_size, (unsigned)info.size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,7 @@ static void netplay_net_post_frame(netplay_t *netplay)
|
||||
static bool netplay_net_init_buffers(netplay_t *netplay)
|
||||
{
|
||||
unsigned i;
|
||||
retro_ctx_size_info_t info;
|
||||
|
||||
if (!netplay)
|
||||
return false;
|
||||
@ -104,7 +105,9 @@ static bool netplay_net_init_buffers(netplay_t *netplay)
|
||||
if (!netplay->buffer)
|
||||
return false;
|
||||
|
||||
netplay->state_size = core.retro_serialize_size();
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
netplay->state_size = info.size;
|
||||
|
||||
for (i = 0; i < netplay->buffer_size; i++)
|
||||
{
|
||||
|
5
rewind.c
5
rewind.c
@ -618,6 +618,7 @@ static void state_manager_capacity(state_manager_t *state,
|
||||
|
||||
void init_rewind(void)
|
||||
{
|
||||
retro_ctx_size_info_t info;
|
||||
void *state = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
@ -630,7 +631,9 @@ void init_rewind(void)
|
||||
return;
|
||||
}
|
||||
|
||||
rewind_state.size = core.retro_serialize_size();
|
||||
core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info);
|
||||
|
||||
rewind_state.size = info.size;
|
||||
|
||||
if (!rewind_state.size)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user