summaryrefslogtreecommitdiff
path: root/games/xtris/patches/patch-ad
diff options
context:
space:
mode:
Diffstat (limited to 'games/xtris/patches/patch-ad')
-rw-r--r--games/xtris/patches/patch-ad102
1 files changed, 102 insertions, 0 deletions
diff --git a/games/xtris/patches/patch-ad b/games/xtris/patches/patch-ad
new file mode 100644
index 00000000000..32ca82af6b2
--- /dev/null
+++ b/games/xtris/patches/patch-ad
@@ -0,0 +1,102 @@
+$NetBSD: patch-ad,v 1.1.1.1 2002/01/25 17:47:19 hubertf Exp $
+
+--- xtris.c.orig Sun Dec 14 19:40:04 1997
++++ xtris.c
+@@ -1633,10 +1633,11 @@
+ fprintf(stderr, "Can't start bot '%s'.\n",
+
+ #ifdef XTRISPATH
+- XTRISPATH "/xtbot");
++ XTRISPATH "/xtbot"
+ #else
+- "xtbot");
++ "xtbot"
+ #endif
++ );
+ _exit(1);
+
+ case -1:
+@@ -2674,11 +2675,11 @@
+
+ fprintf(stderr, "Can't start server '%s'.\n",
+ #ifdef XTRISPATH
+- XTRISPATH "/xtserv");
++ XTRISPATH "/xtserv"
+ #else
+- "xtserv");
++ "xtserv"
+ #endif
+-
++ );
+ _exit(1);
+
+ case -1:
+@@ -2690,11 +2691,60 @@
+ }
+
+ void connect2server(char *h) {
++#ifdef INET6
++ struct addrinfo hints, *res0, *res;
++ int gai;
++ struct sockaddr_storage s;
++ char serv_buf[NI_MAXSERV];
++ char str_buf[512];
++#else
+ struct hostent *hp;
+ struct sockaddr_in s;
++#endif
+ struct protoent *tcpproto;
+ int on = 1, i;
+
++#ifdef INET6
++ snprintf(serv_buf, sizeof(serv_buf) , "%d", port);
++ serv_buf[sizeof(serv_buf)-1] = '\0';
++ for (i=0; i<7; i++){
++ memset (&hints, 0, sizeof(hints));
++ hints.ai_family = PF_UNSPEC;
++ hints.ai_socktype = SOCK_STREAM;
++ gai = getaddrinfo(h, serv_buf, &hints, &res0);
++ if (gai){
++ snprintf(str_buf, sizeof(str_buf)-1,
++ "getaddrinfo(): %s", gai_strerror(gai));
++ fatal(str_buf);
++ }
++ for (res=res0; res; res=res->ai_next){
++ sfd = socket(res->ai_family, res->ai_socktype, 0);
++ if (sfd < 0) continue;
++ if ((tcpproto = getprotobyname("tcp")) != NULL)
++ setsockopt(sfd, tcpproto->p_proto, TCP_NODELAY, (char *)&on, sizeof(int));
++ if (connect(sfd, res->ai_addr, res->ai_addrlen) < 0){
++ close(sfd);
++ sfd = -1;
++ continue;
++ }
++ break;
++ }
++ freeaddrinfo(res0);
++ if (sfd >= 0) break;
++ if (!h){
++ if (i==0){
++ printf("No xtris server on localhost - starting up one ...\n");
++ startserver();
++ }
++ u_sleep(500000);
++ continue;
++ }
++ else
++ break;
++ }
++ if (sfd < 0)
++ fatal("Can't connect to server");
++#else
+ if (h) {
+ if ((s.sin_addr.s_addr = inet_addr(h)) == -1) {
+ hp = gethostbyname(h);
+@@ -2729,6 +2779,7 @@
+ fatal("Can't connect to server");
+ } else fatal("Can't connect to server");
+ }
++#endif
+ }
+
+ void sigchld() {