mirror of
https://github.com/libretro/RetroArch
synced 2024-12-27 15:29:23 +00:00
Simplify content_get_crc
This commit is contained in:
parent
46b1b113e0
commit
de80671658
@ -66,7 +66,7 @@ void content_set_does_not_need_content(void);
|
|||||||
|
|
||||||
void content_unset_does_not_need_content(void);
|
void content_unset_does_not_need_content(void);
|
||||||
|
|
||||||
bool content_get_crc(uint32_t **content_crc_ptr);
|
uint32_t content_get_crc(void);
|
||||||
|
|
||||||
void content_deinit(void);
|
void content_deinit(void);
|
||||||
|
|
||||||
|
17
movie.c
17
movie.c
@ -74,7 +74,7 @@ static struct bsv_state bsv_movie_state;
|
|||||||
static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
|
static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
uint32_t state_size;
|
uint32_t state_size;
|
||||||
uint32_t *content_crc_ptr = NULL;
|
uint32_t content_crc = 0;
|
||||||
uint32_t header[4] = {0};
|
uint32_t header[4] = {0};
|
||||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||||
|
|
||||||
@ -102,10 +102,11 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_get_crc(&content_crc_ptr);
|
content_crc = content_get_crc();
|
||||||
|
|
||||||
if (swap_if_big32(header[CRC_INDEX]) != *content_crc_ptr)
|
if (content_crc != 0)
|
||||||
RARCH_WARN("%s.\n", msg_hash_to_str(MSG_CRC32_CHECKSUM_MISMATCH));
|
if (swap_if_big32(header[CRC_INDEX]) != content_crc)
|
||||||
|
RARCH_WARN("%s.\n", msg_hash_to_str(MSG_CRC32_CHECKSUM_MISMATCH));
|
||||||
|
|
||||||
state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
||||||
|
|
||||||
@ -149,8 +150,8 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path)
|
|||||||
{
|
{
|
||||||
retro_ctx_size_info_t info;
|
retro_ctx_size_info_t info;
|
||||||
uint32_t state_size;
|
uint32_t state_size;
|
||||||
|
uint32_t content_crc = 0;
|
||||||
uint32_t header[4] = {0};
|
uint32_t header[4] = {0};
|
||||||
uint32_t *content_crc_ptr = NULL;
|
|
||||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
@ -159,14 +160,14 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->file = file;
|
handle->file = file;
|
||||||
|
|
||||||
content_get_crc(&content_crc_ptr);
|
content_crc = content_get_crc();
|
||||||
|
|
||||||
/* This value is supposed to show up as
|
/* This value is supposed to show up as
|
||||||
* BSV1 in a HEX editor, big-endian. */
|
* BSV1 in a HEX editor, big-endian. */
|
||||||
header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);
|
header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);
|
||||||
header[CRC_INDEX] = swap_if_big32(*content_crc_ptr);
|
header[CRC_INDEX] = swap_if_big32(content_crc);
|
||||||
|
|
||||||
core_serialize_size(&info);
|
core_serialize_size(&info);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
|||||||
(ssize_t) (2*sizeof(uint32_t)))
|
(ssize_t) (2*sizeof(uint32_t)))
|
||||||
{
|
{
|
||||||
char s[NETPLAY_HOST_STR_LEN];
|
char s[NETPLAY_HOST_STR_LEN];
|
||||||
uint32_t *content_crc_ptr = NULL;
|
uint32_t content_crc = 0;
|
||||||
|
|
||||||
/* Make sure it's a valid query */
|
/* Make sure it's a valid query */
|
||||||
if (memcmp((void *) &ad_packet_buffer, "RANQ", 4))
|
if (memcmp((void *) &ad_packet_buffer, "RANQ", 4))
|
||||||
@ -251,7 +251,7 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
|||||||
info = runloop_get_system_info();
|
info = runloop_get_system_info();
|
||||||
|
|
||||||
/* Now build our response */
|
/* Now build our response */
|
||||||
content_get_crc(&content_crc_ptr);
|
content_crc = content_get_crc();
|
||||||
|
|
||||||
memset(&ad_packet_buffer, 0, sizeof(struct ad_packet));
|
memset(&ad_packet_buffer, 0, sizeof(struct ad_packet));
|
||||||
memcpy(&ad_packet_buffer, "RANS", 4);
|
memcpy(&ad_packet_buffer, "RANS", 4);
|
||||||
@ -274,7 +274,8 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
|||||||
strlcpy(ad_packet_buffer.core_version, info->info.library_version,
|
strlcpy(ad_packet_buffer.core_version, info->info.library_version,
|
||||||
NETPLAY_HOST_STR_LEN);
|
NETPLAY_HOST_STR_LEN);
|
||||||
}
|
}
|
||||||
snprintf(s, sizeof(s), "%d", *content_crc_ptr);
|
|
||||||
|
snprintf(s, sizeof(s), "%d", content_crc);
|
||||||
strlcpy(ad_packet_buffer.content_crc, s,
|
strlcpy(ad_packet_buffer.content_crc, s,
|
||||||
NETPLAY_HOST_STR_LEN);
|
NETPLAY_HOST_STR_LEN);
|
||||||
|
|
||||||
|
@ -605,11 +605,9 @@ static void netplay_announce(void)
|
|||||||
char *corename = NULL;
|
char *corename = NULL;
|
||||||
char *gamename = NULL;
|
char *gamename = NULL;
|
||||||
char *coreversion = NULL;
|
char *coreversion = NULL;
|
||||||
uint32_t *content_crc_ptr = NULL;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
rarch_system_info_t *system = runloop_get_system_info();
|
rarch_system_info_t *system = runloop_get_system_info();
|
||||||
|
uint32_t content_crc = content_get_crc();
|
||||||
content_get_crc(&content_crc_ptr);
|
|
||||||
|
|
||||||
net_http_urlencode_full(&username, settings->paths.username);
|
net_http_urlencode_full(&username, settings->paths.username);
|
||||||
net_http_urlencode_full(&corename, system->info.library_name);
|
net_http_urlencode_full(&corename, system->info.library_name);
|
||||||
@ -621,7 +619,7 @@ static void netplay_announce(void)
|
|||||||
snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&"
|
snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&"
|
||||||
"game_name=%s&game_crc=%08X&port=%d"
|
"game_name=%s&game_crc=%08X&port=%d"
|
||||||
"&has_password=%d&has_spectate_password=%d&force_mitm=%d",
|
"&has_password=%d&has_spectate_password=%d&force_mitm=%d",
|
||||||
username, corename, coreversion, gamename, *content_crc_ptr,
|
username, corename, coreversion, gamename, content_crc,
|
||||||
settings->uints.netplay_port,
|
settings->uints.netplay_port,
|
||||||
*settings->paths.netplay_password ? 1 : 0,
|
*settings->paths.netplay_password ? 1 : 0,
|
||||||
*settings->paths.netplay_spectate_password ? 1 : 0,
|
*settings->paths.netplay_spectate_password ? 1 : 0,
|
||||||
|
@ -471,7 +471,7 @@ static void netplay_handshake_ready(netplay_t *netplay, struct netplay_connectio
|
|||||||
bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *connection)
|
bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *connection)
|
||||||
{
|
{
|
||||||
struct info_buf_s info_buf;
|
struct info_buf_s info_buf;
|
||||||
uint32_t *content_crc_ptr = NULL;
|
uint32_t content_crc = 0;
|
||||||
rarch_system_info_t *core_info = runloop_get_system_info();
|
rarch_system_info_t *core_info = runloop_get_system_info();
|
||||||
|
|
||||||
memset(&info_buf, 0, sizeof(info_buf));
|
memset(&info_buf, 0, sizeof(info_buf));
|
||||||
@ -491,10 +491,10 @@ bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get our content CRC */
|
/* Get our content CRC */
|
||||||
content_crc_ptr = NULL;
|
content_crc = content_get_crc();
|
||||||
content_get_crc(&content_crc_ptr);
|
|
||||||
if (content_crc_ptr)
|
if (content_crc != 0)
|
||||||
info_buf.content_crc = htonl(*content_crc_ptr);
|
info_buf.content_crc = htonl(content_crc);
|
||||||
|
|
||||||
/* Send it off and wait for info back */
|
/* Send it off and wait for info back */
|
||||||
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
||||||
@ -766,7 +766,7 @@ bool netplay_handshake_pre_info(netplay_t *netplay,
|
|||||||
struct info_buf_s info_buf;
|
struct info_buf_s info_buf;
|
||||||
uint32_t cmd_size;
|
uint32_t cmd_size;
|
||||||
ssize_t recvd;
|
ssize_t recvd;
|
||||||
uint32_t *content_crc_ptr = NULL;
|
uint32_t content_crc = 0;
|
||||||
const char *dmsg = NULL;
|
const char *dmsg = NULL;
|
||||||
rarch_system_info_t *core_info = runloop_get_system_info();
|
rarch_system_info_t *core_info = runloop_get_system_info();
|
||||||
|
|
||||||
@ -818,11 +818,11 @@ bool netplay_handshake_pre_info(netplay_t *netplay,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the content CRC */
|
/* Check the content CRC */
|
||||||
content_crc_ptr = NULL;
|
content_crc = content_get_crc();
|
||||||
content_get_crc(&content_crc_ptr);
|
|
||||||
if (content_crc_ptr)
|
if (content_crc != 0)
|
||||||
{
|
{
|
||||||
if (ntohl(info_buf.content_crc) != *content_crc_ptr)
|
if (ntohl(info_buf.content_crc) != content_crc)
|
||||||
{
|
{
|
||||||
dmsg = msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER);
|
dmsg = msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -132,7 +132,7 @@ typedef struct content_information_ctx
|
|||||||
static struct string_list *temporary_content = NULL;
|
static struct string_list *temporary_content = NULL;
|
||||||
static bool _content_is_inited = false;
|
static bool _content_is_inited = false;
|
||||||
static bool core_does_not_need_content = false;
|
static bool core_does_not_need_content = false;
|
||||||
static uint32_t content_crc = 0;
|
static uint32_t content_rom_crc = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* content_file_read:
|
* content_file_read:
|
||||||
@ -320,7 +320,6 @@ static bool load_content_into_memory(
|
|||||||
unsigned i, const char *path, void **buf,
|
unsigned i, const char *path, void **buf,
|
||||||
ssize_t *length)
|
ssize_t *length)
|
||||||
{
|
{
|
||||||
uint32_t *content_crc_ptr = NULL;
|
|
||||||
uint8_t *ret_buf = NULL;
|
uint8_t *ret_buf = NULL;
|
||||||
|
|
||||||
RARCH_LOG("%s: %s.\n",
|
RARCH_LOG("%s: %s.\n",
|
||||||
@ -349,11 +348,9 @@ static bool load_content_into_memory(
|
|||||||
(void*)length);
|
(void*)length);
|
||||||
}
|
}
|
||||||
|
|
||||||
content_get_crc(&content_crc_ptr);
|
content_rom_crc = encoding_crc32(0, ret_buf, *length);
|
||||||
|
|
||||||
*content_crc_ptr = encoding_crc32(0, ret_buf, *length);
|
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)content_rom_crc);
|
||||||
|
|
||||||
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)*content_crc_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = ret_buf;
|
*buf = ret_buf;
|
||||||
@ -1577,12 +1574,9 @@ void content_unset_does_not_need_content(void)
|
|||||||
core_does_not_need_content = false;
|
core_does_not_need_content = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool content_get_crc(uint32_t **content_crc_ptr)
|
uint32_t content_get_crc(void)
|
||||||
{
|
{
|
||||||
if (!content_crc_ptr)
|
return content_rom_crc;
|
||||||
return false;
|
|
||||||
*content_crc_ptr = &content_crc;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool content_is_inited(void)
|
bool content_is_inited(void)
|
||||||
@ -1611,7 +1605,7 @@ void content_deinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
temporary_content = NULL;
|
temporary_content = NULL;
|
||||||
content_crc = 0;
|
content_rom_crc = 0;
|
||||||
_content_is_inited = false;
|
_content_is_inited = false;
|
||||||
core_does_not_need_content = false;
|
core_does_not_need_content = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user