mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-26 05:24:21 +01:00
Make the stuff compile for Wii, removed some cruft and correct the network key
This commit is contained in:
parent
ae2a0a2fb2
commit
2bbbe035ff
@ -24,6 +24,10 @@
|
||||
#include "Prefs.h"
|
||||
#include "menu.h"
|
||||
|
||||
#if defined(GEKKO)
|
||||
# include <wiiuse/wpad.h>
|
||||
#endif
|
||||
|
||||
#define N_SQUARES_W 16
|
||||
#define N_SQUARES_H 8
|
||||
|
||||
@ -753,7 +757,7 @@ bool Network::ConnectToBroker()
|
||||
bool out;
|
||||
|
||||
pi->is_master = this->is_master;
|
||||
pi->key = random() % 0xffff;
|
||||
pi->key = ThePrefs.NetworkKey;
|
||||
strcpy((char*)pi->name, ThePrefs.NetworkName);
|
||||
this->AddNetworkUpdate(ud);
|
||||
out = this->SendUpdate();
|
||||
@ -983,6 +987,7 @@ bool Network::Connect()
|
||||
SDL_Flip(real_screen);
|
||||
#if defined(GEKKO)
|
||||
WPADData *wpad, *wpad_other;
|
||||
Uint32 remote_keys;
|
||||
|
||||
WPAD_ScanPads();
|
||||
|
||||
|
@ -18,48 +18,18 @@ static int set_sock_opts(int sock)
|
||||
return setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
}
|
||||
|
||||
/* From glibc docs */
|
||||
static int make_socket (uint16_t port)
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int sock;
|
||||
|
||||
/* Create the socket. */
|
||||
sock = socket (PF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
perror ("socket");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_sock_opts(sock);
|
||||
|
||||
/* Give the socket a name. */
|
||||
name.sin_family = AF_INET;
|
||||
name.sin_port = htons (port);
|
||||
name.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0)
|
||||
{
|
||||
perror ("bind");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
bool Network::InitSockaddr (struct sockaddr_in *name,
|
||||
const char *hostname, uint16_t port)
|
||||
{
|
||||
struct hostent *hostinfo;
|
||||
|
||||
name->sin_family = AF_INET;
|
||||
name->sin_port = htons (port);
|
||||
hostinfo = gethostbyname (hostname);
|
||||
struct hostent *hostinfo = gethostbyname (hostname);
|
||||
if (hostinfo == NULL)
|
||||
{
|
||||
fprintf (stderr, "Unknown host %s.\n", hostname);
|
||||
return false;
|
||||
}
|
||||
|
||||
name->sin_family = AF_INET;
|
||||
name->sin_port = htons (port);
|
||||
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
|
||||
return true;
|
||||
|
@ -16,50 +16,22 @@ static int set_sock_opts(int sock)
|
||||
return net_setsockopt(sock,SOL_SOCKET,SO_REUSEADDR, &d, sizeof(int));
|
||||
}
|
||||
|
||||
/* From glibc docs */
|
||||
static int make_socket (uint16_t port)
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int sock;
|
||||
|
||||
/* Create the socket. */
|
||||
sock = net_socket (PF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
perror ("socket");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_sock_opts(sock);
|
||||
|
||||
/* Give the socket a name. */
|
||||
name.sin_family = AF_INET;
|
||||
name.sin_port = htons (port);
|
||||
name.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
if (net_bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0)
|
||||
{
|
||||
perror ("bind");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
bool Network::InitSockaddr (struct sockaddr_in *name,
|
||||
const char *hostname, uint16_t port)
|
||||
{
|
||||
struct hostent *hostinfo;
|
||||
struct hostent *hostinfo = net_gethostbyname ((char*)hostname);
|
||||
|
||||
name->sin_family = AF_INET;
|
||||
name->sin_port = htons (port);
|
||||
hostinfo = net_gethostbyname ((char*)hostname);
|
||||
if (hostinfo == NULL)
|
||||
{
|
||||
fprintf (stderr, "Unknown host %s.\n", hostname);
|
||||
return false;
|
||||
}
|
||||
#warning this need to be fixed
|
||||
//name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
|
||||
name->sin_family = AF_INET;
|
||||
name->sin_port = htons (port);
|
||||
name->sin_len = sizeof(struct sockaddr_in);
|
||||
memcpy ((char *) &name->sin_addr, hostinfo->h_addr_list[0],
|
||||
hostinfo->h_length);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include "Prefs.h"
|
||||
@ -102,7 +101,7 @@ Prefs::Prefs()
|
||||
this->DisplayOption = 0;
|
||||
this->MsPerFrame = 28;
|
||||
#endif
|
||||
this->NetworkKey = random() % 0xffff;
|
||||
this->NetworkKey = rand() % 0xffff;
|
||||
snprintf(this->NetworkName, 32, "Unset.%d", this->NetworkKey);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user