mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Reformat
This commit is contained in:
parent
26b15dbe07
commit
87e62a3724
6 changed files with 3713 additions and 3526 deletions
|
@ -24,9 +24,8 @@
|
|||
* =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/* For mremap() - must be before sys/mman.h include! */
|
||||
#if defined( __linux__ ) && ! defined( _GNU_SOURCE )
|
||||
#if defined(__linux__) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
|
@ -36,107 +35,106 @@
|
|||
|
||||
#include "../common/header/common.h"
|
||||
|
||||
#if defined( __FreeBSD__ )
|
||||
#if defined(__FreeBSD__)
|
||||
#include <machine/param.h>
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
|
||||
|
||||
byte *membase;
|
||||
int maxhunksize;
|
||||
int curhunksize;
|
||||
|
||||
void *
|
||||
Hunk_Begin ( int maxsize )
|
||||
Hunk_Begin(int maxsize)
|
||||
{
|
||||
/* reserve a huge chunk of memory, but don't commit any yet */
|
||||
maxhunksize = maxsize + sizeof ( int );
|
||||
maxhunksize = maxsize + sizeof(int);
|
||||
curhunksize = 0;
|
||||
|
||||
membase = mmap( 0, maxhunksize, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 );
|
||||
membase = mmap(0, maxhunksize, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
if ( ( membase == NULL ) || ( membase == (byte *) -1 ) )
|
||||
if ((membase == NULL) || (membase == (byte *)-1))
|
||||
{
|
||||
Sys_Error( "unable to virtual allocate %d bytes", maxsize );
|
||||
Sys_Error("unable to virtual allocate %d bytes", maxsize);
|
||||
}
|
||||
|
||||
*( (int *) membase ) = curhunksize;
|
||||
*((int *)membase) = curhunksize;
|
||||
|
||||
return ( membase + sizeof ( int ) );
|
||||
return membase + sizeof(int);
|
||||
}
|
||||
|
||||
void *
|
||||
Hunk_Alloc ( int size )
|
||||
Hunk_Alloc(int size)
|
||||
{
|
||||
byte *buf;
|
||||
|
||||
/* round to cacheline */
|
||||
size = ( size + 31 ) & ~31;
|
||||
size = (size + 31) & ~31;
|
||||
|
||||
if ( curhunksize + size > maxhunksize )
|
||||
if (curhunksize + size > maxhunksize)
|
||||
{
|
||||
Sys_Error( "Hunk_Alloc overflow" );
|
||||
Sys_Error("Hunk_Alloc overflow");
|
||||
}
|
||||
|
||||
buf = membase + sizeof ( int ) + curhunksize;
|
||||
buf = membase + sizeof(int) + curhunksize;
|
||||
curhunksize += size;
|
||||
return ( buf );
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
Hunk_End ( void )
|
||||
Hunk_End(void)
|
||||
{
|
||||
byte *n = NULL;
|
||||
|
||||
#if defined( __FreeBSD__ )
|
||||
#if defined(__FreeBSD__)
|
||||
size_t old_size = maxhunksize;
|
||||
size_t new_size = curhunksize + sizeof ( int );
|
||||
size_t new_size = curhunksize + sizeof(int);
|
||||
void *unmap_base;
|
||||
size_t unmap_len;
|
||||
|
||||
new_size = round_page( new_size );
|
||||
old_size = round_page( old_size );
|
||||
new_size = round_page(new_size);
|
||||
old_size = round_page(old_size);
|
||||
|
||||
if ( new_size > old_size )
|
||||
if (new_size > old_size)
|
||||
{
|
||||
n = 0; /* error */
|
||||
}
|
||||
else if ( new_size < old_size )
|
||||
else if (new_size < old_size)
|
||||
{
|
||||
unmap_base = (caddr_t) ( membase + new_size );
|
||||
unmap_base = (caddr_t)(membase + new_size);
|
||||
unmap_len = old_size - new_size;
|
||||
n = munmap( unmap_base, unmap_len ) + membase;
|
||||
n = munmap(unmap_base, unmap_len) + membase;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( __linux__ )
|
||||
n = (byte *)mremap( membase, maxhunksize, curhunksize + sizeof ( int ), 0 );
|
||||
#if defined(__linux__)
|
||||
n = (byte *)mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
|
||||
#endif
|
||||
|
||||
if ( n != membase )
|
||||
if (n != membase)
|
||||
{
|
||||
Sys_Error( "Hunk_End: Could not remap virtual block (%d)", errno );
|
||||
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
|
||||
}
|
||||
|
||||
*( (int *) membase ) = curhunksize + sizeof ( int );
|
||||
*((int *)membase) = curhunksize + sizeof(int);
|
||||
|
||||
return ( curhunksize );
|
||||
return curhunksize;
|
||||
}
|
||||
|
||||
void
|
||||
Hunk_Free ( void *base )
|
||||
Hunk_Free(void *base)
|
||||
{
|
||||
byte *m;
|
||||
|
||||
if ( base )
|
||||
if (base)
|
||||
{
|
||||
m = ( (byte *) base ) - sizeof ( int );
|
||||
m = ((byte *)base) - sizeof(int);
|
||||
|
||||
if ( munmap( m, *( (int *) m ) ) )
|
||||
if (munmap(m, *((int *)m)))
|
||||
{
|
||||
Sys_Error( "Hunk_Free: munmap failed (%d)", errno );
|
||||
Sys_Error("Hunk_Free: munmap failed (%d)", errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
cvar_t *nostdout;
|
||||
|
||||
int
|
||||
main ( int argc, char **argv )
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int time, oldtime, newtime;
|
||||
|
||||
/* register signal handler */
|
||||
/* register signal handler */
|
||||
registerHandler();
|
||||
|
||||
/* Prevent running Quake II as root. Only very mad
|
||||
|
@ -61,7 +61,7 @@ main ( int argc, char **argv )
|
|||
{
|
||||
printf("The effective UID is not the real UID! Your binary is probably marked\n");
|
||||
printf("'setuid'. That is not good idea, please fix it :) If you really know\n");
|
||||
printf("what you're doin edit src/unix/main.c and remove this check. Don't\n");
|
||||
printf("what you're doin edit src/unix/main.c and remove this check. Don't\n");
|
||||
printf("complain if Quake II eats your dog afterwards!\n");
|
||||
|
||||
return 1;
|
||||
|
@ -70,8 +70,8 @@ main ( int argc, char **argv )
|
|||
/* enforce C locale */
|
||||
setenv("LC_ALL", "C", 1);
|
||||
|
||||
printf( "\nYamagi Quake II v%4.2f\n", VERSION);
|
||||
printf( "=====================\n\n");
|
||||
printf("\nYamagi Quake II v%4.2f\n", VERSION);
|
||||
printf("=====================\n\n");
|
||||
|
||||
printf("Client build options:\n");
|
||||
#ifdef CDA
|
||||
|
@ -95,28 +95,28 @@ main ( int argc, char **argv )
|
|||
printf(" - Zip file support\n");
|
||||
#endif
|
||||
|
||||
printf("Platform: %s\n", BUILDSTRING);
|
||||
printf("Platform: %s\n", BUILDSTRING);
|
||||
printf("Architecture: %s\n", CPUSTRING);
|
||||
|
||||
|
||||
/* Seed PRNG */
|
||||
randk_seed();
|
||||
|
||||
/* Initialze the game */
|
||||
Qcommon_Init( argc, argv );
|
||||
Qcommon_Init(argc, argv);
|
||||
|
||||
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) | FNDELAY);
|
||||
|
||||
nostdout = Cvar_Get( "nostdout", "0", 0 );
|
||||
nostdout = Cvar_Get("nostdout", "0", 0);
|
||||
|
||||
if ( !nostdout->value )
|
||||
if (!nostdout->value)
|
||||
{
|
||||
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) | FNDELAY);
|
||||
}
|
||||
|
||||
oldtime = Sys_Milliseconds();
|
||||
|
||||
/* The legendary Quake II mainloop */
|
||||
while ( 1 )
|
||||
while (1)
|
||||
{
|
||||
/* find time spent rendering last frame */
|
||||
do
|
||||
|
@ -124,11 +124,12 @@ main ( int argc, char **argv )
|
|||
newtime = Sys_Milliseconds();
|
||||
time = newtime - oldtime;
|
||||
}
|
||||
while ( time < 1 );
|
||||
while (time < 1);
|
||||
|
||||
Qcommon_Frame( time );
|
||||
Qcommon_Frame(time);
|
||||
oldtime = newtime;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,33 +40,33 @@
|
|||
|
||||
netadr_t net_local_adr;
|
||||
|
||||
#define LOOPBACK 0x7f000001
|
||||
#define MAX_LOOPBACK 4
|
||||
#define QUAKE2MCAST "ff12::666"
|
||||
#define LOOPBACK 0x7f000001
|
||||
#define MAX_LOOPBACK 4
|
||||
#define QUAKE2MCAST "ff12::666"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte data [ MAX_MSGLEN ];
|
||||
byte data[MAX_MSGLEN];
|
||||
int datalen;
|
||||
} loopmsg_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
loopmsg_t msgs [ MAX_LOOPBACK ];
|
||||
loopmsg_t msgs[MAX_LOOPBACK];
|
||||
int get, send;
|
||||
} loopback_t;
|
||||
|
||||
loopback_t loopbacks [ 2 ];
|
||||
int ip_sockets [ 2 ];
|
||||
loopback_t loopbacks[2];
|
||||
int ip_sockets[2];
|
||||
int ip6_sockets[2];
|
||||
int ipx_sockets [ 2 ];
|
||||
int ipx_sockets[2];
|
||||
char *multicast_interface = NULL;
|
||||
|
||||
int NET_Socket(char *net_interface, int port, netsrc_t type, int family);
|
||||
char *NET_ErrorString ( void );
|
||||
char *NET_ErrorString(void);
|
||||
|
||||
void
|
||||
NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
||||
NetadrToSockadr(netadr_t *a, struct sockaddr_storage *s)
|
||||
{
|
||||
struct sockaddr_in6 *s6;
|
||||
|
||||
|
@ -91,7 +91,8 @@ NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
|||
|
||||
if (inet_pton(AF_INET6, QUAKE2MCAST, &s6->sin6_addr.s6_addr) != 1)
|
||||
{
|
||||
Com_Printf("NET_NetadrToSockadr: inet_pton: %s\n", strerror(errno));
|
||||
Com_Printf("NET_NetadrToSockadr: inet_pton: %s\n",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,12 +103,13 @@ NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
|||
#endif
|
||||
|
||||
/* scope_id is important for
|
||||
link-local destination.*/
|
||||
* link-local destination.*/
|
||||
s6->sin6_scope_id = a->scope_id;
|
||||
|
||||
break;
|
||||
|
||||
case NA_IP6:
|
||||
|
||||
if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a->ip))
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
|
@ -115,8 +117,8 @@ NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
|||
#endif
|
||||
s->ss_family = AF_INET;
|
||||
memcpy(&((struct sockaddr_in *)s)->sin_addr,
|
||||
&((struct in6_addr *)a->ip)->s6_addr[12],
|
||||
sizeof(struct in_addr));
|
||||
&((struct in6_addr *)a->ip)->s6_addr[12],
|
||||
sizeof(struct in_addr));
|
||||
((struct sockaddr_in *)s)->sin_port = a->port;
|
||||
}
|
||||
else
|
||||
|
@ -131,7 +133,7 @@ NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
|||
#endif
|
||||
|
||||
/* scope_id is important for
|
||||
link-local destination. */
|
||||
* link-local destination. */
|
||||
s6->sin6_scope_id = a->scope_id;
|
||||
}
|
||||
|
||||
|
@ -145,9 +147,9 @@ NetadrToSockadr ( netadr_t *a, struct sockaddr_storage *s )
|
|||
}
|
||||
|
||||
void
|
||||
SockadrToNetadr ( struct sockaddr_storage *s, netadr_t *a )
|
||||
SockadrToNetadr(struct sockaddr_storage *s, netadr_t *a)
|
||||
{
|
||||
struct sockaddr_in6 *s6;
|
||||
struct sockaddr_in6 *s6;
|
||||
|
||||
if (s->ss_family == AF_INET)
|
||||
{
|
||||
|
@ -181,12 +183,12 @@ SockadrToNetadr ( struct sockaddr_storage *s, netadr_t *a )
|
|||
}
|
||||
|
||||
void
|
||||
NET_Init ( )
|
||||
NET_Init()
|
||||
{
|
||||
}
|
||||
|
||||
qboolean
|
||||
NET_CompareAdr ( netadr_t a, netadr_t b )
|
||||
NET_CompareAdr(netadr_t a, netadr_t b)
|
||||
{
|
||||
if (a.type != b.type)
|
||||
{
|
||||
|
@ -222,7 +224,7 @@ NET_CompareAdr ( netadr_t a, netadr_t b )
|
|||
* Compares without the port
|
||||
*/
|
||||
qboolean
|
||||
NET_CompareBaseAdr ( netadr_t a, netadr_t b )
|
||||
NET_CompareBaseAdr(netadr_t a, netadr_t b)
|
||||
{
|
||||
if (a.type != b.type)
|
||||
{
|
||||
|
@ -317,7 +319,9 @@ NET_BaseAdrToString(netadr_t a)
|
|||
#else
|
||||
socklen_t const salen = sizeof(ss);
|
||||
#endif
|
||||
if (getnameinfo((struct sockaddr*)&ss, salen, s, sizeof(s), NULL, 0, NI_NUMERICHOST))
|
||||
|
||||
if (getnameinfo((struct sockaddr *)&ss, salen, s, sizeof(s), NULL,
|
||||
0, NI_NUMERICHOST))
|
||||
{
|
||||
Com_sprintf(s, sizeof(s), "<invalid>");
|
||||
}
|
||||
|
@ -325,7 +329,8 @@ NET_BaseAdrToString(netadr_t a)
|
|||
else
|
||||
{
|
||||
if ((a.type == NA_MULTICAST6) ||
|
||||
IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)&ss)-> sin6_addr))
|
||||
IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)&ss)->
|
||||
sin6_addr))
|
||||
{
|
||||
/* If the address is multicast (link) or a
|
||||
link-local, need to carry the scope. The string
|
||||
|
@ -349,7 +354,7 @@ NET_BaseAdrToString(netadr_t a)
|
|||
}
|
||||
|
||||
char *
|
||||
NET_AdrToString ( netadr_t a )
|
||||
NET_AdrToString(netadr_t a)
|
||||
{
|
||||
static char s[64];
|
||||
const char *base;
|
||||
|
@ -361,7 +366,7 @@ NET_AdrToString ( netadr_t a )
|
|||
}
|
||||
|
||||
qboolean
|
||||
NET_StringToSockaddr ( char *s, struct sockaddr_storage *sadr )
|
||||
NET_StringToSockaddr(char *s, struct sockaddr_storage *sadr)
|
||||
{
|
||||
char copy[128];
|
||||
char *addrs, *space;
|
||||
|
@ -406,7 +411,8 @@ NET_StringToSockaddr ( char *s, struct sockaddr_storage *sadr )
|
|||
if ((err = getaddrinfo(addrs, ports, &hints, &resultp)))
|
||||
{
|
||||
/* Error */
|
||||
Com_Printf("NET_StringToSockaddr: string %s:\n%s\n", s, gai_strerror(err));
|
||||
Com_Printf("NET_StringToSockaddr: string %s:\n%s\n", s,
|
||||
gai_strerror(err));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -434,7 +440,7 @@ NET_StringToSockaddr ( char *s, struct sockaddr_storage *sadr )
|
|||
}
|
||||
|
||||
qboolean
|
||||
NET_StringToAdr ( char *s, netadr_t *a )
|
||||
NET_StringToAdr(char *s, netadr_t *a)
|
||||
{
|
||||
struct sockaddr_storage sadr;
|
||||
|
||||
|
@ -457,55 +463,55 @@ NET_StringToAdr ( char *s, netadr_t *a )
|
|||
}
|
||||
|
||||
qboolean
|
||||
NET_IsLocalAddress ( netadr_t adr )
|
||||
NET_IsLocalAddress(netadr_t adr)
|
||||
{
|
||||
return ( NET_CompareAdr( adr, net_local_adr ) );
|
||||
return NET_CompareAdr(adr, net_local_adr);
|
||||
}
|
||||
|
||||
qboolean
|
||||
NET_GetLoopPacket ( netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message )
|
||||
NET_GetLoopPacket(netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
|
||||
{
|
||||
int i;
|
||||
loopback_t *loop;
|
||||
loopback_t *loop;
|
||||
|
||||
loop = &loopbacks [ sock ];
|
||||
loop = &loopbacks[sock];
|
||||
|
||||
if ( loop->send - loop->get > MAX_LOOPBACK )
|
||||
if (loop->send - loop->get > MAX_LOOPBACK)
|
||||
{
|
||||
loop->get = loop->send - MAX_LOOPBACK;
|
||||
}
|
||||
|
||||
if ( loop->get >= loop->send )
|
||||
if (loop->get >= loop->send)
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
i = loop->get & ( MAX_LOOPBACK - 1 );
|
||||
i = loop->get & (MAX_LOOPBACK - 1);
|
||||
loop->get++;
|
||||
|
||||
memcpy( net_message->data, loop->msgs [ i ].data, loop->msgs [ i ].datalen );
|
||||
net_message->cursize = loop->msgs [ i ].datalen;
|
||||
memcpy(net_message->data, loop->msgs[i].data, loop->msgs[i].datalen);
|
||||
net_message->cursize = loop->msgs[i].datalen;
|
||||
*net_from = net_local_adr;
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
NET_SendLoopPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
||||
NET_SendLoopPacket(netsrc_t sock, int length, void *data, netadr_t to)
|
||||
{
|
||||
int i;
|
||||
loopback_t *loop;
|
||||
loopback_t *loop;
|
||||
|
||||
loop = &loopbacks [ sock ^ 1 ];
|
||||
loop = &loopbacks[sock ^ 1];
|
||||
|
||||
i = loop->send & ( MAX_LOOPBACK - 1 );
|
||||
i = loop->send & (MAX_LOOPBACK - 1);
|
||||
loop->send++;
|
||||
|
||||
memcpy( loop->msgs [ i ].data, data, length );
|
||||
loop->msgs [ i ].datalen = length;
|
||||
memcpy(loop->msgs[i].data, data, length);
|
||||
loop->msgs[i].datalen = length;
|
||||
}
|
||||
|
||||
qboolean
|
||||
NET_GetPacket ( netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message )
|
||||
NET_GetPacket(netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message)
|
||||
{
|
||||
int ret;
|
||||
struct sockaddr_storage from;
|
||||
|
@ -573,7 +579,7 @@ NET_GetPacket ( netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message )
|
|||
}
|
||||
|
||||
void
|
||||
NET_SendPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
||||
NET_SendPacket(netsrc_t sock, int length, void *data, netadr_t to)
|
||||
{
|
||||
int ret;
|
||||
struct sockaddr_storage addr;
|
||||
|
@ -668,13 +674,15 @@ NET_SendPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
|||
error = getnameinfo((struct sockaddr *)s6, s6->sin6_len, tmp,
|
||||
sizeof(tmp), NULL, 0, NI_NUMERICHOST);
|
||||
#else
|
||||
error = getnameinfo((struct sockaddr *)s6, sizeof(struct sockaddr_in6),
|
||||
error = getnameinfo((struct sockaddr *)s6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST);
|
||||
#endif
|
||||
|
||||
if (error)
|
||||
{
|
||||
Com_Printf("NET_SendPacket: getnameinfo: %s\n", gai_strerror(error));
|
||||
Com_Printf("NET_SendPacket: getnameinfo: %s\n",
|
||||
gai_strerror(error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -691,7 +699,8 @@ NET_SendPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
|||
|
||||
if (error)
|
||||
{
|
||||
Com_Printf("NET_SendPacket: getaddrinfo: %s\n", gai_strerror(error));
|
||||
Com_Printf("NET_SendPacket: getaddrinfo: %s\n",
|
||||
gai_strerror(error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -707,7 +716,12 @@ NET_SendPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
|||
}
|
||||
}
|
||||
|
||||
ret = sendto(net_socket, data, length, 0, (struct sockaddr *)&addr, addr_size);
|
||||
ret = sendto(net_socket,
|
||||
data,
|
||||
length,
|
||||
0,
|
||||
(struct sockaddr *)&addr,
|
||||
addr_size);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
|
@ -717,7 +731,7 @@ NET_SendPacket ( netsrc_t sock, int length, void *data, netadr_t to )
|
|||
}
|
||||
|
||||
void
|
||||
NET_OpenIP ( void )
|
||||
NET_OpenIP(void)
|
||||
{
|
||||
cvar_t *port, *ip;
|
||||
|
||||
|
@ -753,7 +767,7 @@ NET_OpenIP ( void )
|
|||
* A single player game will only use the loopback code
|
||||
*/
|
||||
void
|
||||
NET_Config ( qboolean multiplayer )
|
||||
NET_Config(qboolean multiplayer)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -791,7 +805,7 @@ NET_Config ( qboolean multiplayer )
|
|||
/* =================================================================== */
|
||||
|
||||
int
|
||||
NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
||||
NET_Socket(char *net_interface, int port, netsrc_t type, int family)
|
||||
{
|
||||
char Buf[BUFSIZ], *Host, *Service;
|
||||
int newsocket, Error;
|
||||
|
@ -836,7 +850,8 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
|
||||
for (ai = res; ai != NULL; ai = ai->ai_next)
|
||||
{
|
||||
if ((newsocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
if ((newsocket =
|
||||
socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1)
|
||||
{
|
||||
Com_Printf("NET_Socket: socket: %s\n", strerror(errno));
|
||||
continue;
|
||||
|
@ -852,7 +867,8 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
if (family == AF_INET)
|
||||
{
|
||||
/* make it broadcast capable */
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i,
|
||||
sizeof(i)) == -1)
|
||||
{
|
||||
Com_Printf("ERROR: NET_Socket: setsockopt SO_BROADCAST:%s\n",
|
||||
NET_ErrorString());
|
||||
|
@ -861,11 +877,12 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
}
|
||||
|
||||
/* make it reusable */
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)) == -1)
|
||||
if (setsockopt(newsocket, SOL_SOCKET, SO_REUSEADDR, (char *)&i,
|
||||
sizeof(i)) == -1)
|
||||
{
|
||||
Com_Printf("ERROR: NET_Socket: setsockopt SO_REUSEADDR:%s\n",
|
||||
NET_ErrorString());
|
||||
return 0;
|
||||
NET_ErrorString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bind(newsocket, ai->ai_addr, ai->ai_addrlen) < 0)
|
||||
|
@ -895,37 +912,47 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
break;
|
||||
|
||||
case AF_INET6:
|
||||
|
||||
/* Multicast outgoing interface is specified for
|
||||
client and server (+set multicast <ifname>) */
|
||||
mcast = Cvar_Get("multicast", "NULL", CVAR_NOSET);
|
||||
multicast_interface = (strcmp(mcast->string, "NULL") ? mcast->string : NULL);
|
||||
multicast_interface =
|
||||
(strcmp(mcast->string, "NULL") ? mcast->string : NULL);
|
||||
|
||||
if (multicast_interface != NULL)
|
||||
{
|
||||
/* multicast_interface is a global variable.
|
||||
Also used in NET_SendPacket() */
|
||||
if ((mreq.ipv6mr_interface = if_nametoindex(multicast_interface)) == 0)
|
||||
if ((mreq.ipv6mr_interface =
|
||||
if_nametoindex(multicast_interface)) == 0)
|
||||
{
|
||||
Com_Printf("NET_Socket: invalid interface: %s\n", multicast_interface);
|
||||
Com_Printf("NET_Socket: invalid interface: %s\n",
|
||||
multicast_interface);
|
||||
}
|
||||
|
||||
if (setsockopt(newsocket, IPPROTO_IPV6, IPV6_MULTICAST_IF,
|
||||
&mreq.ipv6mr_interface, sizeof(mreq.ipv6mr_interface)) < 0)
|
||||
&mreq.ipv6mr_interface,
|
||||
sizeof(mreq.ipv6mr_interface)) < 0)
|
||||
{
|
||||
Com_Printf("NET_Socket: IPV6_MULTICAST_IF: %s\n", strerror(errno));
|
||||
Com_Printf("NET_Socket: IPV6_MULTICAST_IF: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
/* Join multicast group ONLY if server */
|
||||
if (type == NS_SERVER)
|
||||
{
|
||||
if (inet_pton(AF_INET6, QUAKE2MCAST, &mreq.ipv6mr_multiaddr.s6_addr) != 1)
|
||||
if (inet_pton(AF_INET6, QUAKE2MCAST,
|
||||
&mreq.ipv6mr_multiaddr.s6_addr) != 1)
|
||||
{
|
||||
Com_Printf("NET_Socket: inet_pton: %s\n", strerror(errno));
|
||||
Com_Printf("NET_Socket: inet_pton: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (setsockopt(newsocket, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) < 0)
|
||||
if (setsockopt(newsocket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
|
||||
&mreq, sizeof(mreq)) < 0)
|
||||
{
|
||||
Com_Printf("NET_Socket: IPV6_JOIN_GROUP: %s\n", strerror(errno));
|
||||
Com_Printf("NET_Socket: IPV6_JOIN_GROUP: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -937,32 +964,33 @@ NET_Socket ( char *net_interface, int port, netsrc_t type, int family )
|
|||
}
|
||||
|
||||
void
|
||||
NET_Shutdown ( void )
|
||||
NET_Shutdown(void)
|
||||
{
|
||||
NET_Config( false ); /* close sockets */
|
||||
NET_Config(false); /* close sockets */
|
||||
}
|
||||
|
||||
char *
|
||||
NET_ErrorString ( void )
|
||||
NET_ErrorString(void)
|
||||
{
|
||||
int code;
|
||||
|
||||
code = errno;
|
||||
return ( strerror( code ) );
|
||||
return strerror(code);
|
||||
}
|
||||
|
||||
/*
|
||||
* sleeps msec or until net socket is ready
|
||||
*/
|
||||
void
|
||||
NET_Sleep ( int msec )
|
||||
NET_Sleep(int msec)
|
||||
{
|
||||
struct timeval timeout;
|
||||
fd_set fdset;
|
||||
extern cvar_t *dedicated;
|
||||
extern qboolean stdin_active;
|
||||
|
||||
if ((!ip_sockets[NS_SERVER] && !ip6_sockets[NS_SERVER]) || (dedicated && !dedicated->value))
|
||||
if ((!ip_sockets[NS_SERVER] &&
|
||||
!ip6_sockets[NS_SERVER]) || (dedicated && !dedicated->value))
|
||||
{
|
||||
return; /* we're not a server, just run full speed */
|
||||
}
|
||||
|
@ -978,5 +1006,7 @@ NET_Sleep ( int msec )
|
|||
FD_SET(ip6_sockets[NS_SERVER], &fdset); /* IPv6 network socket */
|
||||
timeout.tv_sec = msec / 1000;
|
||||
timeout.tv_usec = (msec % 1000) * 1000;
|
||||
select(MAX(ip_sockets[NS_SERVER], ip6_sockets[NS_SERVER]) + 1, &fdset, NULL, NULL, &timeout);
|
||||
select(MAX(ip_sockets[NS_SERVER],
|
||||
ip6_sockets[NS_SERVER]) + 1, &fdset, NULL, NULL, &timeout);
|
||||
}
|
||||
|
||||
|
|
6360
src/unix/qgl.c
6360
src/unix/qgl.c
File diff suppressed because it is too large
Load diff
|
@ -53,346 +53,346 @@ unsigned sys_frame_time;
|
|||
int curtime;
|
||||
static void *game_library;
|
||||
|
||||
static char findbase [ MAX_OSPATH ];
|
||||
static char findpath [ MAX_OSPATH ];
|
||||
static char findpattern [ MAX_OSPATH ];
|
||||
static DIR *fdir;
|
||||
static char findbase[MAX_OSPATH];
|
||||
static char findpath[MAX_OSPATH];
|
||||
static char findpattern[MAX_OSPATH];
|
||||
static DIR *fdir;
|
||||
|
||||
qboolean stdin_active = true;
|
||||
extern cvar_t *nostdout;
|
||||
extern FILE *logfile;
|
||||
extern FILE *logfile;
|
||||
|
||||
static qboolean
|
||||
CompareAttributes ( char *path, char *name, unsigned musthave, unsigned canthave )
|
||||
CompareAttributes(char *path, char *name, unsigned musthave, unsigned canthave)
|
||||
{
|
||||
struct stat st;
|
||||
char fn [ MAX_OSPATH ];
|
||||
char fn[MAX_OSPATH];
|
||||
|
||||
/* . and .. never match */
|
||||
if ( ( strcmp( name, "." ) == 0 ) || ( strcmp( name, ".." ) == 0 ) )
|
||||
if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0))
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( true );
|
||||
return true;
|
||||
|
||||
if ( stat( fn, &st ) == -1 )
|
||||
if (stat(fn, &st) == -1)
|
||||
{
|
||||
return ( false ); /* shouldn't happen */
|
||||
return false; /* shouldn't happen */
|
||||
}
|
||||
|
||||
if ( ( st.st_mode & S_IFDIR ) && ( canthave & SFF_SUBDIR ) )
|
||||
if ((st.st_mode & S_IFDIR) && (canthave & SFF_SUBDIR))
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ( musthave & SFF_SUBDIR ) && !( st.st_mode & S_IFDIR ) )
|
||||
if ((musthave & SFF_SUBDIR) && !(st.st_mode & S_IFDIR))
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Init ( void )
|
||||
Sys_Init(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
Sys_Milliseconds ( void )
|
||||
Sys_Milliseconds(void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday( &tp, &tzp );
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if ( !secbase )
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return ( tp.tv_usec / 1000 );
|
||||
return tp.tv_usec / 1000;
|
||||
}
|
||||
|
||||
curtime = ( tp.tv_sec - secbase ) * 1000 + tp.tv_usec / 1000;
|
||||
curtime = (tp.tv_sec - secbase) * 1000 + tp.tv_usec / 1000;
|
||||
|
||||
return ( curtime );
|
||||
return curtime;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Mkdir ( char *path )
|
||||
Sys_Mkdir(char *path)
|
||||
{
|
||||
mkdir( path, 0755 );
|
||||
mkdir(path, 0755);
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_GetCurrentDirectory ( void )
|
||||
Sys_GetCurrentDirectory(void)
|
||||
{
|
||||
static char dir [ MAX_OSPATH ];
|
||||
static char dir[MAX_OSPATH];
|
||||
|
||||
if ( !getcwd( dir, sizeof ( dir ) ) )
|
||||
if (!getcwd(dir, sizeof(dir)))
|
||||
{
|
||||
Sys_Error( "Couldn't get current working directory" );
|
||||
Sys_Error("Couldn't get current working directory");
|
||||
}
|
||||
|
||||
return ( dir );
|
||||
return dir;
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_FindFirst ( char *path, unsigned musthave, unsigned canhave )
|
||||
Sys_FindFirst(char *path, unsigned musthave, unsigned canhave)
|
||||
{
|
||||
struct dirent *d;
|
||||
char *p;
|
||||
|
||||
if ( fdir )
|
||||
if (fdir)
|
||||
{
|
||||
Sys_Error( "Sys_BeginFind without close" );
|
||||
Sys_Error("Sys_BeginFind without close");
|
||||
}
|
||||
|
||||
strcpy( findbase, path );
|
||||
strcpy(findbase, path);
|
||||
|
||||
if ( ( p = strrchr( findbase, '/' ) ) != NULL )
|
||||
if ((p = strrchr(findbase, '/')) != NULL)
|
||||
{
|
||||
*p = 0;
|
||||
strcpy( findpattern, p + 1 );
|
||||
strcpy(findpattern, p + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( findpattern, "*" );
|
||||
strcpy(findpattern, "*");
|
||||
}
|
||||
|
||||
if ( strcmp( findpattern, "*.*" ) == 0 )
|
||||
if (strcmp(findpattern, "*.*") == 0)
|
||||
{
|
||||
strcpy( findpattern, "*" );
|
||||
strcpy(findpattern, "*");
|
||||
}
|
||||
|
||||
if ( ( fdir = opendir( findbase ) ) == NULL )
|
||||
if ((fdir = opendir(findbase)) == NULL)
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ( ( d = readdir( fdir ) ) != NULL )
|
||||
while ((d = readdir(fdir)) != NULL)
|
||||
{
|
||||
if ( !*findpattern || glob_match( findpattern, d->d_name ) )
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name))
|
||||
{
|
||||
if ( CompareAttributes( findbase, d->d_name, musthave, canhave ) )
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave))
|
||||
{
|
||||
sprintf( findpath, "%s/%s", findbase, d->d_name );
|
||||
return ( findpath );
|
||||
sprintf(findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_FindNext ( unsigned musthave, unsigned canhave )
|
||||
Sys_FindNext(unsigned musthave, unsigned canhave)
|
||||
{
|
||||
struct dirent *d;
|
||||
|
||||
if ( fdir == NULL )
|
||||
if (fdir == NULL)
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ( ( d = readdir( fdir ) ) != NULL )
|
||||
while ((d = readdir(fdir)) != NULL)
|
||||
{
|
||||
if ( !*findpattern || glob_match( findpattern, d->d_name ) )
|
||||
if (!*findpattern || glob_match(findpattern, d->d_name))
|
||||
{
|
||||
if ( CompareAttributes( findbase, d->d_name, musthave, canhave ) )
|
||||
if (CompareAttributes(findbase, d->d_name, musthave, canhave))
|
||||
{
|
||||
sprintf( findpath, "%s/%s", findbase, d->d_name );
|
||||
return ( findpath );
|
||||
sprintf(findpath, "%s/%s", findbase, d->d_name);
|
||||
return findpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FindClose ( void )
|
||||
Sys_FindClose(void)
|
||||
{
|
||||
if ( fdir != NULL )
|
||||
if (fdir != NULL)
|
||||
{
|
||||
closedir( fdir );
|
||||
closedir(fdir);
|
||||
}
|
||||
|
||||
fdir = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_ConsoleOutput ( char *string )
|
||||
Sys_ConsoleOutput(char *string)
|
||||
{
|
||||
if ( nostdout && nostdout->value )
|
||||
if (nostdout && nostdout->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fputs( string, stdout );
|
||||
fputs(string, stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Printf ( char *fmt, ... )
|
||||
Sys_Printf(char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text [ 1024 ];
|
||||
unsigned char *p;
|
||||
char text[1024];
|
||||
unsigned char *p;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
vsnprintf( text, 1024, fmt, argptr );
|
||||
va_end( argptr );
|
||||
va_start(argptr, fmt);
|
||||
vsnprintf(text, 1024, fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
if ( nostdout && nostdout->value )
|
||||
if (nostdout && nostdout->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( p = (unsigned char *) text; *p; p++ )
|
||||
for (p = (unsigned char *)text; *p; p++)
|
||||
{
|
||||
*p &= 0x7f;
|
||||
|
||||
if ( ( ( *p > 128 ) || ( *p < 32 ) ) && ( *p != 10 ) && ( *p != 13 ) && ( *p != 9 ) )
|
||||
if (((*p > 128) || (*p < 32)) && (*p != 10) && (*p != 13) && (*p != 9))
|
||||
{
|
||||
printf( "[%02x]", *p );
|
||||
printf("[%02x]", *p);
|
||||
}
|
||||
else
|
||||
{
|
||||
putc( *p, stdout );
|
||||
putc(*p, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Quit ( void )
|
||||
Sys_Quit(void)
|
||||
{
|
||||
#ifndef DEDICATED_ONLY
|
||||
CL_Shutdown();
|
||||
#endif
|
||||
|
||||
if (logfile)
|
||||
if (logfile)
|
||||
{
|
||||
fclose (logfile);
|
||||
fclose(logfile);
|
||||
logfile = NULL;
|
||||
}
|
||||
|
||||
Qcommon_Shutdown();
|
||||
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) & ~FNDELAY );
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~FNDELAY);
|
||||
|
||||
printf("------------------------------------\n");
|
||||
|
||||
exit( 0 );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Error ( char *error, ... )
|
||||
Sys_Error(char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string [ 1024 ];
|
||||
char string[1024];
|
||||
|
||||
/* change stdin to non blocking */
|
||||
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) & ~FNDELAY );
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~FNDELAY);
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
CL_Shutdown();
|
||||
#endif
|
||||
Qcommon_Shutdown();
|
||||
|
||||
va_start( argptr, error );
|
||||
vsnprintf( string, 1024, error, argptr );
|
||||
va_end( argptr );
|
||||
fprintf( stderr, "Error: %s\n", string );
|
||||
va_start(argptr, error);
|
||||
vsnprintf(string, 1024, error, argptr);
|
||||
va_end(argptr);
|
||||
fprintf(stderr, "Error: %s\n", string);
|
||||
|
||||
exit( 1 );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Warn ( char *warning, ... )
|
||||
Sys_Warn(char *warning, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string [ 1024 ];
|
||||
char string[1024];
|
||||
|
||||
va_start( argptr, warning );
|
||||
vsnprintf( string, 1024, warning, argptr );
|
||||
va_end( argptr );
|
||||
fprintf( stderr, "Warning: %s", string );
|
||||
va_start(argptr, warning);
|
||||
vsnprintf(string, 1024, warning, argptr);
|
||||
va_end(argptr);
|
||||
fprintf(stderr, "Warning: %s", string);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns -1 if not present
|
||||
*/
|
||||
int
|
||||
Sys_FileTime ( char *path )
|
||||
Sys_FileTime(char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if ( stat( path, &buf ) == -1 )
|
||||
if (stat(path, &buf) == -1)
|
||||
{
|
||||
return ( -1 );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ( buf.st_mtime );
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
void
|
||||
floating_point_exception_handler ( int whatever )
|
||||
floating_point_exception_handler(int whatever)
|
||||
{
|
||||
signal( SIGFPE, floating_point_exception_handler );
|
||||
signal(SIGFPE, floating_point_exception_handler);
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_ConsoleInput ( void )
|
||||
Sys_ConsoleInput(void)
|
||||
{
|
||||
static char text [ 256 ];
|
||||
static char text[256];
|
||||
int len;
|
||||
fd_set fdset;
|
||||
struct timeval timeout;
|
||||
|
||||
if ( !dedicated || !dedicated->value )
|
||||
if (!dedicated || !dedicated->value)
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !stdin_active )
|
||||
if (!stdin_active)
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FD_ZERO( &fdset );
|
||||
FD_SET( 0, &fdset ); /* stdin */
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(0, &fdset); /* stdin */
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if ( ( select( 1, &fdset, NULL, NULL, &timeout ) == -1 ) || !FD_ISSET( 0, &fdset ) )
|
||||
if ((select(1, &fdset, NULL, NULL, &timeout) == -1) || !FD_ISSET(0, &fdset))
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = read( 0, text, sizeof ( text ) );
|
||||
len = read(0, text, sizeof(text));
|
||||
|
||||
if ( len == 0 ) /* eof! */
|
||||
if (len == 0) /* eof! */
|
||||
{
|
||||
stdin_active = false;
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( len < 1 )
|
||||
if (len < 1)
|
||||
{
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
text [ len - 1 ] = 0; /* rip off the /n and terminate */
|
||||
text[len - 1] = 0; /* rip off the /n and terminate */
|
||||
|
||||
return ( text );
|
||||
return text;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_UnloadGame ( void )
|
||||
Sys_UnloadGame(void)
|
||||
{
|
||||
if ( game_library )
|
||||
if (game_library)
|
||||
{
|
||||
dlclose( game_library );
|
||||
dlclose(game_library);
|
||||
}
|
||||
|
||||
game_library = NULL;
|
||||
|
@ -402,65 +402,65 @@ Sys_UnloadGame ( void )
|
|||
* Loads the game dll
|
||||
*/
|
||||
void *
|
||||
Sys_GetGameAPI ( void *parms )
|
||||
Sys_GetGameAPI(void *parms)
|
||||
{
|
||||
void *( *GetGameAPI )(void *);
|
||||
void *(*GetGameAPI)(void *);
|
||||
|
||||
FILE *fp;
|
||||
char name [ MAX_OSPATH ];
|
||||
char *path;
|
||||
char *str_p;
|
||||
FILE *fp;
|
||||
char name[MAX_OSPATH];
|
||||
char *path;
|
||||
char *str_p;
|
||||
const char *gamename = "game.so";
|
||||
|
||||
setreuid( getuid(), getuid() );
|
||||
setegid( getgid() );
|
||||
setreuid(getuid(), getuid());
|
||||
setegid(getgid());
|
||||
|
||||
if ( game_library )
|
||||
if (game_library)
|
||||
{
|
||||
Com_Error( ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame" );
|
||||
Com_Error(ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame");
|
||||
}
|
||||
|
||||
Com_Printf( "LoadLibrary(\"%s\")\n", gamename );
|
||||
Com_Printf("LoadLibrary(\"%s\")\n", gamename);
|
||||
|
||||
/* now run through the search paths */
|
||||
path = NULL;
|
||||
|
||||
while ( 1 )
|
||||
while (1)
|
||||
{
|
||||
path = FS_NextPath( path );
|
||||
path = FS_NextPath(path);
|
||||
|
||||
if ( !path )
|
||||
if (!path)
|
||||
{
|
||||
return ( NULL ); /* couldn't find one anywhere */
|
||||
return NULL; /* couldn't find one anywhere */
|
||||
}
|
||||
|
||||
snprintf( name, MAX_OSPATH, "%s/%s", path, gamename );
|
||||
snprintf(name, MAX_OSPATH, "%s/%s", path, gamename);
|
||||
|
||||
/* skip it if it just doesn't exist */
|
||||
fp = fopen( name, "rb" );
|
||||
fp = fopen(name, "rb");
|
||||
|
||||
if ( fp == NULL )
|
||||
if (fp == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose( fp );
|
||||
fclose(fp);
|
||||
|
||||
game_library = dlopen( name, RTLD_NOW );
|
||||
game_library = dlopen(name, RTLD_NOW);
|
||||
|
||||
if ( game_library )
|
||||
if (game_library)
|
||||
{
|
||||
Com_MDPrintf( "LoadLibrary (%s)\n", name );
|
||||
Com_MDPrintf("LoadLibrary (%s)\n", name);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf( "LoadLibrary (%s):", name );
|
||||
Com_Printf("LoadLibrary (%s):", name);
|
||||
|
||||
path = (char *) dlerror();
|
||||
str_p = strchr( path, ':' ); /* skip the path (already shown) */
|
||||
path = (char *)dlerror();
|
||||
str_p = strchr(path, ':'); /* skip the path (already shown) */
|
||||
|
||||
if ( str_p == NULL )
|
||||
if (str_p == NULL)
|
||||
{
|
||||
str_p = path;
|
||||
}
|
||||
|
@ -469,35 +469,34 @@ Sys_GetGameAPI ( void *parms )
|
|||
str_p++;
|
||||
}
|
||||
|
||||
Com_Printf( "%s\n", str_p );
|
||||
Com_Printf("%s\n", str_p);
|
||||
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GetGameAPI = (void *) dlsym( game_library, "GetGameAPI" );
|
||||
GetGameAPI = (void *)dlsym(game_library, "GetGameAPI");
|
||||
|
||||
if ( !GetGameAPI )
|
||||
if (!GetGameAPI)
|
||||
{
|
||||
Sys_UnloadGame();
|
||||
return ( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ( GetGameAPI( parms ) );
|
||||
return GetGameAPI(parms);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_SendKeyEvents ( void )
|
||||
Sys_SendKeyEvents(void)
|
||||
{
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
||||
if ( IN_Update_fp )
|
||||
if (IN_Update_fp)
|
||||
{
|
||||
IN_Update_fp();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* grab frame time */
|
||||
sys_frame_time = Sys_Milliseconds();
|
||||
}
|
||||
|
||||
|
|
285
src/unix/vid.c
285
src/unix/vid.c
|
@ -45,69 +45,70 @@
|
|||
refexport_t re;
|
||||
|
||||
/* Console variables that we need to access from this module */
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *vid_ref; /* Name of Refresh DLL loaded */
|
||||
cvar_t *vid_xpos; /* X coordinate of window position */
|
||||
cvar_t *vid_ypos; /* Y coordinate of window position */
|
||||
cvar_t *vid_fullscreen;
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *vid_ref; /* Name of Refresh DLL loaded */
|
||||
cvar_t *vid_xpos; /* X coordinate of window position */
|
||||
cvar_t *vid_ypos; /* Y coordinate of window position */
|
||||
cvar_t *vid_fullscreen;
|
||||
|
||||
/* Global variables used internally by this module */
|
||||
viddef_t viddef; /* global video state; used by other modules */
|
||||
void *reflib_library; /* Handle to refresh DLL */
|
||||
void *reflib_library; /* Handle to refresh DLL */
|
||||
qboolean reflib_active = 0;
|
||||
|
||||
#define VID_NUM_MODES ( sizeof ( vid_modes ) / sizeof ( vid_modes [ 0 ] ) )
|
||||
#define VID_NUM_MODES (sizeof(vid_modes) / sizeof(vid_modes[0]))
|
||||
|
||||
/* INPUT */
|
||||
void Do_Key_Event ( int key, qboolean down );
|
||||
void ( *IN_Update_fp )( void );
|
||||
void ( *IN_KeyboardInit_fp )( Key_Event_fp_t fp );
|
||||
void ( *IN_Close_fp )( void );
|
||||
void Do_Key_Event(int key, qboolean down);
|
||||
|
||||
void (*IN_Update_fp)(void);
|
||||
void (*IN_KeyboardInit_fp)(Key_Event_fp_t fp);
|
||||
void (*IN_Close_fp)(void);
|
||||
|
||||
in_state_t in_state;
|
||||
|
||||
void ( *IN_BackendInit_fp )( in_state_t *in_state_p );
|
||||
void ( *IN_BackendShutdown_fp )( void );
|
||||
void ( *IN_BackendMouseButtons_fp )( void );
|
||||
void ( *IN_BackendMove_fp )( usercmd_t *cmd );
|
||||
void (*IN_BackendInit_fp)(in_state_t *in_state_p);
|
||||
void (*IN_BackendShutdown_fp)(void);
|
||||
void (*IN_BackendMouseButtons_fp)(void);
|
||||
void (*IN_BackendMove_fp)(usercmd_t *cmd);
|
||||
|
||||
extern void VID_MenuShutdown ( void );
|
||||
extern void VID_MenuShutdown(void);
|
||||
|
||||
/* DLL GLUE */
|
||||
|
||||
#define MAXPRINTMSG 4096
|
||||
|
||||
void
|
||||
VID_Printf ( int print_level, char *fmt, ... )
|
||||
VID_Printf(int print_level, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg [ MAXPRINTMSG ];
|
||||
char msg[MAXPRINTMSG];
|
||||
|
||||
va_start( argptr, fmt );
|
||||
vsnprintf( msg, MAXPRINTMSG, fmt, argptr );
|
||||
va_end( argptr );
|
||||
va_start(argptr, fmt);
|
||||
vsnprintf(msg, MAXPRINTMSG, fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
if ( print_level == PRINT_ALL )
|
||||
if (print_level == PRINT_ALL)
|
||||
{
|
||||
Com_Printf( "%s", msg );
|
||||
Com_Printf("%s", msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_DPrintf( "%s", msg );
|
||||
Com_DPrintf("%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_Error ( int err_level, char *fmt, ... )
|
||||
VID_Error(int err_level, char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg [ MAXPRINTMSG ];
|
||||
char msg[MAXPRINTMSG];
|
||||
|
||||
va_start( argptr, fmt );
|
||||
vsnprintf( msg, MAXPRINTMSG, fmt, argptr );
|
||||
va_end( argptr );
|
||||
va_start(argptr, fmt);
|
||||
vsnprintf(msg, MAXPRINTMSG, fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
Com_Error( err_level, "%s", msg );
|
||||
Com_Error(err_level, "%s", msg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -116,7 +117,7 @@ VID_Error ( int err_level, char *fmt, ... )
|
|||
* cause the entire video mode and refresh DLL to be reset on the next frame.
|
||||
*/
|
||||
void
|
||||
VID_Restart_f ( void )
|
||||
VID_Restart_f(void)
|
||||
{
|
||||
vid_ref->modified = true;
|
||||
}
|
||||
|
@ -130,68 +131,68 @@ typedef struct vidmode_s
|
|||
|
||||
/* This must be the same as in menu.c! */
|
||||
vidmode_t vid_modes[] = {
|
||||
{ "Mode 0: 320x240", 320, 240, 0 },
|
||||
{ "Mode 1: 400x300", 400, 300, 1 },
|
||||
{ "Mode 2: 512x384", 512, 384, 2 },
|
||||
{ "Mode 3: 640x400", 640, 400, 3 },
|
||||
{ "Mode 4: 640x480", 640, 480, 4 },
|
||||
{ "Mode 5: 800x500", 800, 500, 5 },
|
||||
{ "Mode 6: 800x600", 800, 600, 6 },
|
||||
{ "Mode 7: 960x720", 960, 720, 7 },
|
||||
{ "Mode 8: 1024x480", 1024, 480, 8 },
|
||||
{ "Mode 9: 1024x640", 1024, 640, 9 },
|
||||
{ "Mode 10: 1024x768", 1024, 768, 10 },
|
||||
{ "Mode 11: 1152x768", 1152, 768, 11 },
|
||||
{ "Mode 12: 1152x864", 1152, 864, 12 },
|
||||
{ "Mode 13: 1280x800", 1280, 800, 13 },
|
||||
{ "Mode 14: 1280x854", 1280, 854, 14 },
|
||||
{ "Mode 15: 1280x960", 1280, 860, 15 },
|
||||
{ "Mode 16: 1280x1024", 1280, 1024, 16 },
|
||||
{ "Mode 17: 1440x900", 1440, 900, 17 },
|
||||
{ "Mode 18: 1600x1200", 1600, 1200, 18 },
|
||||
{ "Mode 19: 1680x1050", 1680, 1050, 19 },
|
||||
{ "Mode 20: 1920x1080", 1920, 1080, 20 },
|
||||
{ "Mode 21: 1920x1200", 1920, 1200, 21 },
|
||||
{ "Mode 22: 2048x1536", 2048, 1536, 22 },
|
||||
{"Mode 0: 320x240", 320, 240, 0},
|
||||
{"Mode 1: 400x300", 400, 300, 1},
|
||||
{"Mode 2: 512x384", 512, 384, 2},
|
||||
{"Mode 3: 640x400", 640, 400, 3},
|
||||
{"Mode 4: 640x480", 640, 480, 4},
|
||||
{"Mode 5: 800x500", 800, 500, 5},
|
||||
{"Mode 6: 800x600", 800, 600, 6},
|
||||
{"Mode 7: 960x720", 960, 720, 7},
|
||||
{"Mode 8: 1024x480", 1024, 480, 8},
|
||||
{"Mode 9: 1024x640", 1024, 640, 9},
|
||||
{"Mode 10: 1024x768", 1024, 768, 10},
|
||||
{"Mode 11: 1152x768", 1152, 768, 11},
|
||||
{"Mode 12: 1152x864", 1152, 864, 12},
|
||||
{"Mode 13: 1280x800", 1280, 800, 13},
|
||||
{"Mode 14: 1280x854", 1280, 854, 14},
|
||||
{"Mode 15: 1280x960", 1280, 860, 15},
|
||||
{"Mode 16: 1280x1024", 1280, 1024, 16},
|
||||
{"Mode 17: 1440x900", 1440, 900, 17},
|
||||
{"Mode 18: 1600x1200", 1600, 1200, 18},
|
||||
{"Mode 19: 1680x1050", 1680, 1050, 19},
|
||||
{"Mode 20: 1920x1080", 1920, 1080, 20},
|
||||
{"Mode 21: 1920x1200", 1920, 1200, 21},
|
||||
{"Mode 22: 2048x1536", 2048, 1536, 22},
|
||||
};
|
||||
|
||||
qboolean
|
||||
VID_GetModeInfo ( int *width, int *height, int mode )
|
||||
VID_GetModeInfo(int *width, int *height, int mode)
|
||||
{
|
||||
if ( ( mode < 0 ) || ( mode >= VID_NUM_MODES ) )
|
||||
if ((mode < 0) || (mode >= VID_NUM_MODES))
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
*width = vid_modes [ mode ].width;
|
||||
*height = vid_modes [ mode ].height;
|
||||
*width = vid_modes[mode].width;
|
||||
*height = vid_modes[mode].height;
|
||||
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
VID_NewWindow ( int width, int height )
|
||||
VID_NewWindow(int width, int height)
|
||||
{
|
||||
viddef.width = width;
|
||||
viddef.width = width;
|
||||
viddef.height = height;
|
||||
}
|
||||
|
||||
void
|
||||
VID_FreeReflib ( void )
|
||||
VID_FreeReflib(void)
|
||||
{
|
||||
if ( reflib_library )
|
||||
if (reflib_library)
|
||||
{
|
||||
if ( IN_Close_fp )
|
||||
if (IN_Close_fp)
|
||||
{
|
||||
IN_Close_fp();
|
||||
}
|
||||
|
||||
if ( IN_BackendShutdown_fp )
|
||||
if (IN_BackendShutdown_fp)
|
||||
{
|
||||
IN_BackendShutdown_fp();
|
||||
}
|
||||
|
||||
dlclose( reflib_library );
|
||||
dlclose(reflib_library);
|
||||
}
|
||||
|
||||
IN_KeyboardInit_fp = NULL;
|
||||
|
@ -202,28 +203,28 @@ VID_FreeReflib ( void )
|
|||
IN_BackendMouseButtons_fp = NULL;
|
||||
IN_BackendMove_fp = NULL;
|
||||
|
||||
memset( &re, 0, sizeof ( re ) );
|
||||
memset(&re, 0, sizeof(re));
|
||||
reflib_library = NULL;
|
||||
reflib_active = false;
|
||||
reflib_active = false;
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_LoadRefresh ( char *name )
|
||||
VID_LoadRefresh(char *name)
|
||||
{
|
||||
refimport_t ri;
|
||||
R_GetRefAPI_t R_GetRefAPI;
|
||||
char fn [ MAX_OSPATH ];
|
||||
char *path;
|
||||
char fn[MAX_OSPATH];
|
||||
char *path;
|
||||
struct stat st;
|
||||
|
||||
if ( reflib_active )
|
||||
if (reflib_active)
|
||||
{
|
||||
if ( IN_Close_fp )
|
||||
if (IN_Close_fp)
|
||||
{
|
||||
IN_Close_fp();
|
||||
}
|
||||
|
||||
if ( IN_BackendShutdown_fp )
|
||||
if (IN_BackendShutdown_fp)
|
||||
{
|
||||
IN_BackendShutdown_fp();
|
||||
}
|
||||
|
@ -234,24 +235,24 @@ VID_LoadRefresh ( char *name )
|
|||
VID_FreeReflib();
|
||||
}
|
||||
|
||||
Com_Printf( "----- refresher initialization -----\n");
|
||||
Com_Printf("----- refresher initialization -----\n");
|
||||
|
||||
path = Cvar_Get( "basedir", ".", CVAR_NOSET )->string;
|
||||
snprintf( fn, MAX_OSPATH, "%s/%s", path, name );
|
||||
path = Cvar_Get("basedir", ".", CVAR_NOSET)->string;
|
||||
snprintf(fn, MAX_OSPATH, "%s/%s", path, name);
|
||||
|
||||
if ( stat( fn, &st ) == -1 )
|
||||
if (stat(fn, &st) == -1)
|
||||
{
|
||||
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror( errno ) );
|
||||
return ( false );
|
||||
Com_Printf("LoadLibrary(\"%s\") failed: %s\n", name, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ( reflib_library = dlopen( fn, RTLD_LAZY ) ) == 0 )
|
||||
if ((reflib_library = dlopen(fn, RTLD_LAZY)) == 0)
|
||||
{
|
||||
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, dlerror() );
|
||||
return ( false );
|
||||
Com_Printf("LoadLibrary(\"%s\") failed: %s\n", name, dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
|
||||
Com_Printf("LoadLibrary(\"%s\")\n", fn);
|
||||
|
||||
ri.Cmd_AddCommand = Cmd_AddCommand;
|
||||
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
||||
|
@ -271,17 +272,17 @@ VID_LoadRefresh ( char *name )
|
|||
ri.Vid_MenuInit = VID_MenuInit;
|
||||
ri.Vid_NewWindow = VID_NewWindow;
|
||||
|
||||
if ( ( R_GetRefAPI = (void *) dlsym( reflib_library, "R_GetRefAPI" ) ) == 0 )
|
||||
if ((R_GetRefAPI = (void *)dlsym(reflib_library, "R_GetRefAPI")) == 0)
|
||||
{
|
||||
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
|
||||
Com_Error(ERR_FATAL, "dlsym failed on %s", name);
|
||||
}
|
||||
|
||||
re = R_GetRefAPI( ri );
|
||||
re = R_GetRefAPI(ri);
|
||||
|
||||
if ( re.api_version != API_VERSION )
|
||||
if (re.api_version != API_VERSION)
|
||||
{
|
||||
VID_FreeReflib();
|
||||
Com_Error( ERR_FATAL, "%s has incompatible api_version", name );
|
||||
Com_Error(ERR_FATAL, "%s has incompatible api_version", name);
|
||||
}
|
||||
|
||||
/* Init IN (Mouse) */
|
||||
|
@ -291,40 +292,40 @@ VID_LoadRefresh ( char *name )
|
|||
in_state.in_strafe_state = &in_strafe.state;
|
||||
in_state.in_speed_state = &in_speed.state;
|
||||
|
||||
if ( ( ( IN_BackendInit_fp = dlsym( reflib_library, "IN_BackendInit" ) ) == NULL ) ||
|
||||
( ( IN_BackendShutdown_fp = dlsym( reflib_library, "IN_BackendShutdown" ) ) == NULL ) ||
|
||||
( ( IN_BackendMouseButtons_fp = dlsym( reflib_library, "IN_BackendMouseButtons" ) ) == NULL ) ||
|
||||
( ( IN_BackendMove_fp = dlsym( reflib_library, "IN_BackendMove" ) ) == NULL ) )
|
||||
if (((IN_BackendInit_fp = dlsym(reflib_library, "IN_BackendInit")) == NULL) ||
|
||||
((IN_BackendShutdown_fp = dlsym(reflib_library, "IN_BackendShutdown")) == NULL) ||
|
||||
((IN_BackendMouseButtons_fp = dlsym(reflib_library, "IN_BackendMouseButtons")) == NULL) ||
|
||||
((IN_BackendMove_fp = dlsym(reflib_library, "IN_BackendMove")) == NULL))
|
||||
{
|
||||
Com_Error( ERR_FATAL, "No input backend init functions in REF.\n" );
|
||||
Com_Error(ERR_FATAL, "No input backend init functions in REF.\n");
|
||||
}
|
||||
|
||||
if ( IN_BackendInit_fp )
|
||||
if (IN_BackendInit_fp)
|
||||
{
|
||||
IN_BackendInit_fp( &in_state );
|
||||
IN_BackendInit_fp(&in_state);
|
||||
}
|
||||
|
||||
if ( re.Init( 0, 0 ) == -1 )
|
||||
if (re.Init(0, 0) == -1)
|
||||
{
|
||||
re.Shutdown();
|
||||
VID_FreeReflib();
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Init IN */
|
||||
if ( ( ( IN_KeyboardInit_fp = dlsym( reflib_library, "IN_KeyboardInit" ) ) == NULL ) ||
|
||||
( ( IN_Update_fp = dlsym( reflib_library, "IN_Update" ) ) == NULL ) ||
|
||||
( ( IN_Close_fp = dlsym( reflib_library, "IN_Close" ) ) == NULL ) )
|
||||
if (((IN_KeyboardInit_fp = dlsym(reflib_library, "IN_KeyboardInit")) == NULL) ||
|
||||
((IN_Update_fp = dlsym(reflib_library, "IN_Update")) == NULL) ||
|
||||
((IN_Close_fp = dlsym(reflib_library, "IN_Close")) == NULL))
|
||||
{
|
||||
Com_Error( ERR_FATAL, "No keyboard input functions in REF.\n" );
|
||||
Com_Error(ERR_FATAL, "No keyboard input functions in REF.\n");
|
||||
}
|
||||
|
||||
IN_KeyboardInit_fp( Do_Key_Event );
|
||||
IN_KeyboardInit_fp(Do_Key_Event);
|
||||
Key_ClearStates();
|
||||
|
||||
Com_Printf( "------------------------------------\n\n" );
|
||||
Com_Printf("------------------------------------\n\n");
|
||||
reflib_active = true;
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -334,16 +335,16 @@ VID_LoadRefresh ( char *name )
|
|||
* and/or video mode to match.
|
||||
*/
|
||||
void
|
||||
VID_CheckChanges ( void )
|
||||
VID_CheckChanges(void)
|
||||
{
|
||||
char name [ 100 ];
|
||||
char name[100];
|
||||
|
||||
if ( vid_ref->modified )
|
||||
if (vid_ref->modified)
|
||||
{
|
||||
S_StopAllSounds();
|
||||
}
|
||||
|
||||
while ( vid_ref->modified )
|
||||
while (vid_ref->modified)
|
||||
{
|
||||
/* refresh has changed */
|
||||
vid_ref->modified = false;
|
||||
|
@ -351,47 +352,46 @@ VID_CheckChanges ( void )
|
|||
cl.refresh_prepped = false;
|
||||
cls.disable_screen = true;
|
||||
|
||||
sprintf( name, "ref_%s.so", vid_ref->string );
|
||||
sprintf(name, "ref_%s.so", vid_ref->string);
|
||||
|
||||
if ( !VID_LoadRefresh( name ) )
|
||||
if (!VID_LoadRefresh(name))
|
||||
{
|
||||
Cvar_Set( "vid_ref", "gl" );
|
||||
Cvar_Set("vid_ref", "gl");
|
||||
}
|
||||
|
||||
cls.disable_screen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VID_Init ( void )
|
||||
VID_Init(void)
|
||||
{
|
||||
/* Create the video variables so we know how to start the graphics drivers */
|
||||
vid_ref = Cvar_Get( "vid_ref", "gl", CVAR_ARCHIVE );
|
||||
vid_ref = Cvar_Get("vid_ref", "gl", CVAR_ARCHIVE);
|
||||
|
||||
vid_xpos = Cvar_Get( "vid_xpos", "3", CVAR_ARCHIVE );
|
||||
vid_ypos = Cvar_Get( "vid_ypos", "22", CVAR_ARCHIVE );
|
||||
vid_fullscreen = Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
|
||||
vid_xpos = Cvar_Get("vid_xpos", "3", CVAR_ARCHIVE);
|
||||
vid_ypos = Cvar_Get("vid_ypos", "22", CVAR_ARCHIVE);
|
||||
vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
|
||||
vid_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE);
|
||||
|
||||
/* Add some console commands that we want to handle */
|
||||
Cmd_AddCommand( "vid_restart", VID_Restart_f );
|
||||
Cmd_AddCommand("vid_restart", VID_Restart_f);
|
||||
|
||||
/* Start the graphics mode and load refresh DLL */
|
||||
VID_CheckChanges();
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown ( void )
|
||||
VID_Shutdown(void)
|
||||
{
|
||||
if ( reflib_active )
|
||||
if (reflib_active)
|
||||
{
|
||||
if ( IN_Close_fp )
|
||||
if (IN_Close_fp)
|
||||
{
|
||||
IN_Close_fp();
|
||||
}
|
||||
|
||||
if ( IN_BackendShutdown_fp )
|
||||
if (IN_BackendShutdown_fp)
|
||||
{
|
||||
IN_BackendShutdown_fp();
|
||||
}
|
||||
|
@ -411,55 +411,56 @@ VID_Shutdown ( void )
|
|||
* ever have their names changed.
|
||||
*/
|
||||
qboolean
|
||||
VID_CheckRefExists ( const char *ref )
|
||||
VID_CheckRefExists(const char *ref)
|
||||
{
|
||||
char fn [ MAX_OSPATH ];
|
||||
char *path;
|
||||
char fn[MAX_OSPATH];
|
||||
char *path;
|
||||
struct stat st;
|
||||
|
||||
path = Cvar_Get( "basedir", ".", CVAR_NOSET )->string;
|
||||
snprintf( fn, MAX_OSPATH, "%s/ref_%s.so", path, ref );
|
||||
path = Cvar_Get("basedir", ".", CVAR_NOSET)->string;
|
||||
snprintf(fn, MAX_OSPATH, "%s/ref_%s.so", path, ref);
|
||||
|
||||
if ( stat( fn, &st ) == 0 )
|
||||
if (stat(fn, &st) == 0)
|
||||
{
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* INPUT */
|
||||
void
|
||||
IN_Shutdown ( void )
|
||||
IN_Shutdown(void)
|
||||
{
|
||||
if ( IN_BackendShutdown_fp )
|
||||
if (IN_BackendShutdown_fp)
|
||||
{
|
||||
IN_BackendShutdown_fp();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_Commands ( void )
|
||||
IN_Commands(void)
|
||||
{
|
||||
if ( IN_BackendMouseButtons_fp )
|
||||
if (IN_BackendMouseButtons_fp)
|
||||
{
|
||||
IN_BackendMouseButtons_fp();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_Move ( usercmd_t *cmd )
|
||||
IN_Move(usercmd_t *cmd)
|
||||
{
|
||||
if ( IN_BackendMove_fp )
|
||||
if (IN_BackendMove_fp)
|
||||
{
|
||||
IN_BackendMove_fp( cmd );
|
||||
IN_BackendMove_fp(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Do_Key_Event ( int key, qboolean down )
|
||||
Do_Key_Event(int key, qboolean down)
|
||||
{
|
||||
Key_Event( key, down, Sys_Milliseconds() );
|
||||
Key_Event(key, down, Sys_Milliseconds());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue