From 0f4487eb68475d772b24469815c82f429c98abbb Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Sun, 12 Jul 2020 22:24:10 +0100
Subject: [PATCH] * i_tcp.c: merge these three ifndef USE_WINSOCK blocks
 together * mserv.c: added i_tcp.c's USE_WINSOCK macros so socklen_t isn't
 redundantly defined if Winsock 2 is used

---
 src/i_tcp.c |  6 ------
 src/mserv.c | 15 ++++++++++++++-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/i_tcp.c b/src/i_tcp.c
index e20e43ea44..4738b9df81 100644
--- a/src/i_tcp.c
+++ b/src/i_tcp.c
@@ -50,9 +50,6 @@
 	#else
 		#ifndef USE_WINSOCK
 			#include <arpa/inet.h>
-		#endif //normal BSD API
-
-		#ifndef USE_WINSOCK
 			#ifdef __APPLE_CC__
 				#ifndef _BSD_SOCKLEN_T_
 					#define _BSD_SOCKLEN_T_
@@ -60,9 +57,6 @@
 			#endif //__APPLE_CC__
 			#include <sys/socket.h>
 			#include <netinet/in.h>
-		#endif //normal BSD API
-
-		#ifndef USE_WINSOCK
 			#include <netdb.h>
 			#include <sys/ioctl.h>
 		#endif //normal BSD API
diff --git a/src/mserv.c b/src/mserv.c
index 58fb36bcbb..84fdca80ed 100644
--- a/src/mserv.c
+++ b/src/mserv.c
@@ -22,6 +22,19 @@
 	#define NONET
 #endif
 
+#ifndef NO_IPV6
+	#define HAVE_IPV6
+#endif
+
+#ifdef _WIN32
+	#define USE_WINSOCK
+	#if /*defined (_WIN64) ||*/ defined (HAVE_IPV6)
+		#define USE_WINSOCK2
+	#else //_WIN64/HAVE_IPV6
+		#define USE_WINSOCK1
+	#endif
+#endif //WIN32 OS
+
 #ifndef NONET
 	#ifndef NO_IPV6
 		#define HAVE_IPV6
@@ -196,7 +209,7 @@ typedef unsigned long SOCKET_TYPE;
 #define ERRSOCKET (-1)
 #endif
 
-#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (_WIN32)
+#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1)
 typedef int socklen_t;
 #endif
 
-- 
GitLab