mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-19 08:51:59 +00:00
make sure networking is initialized before doing /anything/. this should
fix the host lookup failurs for win32 when using -f.
This commit is contained in:
parent
2c1173aadf
commit
234305f0ab
1 changed files with 19 additions and 12 deletions
|
@ -234,24 +234,12 @@ void
|
|||
QW_Master (struct sockaddr_in *addr)
|
||||
{
|
||||
int sock;
|
||||
#ifdef _WIN32
|
||||
int i;
|
||||
WSADATA winsockdata;
|
||||
#endif
|
||||
|
||||
if (!servers) {
|
||||
printf ("initial malloc failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
i = WSAStartup (MAKEWORD (1, 1), &winsockdata);
|
||||
if (i) {
|
||||
printf ("Winsock initialization failed.\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sock < 0) {
|
||||
printf ("socket failed\n");
|
||||
|
@ -373,6 +361,22 @@ read_hosts (const char *fname)
|
|||
fclose (host_file);
|
||||
}
|
||||
|
||||
static int
|
||||
net_init (void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int i;
|
||||
WSADATA winsockdata;
|
||||
|
||||
i = WSAStartup (MAKEWORD (1, 1), &winsockdata);
|
||||
if (i) {
|
||||
printf ("Winsock initialization failed.\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
@ -380,6 +384,9 @@ main (int argc, char **argv)
|
|||
short port = htons (PORT_MASTER);
|
||||
int c;
|
||||
|
||||
if (!net_init ())
|
||||
return 1;
|
||||
|
||||
servers = calloc (sizeof (server_t), serverlen);
|
||||
|
||||
while ((c = getopt (argc, argv, "p:f:")) != -1) {
|
||||
|
|
Loading…
Reference in a new issue