Dynamic loading by default, add OSD message for netplay DC.

This commit is contained in:
Themaister 2011-10-05 21:44:17 +02:00
parent 892e82141f
commit f6d4d32c03
4 changed files with 31 additions and 19 deletions

View File

@ -12,6 +12,7 @@ HAVE_DSOUND = 1
HAVE_SDL = 1 HAVE_SDL = 1
HAVE_DYLIB = 1 HAVE_DYLIB = 1
HAVE_NETPLAY = 1 HAVE_NETPLAY = 1
DYNAMIC = 1
ifeq ($(SLIM),) ifeq ($(SLIM),)
HAVE_SDL_IMAGE = 1 HAVE_SDL_IMAGE = 1

View File

@ -17,6 +17,7 @@
#include "dynamic.h" #include "dynamic.h"
#include "general.h" #include "general.h"
#include "strl.h"
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
@ -47,7 +48,6 @@
static dylib_t lib_handle = NULL; static dylib_t lib_handle = NULL;
#endif #endif
void (*psnes_init)(void); void (*psnes_init)(void);
void (*psnes_set_video_refresh)(snes_video_refresh_t); void (*psnes_set_video_refresh)(snes_video_refresh_t);
@ -112,7 +112,7 @@ static void load_dynamic(void)
SYM(void (*)(snes_audio_sample_t), snes_set_audio_sample); SYM(void (*)(snes_audio_sample_t), snes_set_audio_sample);
SYM(void (*)(snes_input_poll_t), snes_set_input_poll); SYM(void (*)(snes_input_poll_t), snes_set_input_poll);
SYM(void (*)(snes_input_state_t), snes_set_input_state); SYM(void (*)(snes_input_state_t), snes_set_input_state);
OPT_SYM(const char *(*)(void), snes_library_id); SYM(const char *(*)(void), snes_library_id);
SYM(unsigned (*)(void), snes_library_revision_minor); SYM(unsigned (*)(void), snes_library_revision_minor);
SYM(unsigned (*)(void), snes_library_revision_major); SYM(unsigned (*)(void), snes_library_revision_major);
SYM(void (*)(void), snes_cheat_reset); SYM(void (*)(void), snes_cheat_reset);
@ -156,6 +156,7 @@ static void set_statics(void)
SSYM(snes_set_input_state); SSYM(snes_set_input_state);
SSYM(snes_library_revision_minor); SSYM(snes_library_revision_minor);
SSYM(snes_library_revision_major); SSYM(snes_library_revision_major);
SSYM(snes_library_id);
SSYM(snes_cheat_reset); SSYM(snes_cheat_reset);
SSYM(snes_cheat_set); SSYM(snes_cheat_set);
SSYM(snes_reset); SSYM(snes_reset);
@ -204,15 +205,20 @@ void init_dlsym(void)
} }
#endif #endif
if (strlen(g_settings.libsnes) > 0) if (!*g_settings.libsnes)
load_dynamic();
else
{ {
SSNES_ERR("This binary is built to use runtime dynamic binding of libsnes. Set libsnes_path in config to load a libsnes library dynamically.\n"); #if defined(_WIN32)
exit(1); strlcpy(g_settings.libsnes, "snes.dll", sizeof(g_settings.libsnes));
} #elif defined(__APPLE__)
strlcpy(g_settings.libsnes, "libsnes.dylib", sizeof(g_settings.libsnes));
#else #else
set_statics(); strlcpy(g_settings.libsnes, "libsnes.so", sizeof(g_settings.libsnes));
#endif
}
load_dynamic();
#else
set_statics();
#endif #endif
} }

View File

