Lots of win32 (mingw cross) build fixes.

HTTP (curl) support is missing, but everything else builds.
This commit is contained in:
Bill Currie 2010-12-23 11:40:16 +09:00
parent 17b37e93b2
commit de04e1b602
23 changed files with 68 additions and 44 deletions

View file

@ -77,10 +77,6 @@ extern LPDIRECTDRAWSURFACE lpBackBuffer;
extern LPDIRECTDRAWPALETTE lpDDPal; extern LPDIRECTDRAWPALETTE lpDDPal;
#endif #endif
#ifdef HAVE_DSOUND_H
extern LPDIRECTSOUND pDS;
extern LPDIRECTSOUNDBUFFER pDSBuf;
#endif
void VID_LockBuffer (void); void VID_LockBuffer (void);
void VID_UnlockBuffer (void); void VID_UnlockBuffer (void);
void VID_UpdateWindowStatus (int window_x, int window_y); void VID_UpdateWindowStatus (int window_x, int window_y);
@ -100,8 +96,6 @@ extern qboolean winsock_lib_initialized;
extern int window_center_x, window_center_y; extern int window_center_x, window_center_y;
extern RECT window_rect; extern RECT window_rect;
extern qboolean mouseinitialized;
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
extern HWND hwnd_dialog; extern HWND hwnd_dialog;
#endif #endif

View file

@ -334,10 +334,10 @@ SNDDMA_InitDirect (void)
&dwWrite); &dwWrite);
IDirectSoundBuffer_Play (pDSBuf, 0, 0, DSBPLAY_LOOPING); IDirectSoundBuffer_Play (pDSBuf, 0, 0, DSBPLAY_LOOPING);
sn.samples = gSndBufSize / (sn.samplebits / 8); sn.frames = gSndBufSize / (sn.samplebits / 8) / sn.channels;
sn.samplepos = 0; sn.framepos = 0;
sn.submission_chunk = 1; sn.submission_chunk = 1;
sn.buffer = lpData; sn.buffer = (byte *) lpData;
sample16 = (sn.samplebits / 8) - 1; sample16 = (sn.samplebits / 8) - 1;
dsound_init = true; dsound_init = true;
@ -403,8 +403,9 @@ SNDDMA_GetDMAPos (void)
s = mmtime.u.sample - mmstarttime.u.sample; s = mmtime.u.sample - mmstarttime.u.sample;
s >>= sample16; s >>= sample16;
s /= sn.channels;
s &= (sn.samples - 1); s %= sn.frames;
return s; return s;
} }
@ -483,7 +484,7 @@ DSOUND_ClearBuffer (int clear)
// FIXME: this should be called with 2nd pbuf2 = NULL, dwsize =0 // FIXME: this should be called with 2nd pbuf2 = NULL, dwsize =0
pData = DSOUND_LockBuffer (true); pData = DSOUND_LockBuffer (true);
memset (pData, clear, sn.samples * sn.samplebits / 8); memset (pData, clear, sn.frames * sn.channels * sn.samplebits / 8);
DSOUND_LockBuffer (false); DSOUND_LockBuffer (false);
} }

View file

@ -250,8 +250,8 @@ SNDDMA_InitWav (void)
} }
} }
sn.samples = gSndBufSize / (sn.samplebits / 8); sn.frames = gSndBufSize / (sn.samplebits / 8) / sn.channels;
sn.samplepos = 0; sn.framepos = 0;
sn.submission_chunk = 1; sn.submission_chunk = 1;
sn.buffer = (unsigned char *) lpData; sn.buffer = (unsigned char *) lpData;
sample16 = (sn.samplebits / 8) - 1; sample16 = (sn.samplebits / 8) - 1;
@ -295,8 +295,9 @@ SNDDMA_GetDMAPos (void)
s = snd_sent * WAV_BUFFER_SIZE; s = snd_sent * WAV_BUFFER_SIZE;
s >>= sample16; s >>= sample16;
s /= sn.channels;
s &= (sn.samples - 1); s %= sn.frames;
return s; return s;
} }

View file

@ -50,6 +50,11 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/sound.h" #include "QF/sound.h"
#ifdef _WIN32
# include "winquake.h"
HWND mainwindow;
#endif
#define MEMSIZE (32 * 1024 * 1024) #define MEMSIZE (32 * 1024 * 1024)
cbuf_t *testsound_cbuf; cbuf_t *testsound_cbuf;

View file

