mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Turn bunch of functions static
This commit is contained in:
parent
0d549fd42b
commit
f7a5833cb0
@ -90,7 +90,7 @@ void netplay_key_hton_init(void)
|
||||
{
|
||||
uint16_t i;
|
||||
for (i = 0; i < NETPLAY_KEY_LAST; i++)
|
||||
mapping[netplay_key_ntoh(i)] = i;
|
||||
mapping[NETPLAY_KEY_NTOH(i)] = i;
|
||||
mapping_defined = true;
|
||||
}
|
||||
}
|
||||
@ -176,7 +176,7 @@ static void free_input_state(netplay_input_state_t *list)
|
||||
*
|
||||
* Free a delta frame's dependencies
|
||||
*/
|
||||
void netplay_delta_frame_free(struct delta_frame *delta)
|
||||
static void netplay_delta_frame_free(struct delta_frame *delta)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
@ -318,7 +318,7 @@ static size_t buf_remaining(struct socket_buffer *sbuf)
|
||||
*
|
||||
* Initialize a new socket buffer.
|
||||
*/
|
||||
bool netplay_init_socket_buffer(
|
||||
static bool netplay_init_socket_buffer(
|
||||
struct socket_buffer *sbuf, size_t size)
|
||||
{
|
||||
sbuf->data = (unsigned char*)malloc(size);
|
||||
@ -334,7 +334,7 @@ bool netplay_init_socket_buffer(
|
||||
*
|
||||
* Resize the given socket_buffer's buffer to the requested size.
|
||||
*/
|
||||
bool netplay_resize_socket_buffer(
|
||||
static bool netplay_resize_socket_buffer(
|
||||
struct socket_buffer *sbuf, size_t newsize)
|
||||
{
|
||||
unsigned char *newdata = (unsigned char*)malloc(newsize);
|
||||
@ -379,7 +379,7 @@ bool netplay_resize_socket_buffer(
|
||||
*
|
||||
* Free a socket buffer.
|
||||
*/
|
||||
void netplay_deinit_socket_buffer(struct socket_buffer *sbuf)
|
||||
static void netplay_deinit_socket_buffer(struct socket_buffer *sbuf)
|
||||
{
|
||||
if (sbuf->data)
|
||||
free(sbuf->data);
|
||||
@ -641,6 +641,63 @@ void netplay_recv_flush(struct socket_buffer *sbuf)
|
||||
sbuf->start = sbuf->read;
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_cmd_crc
|
||||
*
|
||||
* Send a CRC command to all active clients.
|
||||
*/
|
||||
static bool netplay_cmd_crc(netplay_t *netplay, struct delta_frame *delta)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t payload[2];
|
||||
bool success = true;
|
||||
|
||||
payload[0] = htonl(delta->frame);
|
||||
payload[1] = htonl(delta->crc);
|
||||
|
||||
for (i = 0; i < netplay->connections_size; i++)
|
||||
{
|
||||
if (netplay->connections[i].active &&
|
||||
netplay->connections[i].mode >= NETPLAY_CONNECTION_CONNECTED)
|
||||
success = netplay_send_raw_cmd(netplay, &netplay->connections[i],
|
||||
NETPLAY_CMD_CRC, payload, sizeof(payload)) && success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_cmd_request_savestate
|
||||
*
|
||||
* Send a savestate request command.
|
||||
*/
|
||||
static bool netplay_cmd_request_savestate(netplay_t *netplay)
|
||||
{
|
||||
if (netplay->connections_size == 0 ||
|
||||
!netplay->connections[0].active ||
|
||||
netplay->connections[0].mode < NETPLAY_CONNECTION_CONNECTED)
|
||||
return false;
|
||||
if (netplay->savestate_request_outstanding)
|
||||
return true;
|
||||
netplay->savestate_request_outstanding = true;
|
||||
return netplay_send_raw_cmd(netplay, &netplay->connections[0],
|
||||
NETPLAY_CMD_REQUEST_SAVESTATE, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_cmd_stall
|
||||
*
|
||||
* Send a stall command.
|
||||
*/
|
||||
static bool netplay_cmd_stall(netplay_t *netplay,
|
||||
struct netplay_connection *connection,
|
||||
uint32_t frames)
|
||||
{
|
||||
frames = htonl(frames);
|
||||
return netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_STALL, &frames, sizeof(frames));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void handle_play_spectate(netplay_t *netplay, uint32_t client_num,
|
||||
struct netplay_connection *connection, uint32_t cmd, uint32_t cmd_size,
|
||||
uint32_t *payload);
|
||||
@ -2072,43 +2129,47 @@ static bool netplay_cmd_nak(netplay_t *netplay,
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_cmd_crc
|
||||
* netplay_settings_share_mode
|
||||
*
|
||||
* Send a CRC command to all active clients.
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
bool netplay_cmd_crc(netplay_t *netplay, struct delta_frame *delta)
|
||||
static uint8_t netplay_settings_share_mode(
|
||||
unsigned share_digital, unsigned share_analog)
|
||||
{
|
||||
uint32_t payload[2];
|
||||
bool success = true;
|
||||
size_t i;
|
||||
payload[0] = htonl(delta->frame);
|
||||
payload[1] = htonl(delta->crc);
|
||||
for (i = 0; i < netplay->connections_size; i++)
|
||||
if (share_digital || share_analog)
|
||||
{
|
||||
if (netplay->connections[i].active &&
|
||||
netplay->connections[i].mode >= NETPLAY_CONNECTION_CONNECTED)
|
||||
success = netplay_send_raw_cmd(netplay, &netplay->connections[i],
|
||||
NETPLAY_CMD_CRC, payload, sizeof(payload)) && success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
uint8_t share_mode = 0;
|
||||
|
||||
/**
|
||||
* netplay_cmd_request_savestate
|
||||
*
|
||||
* Send a savestate request command.
|
||||
*/
|
||||
bool netplay_cmd_request_savestate(netplay_t *netplay)
|
||||
{
|
||||
if (netplay->connections_size == 0 ||
|
||||
!netplay->connections[0].active ||
|
||||
netplay->connections[0].mode < NETPLAY_CONNECTION_CONNECTED)
|
||||
return false;
|
||||
if (netplay->savestate_request_outstanding)
|
||||
return true;
|
||||
netplay->savestate_request_outstanding = true;
|
||||
return netplay_send_raw_cmd(netplay, &netplay->connections[0],
|
||||
NETPLAY_CMD_REQUEST_SAVESTATE, NULL, 0);
|
||||
switch (share_digital)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_OR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_OR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_XOR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_VOTE:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_VOTE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
|
||||
switch (share_analog)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_MAX:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_MAX;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_AVERAGE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
|
||||
return share_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2176,19 +2237,6 @@ bool netplay_cmd_mode(netplay_t *netplay,
|
||||
payload ? sizeof(uint32_t) : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_cmd_stall
|
||||
*
|
||||
* Send a stall command.
|
||||
*/
|
||||
bool netplay_cmd_stall(netplay_t *netplay,
|
||||
struct netplay_connection *connection,
|
||||
uint32_t frames)
|
||||
{
|
||||
frames = htonl(frames);
|
||||
return netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_STALL, &frames, sizeof(frames));
|
||||
}
|
||||
|
||||
/**
|
||||
* announce_play_spectate
|
||||
*
|
||||
|
@ -584,27 +584,6 @@ struct netplay
|
||||
* NETPLAY-BUF.C
|
||||
**************************************************************/
|
||||
|
||||
/**
|
||||
* netplay_init_socket_buffer
|
||||
*
|
||||
* Initialize a new socket buffer.
|
||||
*/
|
||||
bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t size);
|
||||
|
||||
/**
|
||||
* netplay_resize_socket_buffer
|
||||
*
|
||||
* Resize the given socket_buffer's buffer to the requested size.
|
||||
*/
|
||||
bool netplay_resize_socket_buffer(struct socket_buffer *sbuf, size_t newsize);
|
||||
|
||||
/**
|
||||
* netplay_deinit_socket_buffer
|
||||
*
|
||||
* Free a socket buffer.
|
||||
*/
|
||||
void netplay_deinit_socket_buffer(struct socket_buffer *sbuf);
|
||||
|
||||
/**
|
||||
* netplay_send
|
||||
*
|
||||
@ -665,13 +644,6 @@ void netplay_recv_flush(struct socket_buffer *sbuf);
|
||||
bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta,
|
||||
uint32_t frame);
|
||||
|
||||
/**
|
||||
* netplay_delta_frame_free
|
||||
*
|
||||
* Free a delta frame's dependencies
|
||||
*/
|
||||
void netplay_delta_frame_free(struct delta_frame *delta);
|
||||
|
||||
/**
|
||||
* netplay_input_state_for
|
||||
*
|
||||
@ -715,13 +687,6 @@ bool netplay_lan_ad_server(netplay_t *netplay);
|
||||
void netplay_load_savestate(netplay_t *netplay,
|
||||
retro_ctx_serialize_info_t *serial_info, bool save);
|
||||
|
||||
/**
|
||||
* netplay_settings_share_mode
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analog);
|
||||
|
||||
/**
|
||||
* input_poll_net
|
||||
*
|
||||
@ -852,20 +817,6 @@ void netplay_send_raw_cmd_all(netplay_t *netplay,
|
||||
struct netplay_connection *except, uint32_t cmd, const void *data,
|
||||
size_t size);
|
||||
|
||||
/**
|
||||
* netplay_cmd_crc
|
||||
*
|
||||
* Send a CRC command to all active clients.
|
||||
*/
|
||||
bool netplay_cmd_crc(netplay_t *netplay, struct delta_frame *delta);
|
||||
|
||||
/**
|
||||
* netplay_cmd_request_savestate
|
||||
*
|
||||
* Send a savestate request command.
|
||||
*/
|
||||
bool netplay_cmd_request_savestate(netplay_t *netplay);
|
||||
|
||||
/**
|
||||
* netplay_cmd_mode
|
||||
*
|
||||
@ -875,15 +826,6 @@ bool netplay_cmd_request_savestate(netplay_t *netplay);
|
||||
bool netplay_cmd_mode(netplay_t *netplay,
|
||||
enum rarch_netplay_connection_mode mode);
|
||||
|
||||
/**
|
||||
* netplay_cmd_stall
|
||||
*
|
||||
* Send a stall command.
|
||||
*/
|
||||
bool netplay_cmd_stall(netplay_t *netplay,
|
||||
struct netplay_connection *connection,
|
||||
uint32_t frames);
|
||||
|
||||
/**
|
||||
* netplay_poll_net_input
|
||||
*
|
||||
@ -929,7 +871,7 @@ enum netplay_keys {
|
||||
|
||||
/* The mapping of keys from netplay (network) to libretro (host) */
|
||||
extern const uint16_t netplay_key_ntoh_mapping[];
|
||||
#define netplay_key_ntoh(k) (netplay_key_ntoh_mapping[k])
|
||||
#define NETPLAY_KEY_NTOH(k) (netplay_key_ntoh_mapping[k])
|
||||
|
||||
/* The mapping of keys from libretro (host) to netplay (network) */
|
||||
uint32_t netplay_key_hton(unsigned key);
|
||||
|
85
retroarch.c
85
retroarch.c
@ -6875,7 +6875,8 @@ static bool get_self_input_state(
|
||||
for (key = 1; key < NETPLAY_KEY_LAST; key++)
|
||||
{
|
||||
state[word] |=
|
||||
cb(local_device, RETRO_DEVICE_KEYBOARD, 0, netplay_key_ntoh(key)) ?
|
||||
cb(local_device, RETRO_DEVICE_KEYBOARD, 0,
|
||||
NETPLAY_KEY_NTOH(key)) ?
|
||||
(UINT32_C(1) << bit) : 0;
|
||||
bit++;
|
||||
if (bit >= 32)
|
||||
@ -7886,28 +7887,26 @@ void netplay_load_savestate(netplay_t *netplay,
|
||||
/* Record it in our own buffer */
|
||||
if (save || !serial_info)
|
||||
{
|
||||
if (netplay_delta_frame_ready(netplay,
|
||||
/* TODO/FIXME: This is a critical failure! */
|
||||
if (!netplay_delta_frame_ready(netplay,
|
||||
&netplay->buffer[netplay->run_ptr], netplay->run_frame_count))
|
||||
{
|
||||
if (!serial_info)
|
||||
{
|
||||
tmp_serial_info.size = netplay->state_size;
|
||||
tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state;
|
||||
if (!core_serialize(&tmp_serial_info))
|
||||
return;
|
||||
tmp_serial_info.data_const = tmp_serial_info.data;
|
||||
serial_info = &tmp_serial_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serial_info->size <= netplay->state_size)
|
||||
memcpy(netplay->buffer[netplay->run_ptr].state,
|
||||
serial_info->data_const, serial_info->size);
|
||||
}
|
||||
}
|
||||
/* FIXME: This is a critical failure! */
|
||||
else
|
||||
return;
|
||||
|
||||
if (!serial_info)
|
||||
{
|
||||
tmp_serial_info.size = netplay->state_size;
|
||||
tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state;
|
||||
if (!core_serialize(&tmp_serial_info))
|
||||
return;
|
||||
tmp_serial_info.data_const = tmp_serial_info.data;
|
||||
serial_info = &tmp_serial_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serial_info->size <= netplay->state_size)
|
||||
memcpy(netplay->buffer[netplay->run_ptr].state,
|
||||
serial_info->data_const, serial_info->size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't send it if we're expected to be desynced */
|
||||
@ -7959,50 +7958,6 @@ static void netplay_core_reset(netplay_t *netplay)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_settings_share_mode
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(
|
||||
unsigned share_digital, unsigned share_analog)
|
||||
{
|
||||
if (share_digital || share_analog)
|
||||
{
|
||||
uint8_t share_mode = 0;
|
||||
|
||||
switch (share_digital)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_OR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_OR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_XOR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_XOR;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_VOTE:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_VOTE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
|
||||
switch (share_analog)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_MAX:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_MAX;
|
||||
break;
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_AVERAGE;
|
||||
break;
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
|
||||
return share_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* netplay_toggle_play_spectate
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user