@ -19,6 +19,7 @@
#include "general.h" #include "general.h"
#include "autosave.h" #include "autosave.h"
#include "dynamic.h" #include "dynamic.h"
#include "message.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/time.h> #include <sys/time.h>
@ -96,6 +97,13 @@ struct netplay
bool has_client_addr; bool has_client_addr;
}; };
static void warn_hangup(void)
{
SSNES_WARN("Netplay has disconnected. Will continue without connection ...\n");
if (g_extern.msg_queue)
msg_queue_push(g_extern.msg_queue, "Netplay has disconnected. Will continue without connection.", 0, 480);
}
void input_poll_net(void) void input_poll_net(void)
{ {
if (!netplay_should_skip(g_extern.netplay) && netplay_can_poll(g_extern.netplay)) if (!netplay_should_skip(g_extern.netplay) && netplay_can_poll(g_extern.netplay))
@ -401,7 +409,7 @@ static bool send_chunk(netplay_t *handle)
{ {
if (sendto(handle->udp_fd, CONST_CAST handle->packet_buffer, sizeof(handle->packet_buffer), 0, addr, sizeof(struct sockaddr)) != sizeof(handle->packet_buffer)) if (sendto(handle->udp_fd, CONST_CAST handle->packet_buffer, sizeof(handle->packet_buffer), 0, addr, sizeof(struct sockaddr)) != sizeof(handle->packet_buffer))
{ {
SSNES_WARN("Netplay connection hung up. Will continue without netplay.\n"); warn_hangup();
handle->has_connection = false; handle->has_connection = false;
return false; return false;
} }
@ -441,7 +449,7 @@ static int poll_input(netplay_t *handle, bool block)
if (block && !send_chunk(handle)) if (block && !send_chunk(handle))
{ {
SSNES_WARN("Netplay connection hung up. Will continue without netplay.\n"); warn_hangup();
handle->has_connection = false; handle->has_connection = false;
return -1; return -1;
} }
@ -483,7 +491,7 @@ static bool get_self_input_state(netplay_t *handle)
if (!send_chunk(handle)) if (!send_chunk(handle))
{ {
SSNES_WARN("Netplay connection hung up. Will continue without netplay.\n"); warn_hangup();
handle->has_connection = false; handle->has_connection = false;
return false; return false;
} }
@ -570,7 +578,7 @@ bool netplay_poll(netplay_t *handle)
if (res == -1) if (res == -1)
{ {
handle->has_connection = false; handle->has_connection = false;
SSNES_WARN("Netplay connection timed out. Will continue without netplay.\n"); warn_hangup();
return false; return false;
} }
@ -582,7 +590,7 @@ bool netplay_poll(netplay_t *handle)
uint32_t buffer[UDP_FRAME_PACKETS * 2]; uint32_t buffer[UDP_FRAME_PACKETS * 2];
if (!receive_data(handle, buffer, sizeof(buffer))) if (!receive_data(handle, buffer, sizeof(buffer)))
{ {
SSNES_WARN("Netplay connection hung up. Will continue without netplay.\n"); warn_hangup();
handle->has_connection = false; handle->has_connection = false;
return false; return false;
} }
@ -597,7 +605,7 @@ bool netplay_poll(netplay_t *handle)
// Cannot allow this. Should not happen though. // Cannot allow this. Should not happen though.
if (handle->self_ptr == handle->other_ptr) if (handle->self_ptr == handle->other_ptr)
{ {
SSNES_WARN("Netplay connection hung up. Will continue without netplay.\n"); warn_hangup();
return false; return false;
} }
} }

View File

@ -1593,10 +1593,7 @@ static void do_state_checks(void)
static void fill_title_buf(void) static void fill_title_buf(void)
{ {
if (psnes_library_id) snprintf(g_extern.title_buf, sizeof(g_extern.title_buf), "SSNES : %s", psnes_library_id());
snprintf(g_extern.title_buf, sizeof(g_extern.title_buf), "SSNES : %s", psnes_library_id());
else
snprintf(g_extern.title_buf, sizeof(g_extern.title_buf), "SSNES");
} }
static void init_state(void) static void init_state(void)