mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
Some more tidy-up and minor fixing in net stuff. Largely trivial. Also
added winquake.h. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@196 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
719ba437b7
commit
013a3ad1db
11 changed files with 269 additions and 243 deletions
|
@ -98,11 +98,11 @@ SDL_CONFIG ?= sdl-config
|
|||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs)
|
||||
|
||||
SDL_LIBS := SDL_net
|
||||
NET_LIBS := SDL_net
|
||||
|
||||
COMMON_LIBS:= m GL
|
||||
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(SDL_LIBS))
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(NET_LIBS))
|
||||
|
||||
# ---------------------------
|
||||
# targets
|
||||
|
|
|
@ -105,12 +105,12 @@ SDL_CONFIG=/usr/local/bin/sdl-config
|
|||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs)
|
||||
|
||||
SDL_LIBS = -L/usr/local/lib -l SDL_net
|
||||
NET_LIBS = -L/usr/local/lib -l SDL_net
|
||||
|
||||
COMMON_LIBS = -Wl,-framework,OpenGL
|
||||
|
||||
#LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(SDL_LIBS))
|
||||
LIBS = $(COMMON_LIBS) $(SDL_LIBS)
|
||||
#LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(NET_LIBS))
|
||||
LIBS = $(COMMON_LIBS) $(NET_LIBS)
|
||||
|
||||
# ---------------------------
|
||||
# targets
|
||||
|
|
|
@ -50,11 +50,13 @@ SDL_CONFIG ?= sdl-config
|
|||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs)
|
||||
|
||||
SDL_LIBS := SDL_net
|
||||
#NET_LIBS := ws2_32
|
||||
#NET_LIBS := wsock32
|
||||
NET_LIBS := SDL_net
|
||||
|
||||
COMMON_LIBS:= m opengl32
|
||||
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(SDL_LIBS))
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(NET_LIBS))
|
||||
|
||||
# ---------------------------
|
||||
# targets
|
||||
|
|
|
@ -50,11 +50,13 @@ SDL_CONFIG ?= sdl-config
|
|||
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||
SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs)
|
||||
|
||||
SDL_LIBS := SDL_net
|
||||
#NET_LIBS := ws2_32
|
||||
#NET_LIBS := wsock32
|
||||
NET_LIBS := SDL_net
|
||||
|
||||
COMMON_LIBS:= m opengl32
|
||||
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(SDL_LIBS))
|
||||
LIBS := $(patsubst %,-l%,$(COMMON_LIBS) $(NET_LIBS))
|
||||
|
||||
# ---------------------------
|
||||
# targets
|
||||
|
|
|
@ -184,14 +184,10 @@ the local network components to fill in the rest
|
|||
*/
|
||||
static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
||||
{
|
||||
char buff[256];
|
||||
char *b;
|
||||
int addr;
|
||||
int num;
|
||||
int mask;
|
||||
int run;
|
||||
int port;
|
||||
|
||||
char buff[256];
|
||||
char *b;
|
||||
int addr, mask, num, port, run;
|
||||
|
||||
buff[0] = '.';
|
||||
b = buff;
|
||||
strcpy(buff+1, in);
|
||||
|
@ -199,7 +195,7 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
|||
b++;
|
||||
|
||||
addr = 0;
|
||||
mask=-1;
|
||||
mask = -1;
|
||||
while (*b == '.')
|
||||
{
|
||||
b++;
|
||||
|
@ -207,27 +203,28 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
|||
run = 0;
|
||||
while (!( *b < '0' || *b > '9'))
|
||||
{
|
||||
num = num*10 + *b++ - '0';
|
||||
if (++run > 3)
|
||||
return -1;
|
||||
num = num*10 + *b++ - '0';
|
||||
if (++run > 3)
|
||||
return -1;
|
||||
}
|
||||
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
|
||||
return -1;
|
||||
if (num < 0 || num > 255)
|
||||
return -1;
|
||||
mask<<=8;
|
||||
mask <<= 8;
|
||||
addr = (addr<<8) + num;
|
||||
}
|
||||
|
||||
|
||||
if (*b++ == ':')
|
||||
port = Q_atoi(b);
|
||||
else
|
||||
port = net_hostport;
|
||||
|
||||
hostaddr->sa_family = AF_INET;
|
||||
((struct sockaddr_in *)hostaddr)->sin_port = htons((short)port);
|
||||
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr = (myAddr & htonl(mask)) | htonl(addr);
|
||||
|
||||
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
|
||||
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
|
||||
(myAddr & htonl(mask)) | htonl(addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
//=============================================================================
|
||||
|
@ -269,7 +266,7 @@ static void get_qsockaddr(struct sockaddr *saddr, struct qsockaddr *qaddr)
|
|||
int UDP_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
static struct sockaddr saddr;
|
||||
socklen_t addrlen = sizeof (struct sockaddr);
|
||||
socklen_t addrlen = sizeof(struct sockaddr);
|
||||
int ret;
|
||||
|
||||
ret = recvfrom (socketid, buf, len, 0, &saddr, &addrlen);
|
||||
|
@ -284,7 +281,7 @@ int UDP_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
|||
|
||||
int UDP_MakeSocketBroadcastCapable (int socketid)
|
||||
{
|
||||
int i = 1;
|
||||
int i = 1;
|
||||
|
||||
// make this socket broadcast capable
|
||||
if (setsockopt(socketid, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) < 0)
|
||||
|
@ -298,12 +295,12 @@ int UDP_MakeSocketBroadcastCapable (int socketid)
|
|||
|
||||
int UDP_Broadcast (int socketid, byte *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (socketid != net_broadcastsocket)
|
||||
{
|
||||
if (net_broadcastsocket != 0)
|
||||
Sys_Error("Attempted to use multiple broadcasts sockets\n");
|
||||
Sys_Error("Attempted to use multiple broadcasts sockets");
|
||||
ret = UDP_MakeSocketBroadcastCapable (socketid);
|
||||
if (ret == -1)
|
||||
{
|
||||
|
@ -319,7 +316,7 @@ int UDP_Broadcast (int socketid, byte *buf, int len)
|
|||
|
||||
int UDP_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = sendto (socketid, buf, len, 0, (struct sockaddr *)addr, sizeof(struct qsockaddr));
|
||||
if (ret == -1 && errno == EWOULDBLOCK)
|
||||
|
@ -332,7 +329,7 @@ int UDP_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
|||
char *UDP_AddrToString (struct qsockaddr *addr)
|
||||
{
|
||||
static char buffer[22];
|
||||
int haddr;
|
||||
int haddr;
|
||||
|
||||
haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr);
|
||||
snprintf (buffer, sizeof(buffer), "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff,
|
||||
|
@ -345,15 +342,14 @@ char *UDP_AddrToString (struct qsockaddr *addr)
|
|||
|
||||
int UDP_StringToAddr (char *string, struct qsockaddr *addr)
|
||||
{
|
||||
int ha1, ha2, ha3, ha4, hp;
|
||||
int ipaddr;
|
||||
int ha1, ha2, ha3, ha4, hp, ipaddr;
|
||||
|
||||
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
|
||||
ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
|
||||
|
||||
addr->sa_family = AF_INET;
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
|
||||
((struct sockaddr_in *)addr)->sin_port = htons(hp);
|
||||
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -381,7 +377,8 @@ int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name)
|
|||
{
|
||||
struct hostent *hostentry;
|
||||
|
||||
hostentry = gethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr, sizeof(struct in_addr), AF_INET);
|
||||
hostentry = gethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET);
|
||||
if (hostentry)
|
||||
{
|
||||
Q_strncpy (name, (char *)hostentry->h_name, NET_NAMELEN - 1);
|
||||
|
@ -406,8 +403,9 @@ int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
|
|||
return -1;
|
||||
|
||||
addr->sa_family = AF_INET;
|
||||
((struct sockaddr_in *)addr)->sin_port = htons(net_hostport);
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
||||
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr =
|
||||
*(in_addr_t *)hostentry->h_addr_list[0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -419,10 +417,12 @@ int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
|
|||
if (addr1->sa_family != addr2->sa_family)
|
||||
return -1;
|
||||
|
||||
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr != ((struct sockaddr_in *)addr2)->sin_addr.s_addr)
|
||||
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr !=
|
||||
((struct sockaddr_in *)addr2)->sin_addr.s_addr)
|
||||
return -1;
|
||||
|
||||
if (((struct sockaddr_in *)addr1)->sin_port != ((struct sockaddr_in *)addr2)->sin_port)
|
||||
if (((struct sockaddr_in *)addr1)->sin_port !=
|
||||
((struct sockaddr_in *)addr2)->sin_port)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -438,7 +438,7 @@ int UDP_GetSocketPort (struct qsockaddr *addr)
|
|||
|
||||
int UDP_SetSocketPort (struct qsockaddr *addr, int port)
|
||||
{
|
||||
((struct sockaddr_in *)addr)->sin_port = htons(port);
|
||||
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
|
||||
extern cvar_t hostname;
|
||||
|
||||
#define MAXHOSTNAMELEN 256
|
||||
|
||||
static int net_acceptsocket = -1; // socket for fielding new connections
|
||||
|
@ -34,27 +32,6 @@ static struct qsockaddr broadcastaddr;
|
|||
|
||||
static unsigned long myAddr;
|
||||
|
||||
qboolean winsock_lib_initialized;
|
||||
|
||||
int (PASCAL FAR *pWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData);
|
||||
int (PASCAL FAR *pWSACleanup)(void);
|
||||
int (PASCAL FAR *pWSAGetLastError)(void);
|
||||
SOCKET (PASCAL FAR *psocket)(int af, int type, int protocol);
|
||||
int (PASCAL FAR *pioctlsocket)(SOCKET s, long cmd, u_long FAR *argp);
|
||||
int (PASCAL FAR *psetsockopt)(SOCKET s, int level, int optname,
|
||||
const char FAR * optval, int optlen);
|
||||
int (PASCAL FAR *precvfrom)(SOCKET s, char FAR * buf, int len, int flags,
|
||||
struct sockaddr FAR *from, int FAR * fromlen);
|
||||
int (PASCAL FAR *psendto)(SOCKET s, const char FAR * buf, int len, int flags,
|
||||
const struct sockaddr FAR *to, int tolen);
|
||||
int (PASCAL FAR *pclosesocket)(SOCKET s);
|
||||
int (PASCAL FAR *pgethostname)(char FAR * name, int namelen);
|
||||
struct hostent FAR * (PASCAL FAR *pgethostbyname)(const char FAR * name);
|
||||
struct hostent FAR * (PASCAL FAR *pgethostbyaddr)(const char FAR * addr,
|
||||
int len, int type);
|
||||
int (PASCAL FAR *pgetsockname)(SOCKET s, struct sockaddr FAR *name,
|
||||
int FAR * namelen);
|
||||
|
||||
#include "net_wins.h"
|
||||
|
||||
int winsock_initialized = 0;
|
||||
|
@ -64,10 +41,10 @@ WSADATA winsockdata;
|
|||
|
||||
static double blocktime;
|
||||
|
||||
BOOL PASCAL FAR BlockingHook(void)
|
||||
static INT_PTR PASCAL FAR BlockingHook (void)
|
||||
{
|
||||
MSG msg;
|
||||
BOOL ret;
|
||||
MSG msg;
|
||||
BOOL ret;
|
||||
|
||||
if ((Sys_FloatTime() - blocktime) > 2.0)
|
||||
{
|
||||
|
@ -75,21 +52,22 @@ BOOL PASCAL FAR BlockingHook(void)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* get the next message, if any */
|
||||
ret = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
||||
/* get the next message, if any */
|
||||
ret = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
||||
|
||||
/* if we got one, process it */
|
||||
if (ret) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
/* if we got one, process it */
|
||||
if (ret)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
/* TRUE if we got a message */
|
||||
return ret;
|
||||
/* TRUE if we got a message */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void WINS_GetLocalAddress()
|
||||
static void WINS_GetLocalAddress (void)
|
||||
{
|
||||
struct hostent *local = NULL;
|
||||
char buff[MAXHOSTNAMELEN];
|
||||
|
@ -98,12 +76,12 @@ void WINS_GetLocalAddress()
|
|||
if (myAddr != INADDR_ANY)
|
||||
return;
|
||||
|
||||
if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
|
||||
if (gethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
|
||||
return;
|
||||
|
||||
blocktime = Sys_FloatTime();
|
||||
WSASetBlockingHook(BlockingHook);
|
||||
local = pgethostbyname(buff);
|
||||
local = gethostbyname(buff);
|
||||
WSAUnhookBlockingHook();
|
||||
if (local == NULL)
|
||||
return;
|
||||
|
@ -117,60 +95,17 @@ void WINS_GetLocalAddress()
|
|||
|
||||
int WINS_Init (void)
|
||||
{
|
||||
int i;
|
||||
int i, err;
|
||||
char buff[MAXHOSTNAMELEN];
|
||||
char *p;
|
||||
int r;
|
||||
WORD wVersionRequested;
|
||||
HINSTANCE hInst;
|
||||
|
||||
// initialize the Winsock function vectors (we do this instead of statically linking
|
||||
// so we can run on Win 3.1, where there isn't necessarily Winsock)
|
||||
hInst = LoadLibrary("wsock32.dll");
|
||||
|
||||
if (hInst == NULL)
|
||||
{
|
||||
Con_SafePrintf ("Failed to load winsock.dll\n");
|
||||
winsock_lib_initialized = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
winsock_lib_initialized = true;
|
||||
|
||||
pWSAStartup = (void *)GetProcAddress(hInst, "WSAStartup");
|
||||
pWSACleanup = (void *)GetProcAddress(hInst, "WSACleanup");
|
||||
pWSAGetLastError = (void *)GetProcAddress(hInst, "WSAGetLastError");
|
||||
psocket = (void *)GetProcAddress(hInst, "socket");
|
||||
pioctlsocket = (void *)GetProcAddress(hInst, "ioctlsocket");
|
||||
psetsockopt = (void *)GetProcAddress(hInst, "setsockopt");
|
||||
precvfrom = (void *)GetProcAddress(hInst, "recvfrom");
|
||||
psendto = (void *)GetProcAddress(hInst, "sendto");
|
||||
pclosesocket = (void *)GetProcAddress(hInst, "closesocket");
|
||||
pgethostname = (void *)GetProcAddress(hInst, "gethostname");
|
||||
pgethostbyname = (void *)GetProcAddress(hInst, "gethostbyname");
|
||||
pgethostbyaddr = (void *)GetProcAddress(hInst, "gethostbyaddr");
|
||||
pgetsockname = (void *)GetProcAddress(hInst, "getsockname");
|
||||
|
||||
if (!pWSAStartup || !pWSACleanup || !pWSAGetLastError ||
|
||||
!psocket || !pioctlsocket || !psetsockopt ||
|
||||
!precvfrom || !psendto || !pclosesocket ||
|
||||
!pgethostname || !pgethostbyname || !pgethostbyaddr ||
|
||||
!pgetsockname)
|
||||
{
|
||||
Con_SafePrintf ("Couldn't GetProcAddress from winsock.dll\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (COM_CheckParm ("-noudp"))
|
||||
return -1;
|
||||
|
||||
if (winsock_initialized == 0)
|
||||
{
|
||||
wVersionRequested = MAKEWORD(1, 1);
|
||||
|
||||
r = pWSAStartup (MAKEWORD(1, 1), &winsockdata);
|
||||
|
||||
if (r)
|
||||
err = WSAStartup(MAKEWORD(1,1), &winsockdata);
|
||||
if (err != 0)
|
||||
{
|
||||
Con_SafePrintf ("Winsock initialization failed.\n");
|
||||
return -1;
|
||||
|
@ -179,11 +114,11 @@ int WINS_Init (void)
|
|||
winsock_initialized++;
|
||||
|
||||
// determine my name
|
||||
if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
|
||||
if (gethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
|
||||
{
|
||||
Con_DPrintf ("Winsock TCP/IP Initialization failed.\n");
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup ();
|
||||
WSACleanup ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -227,11 +162,11 @@ int WINS_Init (void)
|
|||
strcpy(my_tcpip_address, "INADDR_ANY");
|
||||
}
|
||||
|
||||
if ((net_controlsocket = WINS_OpenSocket (0)) == -1)
|
||||
if ((net_controlsocket = WINS_OpenSocket(0)) == -1)
|
||||
{
|
||||
Con_Printf("WINS_Init: Unable to open control socket\n");
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup ();
|
||||
WSACleanup ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -252,7 +187,7 @@ void WINS_Shutdown (void)
|
|||
WINS_Listen (false);
|
||||
WINS_CloseSocket (net_controlsocket);
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup ();
|
||||
WSACleanup ();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -285,10 +220,10 @@ int WINS_OpenSocket (int port)
|
|||
struct sockaddr_in address;
|
||||
u_long _true = 1;
|
||||
|
||||
if ((newsocket = psocket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
|
||||
if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
|
||||
return -1;
|
||||
|
||||
if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||
if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||
goto ErrorReturn;
|
||||
|
||||
address.sin_family = AF_INET;
|
||||
|
@ -299,17 +234,17 @@ int WINS_OpenSocket (int port)
|
|||
|
||||
Sys_Error ("Unable to bind to %s", WINS_AddrToString((struct qsockaddr *)&address));
|
||||
ErrorReturn:
|
||||
pclosesocket (newsocket);
|
||||
closesocket (newsocket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_CloseSocket (int socket)
|
||||
int WINS_CloseSocket (int socketid)
|
||||
{
|
||||
if (socket == net_broadcastsocket)
|
||||
if (socketid == net_broadcastsocket)
|
||||
net_broadcastsocket = 0;
|
||||
return pclosesocket (socket);
|
||||
return closesocket (socketid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -324,13 +259,9 @@ the local network components to fill in the rest
|
|||
*/
|
||||
static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
||||
{
|
||||
char buff[256];
|
||||
char *b;
|
||||
int addr;
|
||||
int num;
|
||||
int mask;
|
||||
int run;
|
||||
int port;
|
||||
char buff[256];
|
||||
char *b;
|
||||
int addr, mask, num, port, run;
|
||||
|
||||
buff[0] = '.';
|
||||
b = buff;
|
||||
|
@ -339,7 +270,7 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
|||
b++;
|
||||
|
||||
addr = 0;
|
||||
mask=-1;
|
||||
mask = -1;
|
||||
while (*b == '.')
|
||||
{
|
||||
b++;
|
||||
|
@ -347,15 +278,15 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
|||
run = 0;
|
||||
while (!( *b < '0' || *b > '9'))
|
||||
{
|
||||
num = num*10 + *b++ - '0';
|
||||
if (++run > 3)
|
||||
return -1;
|
||||
num = num*10 + *b++ - '0';
|
||||
if (++run > 3)
|
||||
return -1;
|
||||
}
|
||||
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
|
||||
return -1;
|
||||
if (num < 0 || num > 255)
|
||||
return -1;
|
||||
mask<<=8;
|
||||
mask <<= 8;
|
||||
addr = (addr<<8) + num;
|
||||
}
|
||||
|
||||
|
@ -365,14 +296,16 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
|||
port = net_hostport;
|
||||
|
||||
hostaddr->sa_family = AF_INET;
|
||||
((struct sockaddr_in *)hostaddr)->sin_port = htons((short)port);
|
||||
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr = (myAddr & htonl(mask)) | htonl(addr);
|
||||
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
|
||||
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
|
||||
(myAddr & htonl(mask)) | htonl(addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_Connect (int socket, struct qsockaddr *addr)
|
||||
int WINS_Connect (int socketid, struct qsockaddr *addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -381,12 +314,13 @@ int WINS_Connect (int socket, struct qsockaddr *addr)
|
|||
|
||||
int WINS_CheckNewConnections (void)
|
||||
{
|
||||
char buf[4096];
|
||||
char buf[4096];
|
||||
|
||||
if (net_acceptsocket == -1)
|
||||
return -1;
|
||||
|
||||
if (precvfrom (net_acceptsocket, buf, sizeof(buf), MSG_PEEK, NULL, NULL) > 0)
|
||||
if (recvfrom (net_acceptsocket, buf, sizeof(buf), MSG_PEEK, NULL, NULL)
|
||||
!= SOCKET_ERROR) /* >= 0 */
|
||||
{
|
||||
return net_acceptsocket;
|
||||
}
|
||||
|
@ -395,16 +329,15 @@ int WINS_CheckNewConnections (void)
|
|||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_Read (int socket, byte *buf, int len, struct qsockaddr *addr)
|
||||
int WINS_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int addrlen = sizeof (struct qsockaddr);
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
int ret;
|
||||
|
||||
ret = precvfrom (socket, buf, len, 0, (struct sockaddr *)addr, &addrlen);
|
||||
if (ret == -1)
|
||||
ret = recvfrom (socketid, (char *)buf, len, 0, (struct sockaddr *)addr, &addrlen);
|
||||
if (ret == SOCKET_ERROR)
|
||||
{
|
||||
int err = pWSAGetLastError();
|
||||
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK || err == WSAECONNREFUSED)
|
||||
return 0;
|
||||
|
||||
|
@ -414,30 +347,31 @@ int WINS_Read (int socket, byte *buf, int len, struct qsockaddr *addr)
|
|||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_MakeSocketBroadcastCapable (int socket)
|
||||
int WINS_MakeSocketBroadcastCapable (int socketid)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
// make this socket broadcast capable
|
||||
if (psetsockopt(socket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) < 0)
|
||||
if (setsockopt(socketid, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i))
|
||||
== SOCKET_ERROR)
|
||||
return -1;
|
||||
net_broadcastsocket = socket;
|
||||
net_broadcastsocket = socketid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_Broadcast (int socket, byte *buf, int len)
|
||||
int WINS_Broadcast (int socketid, byte *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
if (socket != net_broadcastsocket)
|
||||
if (socketid != net_broadcastsocket)
|
||||
{
|
||||
if (net_broadcastsocket != 0)
|
||||
Sys_Error("Attempted to use multiple broadcasts sockets\n");
|
||||
Sys_Error("Attempted to use multiple broadcasts sockets");
|
||||
WINS_GetLocalAddress();
|
||||
ret = WINS_MakeSocketBroadcastCapable (socket);
|
||||
ret = WINS_MakeSocketBroadcastCapable (socketid);
|
||||
if (ret == -1)
|
||||
{
|
||||
Con_Printf("Unable to make socket broadcast capable\n");
|
||||
|
@ -445,19 +379,22 @@ int WINS_Broadcast (int socket, byte *buf, int len)
|
|||
}
|
||||
}
|
||||
|
||||
return WINS_Write (socket, buf, len, &broadcastaddr);
|
||||
return WINS_Write (socketid, buf, len, &broadcastaddr);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_Write (int socket, byte *buf, int len, struct qsockaddr *addr)
|
||||
int WINS_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
ret = psendto (socket, buf, len, 0, (struct sockaddr *)addr, sizeof(struct qsockaddr));
|
||||
if (ret == -1)
|
||||
if (pWSAGetLastError() == WSAEWOULDBLOCK)
|
||||
ret = sendto (socketid, (char *)buf, len, 0, (struct sockaddr *)addr,
|
||||
sizeof(struct qsockaddr));
|
||||
if (ret == SOCKET_ERROR)
|
||||
{
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -467,10 +404,12 @@ int WINS_Write (int socket, byte *buf, int len, struct qsockaddr *addr)
|
|||
char *WINS_AddrToString (struct qsockaddr *addr)
|
||||
{
|
||||
static char buffer[22];
|
||||
int haddr;
|
||||
int haddr;
|
||||
|
||||
haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr);
|
||||
sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port));
|
||||
sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff,
|
||||
(haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff,
|
||||
ntohs(((struct sockaddr_in *)addr)->sin_port));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -478,8 +417,7 @@ char *WINS_AddrToString (struct qsockaddr *addr)
|
|||
|
||||
int WINS_StringToAddr (char *string, struct qsockaddr *addr)
|
||||
{
|
||||
int ha1, ha2, ha3, ha4, hp;
|
||||
int ipaddr;
|
||||
int ha1, ha2, ha3, ha4, hp, ipaddr;
|
||||
|
||||
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
|
||||
ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
|
||||
|
@ -492,13 +430,13 @@ int WINS_StringToAddr (char *string, struct qsockaddr *addr)
|
|||
|
||||
//=============================================================================
|
||||
|
||||
int WINS_GetSocketAddr (int socket, struct qsockaddr *addr)
|
||||
int WINS_GetSocketAddr (int socketid, struct qsockaddr *addr)
|
||||
{
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
unsigned int a;
|
||||
|
||||
Q_memset(addr, 0, sizeof(struct qsockaddr));
|
||||
pgetsockname(socket, (struct sockaddr *)addr, &addrlen);
|
||||
getsockname(socketid, (struct sockaddr *)addr, &addrlen);
|
||||
a = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
|
||||
if (a == 0 || a == inet_addr("127.0.0.1"))
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = myAddr;
|
||||
|
@ -512,7 +450,8 @@ int WINS_GetNameFromAddr (struct qsockaddr *addr, char *name)
|
|||
{
|
||||
struct hostent *hostentry;
|
||||
|
||||
hostentry = pgethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr, sizeof(struct in_addr), AF_INET);
|
||||
hostentry = gethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET);
|
||||
if (hostentry)
|
||||
{
|
||||
Q_strncpy (name, (char *)hostentry->h_name, NET_NAMELEN - 1);
|
||||
|
@ -532,13 +471,14 @@ int WINS_GetAddrFromName(char *name, struct qsockaddr *addr)
|
|||
if (name[0] >= '0' && name[0] <= '9')
|
||||
return PartialIPAddress (name, addr);
|
||||
|
||||
hostentry = pgethostbyname (name);
|
||||
hostentry = gethostbyname (name);
|
||||
if (!hostentry)
|
||||
return -1;
|
||||
|
||||
addr->sa_family = AF_INET;
|
||||
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr =
|
||||
*(u_long *)hostentry->h_addr_list[0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -550,10 +490,12 @@ int WINS_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
|
|||
if (addr1->sa_family != addr2->sa_family)
|
||||
return -1;
|
||||
|
||||
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr != ((struct sockaddr_in *)addr2)->sin_addr.s_addr)
|
||||
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr !=
|
||||
((struct sockaddr_in *)addr2)->sin_addr.s_addr)
|
||||
return -1;
|
||||
|
||||
if (((struct sockaddr_in *)addr1)->sin_port != ((struct sockaddr_in *)addr2)->sin_port)
|
||||
if (((struct sockaddr_in *)addr1)->sin_port !=
|
||||
((struct sockaddr_in *)addr2)->sin_port)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -574,3 +516,4 @@ int WINS_SetSocketPort (struct qsockaddr *addr, int port)
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
|
|
@ -28,15 +28,15 @@ int WINS_Init (void);
|
|||
void WINS_Shutdown (void);
|
||||
void WINS_Listen (qboolean state);
|
||||
int WINS_OpenSocket (int port);
|
||||
int WINS_CloseSocket (int socket);
|
||||
int WINS_Connect (int socket, struct qsockaddr *addr);
|
||||
int WINS_CloseSocket (int socketid);
|
||||
int WINS_Connect (int socketid, struct qsockaddr *addr);
|
||||
int WINS_CheckNewConnections (void);
|
||||
int WINS_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WINS_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WINS_Broadcast (int socket, byte *buf, int len);
|
||||
int WINS_Read (int socketid, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WINS_Write (int socketid, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WINS_Broadcast (int socketid, byte *buf, int len);
|
||||
char *WINS_AddrToString (struct qsockaddr *addr);
|
||||
int WINS_StringToAddr (char *string, struct qsockaddr *addr);
|
||||
int WINS_GetSocketAddr (int socket, struct qsockaddr *addr);
|
||||
int WINS_GetSocketAddr (int socketid, struct qsockaddr *addr);
|
||||
int WINS_GetNameFromAddr (struct qsockaddr *addr, char *name);
|
||||
int WINS_GetAddrFromName (char *name, struct qsockaddr *addr);
|
||||
int WINS_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
|
|
|
@ -44,27 +44,18 @@ static int sequence[IPXSOCKETS];
|
|||
|
||||
int WIPX_Init (void)
|
||||
{
|
||||
int i;
|
||||
int i, err;
|
||||
char buff[MAXHOSTNAMELEN];
|
||||
struct qsockaddr addr;
|
||||
struct qsockaddr addr;
|
||||
char *p;
|
||||
int r;
|
||||
WORD wVersionRequested;
|
||||
|
||||
if (COM_CheckParm ("-noipx"))
|
||||
return -1;
|
||||
|
||||
// make sure LoadLibrary has happened successfully
|
||||
if (!winsock_lib_initialized)
|
||||
return -1;
|
||||
|
||||
if (winsock_initialized == 0)
|
||||
{
|
||||
wVersionRequested = MAKEWORD(1, 1);
|
||||
|
||||
r = pWSAStartup (MAKEWORD(1, 1), &winsockdata);
|
||||
|
||||
if (r)
|
||||
err = WSAStartup(MAKEWORD(1,1), &winsockdata);
|
||||
if (err != 0)
|
||||
{
|
||||
Con_Printf ("Winsock initialization failed.\n");
|
||||
return -1;
|
||||
|
@ -76,7 +67,7 @@ int WIPX_Init (void)
|
|||
ipxsocket[i] = 0;
|
||||
|
||||
// determine my name & address
|
||||
if (pgethostname(buff, MAXHOSTNAMELEN) == 0)
|
||||
if (gethostname(buff, MAXHOSTNAMELEN) == 0)
|
||||
{
|
||||
// if the quake hostname isn't set, set it to the machine name
|
||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
||||
|
@ -98,11 +89,11 @@ int WIPX_Init (void)
|
|||
}
|
||||
}
|
||||
|
||||
if ((net_controlsocket = WIPX_OpenSocket (0)) == -1)
|
||||
if ((net_controlsocket = WIPX_OpenSocket(0)) == -1)
|
||||
{
|
||||
Con_Printf("WIPX_Init: Unable to open control socket\n");
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup ();
|
||||
WSACleanup ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -130,7 +121,7 @@ void WIPX_Shutdown (void)
|
|||
WIPX_Listen (false);
|
||||
WIPX_CloseSocket (net_controlsocket);
|
||||
if (--winsock_initialized == 0)
|
||||
pWSACleanup ();
|
||||
WSACleanup ();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -169,13 +160,14 @@ int WIPX_OpenSocket (int port)
|
|||
if (handle == IPXSOCKETS)
|
||||
return -1;
|
||||
|
||||
if ((newsocket = psocket (AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
|
||||
if ((newsocket = socket (AF_IPX, SOCK_DGRAM, NSPROTO_IPX)) == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||
if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||
goto ErrorReturn;
|
||||
|
||||
if (psetsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof(_true)) < 0)
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof(_true))
|
||||
== SOCKET_ERROR)
|
||||
goto ErrorReturn;
|
||||
|
||||
address.sa_family = AF_IPX;
|
||||
|
@ -191,7 +183,7 @@ int WIPX_OpenSocket (int port)
|
|||
|
||||
Sys_Error ("Winsock IPX bind failed\n");
|
||||
ErrorReturn:
|
||||
pclosesocket (newsocket);
|
||||
closesocket (newsocket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -199,10 +191,10 @@ ErrorReturn:
|
|||
|
||||
int WIPX_CloseSocket (int handle)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int socketid = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
ret = pclosesocket (socket);
|
||||
ret = closesocket (socketid);
|
||||
ipxsocket[handle] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -219,12 +211,12 @@ int WIPX_Connect (int handle, struct qsockaddr *addr)
|
|||
|
||||
int WIPX_CheckNewConnections (void)
|
||||
{
|
||||
unsigned long available;
|
||||
u_long available;
|
||||
|
||||
if (net_acceptsocket == -1)
|
||||
return -1;
|
||||
|
||||
if (pioctlsocket (ipxsocket[net_acceptsocket], FIONREAD, &available) == -1)
|
||||
if (ioctlsocket (ipxsocket[net_acceptsocket], FIONREAD, &available) == -1)
|
||||
Sys_Error ("WIPX: ioctlsocket (FIONREAD) failed\n");
|
||||
if (available)
|
||||
return net_acceptsocket;
|
||||
|
@ -237,18 +229,16 @@ static byte packetBuffer[NET_DATAGRAMSIZE + 4];
|
|||
|
||||
int WIPX_Read (int handle, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int addrlen = sizeof (struct qsockaddr);
|
||||
int socket = ipxsocket[handle];
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
int socketid = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
ret = precvfrom (socket, packetBuffer, len+4, 0, (struct sockaddr *)addr, &addrlen);
|
||||
ret = recvfrom (socketid, (char *)packetBuffer, len+4, 0, (struct sockaddr *)addr, &addrlen);
|
||||
if (ret == -1)
|
||||
{
|
||||
int err = pWSAGetLastError();
|
||||
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK || err == WSAECONNREFUSED)
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if (ret < 4)
|
||||
|
@ -272,7 +262,7 @@ int WIPX_Broadcast (int handle, byte *buf, int len)
|
|||
|
||||
int WIPX_Write (int handle, byte *buf, int len, struct qsockaddr *addr)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int socketid = ipxsocket[handle];
|
||||
int ret;
|
||||
|
||||
// build packet with sequence number
|
||||
|
@ -281,9 +271,9 @@ int WIPX_Write (int handle, byte *buf, int len, struct qsockaddr *addr)
|
|||
memcpy(&packetBuffer[4], buf, len);
|
||||
len += 4;
|
||||
|
||||
ret = psendto (socket, packetBuffer, len, 0, (struct sockaddr *)addr, sizeof(struct qsockaddr));
|
||||
ret = sendto (socketid, packetBuffer, len, 0, (struct sockaddr *)addr, sizeof(struct qsockaddr));
|
||||
if (ret == -1)
|
||||
if (pWSAGetLastError() == WSAEWOULDBLOCK)
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
|
@ -315,19 +305,20 @@ char *WIPX_AddrToString (struct qsockaddr *addr)
|
|||
|
||||
int WIPX_StringToAddr (char *string, struct qsockaddr *addr)
|
||||
{
|
||||
int val;
|
||||
char buf[3];
|
||||
int val;
|
||||
char buf[3];
|
||||
|
||||
buf[2] = 0;
|
||||
Q_memset(addr, 0, sizeof(struct qsockaddr));
|
||||
addr->sa_family = AF_IPX;
|
||||
|
||||
#define DO(src,dest) \
|
||||
buf[0] = string[src]; \
|
||||
buf[1] = string[src + 1]; \
|
||||
if (sscanf (buf, "%x", &val) != 1) \
|
||||
return -1; \
|
||||
((struct sockaddr_ipx *)addr)->dest = val
|
||||
#define DO(src,dest) do { \
|
||||
buf[0] = string[src]; \
|
||||
buf[1] = string[src + 1]; \
|
||||
if (sscanf (buf, "%x", &val) != 1) \
|
||||
return -1; \
|
||||
((struct sockaddr_ipx *)addr)->dest = val; \
|
||||
} while (0)
|
||||
|
||||
DO(0, sa_netnum[0]);
|
||||
DO(2, sa_netnum[1]);
|
||||
|
@ -351,14 +342,15 @@ int WIPX_StringToAddr (char *string, struct qsockaddr *addr)
|
|||
|
||||
int WIPX_GetSocketAddr (int handle, struct qsockaddr *addr)
|
||||
{
|
||||
int socket = ipxsocket[handle];
|
||||
int socketid = ipxsocket[handle];
|
||||
int addrlen = sizeof(struct qsockaddr);
|
||||
unsigned int a;
|
||||
|
||||
Q_memset(addr, 0, sizeof(struct qsockaddr));
|
||||
if(pgetsockname(socket, (struct sockaddr *)addr, &addrlen) != 0)
|
||||
if (getsockname(socketid, (struct sockaddr *)addr, &addrlen) != 0)
|
||||
{
|
||||
int err = pWSAGetLastError();
|
||||
int err = WSAGetLastError();
|
||||
/* FIXME: what action should be taken?... */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -376,8 +368,8 @@ int WIPX_GetNameFromAddr (struct qsockaddr *addr, char *name)
|
|||
|
||||
int WIPX_GetAddrFromName(char *name, struct qsockaddr *addr)
|
||||
{
|
||||
int n;
|
||||
char buf[32];
|
||||
int n;
|
||||
char buf[32];
|
||||
|
||||
n = Q_strlen(name);
|
||||
|
||||
|
@ -431,3 +423,4 @@ int WIPX_SetSocketPort (struct qsockaddr *addr, int port)
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
|
|
@ -20,21 +20,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
// net_wipx.h
|
||||
|
||||
#ifndef __NET_WINIPX_H
|
||||
#define __NET_WINIPX_H
|
||||
|
||||
int WIPX_Init (void);
|
||||
void WIPX_Shutdown (void);
|
||||
void WIPX_Listen (qboolean state);
|
||||
int WIPX_OpenSocket (int port);
|
||||
int WIPX_CloseSocket (int socket);
|
||||
int WIPX_Connect (int socket, struct qsockaddr *addr);
|
||||
int WIPX_CloseSocket (int socketid);
|
||||
int WIPX_Connect (int socketid, struct qsockaddr *addr);
|
||||
int WIPX_CheckNewConnections (void);
|
||||
int WIPX_Read (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Write (int socket, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Broadcast (int socket, byte *buf, int len);
|
||||
int WIPX_Read (int socketid, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Write (int socketid, byte *buf, int len, struct qsockaddr *addr);
|
||||
int WIPX_Broadcast (int socketid, byte *buf, int len);
|
||||
char *WIPX_AddrToString (struct qsockaddr *addr);
|
||||
int WIPX_StringToAddr (char *string, struct qsockaddr *addr);
|
||||
int WIPX_GetSocketAddr (int socket, struct qsockaddr *addr);
|
||||
int WIPX_GetSocketAddr (int socketid, struct qsockaddr *addr);
|
||||
int WIPX_GetNameFromAddr (struct qsockaddr *addr, char *name);
|
||||
int WIPX_GetAddrFromName (char *name, struct qsockaddr *addr);
|
||||
int WIPX_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
int WIPX_GetSocketPort (struct qsockaddr *addr);
|
||||
int WIPX_SetSocketPort (struct qsockaddr *addr, int port);
|
||||
|
||||
#endif /* __NET_WINIPX_H */
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// moved here for global use -- kristian
|
||||
typedef enum { NO_MODE=-1, MODE_WINDOWED, MODE_FULLSCREEN_DEFAULT } modestate_t;
|
||||
|
||||
extern modestate_t modestate;
|
||||
|
||||
// a pixel can be one, two, or four bytes
|
||||
typedef byte pixel_t;
|
||||
|
||||
|
|
78
quakespasm/Quake/winquake.h
Normal file
78
quakespasm/Quake/winquake.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
Copyright (C) 1996-2001 Id Software, Inc.
|
||||
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// winquake.h: Win32-specific Quake header file
|
||||
|
||||
#ifndef __WINQUAKE_H
|
||||
#define __WINQUAKE_H
|
||||
|
||||
/* include windows.h here, because we need the data types */
|
||||
#include <windows.h>
|
||||
|
||||
/* required compatibility versions for directx components */
|
||||
#define DIRECTDRAW_VERSION 0x0300
|
||||
#define DIRECTSOUND_VERSION 0x0300
|
||||
#define DIRECTINPUT_VERSION 0x0300
|
||||
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL 0x020A
|
||||
#endif
|
||||
|
||||
extern qboolean WinNT;
|
||||
|
||||
extern HINSTANCE global_hInstance;
|
||||
extern int global_nCmdShow;
|
||||
|
||||
extern qboolean DDActive;
|
||||
|
||||
extern HWND mainwindow;
|
||||
extern qboolean ActiveApp, Minimized;
|
||||
|
||||
void VID_LockBuffer (void);
|
||||
void VID_UnlockBuffer (void);
|
||||
|
||||
int VID_ForceUnlockedAndReturnState (void);
|
||||
void VID_ForceLockState (int lk);
|
||||
|
||||
void IN_ShowMouse (void);
|
||||
void IN_DeactivateMouse (void);
|
||||
void IN_HideMouse (void);
|
||||
void IN_ActivateMouse (void);
|
||||
void IN_RestoreOriginalMouseState (void);
|
||||
void IN_SetQuakeMouseState (void);
|
||||
void IN_MouseEvent (int mstate);
|
||||
|
||||
extern cvar_t _windowed_mouse;
|
||||
|
||||
extern int window_center_x, window_center_y;
|
||||
extern RECT window_rect;
|
||||
|
||||
extern qboolean mouseinitialized;
|
||||
extern HWND hwnd_dialog;
|
||||
|
||||
extern HANDLE hinput, houtput;
|
||||
|
||||
void IN_UpdateClipCursor (void);
|
||||
void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify);
|
||||
|
||||
void VID_SetDefaultMode (void);
|
||||
|
||||
#endif /* __WINQUAKE_H */
|
||||
|
Loading…
Reference in a new issue