Making negative check_frames be "check only" mode

This commit is contained in:
Gregor Richards 2016-12-18 19:27:51 -05:00
parent 677ffa9ebd
commit dcd4b3046b
6 changed files with 18 additions and 16 deletions

View File

@ -402,7 +402,7 @@ typedef struct settings
char server[255];
unsigned port;
bool stateless_mode;
unsigned check_frames;
int check_frames;
bool swap_input;
bool nat_traversal;
char password[128];

View File

@ -4703,7 +4703,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
count++;
if (menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES,
PARSE_ONLY_UINT, false) != -1)
PARSE_ONLY_INT, false) != -1)
count++;
if (menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL,

View File

@ -1728,15 +1728,9 @@ void general_write_handler(void *data)
break;
case MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES:
#ifdef HAVE_NETWORKING
{
bool val = (settings->netplay.check_frames > 0);
if (val)
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL);
else
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL);
}
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL);
#endif
break;
default:
break;
}
@ -5624,7 +5618,7 @@ static bool setting_append_list(
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 0, 600, 1, true, false);
menu_settings_list_current_add_range(list, list_info, -600, 600, 1, true, false);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
CONFIG_BOOL(

View File

@ -414,7 +414,7 @@ static bool netplay_init_buffers(netplay_t *netplay)
*/
netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
const char *play_password, const char *spectate_password,
bool stateless_mode, unsigned check_frames,
bool stateless_mode, int check_frames,
const struct retro_callbacks *cb, bool nat_traversal, const char *nick,
uint64_t quirks)
{

View File

@ -442,7 +442,7 @@ struct netplay
bool catch_up;
/* Frequency with which to check CRCs */
uint32_t check_frames;
int check_frames;
/* Have we checked whether CRCs are valid at all? */
bool crc_validity_checked;
@ -647,7 +647,7 @@ bool netplay_wait_and_init_serialization(netplay_t *netplay);
*/
netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
const char *play_password, const char *spectate_password,
bool stateless_mode, unsigned check_frames,
bool stateless_mode, int check_frames,
const struct retro_callbacks *cb, bool nat_traversal, const char *nick,
uint64_t quirks);

View File

@ -137,7 +137,7 @@ static void netplay_handle_frame_hash(netplay_t *netplay, struct delta_frame *de
if (netplay->is_server)
{
if (netplay->check_frames &&
delta->frame % netplay->check_frames == 0)
delta->frame % abs(netplay->check_frames) == 0)
{
delta->crc = netplay_delta_frame_crc(netplay, delta);
netplay_cmd_crc(netplay, delta);
@ -158,7 +158,15 @@ static void netplay_handle_frame_hash(netplay_t *netplay, struct delta_frame *de
else if (netplay->crcs_valid)
{
/* Fix this! */
netplay_cmd_request_savestate(netplay);
if (netplay->check_frames < 0)
{
/* Just report */
RARCH_ERR("Netplay CRCs mismatch!\n");
}
else
{
netplay_cmd_request_savestate(netplay);
}
}
}
else if (!netplay->crc_validity_checked)