mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Move nickname field to connections. Spectate mode officially broken.
This commit is contained in:
parent
189cc6e5d6
commit
d1d29143b2
@ -29,51 +29,6 @@
|
||||
#include "../../runloop.h"
|
||||
#include "../../version.h"
|
||||
|
||||
bool netplay_get_nickname(netplay_t *netplay, int fd)
|
||||
{
|
||||
uint8_t nick_size;
|
||||
|
||||
if (!socket_receive_all_blocking(fd, &nick_size, sizeof(nick_size)))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_NICKNAME_SIZE_FROM_HOST));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nick_size >= sizeof(netplay->other_nick))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_INVALID_NICKNAME_SIZE));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!socket_receive_all_blocking(fd, netplay->other_nick, nick_size))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_RECEIVE_NICKNAME));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool netplay_send_nickname(netplay_t *netplay, int fd)
|
||||
{
|
||||
uint8_t nick_size = strlen(netplay->nick);
|
||||
|
||||
if (!socket_send_all_blocking(fd, &nick_size, sizeof(nick_size), false))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_SEND_NICKNAME_SIZE));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!socket_send_all_blocking(fd, netplay->nick, nick_size, false))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_SEND_NICKNAME));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_impl_magic:
|
||||
*
|
||||
@ -307,7 +262,7 @@ static void netplay_handshake_ready(netplay_t *netplay, struct netplay_connectio
|
||||
|
||||
if (netplay->is_server)
|
||||
{
|
||||
netplay_log_connection(&netplay->other_addr, 0, netplay->other_nick);
|
||||
netplay_log_connection(&netplay->other_addr, 0, connection->nick);
|
||||
|
||||
/* Send them the savestate */
|
||||
if (!(netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION)))
|
||||
@ -319,7 +274,7 @@ static void netplay_handshake_ready(netplay_t *netplay, struct netplay_connectio
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "%s: \"%s\"",
|
||||
msg_hash_to_str(MSG_CONNECTED_TO),
|
||||
netplay->other_nick);
|
||||
connection->nick);
|
||||
RARCH_LOG("%s\n", msg);
|
||||
runloop_msg_queue_push(msg, 1, 180, false);
|
||||
}
|
||||
@ -359,9 +314,9 @@ bool netplay_handshake_pre_nick(netplay_t *netplay, struct netplay_connection *c
|
||||
return false;
|
||||
}
|
||||
|
||||
strlcpy(netplay->other_nick, nick_buf.nick,
|
||||
(sizeof(netplay->other_nick) < sizeof(nick_buf.nick)) ?
|
||||
sizeof(netplay->other_nick) : sizeof(nick_buf.nick));
|
||||
strlcpy(connection->nick, nick_buf.nick,
|
||||
(sizeof(connection->nick) < sizeof(nick_buf.nick)) ?
|
||||
sizeof(connection->nick) : sizeof(nick_buf.nick));
|
||||
|
||||
if (netplay->is_server)
|
||||
{
|
||||
|
@ -232,6 +232,9 @@ struct netplay_connection
|
||||
/* fd associated with this connection */
|
||||
int fd;
|
||||
|
||||
/* Nickname of peer */
|
||||
char nick[32];
|
||||
|
||||
/* Buffers for sending and receiving data */
|
||||
struct socket_buffer send_packet_buffer, recv_packet_buffer;
|
||||
|
||||
@ -247,9 +250,6 @@ struct netplay
|
||||
/* Our nickname */
|
||||
char nick[32];
|
||||
|
||||
/* Nickname of peer */
|
||||
char other_nick[32];
|
||||
|
||||
/* Address of peer */
|
||||
struct sockaddr_storage other_addr;
|
||||
|
||||
|
@ -97,6 +97,7 @@ static bool netplay_spectate_pre_frame(netplay_t *netplay)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!netplay_get_nickname(netplay, new_fd))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_GET_NICKNAME_FROM_CLIENT));
|
||||
@ -110,6 +111,7 @@ static bool netplay_spectate_pre_frame(netplay_t *netplay)
|
||||
socket_close(new_fd);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wait until it's safe to serialize */
|
||||
if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION)
|
||||
@ -278,11 +280,13 @@ static bool netplay_spectate_info_cb(netplay_t* netplay, unsigned frames)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
if (!netplay_send_nickname(netplay, netplay->connections[0].fd))
|
||||
return false;
|
||||
|
||||
if (!netplay_get_nickname(netplay, netplay->connections[0].fd))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
netplay->connections[0].mode = netplay->self_mode = NETPLAY_CONNECTION_PLAYING;
|
||||
|
Loading…
x
Reference in New Issue
Block a user