mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Re-fix Wii compile
This commit is contained in:
parent
4e90dad903
commit
ed13ce7073
@ -187,6 +187,7 @@ private:
|
||||
public:
|
||||
CmdPipe *gui;
|
||||
#elif defined(GEKKO)
|
||||
public:
|
||||
void open_close_joystick(int port, int oldjoy, int newjoy);
|
||||
double speed_index;
|
||||
#endif
|
||||
|
@ -395,9 +395,6 @@ size_t Network::EncodeSoundBuffer(struct NetworkUpdate *dst, Uint8 *buf, size_t
|
||||
|
||||
void Network::EncodeSound()
|
||||
{
|
||||
NetworkUpdate *dst = (NetworkUpdate *)this->cur_ud;
|
||||
int cnt = 0;
|
||||
|
||||
/* Nothing to encode? */
|
||||
if (!this->is_master ||
|
||||
Network::sample_head == Network::sample_tail)
|
||||
@ -561,7 +558,6 @@ bool Network::SendUpdate()
|
||||
|
||||
void Network::AddNetworkUpdate(NetworkUpdate *update)
|
||||
{
|
||||
size_t sz = update->size;
|
||||
Uint8 *next = (Uint8*)this->cur_ud + update->size;
|
||||
|
||||
this->cur_ud = (NetworkUpdate*)next;
|
||||
@ -584,7 +580,7 @@ bool Network::MarshalData(NetworkUpdate *p)
|
||||
case LIST_PEERS:
|
||||
{
|
||||
NetworkUpdateListPeers *lp = (NetworkUpdateListPeers *)p->data;
|
||||
for (int i = 0; i < lp->n_peers; i++)
|
||||
for (unsigned int i = 0; i < lp->n_peers; i++)
|
||||
{
|
||||
NetworkUpdatePeerInfo *peer = &lp->peers[i];
|
||||
|
||||
@ -654,7 +650,7 @@ bool Network::DeMarshalData(NetworkUpdate *p)
|
||||
NetworkUpdateListPeers *lp = (NetworkUpdateListPeers *)p->data;
|
||||
|
||||
lp->n_peers = ntohl(lp->n_peers);
|
||||
for (int i = 0; i < lp->n_peers; i++)
|
||||
for (unsigned int i = 0; i < lp->n_peers; i++)
|
||||
{
|
||||
NetworkUpdatePeerInfo *peer = &lp->peers[i];
|
||||
|
||||
@ -716,8 +712,6 @@ bool Network::DecodeUpdate(uint8 *screen, uint8 *js)
|
||||
break;
|
||||
case LIST_PEERS:
|
||||
{
|
||||
NetworkUpdateListPeers *lp = (NetworkUpdateListPeers *)p->data;
|
||||
|
||||
} break;
|
||||
case PING:
|
||||
/* Send an ack */
|
||||
@ -844,7 +838,6 @@ bool Network::WaitForPeerList()
|
||||
bool Network::WaitForPeerReply()
|
||||
{
|
||||
struct timeval tv;
|
||||
const char **msgs;
|
||||
|
||||
tv.tv_sec = 3;
|
||||
tv.tv_usec = 0;
|
||||
@ -966,7 +959,7 @@ uint8 Network::sample_buf[NETWORK_SOUND_BUF_SIZE];
|
||||
int Network::sample_head;
|
||||
int Network::sample_tail;
|
||||
|
||||
#if defined(GEKKOd)
|
||||
#if defined(GEKKO)
|
||||
#include "NetworkWii.h"
|
||||
#else
|
||||
#include "NetworkUnix.h"
|
||||
|
@ -15,7 +15,7 @@ static int set_sock_opts(int sock)
|
||||
&tv, sizeof(struct timeval));
|
||||
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
|
||||
&tv, sizeof(struct timeval));
|
||||
setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
return setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
}
|
||||
|
||||
/* From glibc docs */
|
||||
|
130
Src/NetworkWii.h
130
Src/NetworkWii.h
@ -13,9 +13,7 @@ static int set_sock_opts(int sock)
|
||||
&tv, sizeof(struct timeval));
|
||||
net_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
|
||||
&tv, sizeof(struct timeval));
|
||||
net_setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
|
||||
return 0;
|
||||
return net_setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
}
|
||||
|
||||
/* From glibc docs */
|
||||
@ -47,7 +45,7 @@ static int make_socket (uint16_t port)
|
||||
return sock;
|
||||
}
|
||||
|
||||
bool init_sockaddr (struct sockaddr_in *name,
|
||||
bool Network::InitSockaddr (struct sockaddr_in *name,
|
||||
const char *hostname, uint16_t port)
|
||||
{
|
||||
struct hostent *hostinfo;
|
||||
@ -60,103 +58,57 @@ bool init_sockaddr (struct sockaddr_in *name,
|
||||
fprintf (stderr, "Unknown host %s.\n", hostname);
|
||||
return false;
|
||||
}
|
||||
#warning this need to be fixed
|
||||
//name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Network::StartListener(int port)
|
||||
bool Network::InitSocket(const char *remote_host, int port)
|
||||
{
|
||||
Network::listen_sock = make_socket(port);
|
||||
|
||||
if (Network::listen_sock < 0)
|
||||
return false;
|
||||
if (net_listen(Network::listen_sock, MAX_NETWORK_PEERS) < 0)
|
||||
{
|
||||
perror("listen");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::CheckNewConnection()
|
||||
{
|
||||
struct timeval tv;
|
||||
struct sockaddr_in peer_name;
|
||||
size_t size;
|
||||
int peer_sock;
|
||||
fd_set listen_fds;
|
||||
Network *peer;
|
||||
|
||||
/* Not initialized yet */
|
||||
if (Network::listen_sock <= 0)
|
||||
return false;
|
||||
|
||||
/* No more than that thanks... */
|
||||
if (Network::n_peers >= MAX_NETWORK_PEERS)
|
||||
return false;
|
||||
|
||||
FD_ZERO(&listen_fds);
|
||||
FD_SET(Network::listen_sock, &listen_fds);
|
||||
|
||||
/* If something connects, create a new client */
|
||||
memset(&tv, 0, sizeof(tv));
|
||||
int v = net_select(Network::listen_sock + 1, &listen_fds, NULL, NULL, &tv);
|
||||
|
||||
if ( v < 0)
|
||||
{
|
||||
perror("select");
|
||||
exit(1);
|
||||
}
|
||||
else if ( v == 0 )
|
||||
return false;
|
||||
|
||||
size = sizeof(peer_name);
|
||||
peer_sock = net_accept(Network::listen_sock, (struct sockaddr*)&peer_name, &size);
|
||||
if (peer_sock < 0)
|
||||
{
|
||||
fprintf(stderr, "Accepting peer failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* And add the new one! */
|
||||
Network::AddPeer(new Network(peer_sock, true));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::ConnectTo(const char *hostname, int port)
|
||||
{
|
||||
/* Again from glibc docs */
|
||||
struct sockaddr_in servername;
|
||||
int sock;
|
||||
|
||||
/* Create the socket. */
|
||||
sock = net_socket (PF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
this->sock = net_socket (PF_INET, SOCK_DGRAM, 0);
|
||||
if (this->sock < 0)
|
||||
{
|
||||
perror ("socket (client)");
|
||||
return false;
|
||||
}
|
||||
|
||||
set_sock_opts(sock);
|
||||
set_sock_opts(this->sock);
|
||||
|
||||
/* Connect to the server. */
|
||||
init_sockaddr (&servername, hostname, port);
|
||||
if (net_connect(sock, (struct sockaddr *) &servername,
|
||||
sizeof (servername)) != 0)
|
||||
this->InitSockaddr(&this->connection_addr, remote_host, port);
|
||||
|
||||
if (this->is_master)
|
||||
{
|
||||
perror ("connect (client)");
|
||||
return false;
|
||||
if (net_bind(this->sock, (struct sockaddr *)&this->connection_addr,
|
||||
sizeof (this->connection_addr)) < 0)
|
||||
{
|
||||
perror ("bind");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Network::AddPeer( new Network(sock, false) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::ReceiveData(void *dst, int sock, size_t sz)
|
||||
{
|
||||
size_t received_sz = 0;
|
||||
|
||||
while (received_sz < sz)
|
||||
{
|
||||
int v = net_read(sock, dst, sz);
|
||||
|
||||
if (v < 0)
|
||||
return false;
|
||||
received_sz += v;
|
||||
}
|
||||
this->traffic += received_sz;
|
||||
|
||||
return sz > 0;
|
||||
}
|
||||
|
||||
ssize_t Network::ReceiveFrom(void *dst, int sock, size_t sz,
|
||||
struct sockaddr_in *from)
|
||||
{
|
||||
@ -173,6 +125,22 @@ ssize_t Network::SendTo(void *src, int sock, size_t sz, struct sockaddr_in *to)
|
||||
return net_sendto(sock, src, sz, 0, (struct sockaddr*)to, to_sz);
|
||||
}
|
||||
|
||||
bool Network::SendData(void *src, int sock, size_t sz)
|
||||
{
|
||||
size_t sent_sz = 0;
|
||||
|
||||
while (sent_sz < sz)
|
||||
{
|
||||
int v = net_write(sock, (void*)src, sz);
|
||||
|
||||
if (v < 0)
|
||||
return false;
|
||||
sent_sz += v;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::Select(int sock, struct timeval *tv)
|
||||
{
|
||||
fd_set fds;
|
||||
|
@ -117,7 +117,7 @@ void VirtualKeyboard::draw()
|
||||
(this->shift_on && key.is_shift))
|
||||
b = 0;
|
||||
|
||||
menu_print_font(this->screen, this->font, r, g, b,
|
||||
menu_print_font(this->screen, r, g, b,
|
||||
x * key_w + border_x, y * key_h + border_y,
|
||||
what);
|
||||
}
|
||||
@ -313,7 +313,7 @@ const char *VirtualKeyboard::get_string()
|
||||
|
||||
/* SDL_Flip is done in get_key_internal() */
|
||||
SDL_FillRect(this->screen, 0, SDL_MapRGB(screen->format, 0x00, 0x80, 0x80));
|
||||
menu_print_font(this->screen, this->font, 255, 255, 0,
|
||||
menu_print_font(this->screen, 255, 255, 0,
|
||||
40, screen->h - 50,
|
||||
this->buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user