diff --git a/netplay.c b/netplay.c index 96c4c11804..26bfac9440 100644 --- a/netplay.c +++ b/netplay.c @@ -395,7 +395,7 @@ static bool init_udp_socket(netplay_t *handle, const char *server, uint16_t port } // Platform specific socket library init. -static bool init_network(void) +bool netplay_init_network(void) { static bool inited = false; if (inited) @@ -421,7 +421,7 @@ static bool init_network(void) static bool init_socket(netplay_t *handle, const char *server, uint16_t port) { - if (!init_network()) + if (!netplay_init_network()) return false; if (!init_tcp_socket(handle, server, port, handle->spectate)) diff --git a/netplay.h b/netplay.h index 5da2df58aa..4da0a58064 100644 --- a/netplay.h +++ b/netplay.h @@ -41,6 +41,8 @@ struct retro_callbacks retro_input_state_t state_cb; }; +bool netplay_init_network(void); + // Creates a new netplay handle. A NULL host means we're hosting (player 1). :) netplay_t *netplay_new(const char *server, uint16_t port, unsigned frames, diff --git a/network_cmd.c b/network_cmd.c index 10d745875d..91ef85aabf 100644 --- a/network_cmd.c +++ b/network_cmd.c @@ -14,6 +14,7 @@ */ #include "netplay_compat.h" +#include "netplay.h" #include "network_cmd.h" #include "driver.h" #include "general.h" @@ -42,6 +43,9 @@ static bool socket_nonblock(int fd) network_cmd_t *network_cmd_new(uint16_t port) { + if (!netplay_init_network()) + return NULL; + network_cmd_t *handle = (network_cmd_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; @@ -264,6 +268,9 @@ static bool verify_command(const char *cmd) bool network_cmd_send(const char *cmd_) { + if (!netplay_init_network()) + return NULL; + char *command = strdup(cmd_); if (!command) return false;