From f19d99d5236af975d9d8a8e98f6250986e34f777 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 3 Nov 2011 21:05:12 +0100 Subject: [PATCH] Log error when netplay init fails. --- ssnes.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/ssnes.c b/ssnes.c index d6c50a9c2a..d51b0be9ae 100644 --- a/ssnes.c +++ b/ssnes.c @@ -1082,27 +1082,37 @@ static void deinit_movie(void) #ifdef HAVE_NETPLAY static void init_netplay(void) { - if (g_extern.netplay_enable) + if (!g_extern.netplay_enable) + return; + + struct snes_callbacks cbs = { + .frame_cb = video_frame, + .sample_cb = audio_sample, + .state_cb = input_state + }; + + if (*g_extern.netplay_server) { - struct snes_callbacks cbs = { - .frame_cb = video_frame, - .sample_cb = audio_sample, - .state_cb = input_state - }; + SSNES_LOG("Connecting to netplay host...\n"); + g_extern.netplay_is_client = true; + } + else + SSNES_LOG("Waiting for client...\n"); - if (strlen(g_extern.netplay_server) > 0) - { - SSNES_LOG("Connecting to netplay host...\n"); - g_extern.netplay_is_client = true; - } - else - SSNES_LOG("Waiting for client...\n"); + g_extern.netplay = netplay_new(g_extern.netplay_is_client ? g_extern.netplay_server : NULL, + g_extern.netplay_port ? g_extern.netplay_port : SSNES_DEFAULT_PORT, + g_extern.netplay_sync_frames, &cbs); - g_extern.netplay = netplay_new(g_extern.netplay_is_client ? g_extern.netplay_server : NULL, g_extern.netplay_port ? g_extern.netplay_port : SSNES_DEFAULT_PORT, g_extern.netplay_sync_frames, &cbs); - if (!g_extern.netplay) + if (!g_extern.netplay) + { + g_extern.netplay_is_client = false; + SSNES_WARN("Failed to init netplay ...\n"); + + if (g_extern.msg_queue) { - g_extern.netplay_is_client = false; - SSNES_WARN("Failed to init netplay...\n"); + msg_queue_push(g_extern.msg_queue, + "Failed to init netplay ...", + 0, 180); } } }