@ -336,17 +336,18 @@ setgeometry_status (view_t *view)
sb->text = realloc (sb->text, sb->width); sb->text = realloc (sb->text, sb->width);
memset (sb->text, 0, sb->width); // force an update memset (sb->text, 0, sb->width); // force an update
} }
#ifdef SIGWINCH
static void static void
sigwinch (int sig) sigwinch (int sig)
{ {
interrupted = 1; interrupted = 1;
signal (SIGWINCH, sigwinch); signal (SIGWINCH, sigwinch);
} }
#endif
static void static void
get_size (int *xlen, int *ylen) get_size (int *xlen, int *ylen)
{ {
#if 0
struct winsize size; struct winsize size;
*xlen = *ylen = 0; *xlen = *ylen = 0;
@ -354,6 +355,8 @@ get_size (int *xlen, int *ylen)
return; return;
*xlen = size.ws_col; *xlen = size.ws_col;
*ylen = size.ws_row; *ylen = size.ws_row;
#endif
getmaxyx (stdscr, *ylen, *xlen);
} }
static void static void
@ -363,12 +366,14 @@ process_input (void)
int escape = 0; int escape = 0;
if (interrupted) { if (interrupted) {
#ifdef SIGWINCH
interrupted = 0; interrupted = 0;
get_size (&screen_x, &screen_y); get_size (&screen_x, &screen_y);
resizeterm (screen_y, screen_x); resizeterm (screen_y, screen_x);
con_linewidth = screen_x; con_linewidth = screen_x;
view_resize (sv_con_data.view, screen_x, screen_y); view_resize (sv_con_data.view, screen_x, screen_y);
sv_con_data.view->draw (sv_con_data.view); sv_con_data.view->draw (sv_con_data.view);
#endif
} }
for (ch = 1; ch; ) { for (ch = 1; ch; ) {
@ -557,7 +562,9 @@ create_input_line (int width)
static void static void
init (void) init (void)
{ {
#ifdef SIGWINCH
signal (SIGWINCH, sigwinch); signal (SIGWINCH, sigwinch);
#endif
initscr (); initscr ();
start_color (); start_color ();

View file

@ -88,10 +88,14 @@ static __attribute__ ((used)) const char rcsid[] =
#endif #endif
#ifndef HAVE_SOCKLEN_T #ifndef HAVE_SOCKLEN_T
# ifdef HAVE_SIZE # ifdef _WIN32
typedef size_t socklen_t; typedef int socklen_t;
# else # else
# ifdef HAVE_SIZE
typedef size_t socklen_t;
# else
typedef unsigned int socklen_t; typedef unsigned int socklen_t;
# endif
# endif # endif
#endif #endif

View file

@ -59,7 +59,8 @@ static __attribute__ ((used)) const char rcsid[] =
#ifdef BAN_TEST #ifdef BAN_TEST
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include "winquake.h"
typedef uint32_t in_addr_t;
#else #else
# include <sys/socket.h> # include <sys/socket.h>
# include <netinet/in.h> # include <netinet/in.h>

View file

@ -413,12 +413,13 @@ WINS_CheckNewConnections (void)
//============================================================================= //=============================================================================
int int
WINS_Read (int socket, byte * buf, int len, struct qsockaddr *addr) WINS_Read (int socket, byte *buf, int len, struct qsockaddr *addr)
{ {
int addrlen = sizeof (struct qsockaddr); int addrlen = sizeof (struct qsockaddr);
int ret; int ret;
ret = precvfrom (socket, buf, len, 0, (struct sockaddr *) addr, &addrlen); ret = precvfrom (socket, (char *) buf, len, 0, (struct sockaddr *) addr,
&addrlen);
if (ret == -1) { if (ret == -1) {
int err = pWSAGetLastError (); int err = pWSAGetLastError ();
@ -469,13 +470,13 @@ WINS_Broadcast (int socket, byte * buf, int len)
//============================================================================= //=============================================================================
int int
WINS_Write (int socket, byte * buf, int len, struct qsockaddr *addr) WINS_Write (int socket, byte *buf, int len, struct qsockaddr *addr)
{ {
int ret; int ret;
ret = ret =
psendto (socket, buf, len, 0, (struct sockaddr *) addr, psendto (socket, (char *) buf, len, 0, (struct sockaddr *) addr,
sizeof (struct qsockaddr)); sizeof (struct qsockaddr));
if (ret == -1) if (ret == -1)
if (pWSAGetLastError () == WSAEWOULDBLOCK) if (pWSAGetLastError () == WSAEWOULDBLOCK)

View file

@ -193,14 +193,15 @@ LoadBSPMem (void *mem, size_t mem_size, void (*cb) (const bsp_t *, void *),
void *cbdata) void *cbdata)
{ {
bsp_t *bsp; bsp_t *bsp;
int version;
bsp = calloc (sizeof (bsp_t), 1); bsp = calloc (sizeof (bsp_t), 1);
bsp->header = mem; bsp->header = mem;
if (LittleLong (bsp->header->version) != BSPVERSION) version = LittleLong (bsp->header->version);
Sys_Error ("version %i, not %i", LittleLong (bsp->header->version), if (version != BSPVERSION)
BSPVERSION); Sys_Error ("version %i, not %i", version, BSPVERSION);
#undef SET_LUMP #undef SET_LUMP
#define SET_LUMP(l,n) \ #define SET_LUMP(l,n) \

View file

@ -604,7 +604,7 @@ Sys_ConsoleInput (void)
} }
text[len] = c; text[len] = c;
len++; len++;
if (len < sizeof (text)) if (len < (int) sizeof (text))
text[len] = 0; text[len] = 0;
else { else {
// buffer is full // buffer is full

View file

@ -157,7 +157,7 @@ VID_SetWindowedMode ( void )
height = rect.bottom - rect.top; height = rect.bottom - rect.top;
// Create the window // Create the window
mainwindow = CreateWindow ("QuakeForge", PROGRAM, mainwindow = CreateWindow ("QuakeForge", PACKAGE_NAME,
WindowStyle, rect.left, rect.top, width, height, WindowStyle, rect.left, rect.top, width, height,
NULL, NULL, global_hInstance, NULL); NULL, NULL, global_hInstance, NULL);
@ -382,7 +382,8 @@ VID_Shutdown (void)
{ {
HGLRC hRC; HGLRC hRC;
HDC hDC; HDC hDC;
int i, temp[8192]; int i;
GLuint temp[8192];
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
if(hwnd_dialog) if(hwnd_dialog)

View file

@ -93,7 +93,7 @@ startup (void)
if ((vinfo.dwMajorVersion < 4) if ((vinfo.dwMajorVersion < 4)
|| (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) { || (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
Sys_Error ("This version of " PROGRAM Sys_Error ("This version of " PACKAGE_NAME
" requires at least Win95 or NT 4.0"); " requires at least Win95 or NT 4.0");
} }
#endif #endif

View file

@ -70,7 +70,7 @@ main (int argc, const char **argv)
if (!strcmp (argv[i], "-dedicated")) if (!strcmp (argv[i], "-dedicated"))
break; break;
if (i == argc) { if (i == argc) {
char **newargv; const char **newargv;
newargv = malloc ((argc + 2) * sizeof (*newargv)); newargv = malloc ((argc + 2) * sizeof (*newargv));
memcpy (newargv, argv, argc * 4); memcpy (newargv, argv, argc * 4);

View file

@ -113,7 +113,11 @@ qtv_print (const char *fmt, va_list args)
} else { } else {
mytime = time (NULL); mytime = time (NULL);
local = localtime (&mytime); local = localtime (&mytime);
#ifdef _WIN32
strftime (stamp, sizeof (stamp), "[%b %d %X] ", local);
#else
strftime (stamp, sizeof (stamp), "[%b %e %X] ", local); strftime (stamp, sizeof (stamp), "[%b %e %X] ", local);
#endif
Con_Printf ("%s%s", stamp, msg->str); Con_Printf ("%s%s", stamp, msg->str);
} }
if (msg->str[0] && msg->str[strlen (msg->str) - 1] != '\n') { if (msg->str[0] && msg->str[strlen (msg->str) - 1] != '\n') {

View file

@ -421,7 +421,7 @@ extern struct cvar_s *sv_highchars;
extern struct cvar_s *sv_mintic, *sv_maxtic; extern struct cvar_s *sv_mintic, *sv_maxtic;
extern struct cvar_s *sv_maxspeed; extern struct cvar_s *sv_maxspeed;
extern struct cvar_s *timeout; extern struct cvar_s *sv_timeout;
extern netadr_t master_adr[MAX_MASTERS]; // address of the master server extern netadr_t master_adr[MAX_MASTERS]; // address of the master server

View file

@ -94,7 +94,7 @@ startup (void)
if ((vinfo.dwMajorVersion < 4) if ((vinfo.dwMajorVersion < 4)
|| (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) { || (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
Sys_Error ("This version of " PROGRAM Sys_Error ("This version of " PACKAGE_NAME
" requires at least Win95 or NT 4.0"); " requires at least Win95 or NT 4.0");
} }
#endif #endif

View file

@ -104,7 +104,7 @@ startup (void)
if ((vinfo.dwMajorVersion < 4) || if ((vinfo.dwMajorVersion < 4) ||
(vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) { (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
Sys_Error ("This version of " PROGRAM Sys_Error ("This version of " PACKAGE_NAME
" requires a full Win32 implementation."); " requires a full Win32 implementation.");
} }

View file

@ -505,7 +505,11 @@ ma_log (const char *fmt, ...)
mytime = time (NULL); mytime = time (NULL);
local = localtime (&mytime); local = localtime (&mytime);
#ifdef _WIN32
strftime (stamp, sizeof (stamp), "[%b %d %X] ", local);
#else
strftime (stamp, sizeof (stamp), "[%b %e %X] ", local); strftime (stamp, sizeof (stamp), "[%b %e %X] ", local);
#endif
fprintf (stdout, "%s", stamp); fprintf (stdout, "%s", stamp);
va_start (args, fmt); va_start (args, fmt);
vfprintf (stdout, fmt, args); vfprintf (stdout, fmt, args);

View file

@ -141,7 +141,7 @@ cvar_t *sv_maxtic; // physics time tic
cvar_t *sv_netdosprotect; // tone down DoS from quake servers cvar_t *sv_netdosprotect; // tone down DoS from quake servers
cvar_t *timeout; // seconds without any message cvar_t *sv_timeout; // seconds without any message
cvar_t *zombietime; // seconds to sink messages after cvar_t *zombietime; // seconds to sink messages after
// disconnect // disconnect
@ -1839,7 +1839,7 @@ SV_CheckTimeouts (void)
float droptime; float droptime;
int nclients, i; int nclients, i;
droptime = realtime - timeout->value; droptime = realtime - sv_timeout->value;
nclients = 0; nclients = 0;
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
@ -2104,8 +2104,8 @@ SV_InitLocal (void)
"Spawn the player entity"); "Spawn the player entity");
watervis = Cvar_Get ("watervis", "0", CVAR_SERVERINFO, Cvar_Info, watervis = Cvar_Get ("watervis", "0", CVAR_SERVERINFO, Cvar_Info,
"Set nonzero to enable r_wateralpha on clients"); "Set nonzero to enable r_wateralpha on clients");
timeout = Cvar_Get ("timeout", "65", CVAR_NONE, NULL, "Sets the amount of " sv_timeout = Cvar_Get ("timeout", "65", CVAR_NONE, NULL, "Sets the amount "
"time in seconds before a client is considered " "of time in seconds before a client is considered "
"disconnected if the server does not receive a " "disconnected if the server does not receive a "
"packet"); "packet");
zombietime = Cvar_Get ("zombietime", "2", CVAR_NONE, NULL, "The number of " zombietime = Cvar_Get ("zombietime", "2", CVAR_NONE, NULL, "The number of "

View file

@ -457,7 +457,7 @@ SV_qtvCheckTimeouts (void)
float droptime; float droptime;
sv_qtv_t *proxy; sv_qtv_t *proxy;
droptime = realtime - timeout->value; droptime = realtime - sv_timeout->value;
for (i = 0; i < MAX_PROXIES; i++) { for (i = 0; i < MAX_PROXIES; i++) {
proxy = proxies + i; proxy = proxies + i;

View file

@ -64,7 +64,7 @@ startup (void)
if ((vinfo.dwMajorVersion < 4) || if ((vinfo.dwMajorVersion < 4) ||
(vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) { (vinfo.dwPlatformId == VER_PLATFORM_WIN32s)) {
Sys_Error (PROGRAM " requires at least Win95 or NT 4.0"); Sys_Error (PACKAGE_NAME " requires at least Win95 or NT 4.0");
} }
if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)

View file

@ -169,7 +169,7 @@ LightWorld (void)
BSP_AddLighting (bsp, (byte *) lightdata->str, lightdata->size); BSP_AddLighting (bsp, (byte *) lightdata->str, lightdata->size);
if (options.verbosity >= 0) if (options.verbosity >= 0)
printf ("lightdatasize: %zi\n", bsp->lightdatasize); printf ("lightdatasize: %ld\n", (long) bsp->lightdatasize);
} }
int int

View file

@ -317,7 +317,7 @@ WatchThread (void *_thread)
int ind = 0; int ind = 0;
while (1) { while (1) {
sleep (1); usleep (1000000);
for (i = 0; i < thread; i ++) for (i = 0; i < thread; i ++)
local_work[i] = working[i]; local_work[i] = working[i];
@ -884,8 +884,8 @@ main (int argc, char **argv)
BSP_AddVisibility (bsp, (byte *) visdata->str, visdata->size); BSP_AddVisibility (bsp, (byte *) visdata->str, visdata->size);
if (options.verbosity >= 0) if (options.verbosity >= 0)
printf ("visdatasize:%zi compressed from %zi\n", bsp->visdatasize, printf ("visdatasize:%ld compressed from %ld\n",
originalvismapsize); (long) bsp->visdatasize, (long) originalvismapsize);
CalcAmbientSounds (); CalcAmbientSounds ();