Rename np_ functions
This commit is contained in:
parent
315c6b9687
commit
cba281052a
|
@ -589,7 +589,7 @@ int16_t input_state_net(unsigned port, unsigned device,
|
||||||
|
|
||||||
#ifndef HAVE_SOCKET_LEGACY
|
#ifndef HAVE_SOCKET_LEGACY
|
||||||
/* Custom inet_ntop. Win32 doesn't seem to support this ... */
|
/* Custom inet_ntop. Win32 doesn't seem to support this ... */
|
||||||
void np_log_connection(const struct sockaddr_storage *their_addr,
|
void netplay_log_connection(const struct sockaddr_storage *their_addr,
|
||||||
unsigned slot, const char *nick)
|
unsigned slot, const char *nick)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <net/net_socket.h>
|
#include <net/net_socket.h>
|
||||||
#include "../content.h"
|
#include "../content.h"
|
||||||
|
|
||||||
bool np_get_nickname(netplay_t *netplay, int fd)
|
bool netplay_get_nickname(netplay_t *netplay, int fd)
|
||||||
{
|
{
|
||||||
uint8_t nick_size;
|
uint8_t nick_size;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ bool np_get_nickname(netplay_t *netplay, int fd)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool np_send_nickname(netplay_t *netplay, int fd)
|
bool netplay_send_nickname(netplay_t *netplay, int fd)
|
||||||
{
|
{
|
||||||
uint8_t nick_size = strlen(netplay->nick);
|
uint8_t nick_size = strlen(netplay->nick);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ bool np_send_nickname(netplay_t *netplay, int fd)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic)
|
uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic)
|
||||||
{
|
{
|
||||||
retro_ctx_serialize_info_t serial_info;
|
retro_ctx_serialize_info_t serial_info;
|
||||||
retro_ctx_size_info_t info;
|
retro_ctx_size_info_t info;
|
||||||
|
@ -100,7 +100,7 @@ error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool np_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||||
{
|
{
|
||||||
retro_ctx_size_info_t info;
|
retro_ctx_size_info_t info;
|
||||||
uint32_t *content_crc_ptr;
|
uint32_t *content_crc_ptr;
|
||||||
|
@ -146,7 +146,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* np_impl_magic:
|
* netplay_impl_magic:
|
||||||
*
|
*
|
||||||
* Not really a hash, but should be enough to differentiate
|
* Not really a hash, but should be enough to differentiate
|
||||||
* implementations from each other.
|
* implementations from each other.
|
||||||
|
@ -155,7 +155,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic)
|
||||||
* The alternative would have been checking serialization sizes, but it
|
* The alternative would have been checking serialization sizes, but it
|
||||||
* was troublesome for cross platform compat.
|
* was troublesome for cross platform compat.
|
||||||
**/
|
**/
|
||||||
uint32_t np_impl_magic(void)
|
uint32_t netplay_impl_magic(void)
|
||||||
{
|
{
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
retro_ctx_api_info_t api_info;
|
retro_ctx_api_info_t api_info;
|
||||||
|
@ -193,7 +193,7 @@ uint32_t np_impl_magic(void)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool np_send_info(netplay_t *netplay)
|
bool netplay_send_info(netplay_t *netplay)
|
||||||
{
|
{
|
||||||
unsigned sram_size;
|
unsigned sram_size;
|
||||||
retro_ctx_memory_info_t mem_info;
|
retro_ctx_memory_info_t mem_info;
|
||||||
|
@ -208,13 +208,13 @@ bool np_send_info(netplay_t *netplay)
|
||||||
content_get_crc(&content_crc_ptr);
|
content_get_crc(&content_crc_ptr);
|
||||||
|
|
||||||
header[0] = htonl(*content_crc_ptr);
|
header[0] = htonl(*content_crc_ptr);
|
||||||
header[1] = htonl(np_impl_magic());
|
header[1] = htonl(netplay_impl_magic());
|
||||||
header[2] = htonl(mem_info.size);
|
header[2] = htonl(mem_info.size);
|
||||||
|
|
||||||
if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false))
|
if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!np_send_nickname(netplay, netplay->fd))
|
if (!netplay_send_nickname(netplay, netplay->fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to send nick to host.\n");
|
RARCH_ERR("Failed to send nick to host.\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -230,7 +230,7 @@ bool np_send_info(netplay_t *netplay)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!np_get_nickname(netplay, netplay->fd))
|
if (!netplay_get_nickname(netplay, netplay->fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to receive nick from host.\n");
|
RARCH_ERR("Failed to receive nick from host.\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -243,7 +243,7 @@ bool np_send_info(netplay_t *netplay)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool np_get_info(netplay_t *netplay)
|
bool netplay_get_info(netplay_t *netplay)
|
||||||
{
|
{
|
||||||
unsigned sram_size;
|
unsigned sram_size;
|
||||||
uint32_t header[3];
|
uint32_t header[3];
|
||||||
|
@ -265,7 +265,7 @@ bool np_get_info(netplay_t *netplay)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np_impl_magic() != ntohl(header[1]))
|
if (netplay_impl_magic() != ntohl(header[1]))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Implementations differ, make sure you're using exact same "
|
RARCH_ERR("Implementations differ, make sure you're using exact same "
|
||||||
"libretro implementations and RetroArch version.\n");
|
"libretro implementations and RetroArch version.\n");
|
||||||
|
@ -282,7 +282,7 @@ bool np_get_info(netplay_t *netplay)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!np_get_nickname(netplay, netplay->fd))
|
if (!netplay_get_nickname(netplay, netplay->fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to get nickname from client.\n");
|
RARCH_ERR("Failed to get nickname from client.\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -298,14 +298,14 @@ bool np_get_info(netplay_t *netplay)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!np_send_nickname(netplay, netplay->fd))
|
if (!netplay_send_nickname(netplay, netplay->fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to send nickname to client.\n");
|
RARCH_ERR("Failed to send nickname to client.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_SOCKET_LEGACY
|
#ifndef HAVE_SOCKET_LEGACY
|
||||||
np_log_connection(&netplay->other_addr, 0, netplay->other_nick);
|
netplay_log_connection(&netplay->other_addr, 0, netplay->other_nick);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -318,7 +318,7 @@ bool netplay_is_server(netplay_t* netplay)
|
||||||
return netplay->is_server;
|
return netplay->is_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool np_is_spectate(netplay_t* netplay)
|
bool netplay_is_spectate(netplay_t* netplay)
|
||||||
{
|
{
|
||||||
if (!netplay)
|
if (!netplay)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -139,12 +139,12 @@ static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames)
|
||||||
{
|
{
|
||||||
if (netplay_is_server(netplay))
|
if (netplay_is_server(netplay))
|
||||||
{
|
{
|
||||||
if (!np_send_info(netplay))
|
if (!netplay_send_info(netplay))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!np_get_info(netplay))
|
if (!netplay_get_info(netplay))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,18 +139,18 @@ extern void *netplay_data;
|
||||||
|
|
||||||
struct netplay_callbacks* netplay_get_cbs_net(void);
|
struct netplay_callbacks* netplay_get_cbs_net(void);
|
||||||
struct netplay_callbacks* netplay_get_cbs_spectate(void);
|
struct netplay_callbacks* netplay_get_cbs_spectate(void);
|
||||||
void np_log_connection(const struct sockaddr_storage *their_addr,
|
void netplay_log_connection(const struct sockaddr_storage *their_addr,
|
||||||
unsigned slot, const char *nick);
|
unsigned slot, const char *nick);
|
||||||
|
|
||||||
bool np_get_nickname(netplay_t *netplay, int fd);
|
bool netplay_get_nickname(netplay_t *netplay, int fd);
|
||||||
bool np_send_nickname(netplay_t *netplay, int fd);
|
bool netplay_send_nickname(netplay_t *netplay, int fd);
|
||||||
bool np_send_info(netplay_t *netplay);
|
bool netplay_send_info(netplay_t *netplay);
|
||||||
uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic);
|
uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic);
|
||||||
bool np_bsv_parse_header(const uint32_t *header, uint32_t magic);
|
bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic);
|
||||||
uint32_t np_impl_magic(void);
|
uint32_t netplay_impl_magic(void);
|
||||||
bool np_send_info(netplay_t *netplay);
|
bool netplay_send_info(netplay_t *netplay);
|
||||||
bool np_get_info(netplay_t *netplay);
|
bool netplay_get_info(netplay_t *netplay);
|
||||||
bool netplay_is_server(netplay_t* netplay);
|
bool netplay_is_server(netplay_t* netplay);
|
||||||
bool np_is_spectate(netplay_t* netplay);
|
bool netplay_is_spectate(netplay_t* netplay);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -78,22 +78,22 @@ static void netplay_spectate_pre_frame(netplay_t *netplay)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!np_get_nickname(netplay, new_fd))
|
if (!netplay_get_nickname(netplay, new_fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to get nickname from client.\n");
|
RARCH_ERR("Failed to get nickname from client.\n");
|
||||||
socket_close(new_fd);
|
socket_close(new_fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!np_send_nickname(netplay, new_fd))
|
if (!netplay_send_nickname(netplay, new_fd))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to send nickname to client.\n");
|
RARCH_ERR("Failed to send nickname to client.\n");
|
||||||
socket_close(new_fd);
|
socket_close(new_fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
header = np_bsv_header_generate(&header_size,
|
header = netplay_bsv_header_generate(&header_size,
|
||||||
np_impl_magic());
|
netplay_impl_magic());
|
||||||
|
|
||||||
if (!header)
|
if (!header)
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay)
|
||||||
netplay->spectate.fds[idx] = new_fd;
|
netplay->spectate.fds[idx] = new_fd;
|
||||||
|
|
||||||
#ifndef HAVE_SOCKET_LEGACY
|
#ifndef HAVE_SOCKET_LEGACY
|
||||||
np_log_connection(&their_addr, idx, netplay->other_nick);
|
netplay_log_connection(&their_addr, idx, netplay->other_nick);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ static bool netplay_spectate_info_cb(netplay_t *netplay, unsigned frames)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
if(netplay_is_server(netplay))
|
if(netplay_is_server(netplay))
|
||||||
{
|
{
|
||||||
if(!np_get_info(netplay))
|
if(!netplay_get_info(netplay))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue