mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-11 02:00:56 +00:00
console.c, gl_vidsdl.c, host_cmd.c, in_sdl.c, main.c, menu.c, net_sdl.c,
net_sdlnet.c, sys_sdl.c: a lot of space-to-tab whitespace tidy-ups in the files created or touched by the SDL port. no actual code change. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@43 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
9d9354165c
commit
6c7d3d7205
9 changed files with 876 additions and 879 deletions
|
@ -111,7 +111,7 @@ void Con_ToggleConsole_f (void)
|
||||||
{
|
{
|
||||||
if (cls.state == ca_connected)
|
if (cls.state == ca_connected)
|
||||||
{
|
{
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
key_lines[edit_line][1] = 0; // clear any typing
|
key_lines[edit_line][1] = 0; // clear any typing
|
||||||
key_linepos = 1;
|
key_linepos = 1;
|
||||||
|
@ -124,10 +124,10 @@ void Con_ToggleConsole_f (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_console;
|
key_dest = key_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCR_EndLoadingPlaque ();
|
SCR_EndLoadingPlaque ();
|
||||||
memset (con_times, 0, sizeof(con_times));
|
memset (con_times, 0, sizeof(con_times));
|
||||||
|
@ -1104,7 +1104,7 @@ void Con_NotifyBox (char *text)
|
||||||
Con_Printf (Con_Quakebar(40)); //johnfitz
|
Con_Printf (Con_Quakebar(40)); //johnfitz
|
||||||
|
|
||||||
key_count = -2; // wait for a key down and up
|
key_count = -2; // wait for a key down and up
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_console;
|
key_dest = key_console;
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -1117,7 +1117,7 @@ void Con_NotifyBox (char *text)
|
||||||
} while (key_count < 0);
|
} while (key_count < 0);
|
||||||
|
|
||||||
Con_Printf ("\n");
|
Con_Printf ("\n");
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
realtime = 0; // put the cursor back to invisible
|
realtime = 0; // put the cursor back to invisible
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define MAX_MODE_LIST 600 //johnfitz -- was 30
|
#define MAX_MODE_LIST 600 //johnfitz -- was 30
|
||||||
#define VID_ROW_SIZE 3
|
#define VID_ROW_SIZE 3
|
||||||
#define WARP_WIDTH 320
|
#define WARP_WIDTH 320
|
||||||
#define WARP_HEIGHT 200
|
#define WARP_HEIGHT 200
|
||||||
#define MAXWIDTH 10000
|
#define MAXWIDTH 10000
|
||||||
#define MAXHEIGHT 10000
|
#define MAXHEIGHT 10000
|
||||||
#define BASEWIDTH 320
|
#define BASEWIDTH 320
|
||||||
#define BASEHEIGHT 200
|
#define BASEHEIGHT 200
|
||||||
#define SDL_DEFAULT_FLAGS SDL_OPENGL
|
|
||||||
|
#define SDL_DEFAULT_FLAGS SDL_OPENGL
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
modestate_t type;
|
modestate_t type;
|
||||||
|
@ -75,7 +76,7 @@ static qboolean windowed, leavecurrentmode;
|
||||||
static qboolean vid_canalttab = false;
|
static qboolean vid_canalttab = false;
|
||||||
extern qboolean mouseactive; // from in_win.c
|
extern qboolean mouseactive; // from in_win.c
|
||||||
|
|
||||||
SDL_Surface *draw_context;
|
SDL_Surface *draw_context;
|
||||||
|
|
||||||
int vid_modenum = NO_MODE;
|
int vid_modenum = NO_MODE;
|
||||||
int vid_realmode;
|
int vid_realmode;
|
||||||
|
@ -146,10 +147,6 @@ cvar_t vid_gamma = {"gamma", "1", true}; //johnfitz -- moved here from view.c
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
//typedef int (WINAPI * RAMPFUNC)();
|
|
||||||
//RAMPFUNC wglGetDeviceGammaRamp3DFX;
|
|
||||||
//RAMPFUNC wglSetDeviceGammaRamp3DFX;
|
|
||||||
|
|
||||||
unsigned short vid_gamma_red[256];
|
unsigned short vid_gamma_red[256];
|
||||||
unsigned short vid_gamma_green[256];
|
unsigned short vid_gamma_green[256];
|
||||||
unsigned short vid_gamma_blue[256];
|
unsigned short vid_gamma_blue[256];
|
||||||
|
@ -167,9 +164,9 @@ VID_Gamma_SetGamma -- apply gamma correction
|
||||||
*/
|
*/
|
||||||
void VID_Gamma_SetGamma (void)
|
void VID_Gamma_SetGamma (void)
|
||||||
{
|
{
|
||||||
if (draw_context && vid_gammaworks)
|
if (draw_context && vid_gammaworks)
|
||||||
if (SDL_SetGammaRamp(&vid_gamma_red[0], &vid_gamma_green[0], &vid_gamma_blue[0]) == -1)
|
if (SDL_SetGammaRamp(&vid_gamma_red[0], &vid_gamma_green[0], &vid_gamma_blue[0]) == -1)
|
||||||
Con_Printf ("VID_Gamma_SetGamma: failed on SDL_SetGammaRamp\n");
|
Con_Printf ("VID_Gamma_SetGamma: failed on SDL_SetGammaRamp\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -179,9 +176,9 @@ VID_Gamma_Restore -- restore system gamma
|
||||||
*/
|
*/
|
||||||
void VID_Gamma_Restore (void)
|
void VID_Gamma_Restore (void)
|
||||||
{
|
{
|
||||||
if (draw_context && vid_gammaworks)
|
if (draw_context && vid_gammaworks)
|
||||||
if (SDL_SetGammaRamp(&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) == -1)
|
if (SDL_SetGammaRamp(&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) == -1)
|
||||||
Con_Printf ("VID_Gamma_Restore: failed on SDL_SetGammaRamp\n");
|
Con_Printf ("VID_Gamma_Restore: failed on SDL_SetGammaRamp\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -209,11 +206,11 @@ void VID_Gamma_f (void)
|
||||||
|
|
||||||
oldgamma = vid_gamma.value;
|
oldgamma = vid_gamma.value;
|
||||||
|
|
||||||
for (i=0; i<256; i++)
|
for (i=0; i<256; i++)
|
||||||
{
|
{
|
||||||
vid_gamma_red[i] = CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8;
|
vid_gamma_red[i] = CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8;
|
||||||
vid_gamma_green[i] = vid_gamma_red[i];
|
vid_gamma_green[i] = vid_gamma_red[i];
|
||||||
vid_gamma_blue[i] = vid_gamma_red[i];
|
vid_gamma_blue[i] = vid_gamma_red[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
VID_Gamma_SetGamma ();
|
VID_Gamma_SetGamma ();
|
||||||
|
@ -246,7 +243,7 @@ int VID_SetMode (int modenum)
|
||||||
Uint32 flags = SDL_DEFAULT_FLAGS;
|
Uint32 flags = SDL_DEFAULT_FLAGS;
|
||||||
char caption[50];
|
char caption[50];
|
||||||
|
|
||||||
//TODO: check if video mode is supported using SDL_VideoModeOk
|
// TODO: check if video mode is supported using SDL_VideoModeOk
|
||||||
if ((windowed && (modenum != 0)) ||
|
if ((windowed && (modenum != 0)) ||
|
||||||
(!windowed && (modenum < 1)) ||
|
(!windowed && (modenum < 1)) ||
|
||||||
(!windowed && (modenum >= nummodes)))
|
(!windowed && (modenum >= nummodes)))
|
||||||
|
@ -260,7 +257,7 @@ int VID_SetMode (int modenum)
|
||||||
|
|
||||||
CDAudio_Pause ();
|
CDAudio_Pause ();
|
||||||
|
|
||||||
// set vertical sync
|
// set vertical sync
|
||||||
if (gl_swap_control)
|
if (gl_swap_control)
|
||||||
{
|
{
|
||||||
if (vid_vsync.value)
|
if (vid_vsync.value)
|
||||||
|
@ -275,44 +272,49 @@ int VID_SetMode (int modenum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelist[modenum].type == MODE_WINDOWED)
|
if (modelist[modenum].type == MODE_WINDOWED)
|
||||||
{
|
{
|
||||||
if (_windowed_mouse.value && key_dest == key_game)
|
if (_windowed_mouse.value && key_dest == key_game)
|
||||||
{
|
{
|
||||||
draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags);
|
draw_context = SDL_SetVideoMode(modelist[modenum].width,
|
||||||
stat = true;
|
modelist[modenum].height,
|
||||||
|
modelist[modenum].bpp, flags);
|
||||||
|
stat = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags);
|
draw_context = SDL_SetVideoMode(modelist[modenum].width,
|
||||||
stat = true;
|
modelist[modenum].height,
|
||||||
|
modelist[modenum].bpp, flags);
|
||||||
|
stat = true;
|
||||||
}
|
}
|
||||||
modestate = MODE_WINDOWED;
|
modestate = MODE_WINDOWED;
|
||||||
// TODO set icon and title
|
// TODO set icon and title
|
||||||
}
|
}
|
||||||
else if (modelist[modenum].type == MODE_FULLSCREEN_DEFAULT)
|
else if (modelist[modenum].type == MODE_FULLSCREEN_DEFAULT)
|
||||||
{
|
{
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags);
|
draw_context = SDL_SetVideoMode(modelist[modenum].width,
|
||||||
|
modelist[modenum].height,
|
||||||
stat = true;
|
modelist[modenum].bpp, flags);
|
||||||
modestate = MODE_FULLSCREEN_DEFAULT;
|
stat = true;
|
||||||
|
modestate = MODE_FULLSCREEN_DEFAULT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Sys_Error ("VID_SetMode: Bad mode type in modelist");
|
Sys_Error ("VID_SetMode: Bad mode type in modelist");
|
||||||
}
|
}
|
||||||
|
|
||||||
//kristian -- set window caption
|
//kristian -- set window caption
|
||||||
sprintf(caption, "FitzQuake (SDL port) Version %1.2f", FITZQUAKE_VERSION);
|
sprintf(caption, "FitzQuake (SDL port) Version %1.2f", FITZQUAKE_VERSION);
|
||||||
SDL_WM_SetCaption((const char* )&caption, (const char*)&caption);
|
SDL_WM_SetCaption((const char* )&caption, (const char*)&caption);
|
||||||
|
|
||||||
vid.width = modelist[modenum].width;
|
vid.width = modelist[modenum].width;
|
||||||
vid.height = modelist[modenum].height;
|
vid.height = modelist[modenum].height;
|
||||||
vid.conwidth = vid.width & 0xFFFFFFF8;
|
vid.conwidth = vid.width & 0xFFFFFFF8;
|
||||||
vid.conheight = vid.conwidth * vid.height / vid.width;
|
vid.conheight = vid.conwidth * vid.height / vid.width;
|
||||||
vid.numpages = 2;
|
vid.numpages = 2;
|
||||||
vid.type = modelist[modenum].type;
|
vid.type = modelist[modenum].type;
|
||||||
|
|
||||||
VID_UpdateWindowStatus ();
|
VID_UpdateWindowStatus ();
|
||||||
|
|
||||||
|
@ -326,7 +328,7 @@ int VID_SetMode (int modenum)
|
||||||
|
|
||||||
vid_modenum = modenum;
|
vid_modenum = modenum;
|
||||||
|
|
||||||
// fix the leftover Alt from any Alt-Tab or the like that switched us away
|
// fix the leftover Alt from any Alt-Tab or the like that switched us away
|
||||||
ClearAllStates ();
|
ClearAllStates ();
|
||||||
|
|
||||||
if (!msg_suppress_1)
|
if (!msg_suppress_1)
|
||||||
|
@ -334,12 +336,12 @@ int VID_SetMode (int modenum)
|
||||||
|
|
||||||
vid.recalc_refdef = 1;
|
vid.recalc_refdef = 1;
|
||||||
|
|
||||||
// with SDL, this needs to be done every time the render context is recreated, so I moved it here
|
// with SDL, this needs to be done every time the render context is recreated, so I moved it here
|
||||||
TexMgr_ReloadImages ();
|
TexMgr_ReloadImages ();
|
||||||
GL_SetupState ();
|
GL_SetupState ();
|
||||||
|
|
||||||
// no pending changes
|
// no pending changes
|
||||||
vid_changed = false;
|
vid_changed = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,7 @@ VID_Changed_f -- kristian -- notify us that a value has changed that requires a
|
||||||
*/
|
*/
|
||||||
void VID_Changed_f (void)
|
void VID_Changed_f (void)
|
||||||
{
|
{
|
||||||
vid_changed = true;
|
vid_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -370,75 +372,75 @@ void VID_Restart (void)
|
||||||
//
|
//
|
||||||
// decide which mode to set
|
// decide which mode to set
|
||||||
//
|
//
|
||||||
oldmode = modelist[vid_default];
|
oldmode = modelist[vid_default];
|
||||||
|
|
||||||
if (vid_fullscreen.value)
|
if (vid_fullscreen.value)
|
||||||
{
|
{
|
||||||
for (i=1; i<nummodes; i++)
|
for (i=1; i<nummodes; i++)
|
||||||
{
|
{
|
||||||
if (modelist[i].width == (int)vid_width.value &&
|
if (modelist[i].width == (int)vid_width.value &&
|
||||||
modelist[i].height == (int)vid_height.value &&
|
modelist[i].height == (int)vid_height.value &&
|
||||||
modelist[i].bpp == (int)vid_bpp.value)
|
modelist[i].bpp == (int)vid_bpp.value)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == nummodes)
|
if (i == nummodes)
|
||||||
{
|
{
|
||||||
Con_Printf ("%dx%dx%d %dHz is not a valid fullscreen mode\n",
|
Con_Printf ("%dx%dx%d %dHz is not a valid fullscreen mode\n",
|
||||||
(int)vid_width.value,
|
(int)vid_width.value,
|
||||||
(int)vid_height.value,
|
(int)vid_height.value,
|
||||||
(int)vid_bpp.value,
|
(int)vid_bpp.value,
|
||||||
(int)vid_refreshrate.value);
|
(int)vid_refreshrate.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
windowed = false;
|
windowed = false;
|
||||||
vid_default = i;
|
vid_default = i;
|
||||||
}
|
}
|
||||||
else //not fullscreen
|
else //not fullscreen
|
||||||
{
|
{
|
||||||
if (vid_width.value < 320)
|
if (vid_width.value < 320)
|
||||||
{
|
{
|
||||||
Con_Printf ("Window width can't be less than 320\n");
|
Con_Printf ("Window width can't be less than 320\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vid_height.value < 200)
|
if (vid_height.value < 200)
|
||||||
{
|
{
|
||||||
Con_Printf ("Window height can't be less than 200\n");
|
Con_Printf ("Window height can't be less than 200\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modelist[0].width = (int)vid_width.value;
|
modelist[0].width = (int)vid_width.value;
|
||||||
modelist[0].height = (int)vid_height.value;
|
modelist[0].height = (int)vid_height.value;
|
||||||
sprintf (modelist[0].modedesc, "%dx%dx%d",
|
sprintf (modelist[0].modedesc, "%dx%dx%d",
|
||||||
modelist[0].width,
|
modelist[0].width,
|
||||||
modelist[0].height,
|
modelist[0].height,
|
||||||
modelist[0].bpp);
|
modelist[0].bpp);
|
||||||
|
|
||||||
windowed = true;
|
windowed = true;
|
||||||
vid_default = 0;
|
vid_default = 0;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// set new mode
|
// set new mode
|
||||||
//
|
//
|
||||||
VID_SetMode (vid_default);
|
VID_SetMode (vid_default);
|
||||||
|
|
||||||
vid_canalttab = true;
|
vid_canalttab = true;
|
||||||
|
|
||||||
// Clear menu pic cache
|
// Clear menu pic cache
|
||||||
Draw_ClearMenuPicCache ();
|
Draw_ClearMenuPicCache ();
|
||||||
//warpimages needs to be recalculated
|
//warpimages needs to be recalculated
|
||||||
TexMgr_RecalcWarpImageSize ();
|
TexMgr_RecalcWarpImageSize ();
|
||||||
|
|
||||||
//conwidth and conheight need to be recalculated
|
//conwidth and conheight need to be recalculated
|
||||||
vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : vid.width;
|
vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : vid.width;
|
||||||
vid.conwidth = CLAMP (320, vid.conwidth, vid.width);
|
vid.conwidth = CLAMP (320, vid.conwidth, vid.width);
|
||||||
vid.conwidth &= 0xFFFFFFF8;
|
vid.conwidth &= 0xFFFFFFF8;
|
||||||
vid.conheight = vid.conwidth * vid.height / vid.width;
|
vid.conheight = vid.conwidth * vid.height / vid.width;
|
||||||
//
|
//
|
||||||
// keep cvars in line with actual mode
|
// keep cvars in line with actual mode
|
||||||
//
|
//
|
||||||
Cvar_Set ("vid_width", va("%i", modelist[vid_default].width));
|
Cvar_Set ("vid_width", va("%i", modelist[vid_default].width));
|
||||||
|
@ -573,9 +575,9 @@ void CheckArrayExtensions (void)
|
||||||
if (strncmp((const char*)tmp, "GL_EXT_vertex_array", strlen("GL_EXT_vertex_array")) == 0)
|
if (strncmp((const char*)tmp, "GL_EXT_vertex_array", strlen("GL_EXT_vertex_array")) == 0)
|
||||||
{
|
{
|
||||||
if (((glArrayElementEXT = SDL_GL_GetProcAddress("glArrayElementEXT")) == NULL) ||
|
if (((glArrayElementEXT = SDL_GL_GetProcAddress("glArrayElementEXT")) == NULL) ||
|
||||||
((glColorPointerEXT = SDL_GL_GetProcAddress("glColorPointerEXT")) == NULL) ||
|
((glColorPointerEXT = SDL_GL_GetProcAddress("glColorPointerEXT")) == NULL) ||
|
||||||
((glTexCoordPointerEXT = SDL_GL_GetProcAddress("glTexCoordPointerEXT")) == NULL) ||
|
((glTexCoordPointerEXT = SDL_GL_GetProcAddress("glTexCoordPointerEXT")) == NULL) ||
|
||||||
((glVertexPointerEXT = SDL_GL_GetProcAddress("glVertexPointerEXT")) == NULL) )
|
((glVertexPointerEXT = SDL_GL_GetProcAddress("glVertexPointerEXT")) == NULL) )
|
||||||
{
|
{
|
||||||
Sys_Error ("GetProcAddress for vertex extension failed");
|
Sys_Error ("GetProcAddress for vertex extension failed");
|
||||||
return;
|
return;
|
||||||
|
@ -595,7 +597,7 @@ GL_CheckExtensions -- johnfitz
|
||||||
*/
|
*/
|
||||||
void GL_CheckExtensions (void)
|
void GL_CheckExtensions (void)
|
||||||
{
|
{
|
||||||
int swap_control;
|
int swap_control;
|
||||||
|
|
||||||
//
|
//
|
||||||
// multitexture
|
// multitexture
|
||||||
|
@ -677,28 +679,32 @@ void GL_CheckExtensions (void)
|
||||||
Con_Warning ("texture_env_add not supported\n");
|
Con_Warning ("texture_env_add not supported\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// swap control
|
// swap control
|
||||||
//
|
//
|
||||||
if (strstr(gl_extensions, "GL_EXT_swap_control"))
|
if (strstr(gl_extensions, "GL_EXT_swap_control"))
|
||||||
{
|
{
|
||||||
if (SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0) == -1) {
|
if (SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0) == -1)
|
||||||
Con_Printf("WARNING: vertical sync not supported (SDL_GL_SetAttribute failed)\n");
|
{
|
||||||
}
|
Con_Printf("WARNING: vertical sync not supported (SDL_GL_SetAttribute failed)\n");
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == -1) {
|
{
|
||||||
Con_Printf("WARNING: vertical sync not supported (SDL_GL_GetAttribute failed). Make sure you don't have vertical sync disabled in your driver settings.\n");
|
if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == -1)
|
||||||
} else if (swap_control == -1) {
|
{
|
||||||
// TODO: check if this is correct - I don't know what SDL returns if vertical sync is disabled
|
Con_Printf("WARNING: vertical sync not supported (SDL_GL_GetAttribute failed). Make sure you don't have vertical sync disabled in your driver settings.\n");
|
||||||
Con_Printf("WARNING: vertical sync not supported (swap interval is -1.) Make sure you don't have vertical sync disabled in your driver settings.\n");
|
}
|
||||||
}
|
else if (swap_control == -1)
|
||||||
else
|
{
|
||||||
{
|
// TODO: check if this is correct - I don't know what SDL returns if vertical sync is disabled
|
||||||
Con_Printf("FOUND: WGL_EXT_swap_control\n");
|
Con_Printf("WARNING: vertical sync not supported (swap interval is -1.) Make sure you don't have vertical sync disabled in your driver settings.\n");
|
||||||
gl_swap_control = true;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
Con_Printf("FOUND: WGL_EXT_swap_control\n");
|
||||||
|
gl_swap_control = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Con_Printf ("WARNING: vertical sync not supported (extension not found)\n");
|
Con_Printf ("WARNING: vertical sync not supported (extension not found)\n");
|
||||||
|
@ -709,7 +715,7 @@ void GL_CheckExtensions (void)
|
||||||
if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic"))
|
if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic"))
|
||||||
{
|
{
|
||||||
float test1,test2;
|
float test1,test2;
|
||||||
GLuint tex;
|
GLuint tex;
|
||||||
|
|
||||||
// test to make sure we really have control over it
|
// test to make sure we really have control over it
|
||||||
// 1.0 and 2.0 should always be legal values
|
// 1.0 and 2.0 should always be legal values
|
||||||
|
@ -783,11 +789,10 @@ void GL_Init (void)
|
||||||
|
|
||||||
Cvar_RegisterVariable (&vid_vsync, VID_Changed_f); //johnfitz
|
Cvar_RegisterVariable (&vid_vsync, VID_Changed_f); //johnfitz
|
||||||
|
|
||||||
if (SDL_strncasecmp(gl_renderer,"PowerVR",7)==0)
|
if (SDL_strncasecmp(gl_renderer,"PowerVR",7)==0)
|
||||||
fullsbardraw = true;
|
fullsbardraw = true;
|
||||||
|
if (SDL_strncasecmp(gl_renderer,"Permedia",8)==0)
|
||||||
if (SDL_strncasecmp(gl_renderer,"Permedia",8)==0)
|
isPermedia = true;
|
||||||
isPermedia = true;
|
|
||||||
#if 1
|
#if 1
|
||||||
//johnfitz -- intel video workarounds from Baker
|
//johnfitz -- intel video workarounds from Baker
|
||||||
if (!strcmp(gl_vendor, "Intel"))
|
if (!strcmp(gl_vendor, "Intel"))
|
||||||
|
@ -830,7 +835,7 @@ GL_EndRendering
|
||||||
void GL_EndRendering (void)
|
void GL_EndRendering (void)
|
||||||
{
|
{
|
||||||
if (!scr_skipupdate || block_drawing)
|
if (!scr_skipupdate || block_drawing)
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
|
|
||||||
if (fullsbardraw)
|
if (fullsbardraw)
|
||||||
Sbar_Changed();
|
Sbar_Changed();
|
||||||
|
@ -848,10 +853,10 @@ void VID_Shutdown (void)
|
||||||
vid_canalttab = false;
|
vid_canalttab = false;
|
||||||
VID_Gamma_Shutdown (); //johnfitz
|
VID_Gamma_Shutdown (); //johnfitz
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
draw_context = NULL;
|
draw_context = NULL;
|
||||||
|
|
||||||
PL_VID_Shutdown();
|
PL_VID_Shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,9 +1011,9 @@ VID_DescribeModes_f -- johnfitz -- changed formatting, and added refresh rates a
|
||||||
*/
|
*/
|
||||||
void VID_DescribeModes_f (void)
|
void VID_DescribeModes_f (void)
|
||||||
{
|
{
|
||||||
int i, lnummodes, t;
|
int i, lnummodes, t;
|
||||||
vmode_t *pv;
|
vmode_t *pv;
|
||||||
int lastwidth=0, lastheight=0, lastbpp=0, count=0;
|
int lastwidth=0, lastheight=0, lastbpp=0, count=0;
|
||||||
|
|
||||||
lnummodes = VID_NumModes ();
|
lnummodes = VID_NumModes ();
|
||||||
|
|
||||||
|
@ -1045,9 +1050,9 @@ void VID_DescribeModes_f (void)
|
||||||
VID_InitDIB
|
VID_InitDIB
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void VID_InitDIB ()
|
void VID_InitDIB (void)
|
||||||
{
|
{
|
||||||
const SDL_VideoInfo *info;
|
const SDL_VideoInfo *info;
|
||||||
|
|
||||||
modelist[0].type = MODE_WINDOWED;
|
modelist[0].type = MODE_WINDOWED;
|
||||||
|
|
||||||
|
@ -1067,8 +1072,8 @@ void VID_InitDIB ()
|
||||||
if (modelist[0].height < 200) //johnfitz -- was 240
|
if (modelist[0].height < 200) //johnfitz -- was 240
|
||||||
modelist[0].height = 200; //johnfitz -- was 240
|
modelist[0].height = 200; //johnfitz -- was 240
|
||||||
|
|
||||||
info = SDL_GetVideoInfo();
|
info = SDL_GetVideoInfo();
|
||||||
modelist[0].bpp = info->vfmt->BitsPerPixel;
|
modelist[0].bpp = info->vfmt->BitsPerPixel;
|
||||||
|
|
||||||
sprintf (modelist[0].modedesc, "%dx%dx%d", //johnfitz -- added bpp
|
sprintf (modelist[0].modedesc, "%dx%dx%d", //johnfitz -- added bpp
|
||||||
modelist[0].width,
|
modelist[0].width,
|
||||||
|
@ -1088,83 +1093,83 @@ void VID_InitDIB ()
|
||||||
VID_InitFullDIB
|
VID_InitFullDIB
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void VID_InitFullDIB ()
|
void VID_InitFullDIB (void)
|
||||||
{
|
{
|
||||||
SDL_PixelFormat format;
|
SDL_PixelFormat format;
|
||||||
SDL_Rect **modes;
|
SDL_Rect **modes;
|
||||||
Uint32 flags;
|
Uint32 flags;
|
||||||
int i, j, k, modenum, originalnummodes, existingmode;
|
int i, j, k, modenum, originalnummodes, existingmode;
|
||||||
int bpps[3] = {16, 24, 32}; // enumerate >8 bpp modes
|
int bpps[3] = {16, 24, 32}; // enumerate >8 bpp modes
|
||||||
|
|
||||||
originalnummodes = nummodes;
|
originalnummodes = nummodes;
|
||||||
modenum = 0;
|
modenum = 0;
|
||||||
format.palette = NULL;
|
format.palette = NULL;
|
||||||
|
|
||||||
// enumerate fullscreen modes
|
// enumerate fullscreen modes
|
||||||
flags = SDL_DEFAULT_FLAGS | SDL_FULLSCREEN;
|
flags = SDL_DEFAULT_FLAGS | SDL_FULLSCREEN;
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (nummodes >= MAX_MODE_LIST)
|
if (nummodes >= MAX_MODE_LIST)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
format.BitsPerPixel = bpps[i];
|
format.BitsPerPixel = bpps[i];
|
||||||
modes = SDL_ListModes(&format, flags);
|
modes = SDL_ListModes(&format, flags);
|
||||||
|
|
||||||
if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
|
if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; modes[j]; j++)
|
for (j = 0; modes[j]; j++)
|
||||||
{
|
{
|
||||||
if (modes[j]->w > MAXWIDTH || modes[j]->h > MAXHEIGHT || nummodes >= MAX_MODE_LIST)
|
if (modes[j]->w > MAXWIDTH || modes[j]->h > MAXHEIGHT || nummodes >= MAX_MODE_LIST)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
modelist[nummodes].type = MODE_FULLSCREEN_DEFAULT;
|
modelist[nummodes].type = MODE_FULLSCREEN_DEFAULT;
|
||||||
modelist[nummodes].width = modes[j]->w;
|
modelist[nummodes].width = modes[j]->w;
|
||||||
modelist[nummodes].height = modes[j]->h;
|
modelist[nummodes].height = modes[j]->h;
|
||||||
modelist[nummodes].modenum = 0;
|
modelist[nummodes].modenum = 0;
|
||||||
modelist[nummodes].halfscreen = 0;
|
modelist[nummodes].halfscreen = 0;
|
||||||
modelist[nummodes].dib = 1;
|
modelist[nummodes].dib = 1;
|
||||||
modelist[nummodes].fullscreen = 1;
|
modelist[nummodes].fullscreen = 1;
|
||||||
modelist[nummodes].bpp = bpps[i];
|
modelist[nummodes].bpp = bpps[i];
|
||||||
|
|
||||||
sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
|
sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
|
||||||
modelist[nummodes].width,
|
modelist[nummodes].width,
|
||||||
modelist[nummodes].height,
|
modelist[nummodes].height,
|
||||||
modelist[nummodes].bpp); //johnfitz -- refreshrate
|
modelist[nummodes].bpp); //johnfitz -- refreshrate
|
||||||
|
|
||||||
// if the width is more than twice the height, reduce it by half because this
|
// if the width is more than twice the height, reduce it by half because this
|
||||||
// is probably a dual-screen monitor
|
// is probably a dual-screen monitor
|
||||||
if (!COM_CheckParm("-noadjustaspect"))
|
if (!COM_CheckParm("-noadjustaspect"))
|
||||||
{
|
{
|
||||||
if (modelist[nummodes].width > (modelist[nummodes].height << 1))
|
if (modelist[nummodes].width > (modelist[nummodes].height << 1))
|
||||||
{
|
{
|
||||||
modelist[nummodes].width >>= 1;
|
modelist[nummodes].width >>= 1;
|
||||||
modelist[nummodes].halfscreen = 1;
|
modelist[nummodes].halfscreen = 1;
|
||||||
sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
|
sprintf (modelist[nummodes].modedesc, "%dx%dx%d",
|
||||||
modelist[nummodes].width,
|
modelist[nummodes].width,
|
||||||
modelist[nummodes].height,
|
modelist[nummodes].height,
|
||||||
modelist[nummodes].bpp);
|
modelist[nummodes].bpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k=originalnummodes, existingmode = 0 ; k < nummodes ; k++)
|
for (k=originalnummodes, existingmode = 0 ; k < nummodes ; k++)
|
||||||
{
|
{
|
||||||
if ((modelist[nummodes].width == modelist[k].width) &&
|
if ((modelist[nummodes].width == modelist[k].width) &&
|
||||||
(modelist[nummodes].height == modelist[k].height) &&
|
(modelist[nummodes].height == modelist[k].height) &&
|
||||||
(modelist[nummodes].bpp == modelist[k].bpp))
|
(modelist[nummodes].bpp == modelist[k].bpp))
|
||||||
{
|
{
|
||||||
existingmode = 1;
|
existingmode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existingmode)
|
if (!existingmode)
|
||||||
{
|
{
|
||||||
nummodes++;
|
nummodes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modenum++;
|
modenum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nummodes == originalnummodes)
|
if (nummodes == originalnummodes)
|
||||||
Con_SafePrintf ("No fullscreen DIB modes found\n");
|
Con_SafePrintf ("No fullscreen DIB modes found\n");
|
||||||
|
@ -1177,10 +1182,10 @@ VID_Init
|
||||||
*/
|
*/
|
||||||
void VID_Init (void)
|
void VID_Init (void)
|
||||||
{
|
{
|
||||||
const SDL_VideoInfo *info;
|
const SDL_VideoInfo *info;
|
||||||
int i, existingmode;
|
int i, existingmode;
|
||||||
int basenummodes, width, height, bpp, findbpp, done;
|
int basenummodes, width, height, bpp, findbpp, done;
|
||||||
char gldir[MAX_OSPATH];
|
char gldir[MAX_OSPATH];
|
||||||
|
|
||||||
//johnfitz -- clean up init readouts
|
//johnfitz -- clean up init readouts
|
||||||
//Con_Printf("------------- Init Video -------------\n");
|
//Con_Printf("------------- Init Video -------------\n");
|
||||||
|
@ -1200,12 +1205,10 @@ void VID_Init (void)
|
||||||
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
|
||||||
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);
|
||||||
|
|
||||||
//InitCommonControls();
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
|
||||||
|
Sys_Error("Could not initialize SDL Video");
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
|
SDL_putenv("SDL_VIDEO_CENTERED=center");
|
||||||
Sys_Error("Could not initialize SDL Video");
|
|
||||||
|
|
||||||
SDL_putenv("SDL_VIDEO_CENTERED=center");
|
|
||||||
|
|
||||||
VID_InitDIB();
|
VID_InitDIB();
|
||||||
basenummodes = nummodes = 1;
|
basenummodes = nummodes = 1;
|
||||||
|
@ -1236,7 +1239,7 @@ void VID_Init (void)
|
||||||
{
|
{
|
||||||
if (COM_CheckParm("-current"))
|
if (COM_CheckParm("-current"))
|
||||||
{
|
{
|
||||||
info = SDL_GetVideoInfo();
|
info = SDL_GetVideoInfo();
|
||||||
modelist[MODE_FULLSCREEN_DEFAULT].width = info->current_w;
|
modelist[MODE_FULLSCREEN_DEFAULT].width = info->current_w;
|
||||||
modelist[MODE_FULLSCREEN_DEFAULT].height = info->current_h;
|
modelist[MODE_FULLSCREEN_DEFAULT].height = info->current_h;
|
||||||
vid_default = MODE_FULLSCREEN_DEFAULT;
|
vid_default = MODE_FULLSCREEN_DEFAULT;
|
||||||
|
@ -1375,8 +1378,8 @@ void VID_Init (void)
|
||||||
vid.colormap = host_colormap;
|
vid.colormap = host_colormap;
|
||||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||||
|
|
||||||
// set window icon
|
// set window icon
|
||||||
PL_SetWindowIcon();
|
PL_SetWindowIcon();
|
||||||
|
|
||||||
VID_SetMode (vid_default);
|
VID_SetMode (vid_default);
|
||||||
GL_Init ();
|
GL_Init ();
|
||||||
|
@ -1443,15 +1446,15 @@ VID_SyncCvars -- johnfitz -- set vid cvars to match current video mode
|
||||||
*/
|
*/
|
||||||
void VID_SyncCvars (void)
|
void VID_SyncCvars (void)
|
||||||
{
|
{
|
||||||
int swap_control;
|
int swap_control;
|
||||||
|
|
||||||
Cvar_Set ("vid_width", va("%i", modelist[vid_default].width));
|
Cvar_Set ("vid_width", va("%i", modelist[vid_default].width));
|
||||||
Cvar_Set ("vid_height", va("%i", modelist[vid_default].height));
|
Cvar_Set ("vid_height", va("%i", modelist[vid_default].height));
|
||||||
Cvar_Set ("vid_bpp", va("%i", modelist[vid_default].bpp));
|
Cvar_Set ("vid_bpp", va("%i", modelist[vid_default].bpp));
|
||||||
Cvar_Set ("vid_fullscreen", (windowed) ? "0" : "1");
|
Cvar_Set ("vid_fullscreen", (windowed) ? "0" : "1");
|
||||||
|
|
||||||
if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == 0)
|
if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == 0)
|
||||||
Cvar_Set ("vid_vsync", (swap_control) ? "1" : "0");
|
Cvar_Set ("vid_vsync", (swap_control) ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1732,10 +1735,10 @@ void VID_MenuKey (int key)
|
||||||
Cbuf_AddText ("toggle vid_fullscreen\n");
|
Cbuf_AddText ("toggle vid_fullscreen\n");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
Cbuf_AddText ("toggle vid_vsync\n"); // kristian
|
Cbuf_AddText ("toggle vid_vsync\n"); // kristian
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1758,10 +1761,10 @@ void VID_MenuKey (int key)
|
||||||
Cbuf_AddText ("toggle vid_fullscreen\n");
|
Cbuf_AddText ("toggle vid_fullscreen\n");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
Cbuf_AddText ("toggle vid_vsync\n");
|
Cbuf_AddText ("toggle vid_vsync\n");
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1791,9 +1794,9 @@ void VID_MenuKey (int key)
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
Cbuf_AddText ("vid_restart\n");
|
Cbuf_AddText ("vid_restart\n");
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1844,12 +1847,12 @@ void VID_MenuDraw (void)
|
||||||
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_fullscreen.value);
|
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_fullscreen.value);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// added vsync to the video menu -- kristian
|
// added vsync to the video menu -- kristian
|
||||||
M_Print (16, video_cursor_table[i], " Vertical Sync");
|
M_Print (16, video_cursor_table[i], " Vertical Sync");
|
||||||
if (gl_swap_control)
|
if (gl_swap_control)
|
||||||
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_vsync.value);
|
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_vsync.value);
|
||||||
else
|
else
|
||||||
M_Print (216, video_cursor_table[i], "N/A");
|
M_Print (216, video_cursor_table[i], "N/A");
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
125
Quake/host_cmd.c
125
Quake/host_cmd.c
|
@ -252,14 +252,14 @@ void ExtraMaps_Add (char *name)
|
||||||
|
|
||||||
void ExtraMaps_Init (void)
|
void ExtraMaps_Init (void)
|
||||||
{
|
{
|
||||||
DIR *dir_p;
|
DIR *dir_p;
|
||||||
struct dirent *dir_t;
|
struct dirent *dir_t;
|
||||||
char filestring[MAX_OSPATH];
|
char filestring[MAX_OSPATH];
|
||||||
char mapname[32];
|
char mapname[32];
|
||||||
char ignorepakdir[32];
|
char ignorepakdir[32];
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
pack_t *pak;
|
pack_t *pak;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//we don't want to list the maps in id1 pakfiles, becuase these are not "add-on" levels
|
//we don't want to list the maps in id1 pakfiles, becuase these are not "add-on" levels
|
||||||
sprintf (ignorepakdir, "/%s/", GAMENAME);
|
sprintf (ignorepakdir, "/%s/", GAMENAME);
|
||||||
|
@ -269,32 +269,34 @@ void ExtraMaps_Init (void)
|
||||||
if (*search->filename) //directory
|
if (*search->filename) //directory
|
||||||
{
|
{
|
||||||
sprintf (filestring,"%s/maps/",search->filename);
|
sprintf (filestring,"%s/maps/",search->filename);
|
||||||
dir_p = opendir(filestring);
|
dir_p = opendir(filestring);
|
||||||
|
if (dir_p == NULL)
|
||||||
if (dir_p == NULL)
|
continue;
|
||||||
continue;
|
while ((dir_t = readdir(dir_p)) != NULL)
|
||||||
|
{
|
||||||
while ((dir_t = readdir(dir_p)) != NULL)
|
if (!strstr(dir_t->d_name, ".bsp") && !strstr(dir_t->d_name, ".BSP"))
|
||||||
{
|
continue;
|
||||||
if (!strstr(dir_t->d_name, ".bsp") && !strstr(dir_t->d_name, ".BSP"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
COM_StripExtension(dir_t->d_name, mapname);
|
COM_StripExtension(dir_t->d_name, mapname);
|
||||||
ExtraMaps_Add (mapname);
|
ExtraMaps_Add (mapname);
|
||||||
}
|
}
|
||||||
|
closedir(dir_p);
|
||||||
closedir(dir_p);
|
|
||||||
}
|
}
|
||||||
else //pakfile
|
else //pakfile
|
||||||
{
|
{
|
||||||
if (!strstr(search->pack->filename, ignorepakdir)) //don't list standard id maps
|
if (!strstr(search->pack->filename, ignorepakdir)) //don't list standard id maps
|
||||||
|
{
|
||||||
for (i=0, pak=search->pack; i<pak->numfiles ; i++)
|
for (i=0, pak=search->pack; i<pak->numfiles ; i++)
|
||||||
|
{
|
||||||
if (strstr(pak->files[i].name, ".bsp"))
|
if (strstr(pak->files[i].name, ".bsp"))
|
||||||
|
{
|
||||||
if (pak->files[i].filelen > 32*1024) // don't list files under 32k (ammo boxes etc)
|
if (pak->files[i].filelen > 32*1024) // don't list files under 32k (ammo boxes etc)
|
||||||
{
|
{
|
||||||
COM_StripExtension(pak->files[i].name + 5, mapname);
|
COM_StripExtension(pak->files[i].name + 5, mapname);
|
||||||
ExtraMaps_Add (mapname);
|
ExtraMaps_Add (mapname);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,60 +384,51 @@ void Modlist_Add (char *name)
|
||||||
|
|
||||||
void Modlist_Init (void)
|
void Modlist_Init (void)
|
||||||
{
|
{
|
||||||
DIR *dir_p, *mod_dir_p;
|
DIR *dir_p, *mod_dir_p;
|
||||||
struct dirent *dir_t, *mod_dir_t;
|
struct dirent *dir_t, *mod_dir_t;
|
||||||
qboolean progs_found, pak_found;
|
qboolean progs_found, pak_found;
|
||||||
char dir_string[MAX_OSPATH], mod_dir_string[MAX_OSPATH];
|
char dir_string[MAX_OSPATH], mod_dir_string[MAX_OSPATH];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = COM_CheckParm ("-basedir");
|
i = COM_CheckParm ("-basedir");
|
||||||
if (i && i < com_argc-1)
|
if (i && i < com_argc-1)
|
||||||
sprintf (dir_string, "%s/", com_argv[i+1]);
|
sprintf (dir_string, "%s/", com_argv[i+1]);
|
||||||
else
|
else
|
||||||
sprintf (dir_string, "%s/", host_parms.basedir);
|
sprintf (dir_string, "%s/", host_parms.basedir);
|
||||||
|
|
||||||
dir_p = opendir(dir_string);
|
dir_p = opendir(dir_string);
|
||||||
if (dir_p == NULL)
|
if (dir_p == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while ((dir_t = readdir(dir_p)) != NULL)
|
while ((dir_t = readdir(dir_p)) != NULL)
|
||||||
{
|
{
|
||||||
if ((strcmp(dir_t->d_name, ".") == 0) || (strcmp(dir_t->d_name, "..") == 0))
|
if ((strcmp(dir_t->d_name, ".") == 0) || (strcmp(dir_t->d_name, "..") == 0))
|
||||||
continue;
|
continue;
|
||||||
|
sprintf(mod_dir_string, "%s%s/", dir_string, dir_t->d_name);
|
||||||
|
mod_dir_p = opendir(mod_dir_string);
|
||||||
|
if (mod_dir_p == NULL)
|
||||||
|
continue;
|
||||||
|
progs_found = false;
|
||||||
|
pak_found = false;
|
||||||
|
// find progs.dat and pak file(s)
|
||||||
|
while ((mod_dir_t = readdir(mod_dir_p)) != NULL)
|
||||||
|
{
|
||||||
|
if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0))
|
||||||
|
continue;
|
||||||
|
if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") != -1)
|
||||||
|
progs_found = true;
|
||||||
|
if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK"))
|
||||||
|
pak_found = true;
|
||||||
|
if (progs_found || pak_found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
closedir(mod_dir_p);
|
||||||
|
if (!progs_found && !pak_found)
|
||||||
|
continue;
|
||||||
|
Modlist_Add(dir_t->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(mod_dir_string, "%s%s/", dir_string, dir_t->d_name);
|
closedir(dir_p);
|
||||||
mod_dir_p = opendir(mod_dir_string);
|
|
||||||
|
|
||||||
if (mod_dir_p == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
progs_found = false;
|
|
||||||
pak_found = false;
|
|
||||||
|
|
||||||
// find progs.dat and pak file(s)
|
|
||||||
while ((mod_dir_t = readdir(mod_dir_p)) != NULL)
|
|
||||||
{
|
|
||||||
if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") != -1)
|
|
||||||
progs_found = true;
|
|
||||||
|
|
||||||
if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK"))
|
|
||||||
pak_found = true;
|
|
||||||
|
|
||||||
if (progs_found || pak_found)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
closedir(mod_dir_p);
|
|
||||||
|
|
||||||
if (!progs_found && !pak_found)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Modlist_Add(dir_t->d_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir_p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -824,7 +817,7 @@ void Host_Map_f (void)
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
Host_ShutdownServer(false);
|
Host_ShutdownServer(false);
|
||||||
|
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game; // remove console or menu
|
key_dest = key_game; // remove console or menu
|
||||||
SCR_BeginLoadingPlaque ();
|
SCR_BeginLoadingPlaque ();
|
||||||
|
|
||||||
|
|
170
Quake/in_sdl.c
170
Quake/in_sdl.c
|
@ -31,81 +31,82 @@ int total_dx, total_dy = 0;
|
||||||
|
|
||||||
int FilterMouseEvents (const SDL_Event *event)
|
int FilterMouseEvents (const SDL_Event *event)
|
||||||
{
|
{
|
||||||
switch (event->type) {
|
switch (event->type)
|
||||||
case SDL_MOUSEMOTION:
|
{
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEMOTION:
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
return 0;
|
case SDL_MOUSEBUTTONUP:
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Activate (void)
|
void IN_Activate (void)
|
||||||
{
|
{
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
||||||
{
|
{
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
||||||
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_ON) failed.\n");
|
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_ON) failed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE)
|
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE)
|
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE)
|
||||||
Con_Printf("WARNING: SDL_ShowCursor(SDL_DISABLE) failed.\n");
|
Con_Printf("WARNING: SDL_ShowCursor(SDL_DISABLE) failed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GetEventFilter() != NULL)
|
if (SDL_GetEventFilter() != NULL)
|
||||||
SDL_SetEventFilter(NULL);
|
SDL_SetEventFilter(NULL);
|
||||||
|
|
||||||
total_dx = 0;
|
total_dx = 0;
|
||||||
total_dy = 0;
|
total_dy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Deactivate (qboolean free_cursor)
|
void IN_Deactivate (qboolean free_cursor)
|
||||||
{
|
{
|
||||||
if (free_cursor)
|
if (free_cursor)
|
||||||
{
|
{
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
||||||
{
|
{
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
||||||
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_OFF) failed.\n");
|
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_OFF) failed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE)
|
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE)
|
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE)
|
||||||
Con_Printf("WARNING: SDL_ShowCursor(SDL_ENABLE) failed.\n");
|
Con_Printf("WARNING: SDL_ShowCursor(SDL_ENABLE) failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// discard all mouse events when input is deactivated
|
// discard all mouse events when input is deactivated
|
||||||
if (SDL_GetEventFilter() != FilterMouseEvents)
|
if (SDL_GetEventFilter() != FilterMouseEvents)
|
||||||
SDL_SetEventFilter(FilterMouseEvents);
|
SDL_SetEventFilter(FilterMouseEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Init (void)
|
void IN_Init (void)
|
||||||
{
|
{
|
||||||
BuildKeyMaps();
|
BuildKeyMaps();
|
||||||
|
|
||||||
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
|
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
|
||||||
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
|
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
|
||||||
|
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Shutdown (void)
|
void IN_Shutdown (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(true);
|
IN_Deactivate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Commands (void)
|
void IN_Commands (void)
|
||||||
{
|
{
|
||||||
// TODO: implement this for joystick support
|
// TODO: implement this for joystick support
|
||||||
}
|
}
|
||||||
|
|
||||||
extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping
|
extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping
|
||||||
|
@ -114,55 +115,56 @@ extern cvar_t cl_minpitch; //johnfitz -- variable pitch clamping
|
||||||
|
|
||||||
void IN_MouseMove(int dx, int dy)
|
void IN_MouseMove(int dx, int dy)
|
||||||
{
|
{
|
||||||
total_dx += dx;
|
total_dx += dx;
|
||||||
total_dy += dy;
|
total_dy += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_Move (usercmd_t *cmd)
|
void IN_Move (usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
int dmx, dmy;
|
int dmx, dmy;
|
||||||
|
|
||||||
/* TODO: fix this
|
/* TODO: fix this
|
||||||
if (m_filter.value)
|
if (m_filter.value)
|
||||||
{
|
{
|
||||||
dmx = (2*mx - dmx) * 0.5;
|
dmx = (2*mx - dmx) * 0.5;
|
||||||
dmy = (2*my - dmy) * 0.5;
|
dmy = (2*my - dmy) * 0.5;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dmx = total_dx * sensitivity.value;
|
dmx = total_dx * sensitivity.value;
|
||||||
dmy = total_dy * sensitivity.value;
|
dmy = total_dy * sensitivity.value;
|
||||||
|
|
||||||
total_dx = 0;
|
total_dx = 0;
|
||||||
total_dy = 0;
|
total_dy = 0;
|
||||||
|
|
||||||
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||||
cmd->sidemove += m_side.value * dmx;
|
cmd->sidemove += m_side.value * dmx;
|
||||||
else
|
else
|
||||||
cl.viewangles[YAW] -= m_yaw.value * dmx;
|
cl.viewangles[YAW] -= m_yaw.value * dmx;
|
||||||
|
|
||||||
if (in_mlook.state & 1)
|
if (in_mlook.state & 1)
|
||||||
V_StopPitchDrift ();
|
V_StopPitchDrift ();
|
||||||
|
|
||||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||||
{
|
{
|
||||||
cl.viewangles[PITCH] += m_pitch.value * dmy;
|
cl.viewangles[PITCH] += m_pitch.value * dmy;
|
||||||
//johnfitz -- variable pitch clamping
|
//johnfitz -- variable pitch clamping
|
||||||
if (cl.viewangles[PITCH] > cl_maxpitch.value)
|
if (cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||||
cl.viewangles[PITCH] = cl_maxpitch.value;
|
cl.viewangles[PITCH] = cl_maxpitch.value;
|
||||||
if (cl.viewangles[PITCH] < cl_minpitch.value)
|
if (cl.viewangles[PITCH] < cl_minpitch.value)
|
||||||
cl.viewangles[PITCH] = cl_minpitch.value;
|
cl.viewangles[PITCH] = cl_minpitch.value;
|
||||||
//johnfitz
|
//johnfitz
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||||
cmd->upmove -= m_forward.value * dmy;
|
cmd->upmove -= m_forward.value * dmy;
|
||||||
else
|
else
|
||||||
cmd->forwardmove -= m_forward.value * dmy;
|
cmd->forwardmove -= m_forward.value * dmy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_ClearStates (void)
|
void IN_ClearStates (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
220
Quake/main.c
220
Quake/main.c
|
@ -26,133 +26,133 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
quakeparms_t parms;
|
quakeparms_t parms;
|
||||||
int t;
|
int t;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
double time, oldtime, newtime;
|
double time, oldtime, newtime;
|
||||||
|
|
||||||
parms.basedir = ".";
|
parms.basedir = ".";
|
||||||
parms.cachedir = NULL;
|
parms.cachedir = NULL;
|
||||||
|
|
||||||
parms.argc = argc;
|
parms.argc = argc;
|
||||||
parms.argv = argv;
|
parms.argv = argv;
|
||||||
|
|
||||||
COM_InitArgv(parms.argc, parms.argv);
|
COM_InitArgv(parms.argc, parms.argv);
|
||||||
|
|
||||||
isDedicated = (COM_CheckParm("-dedicated") != 0);
|
isDedicated = (COM_CheckParm("-dedicated") != 0);
|
||||||
|
|
||||||
// default memory size
|
// default memory size
|
||||||
parms.memsize = DEFAULT_MEMORY;
|
parms.memsize = DEFAULT_MEMORY;
|
||||||
|
|
||||||
if (COM_CheckParm("-heapsize"))
|
if (COM_CheckParm("-heapsize"))
|
||||||
{
|
{
|
||||||
t = COM_CheckParm("-heapsize") + 1;
|
t = COM_CheckParm("-heapsize") + 1;
|
||||||
if (t < com_argc)
|
if (t < com_argc)
|
||||||
parms.memsize = Q_atoi(com_argv[t]) * 1024;
|
parms.memsize = Q_atoi(com_argv[t]) * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
parms.membase = malloc (parms.memsize);
|
// TODO: dedicated server setup
|
||||||
|
|
||||||
if (!parms.membase)
|
parms.membase = malloc (parms.memsize);
|
||||||
Sys_Error ("Not enough memory free; check disk space\n");
|
|
||||||
|
|
||||||
// TODO: dedicated server setup
|
if (!parms.membase)
|
||||||
|
Sys_Error ("Not enough memory free; check disk space\n");
|
||||||
|
|
||||||
// S_BlockSound(); do I need this?
|
Con_Printf("\nFitzQuake Version %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
|
||||||
|
Con_Printf("SDL port (c) Sleepwalkr, Baker, and OZ\n");
|
||||||
|
Con_Printf("This version hacked by Stevenaaus and OZ\n");
|
||||||
|
|
||||||
Con_Printf("\nFitzQuake Version %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
|
Con_Printf("Host_Init\n");
|
||||||
Con_Printf("SDL port (c) Sleepwalkr, Baker, and OZ\n");
|
Host_Init(&parms);
|
||||||
Con_Printf("This version hacked by Stevenaaus and OZ\n");
|
|
||||||
|
|
||||||
Con_Printf("Host_Init\n");
|
oldtime = Sys_FloatTime();
|
||||||
Host_Init(&parms);
|
while (!done)
|
||||||
|
{
|
||||||
|
// TODO: dedicated server loop
|
||||||
|
|
||||||
oldtime = Sys_FloatTime();
|
while (!done && SDL_PollEvent (&event))
|
||||||
while (!done)
|
{
|
||||||
{
|
switch (event.type)
|
||||||
// TODO: dedicated server loop
|
{
|
||||||
|
case SDL_ACTIVEEVENT:
|
||||||
while (!done && SDL_PollEvent (&event)) {
|
if (event.active.state & SDL_APPACTIVE & SDL_APPINPUTFOCUS)
|
||||||
switch (event.type) {
|
{
|
||||||
case SDL_ACTIVEEVENT:
|
if (event.active.gain)
|
||||||
if (event.active.state & SDL_APPACTIVE & SDL_APPINPUTFOCUS)
|
{
|
||||||
{
|
IN_Activate();
|
||||||
if (event.active.gain)
|
}
|
||||||
{
|
else
|
||||||
IN_Activate();
|
{
|
||||||
}
|
// TODO: handle sound
|
||||||
else
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
{
|
}
|
||||||
// TODO: handle sound
|
}
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
break;
|
||||||
}
|
case SDL_MOUSEMOTION:
|
||||||
}
|
IN_MouseMove(event.motion.xrel, event.motion.yrel);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
IN_MouseMove(event.motion.xrel, event.motion.yrel);
|
case SDL_MOUSEBUTTONUP:
|
||||||
break;
|
switch (event.button.button)
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
{
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_BUTTON_LEFT:
|
||||||
|
Key_Event(K_MOUSE1, event.button.type == SDL_MOUSEBUTTONDOWN);
|
||||||
switch (event.button.button) {
|
break;
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_RIGHT:
|
||||||
Key_Event(K_MOUSE1, event.button.type == SDL_MOUSEBUTTONDOWN);
|
Key_Event(K_MOUSE2, event.button.type == SDL_MOUSEBUTTONDOWN);
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_RIGHT:
|
case SDL_BUTTON_MIDDLE:
|
||||||
Key_Event(K_MOUSE2, event.button.type == SDL_MOUSEBUTTONDOWN);
|
Key_Event(K_MOUSE3, event.button.type == SDL_MOUSEBUTTONDOWN);
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_WHEELUP:
|
||||||
Key_Event(K_MOUSE3, event.button.type == SDL_MOUSEBUTTONDOWN);
|
Key_Event(K_MWHEELUP, event.button.type == SDL_MOUSEBUTTONDOWN);
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_WHEELUP:
|
case SDL_BUTTON_WHEELDOWN:
|
||||||
Key_Event(K_MWHEELUP, event.button.type == SDL_MOUSEBUTTONDOWN);
|
Key_Event(K_MWHEELDOWN, event.button.type == SDL_MOUSEBUTTONDOWN);
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_WHEELDOWN:
|
}
|
||||||
Key_Event(K_MWHEELDOWN, event.button.type == SDL_MOUSEBUTTONDOWN);
|
break;
|
||||||
break;
|
case SDL_KEYDOWN:
|
||||||
}
|
case SDL_KEYUP:
|
||||||
break;
|
// SHIFT + ESC and circomflex always opens the console no matter what
|
||||||
case SDL_KEYDOWN:
|
if ((event.key.keysym.sym == SDLK_ESCAPE && (event.key.keysym.mod & KMOD_SHIFT))
|
||||||
case SDL_KEYUP:
|
|| (event.key.keysym.sym == SDLK_CARET))
|
||||||
// SHIFT + ESC and circomflex always opens the console no matter what
|
{
|
||||||
if ((event.key.keysym.sym == SDLK_ESCAPE && (event.key.keysym.mod & KMOD_SHIFT))
|
if (event.key.type == SDL_KEYDOWN)
|
||||||
|| (event.key.keysym.sym == SDLK_CARET))
|
Con_ToggleConsole_f();
|
||||||
{
|
}
|
||||||
if (event.key.type == SDL_KEYDOWN)
|
else if ((event.key.keysym.sym == SDLK_RETURN) &&
|
||||||
Con_ToggleConsole_f();
|
(event.key.keysym.mod & KMOD_ALT))
|
||||||
}
|
{
|
||||||
else if ((event.key.keysym.sym == SDLK_RETURN) &&
|
if (event.key.type == SDL_KEYDOWN)
|
||||||
(event.key.keysym.mod & KMOD_ALT))
|
VID_Toggle();
|
||||||
{
|
}
|
||||||
if (event.key.type == SDL_KEYDOWN)
|
else
|
||||||
VID_Toggle();
|
{
|
||||||
}
|
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
|
case SDL_QUIT:
|
||||||
}
|
done = 1;
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
default:
|
||||||
done = 1;
|
break;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newtime = Sys_FloatTime();
|
newtime = Sys_FloatTime();
|
||||||
time = newtime - oldtime;
|
time = newtime - oldtime;
|
||||||
|
Host_Frame(time);
|
||||||
|
|
||||||
Host_Frame(time);
|
// throttle the game loop just a little bit - noone needs more than 1000fps, I think
|
||||||
|
if (newtime - oldtime < 1)
|
||||||
|
SDL_Delay(1);
|
||||||
|
|
||||||
// throttle the game loop just a little bit - noone needs more than 1000fps, I think
|
oldtime = newtime;
|
||||||
if (newtime - oldtime < 1)
|
}
|
||||||
SDL_Delay(1);
|
|
||||||
|
|
||||||
oldtime = newtime;
|
Sys_Quit();
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
Sys_Quit();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
Quake/menu.c
58
Quake/menu.c
|
@ -243,7 +243,7 @@ void M_ToggleMenu_f (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
return;
|
return;
|
||||||
|
@ -273,7 +273,7 @@ void M_Menu_Main_f (void)
|
||||||
m_save_demonum = cls.demonum;
|
m_save_demonum = cls.demonum;
|
||||||
cls.demonum = -1;
|
cls.demonum = -1;
|
||||||
}
|
}
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_main;
|
m_state = m_main;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -301,7 +301,7 @@ void M_Main_Key (int key)
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case K_ESCAPE:
|
case K_ESCAPE:
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
cls.demonum = m_save_demonum;
|
cls.demonum = m_save_demonum;
|
||||||
|
@ -358,7 +358,7 @@ int m_singleplayer_cursor;
|
||||||
|
|
||||||
void M_Menu_SinglePlayer_f (void)
|
void M_Menu_SinglePlayer_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_singleplayer;
|
m_state = m_singleplayer;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -410,7 +410,7 @@ void M_SinglePlayer_Key (int key)
|
||||||
if (sv.active)
|
if (sv.active)
|
||||||
if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n", 0.0f))
|
if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n", 0.0f))
|
||||||
break;
|
break;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
if (sv.active)
|
if (sv.active)
|
||||||
Cbuf_AddText ("disconnect\n");
|
Cbuf_AddText ("disconnect\n");
|
||||||
|
@ -473,7 +473,7 @@ void M_Menu_Load_f (void)
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
m_state = m_load;
|
m_state = m_load;
|
||||||
|
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
M_ScanSaves ();
|
M_ScanSaves ();
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ void M_Menu_Save_f (void)
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
m_state = m_save;
|
m_state = m_save;
|
||||||
|
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
M_ScanSaves ();
|
M_ScanSaves ();
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ void M_Load_Key (int k)
|
||||||
if (!loadable[load_cursor])
|
if (!loadable[load_cursor])
|
||||||
return;
|
return;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
|
|
||||||
// Host_Loadgame_f can't bring up the loading plaque because too much
|
// Host_Loadgame_f can't bring up the loading plaque because too much
|
||||||
|
@ -581,7 +581,7 @@ void M_Save_Key (int k)
|
||||||
|
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
Cbuf_AddText (va("save s%i\n", load_cursor));
|
Cbuf_AddText (va("save s%i\n", load_cursor));
|
||||||
return;
|
return;
|
||||||
|
@ -613,7 +613,7 @@ int m_multiplayer_cursor;
|
||||||
|
|
||||||
void M_Menu_MultiPlayer_f (void)
|
void M_Menu_MultiPlayer_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_multiplayer;
|
m_state = m_multiplayer;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -698,7 +698,7 @@ int setup_bottom;
|
||||||
|
|
||||||
void M_Menu_Setup_f (void)
|
void M_Menu_Setup_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_setup;
|
m_state = m_setup;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -888,7 +888,7 @@ char *net_helpMessage [] =
|
||||||
|
|
||||||
void M_Menu_Net_f (void)
|
void M_Menu_Net_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_net;
|
m_state = m_net;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -1053,7 +1053,7 @@ int options_cursor;
|
||||||
|
|
||||||
void M_Menu_Options_f (void)
|
void M_Menu_Options_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_options;
|
m_state = m_options;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -1318,7 +1318,7 @@ int bind_grab;
|
||||||
|
|
||||||
void M_Menu_Keys_f (void)
|
void M_Menu_Keys_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_keys;
|
m_state = m_keys;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -1436,7 +1436,7 @@ void M_Keys_Key (int k)
|
||||||
}
|
}
|
||||||
|
|
||||||
bind_grab = false;
|
bind_grab = false;
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED); // deactivate because we're returning to the menu
|
IN_Deactivate(vid.type == MODE_WINDOWED); // deactivate because we're returning to the menu
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ void M_Keys_Key (int k)
|
||||||
if (keys[1] != -1)
|
if (keys[1] != -1)
|
||||||
M_UnbindCommand (bindnames[keys_cursor][0]);
|
M_UnbindCommand (bindnames[keys_cursor][0]);
|
||||||
bind_grab = true;
|
bind_grab = true;
|
||||||
IN_Activate(); // activate to allow mouse key binding
|
IN_Activate(); // activate to allow mouse key binding
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case K_BACKSPACE: // delete bindings
|
case K_BACKSPACE: // delete bindings
|
||||||
|
@ -1508,7 +1508,7 @@ int help_page;
|
||||||
|
|
||||||
void M_Menu_Help_f (void)
|
void M_Menu_Help_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_help;
|
m_state = m_help;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -1560,7 +1560,7 @@ void M_Menu_Quit_f (void)
|
||||||
if (m_state == m_quit)
|
if (m_state == m_quit)
|
||||||
return;
|
return;
|
||||||
wasInMenus = (key_dest == key_menu);
|
wasInMenus = (key_dest == key_menu);
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_quit_prevstate = m_state;
|
m_quit_prevstate = m_state;
|
||||||
m_state = m_quit;
|
m_state = m_quit;
|
||||||
|
@ -1583,7 +1583,7 @@ void M_Quit_Key (int key)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1591,7 @@ void M_Quit_Key (int key)
|
||||||
|
|
||||||
case 'Y':
|
case 'Y':
|
||||||
case 'y':
|
case 'y':
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_console;
|
key_dest = key_console;
|
||||||
Host_Quit_f ();
|
Host_Quit_f ();
|
||||||
break;
|
break;
|
||||||
|
@ -1658,7 +1658,7 @@ void M_Menu_SerialConfig_f (void)
|
||||||
int baudrate;
|
int baudrate;
|
||||||
qboolean useModem;
|
qboolean useModem;
|
||||||
|
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_serialconfig;
|
m_state = m_serialconfig;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -1880,7 +1880,7 @@ forward:
|
||||||
|
|
||||||
m_return_state = m_state;
|
m_return_state = m_state;
|
||||||
m_return_onerror = true;
|
m_return_onerror = true;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
|
|
||||||
|
@ -1943,7 +1943,7 @@ char modemConfig_hangup [16];
|
||||||
|
|
||||||
void M_Menu_ModemConfig_f (void)
|
void M_Menu_ModemConfig_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_modemconfig;
|
m_state = m_modemconfig;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -2115,7 +2115,7 @@ char lanConfig_joinname[22];
|
||||||
|
|
||||||
void M_Menu_LanConfig_f (void)
|
void M_Menu_LanConfig_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_lanconfig;
|
m_state = m_lanconfig;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -2242,7 +2242,7 @@ void M_LanConfig_Key (int key)
|
||||||
{
|
{
|
||||||
m_return_state = m_state;
|
m_return_state = m_state;
|
||||||
m_return_onerror = true;
|
m_return_onerror = true;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
|
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
|
||||||
|
@ -2463,7 +2463,7 @@ double m_serverInfoMessageTime;
|
||||||
|
|
||||||
void M_Menu_GameOptions_f (void)
|
void M_Menu_GameOptions_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_gameoptions;
|
m_state = m_gameoptions;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -2774,7 +2774,7 @@ double searchCompleteTime;
|
||||||
|
|
||||||
void M_Menu_Search_f (void)
|
void M_Menu_Search_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_search;
|
m_state = m_search;
|
||||||
m_entersound = false;
|
m_entersound = false;
|
||||||
|
@ -2835,7 +2835,7 @@ qboolean slist_sorted;
|
||||||
|
|
||||||
void M_Menu_ServerList_f (void)
|
void M_Menu_ServerList_f (void)
|
||||||
{
|
{
|
||||||
IN_Deactivate(vid.type == MODE_WINDOWED);
|
IN_Deactivate(vid.type == MODE_WINDOWED);
|
||||||
key_dest = key_menu;
|
key_dest = key_menu;
|
||||||
m_state = m_slist;
|
m_state = m_slist;
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
|
@ -2920,7 +2920,7 @@ void M_ServerList_Key (int k)
|
||||||
m_return_state = m_state;
|
m_return_state = m_state;
|
||||||
m_return_onerror = true;
|
m_return_onerror = true;
|
||||||
slist_sorted = false;
|
slist_sorted = false;
|
||||||
IN_Activate();
|
IN_Activate();
|
||||||
key_dest = key_game;
|
key_dest = key_game;
|
||||||
m_state = m_none;
|
m_state = m_none;
|
||||||
Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
|
Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
|
||||||
|
|
|
@ -84,7 +84,7 @@ int net_numdrivers = 2;
|
||||||
|
|
||||||
net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
|
net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"UDP",
|
"UDP",
|
||||||
false,
|
false,
|
||||||
0,
|
0,
|
||||||
|
@ -110,3 +110,4 @@ net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
|
||||||
};
|
};
|
||||||
|
|
||||||
int net_numlandrivers = 1;
|
int net_numlandrivers = 1;
|
||||||
|
|
||||||
|
|
|
@ -28,89 +28,87 @@ Foundat(&addr->sa_dataion, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-
|
||||||
|
|
||||||
#include "net_sdlnet.h"
|
#include "net_sdlnet.h"
|
||||||
|
|
||||||
#define MAX_SOCKETS 32
|
#define MAX_SOCKETS 32
|
||||||
#define MAXHOSTNAMELEN 255
|
#define MAXHOSTNAMELEN 255
|
||||||
#define AF_INET 2 /* internet */
|
#define AF_INET 2 /* internet */
|
||||||
|
|
||||||
static int net_controlsocket;
|
static int net_controlsocket;
|
||||||
static int net_broadcastsocket = 0;
|
static int net_broadcastsocket = 0;
|
||||||
static int net_acceptsocket = -1;
|
static int net_acceptsocket = -1;
|
||||||
static struct qsockaddr broadcastaddr;
|
static struct qsockaddr broadcastaddr;
|
||||||
|
|
||||||
SDLNet_SocketSet acceptsocket_set;
|
|
||||||
|
|
||||||
IPaddress myaddr;
|
|
||||||
|
|
||||||
|
SDLNet_SocketSet acceptsocket_set;
|
||||||
|
IPaddress myaddr;
|
||||||
// contains a map of socket numbers to SDL_net UDP sockets
|
// contains a map of socket numbers to SDL_net UDP sockets
|
||||||
UDPsocket net_sockets[MAX_SOCKETS];
|
UDPsocket net_sockets[MAX_SOCKETS];
|
||||||
|
|
||||||
int socket_id(UDPsocket socket)
|
int socket_id (UDPsocket socket)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int index = -1;
|
int idx = -1;
|
||||||
|
|
||||||
for (i = 0; i < MAX_SOCKETS; i++)
|
for (i = 0; i < MAX_SOCKETS; i++)
|
||||||
{
|
{
|
||||||
if (net_sockets[i] == socket)
|
if (net_sockets[i] == socket)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
if (net_sockets[i] == NULL && index == -1)
|
if (net_sockets[i] == NULL && idx == -1)
|
||||||
{
|
{
|
||||||
index = i;
|
idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == -1)
|
if (idx == -1)
|
||||||
{
|
{
|
||||||
// todo error
|
// todo error
|
||||||
}
|
}
|
||||||
|
|
||||||
net_sockets[index] = socket;
|
net_sockets[idx] = socket;
|
||||||
|
|
||||||
return index;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_AddrToString (int ip, int port)
|
char *_AddrToString (int ip, int port)
|
||||||
{
|
{
|
||||||
static char buffer[22];
|
static char buffer[22];
|
||||||
|
|
||||||
sprintf(buffer, "%d.%d.%d.%d:%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff, port);
|
sprintf(buffer, "%d.%d.%d.%d:%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff, port);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_IPAddrToString (IPaddress *address)
|
char *_IPAddrToString (IPaddress *address)
|
||||||
{
|
{
|
||||||
int ip;
|
int ip;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
ip = SDLNet_Read32(&address->host);
|
ip = SDLNet_Read32(&address->host);
|
||||||
port = SDLNet_Read16(&address->port);
|
port = SDLNet_Read16(&address->port);
|
||||||
|
|
||||||
return _AddrToString(ip, port);
|
return _AddrToString(ip, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_Init (void)
|
int SDLN_Init (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char buff[MAXHOSTNAMELEN];
|
char buff[MAXHOSTNAMELEN];
|
||||||
char *p;
|
char *p;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
// init SDL
|
// init SDL
|
||||||
if (SDLNet_Init() == -1)
|
if (SDLNet_Init() == -1)
|
||||||
{
|
{
|
||||||
Con_SafePrintf ("SDL_net initialization failed.\n");
|
Con_SafePrintf ("SDL_net initialization failed.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate a socket set for the accept socket
|
// allocate a socket set for the accept socket
|
||||||
acceptsocket_set = SDLNet_AllocSocketSet(1);
|
acceptsocket_set = SDLNet_AllocSocketSet(1);
|
||||||
if (acceptsocket_set == NULL)
|
if (acceptsocket_set == NULL)
|
||||||
{
|
{
|
||||||
Con_DPrintf ("SDL_net initialization failed: Could not create socket set.\n");
|
Con_DPrintf ("SDL_net initialization failed: Could not create socket set.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine my name
|
// determine my name
|
||||||
if (gethostname(buff, MAXHOSTNAMELEN) == -1)
|
if (gethostname(buff, MAXHOSTNAMELEN) == -1)
|
||||||
|
@ -138,13 +136,13 @@ int SDLN_Init (void)
|
||||||
Cvar_Set ("hostname", buff);
|
Cvar_Set ("hostname", buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set my IP address
|
// set my IP address
|
||||||
i = COM_CheckParm ("-ip");
|
i = COM_CheckParm ("-ip");
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
if (i < com_argc-1)
|
if (i < com_argc-1)
|
||||||
{
|
{
|
||||||
SDLNet_ResolveHost(&myaddr, com_argv[i+1], 0);
|
SDLNet_ResolveHost(&myaddr, com_argv[i+1], 0);
|
||||||
if (myaddr.host == INADDR_NONE)
|
if (myaddr.host == INADDR_NONE)
|
||||||
Sys_Error ("%s is not a valid IP address", com_argv[i+1]);
|
Sys_Error ("%s is not a valid IP address", com_argv[i+1]);
|
||||||
strcpy(my_tcpip_address, com_argv[i+1]);
|
strcpy(my_tcpip_address, com_argv[i+1]);
|
||||||
|
@ -156,21 +154,21 @@ int SDLN_Init (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDLNet_ResolveHost(&myaddr, NULL, 0);
|
SDLNet_ResolveHost(&myaddr, NULL, 0);
|
||||||
strcpy(my_tcpip_address, "INADDR_ANY");
|
strcpy(my_tcpip_address, "INADDR_ANY");
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the control socket
|
// open the control socket
|
||||||
if ((net_controlsocket = SDLN_OpenSocket (0)) == -1)
|
if ((net_controlsocket = SDLN_OpenSocket (0)) == -1)
|
||||||
{
|
{
|
||||||
Con_Printf("SDLN_Init: Unable to open control socket\n");
|
Con_Printf("SDLN_Init: Unable to open control socket\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcastaddr.sa_family = AF_INET;
|
broadcastaddr.sa_family = AF_INET;
|
||||||
ipaddress = (IPaddress *)&(broadcastaddr.sa_data);
|
ipaddress = (IPaddress *)&(broadcastaddr.sa_data);
|
||||||
SDLNet_Write32(INADDR_BROADCAST, &ipaddress->host);
|
SDLNet_Write32(INADDR_BROADCAST, &ipaddress->host);
|
||||||
SDLNet_Write16(net_hostport, &ipaddress->port);
|
SDLNet_Write16(net_hostport, &ipaddress->port);
|
||||||
|
|
||||||
Con_Printf("SDL_net TCP/IP initialized\n");
|
Con_Printf("SDL_net TCP/IP initialized\n");
|
||||||
tcpipAvailable = true;
|
tcpipAvailable = true;
|
||||||
|
@ -189,7 +187,7 @@ void SDLN_GetLocalAddress()
|
||||||
if (myaddr.host != INADDR_ANY)
|
if (myaddr.host != INADDR_ANY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDLNet_ResolveHost(&myaddr, NULL, 0);
|
SDLNet_ResolveHost(&myaddr, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLN_Listen (qboolean state)
|
void SDLN_Listen (qboolean state)
|
||||||
|
@ -204,39 +202,38 @@ void SDLN_Listen (qboolean state)
|
||||||
if ((net_acceptsocket = SDLN_OpenSocket (net_hostport)) == -1)
|
if ((net_acceptsocket = SDLN_OpenSocket (net_hostport)) == -1)
|
||||||
Sys_Error ("SDLN_Listen: Unable to open accept socket\n");
|
Sys_Error ("SDLN_Listen: Unable to open accept socket\n");
|
||||||
|
|
||||||
SDLNet_UDP_AddSocket(acceptsocket_set, net_sockets[net_acceptsocket]);
|
SDLNet_UDP_AddSocket(acceptsocket_set, net_sockets[net_acceptsocket]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// disable listening
|
// disable listening
|
||||||
if (net_acceptsocket == -1)
|
if (net_acceptsocket == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDLNet_UDP_DelSocket(acceptsocket_set, net_sockets[net_acceptsocket]);
|
SDLNet_UDP_DelSocket(acceptsocket_set, net_sockets[net_acceptsocket]);
|
||||||
SDLN_CloseSocket(net_acceptsocket);
|
SDLN_CloseSocket(net_acceptsocket);
|
||||||
|
|
||||||
net_acceptsocket = -1;
|
net_acceptsocket = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_OpenSocket (int port)
|
int SDLN_OpenSocket (int port)
|
||||||
{
|
{
|
||||||
|
UDPsocket newsocket;
|
||||||
|
static IPaddress address;
|
||||||
|
|
||||||
UDPsocket newsocket;
|
if ((newsocket = SDLNet_UDP_Open(port)) == NULL)
|
||||||
static IPaddress address;
|
return -1;
|
||||||
|
|
||||||
if ((newsocket = SDLNet_UDP_Open(port)) == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// todo check what this does
|
// todo check what this does
|
||||||
// if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
// if (pioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||||
// goto ErrorReturn;
|
// goto ErrorReturn;
|
||||||
|
|
||||||
address.host = myaddr.host;
|
address.host = myaddr.host;
|
||||||
address.port = SDLNet_Read16(&port);
|
address.port = SDLNet_Read16(&port);
|
||||||
|
|
||||||
if (SDLNet_UDP_Bind(newsocket, 0, &address) != -1)
|
if (SDLNet_UDP_Bind(newsocket, 0, &address) != -1)
|
||||||
return socket_id(newsocket);
|
return socket_id(newsocket);
|
||||||
|
|
||||||
Sys_Error ("Unable to bind to %s", _IPAddrToString(&address));
|
Sys_Error ("Unable to bind to %s", _IPAddrToString(&address));
|
||||||
|
|
||||||
|
@ -244,201 +241,200 @@ int SDLN_OpenSocket (int port)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_CloseSocket (int socketid)
|
int SDLN_CloseSocket (int socketid)
|
||||||
{
|
{
|
||||||
UDPsocket socket;
|
UDPsocket socket;
|
||||||
|
|
||||||
if (socketid == net_broadcastsocket)
|
if (socketid == net_broadcastsocket)
|
||||||
net_broadcastsocket = -1;
|
net_broadcastsocket = -1;
|
||||||
|
|
||||||
socket = net_sockets[socketid];
|
socket = net_sockets[socketid];
|
||||||
|
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
SDLNet_UDP_Close(socket);
|
SDLNet_UDP_Close(socket);
|
||||||
|
|
||||||
net_sockets[socketid] = NULL;
|
net_sockets[socketid] = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_Connect (int socket, struct qsockaddr *addr)
|
int SDLN_Connect (int socket, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_CheckNewConnections (void)
|
int SDLN_CheckNewConnections (void)
|
||||||
{
|
{
|
||||||
if (net_acceptsocket == -1)
|
if (net_acceptsocket == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (SDLNet_CheckSockets(acceptsocket_set, 0) > 0)
|
if (SDLNet_CheckSockets(acceptsocket_set, 0) > 0)
|
||||||
return net_acceptsocket;
|
return net_acceptsocket;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPpacket *init_packet(UDPpacket *packet, int len)
|
UDPpacket *init_packet(UDPpacket *packet, int len)
|
||||||
{
|
{
|
||||||
if (packet == NULL)
|
if (packet == NULL)
|
||||||
return SDLNet_AllocPacket(len);
|
return SDLNet_AllocPacket(len);
|
||||||
|
|
||||||
if (packet->maxlen < len)
|
if (packet->maxlen < len)
|
||||||
SDLNet_ResizePacket(packet, len);
|
SDLNet_ResizePacket(packet, len);
|
||||||
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
int SDLN_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
int numrecv;
|
int numrecv;
|
||||||
static UDPpacket *packet;
|
static UDPpacket *packet;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
UDPsocket socket = net_sockets[socketid];
|
UDPsocket socket = net_sockets[socketid];
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
packet = init_packet(packet, len);
|
packet = init_packet(packet, len);
|
||||||
|
|
||||||
numrecv = SDLNet_UDP_Recv(socket, packet);
|
numrecv = SDLNet_UDP_Recv(socket, packet);
|
||||||
if (numrecv == 1)
|
if (numrecv == 1)
|
||||||
{
|
{
|
||||||
memcpy(buf, packet->data, packet->len);
|
memcpy(buf, packet->data, packet->len);
|
||||||
|
|
||||||
addr->sa_family = AF_INET;
|
addr->sa_family = AF_INET;
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
ipaddress->host = packet->address.host;
|
ipaddress->host = packet->address.host;
|
||||||
ipaddress->port = packet->address.port;
|
ipaddress->port = packet->address.port;
|
||||||
|
|
||||||
return packet->len;
|
return packet->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return numrecv;
|
|
||||||
|
|
||||||
|
return numrecv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
int SDLN_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
int numsent;
|
int numsent;
|
||||||
static UDPpacket *packet;
|
static UDPpacket *packet;
|
||||||
UDPsocket socket;
|
UDPsocket socket;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
socket = net_sockets[socketid];
|
socket = net_sockets[socketid];
|
||||||
|
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
packet = init_packet(packet, len);
|
packet = init_packet(packet, len);
|
||||||
memcpy(packet->data, buf, len);
|
memcpy(packet->data, buf, len);
|
||||||
packet->len = len;
|
packet->len = len;
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
packet->address.host = ipaddress->host;
|
packet->address.host = ipaddress->host;
|
||||||
packet->address.port = ipaddress->port;
|
packet->address.port = ipaddress->port;
|
||||||
|
|
||||||
numsent = SDLNet_UDP_Send(socket, -1, packet);
|
numsent = SDLNet_UDP_Send(socket, -1, packet);
|
||||||
if (numsent == 0)
|
if (numsent == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_Broadcast (int socketid, byte *buf, int len)
|
int SDLN_Broadcast (int socketid, byte *buf, int len)
|
||||||
{
|
{
|
||||||
|
if (socketid != net_broadcastsocket)
|
||||||
|
{
|
||||||
|
if (net_broadcastsocket != 0)
|
||||||
|
Sys_Error("Attempted to use multiple broadcast sockets\n");
|
||||||
|
|
||||||
if (socketid != net_broadcastsocket)
|
// todo make socket broadcast capable
|
||||||
{
|
Sys_Error("Unable to make socket broadcast capable\n");
|
||||||
if (net_broadcastsocket != 0)
|
}
|
||||||
Sys_Error("Attempted to use multiple broadcast sockets\n");
|
|
||||||
|
|
||||||
// todo make socket broadcast capable
|
return SDLN_Write(socketid, buf, len, &broadcastaddr);
|
||||||
Sys_Error("Unable to make socket broadcast capable\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SDLN_Write(socketid, buf, len, &broadcastaddr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *SDLN_AddrToString (struct qsockaddr *addr)
|
char *SDLN_AddrToString (struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
int ip;
|
int ip;
|
||||||
int port;
|
int port;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
|
|
||||||
ip = SDLNet_Read32(&ipaddress->host);
|
ip = SDLNet_Read32(&ipaddress->host);
|
||||||
port = SDLNet_Read16(&ipaddress->port);
|
port = SDLNet_Read16(&ipaddress->port);
|
||||||
|
|
||||||
return _AddrToString(ip, port);
|
return _AddrToString(ip, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_StringToAddr (char *string, struct qsockaddr *addr)
|
int SDLN_StringToAddr (char *string, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
int ha1, ha2, ha3, ha4, hp;
|
int ha1, ha2, ha3, ha4, hp;
|
||||||
int hostaddr;
|
int hostaddr;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
|
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
|
||||||
hostaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
|
hostaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
|
||||||
|
|
||||||
addr->sa_family = AF_INET;
|
addr->sa_family = AF_INET;
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
|
|
||||||
SDLNet_Write32(hostaddr, &ipaddress->host);
|
SDLNet_Write32(hostaddr, &ipaddress->host);
|
||||||
SDLNet_Write16(hp, &ipaddress->port);
|
SDLNet_Write16(hp, &ipaddress->port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_GetSocketAddr (int socketid, struct qsockaddr *addr)
|
int SDLN_GetSocketAddr (int socketid, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
static UDPsocket socket;
|
static UDPsocket socket;
|
||||||
IPaddress *peeraddress;
|
IPaddress *peeraddress;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
Q_memset(addr, 0, sizeof(struct qsockaddr));
|
Q_memset(addr, 0, sizeof(struct qsockaddr));
|
||||||
|
|
||||||
socket = net_sockets[socketid];
|
socket = net_sockets[socketid];
|
||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
peeraddress = SDLNet_UDP_GetPeerAddress(socket, -1);
|
peeraddress = SDLNet_UDP_GetPeerAddress(socket, -1);
|
||||||
if (peeraddress == NULL)
|
if (peeraddress == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
addr->sa_family = AF_INET;
|
addr->sa_family = AF_INET;
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
if (peeraddress->host == 0 || peeraddress->host == inet_addr("127.0.0.1"))
|
if (peeraddress->host == 0 || peeraddress->host == inet_addr("127.0.0.1"))
|
||||||
{
|
{
|
||||||
ipaddress->host = myaddr.host;
|
ipaddress->host = myaddr.host;
|
||||||
ipaddress->port = myaddr.port;
|
ipaddress->port = myaddr.port;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ipaddress->host = peeraddress->host;
|
ipaddress->host = peeraddress->host;
|
||||||
ipaddress->port = peeraddress->port;
|
ipaddress->port = peeraddress->port;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_GetNameFromAddr (struct qsockaddr *addr, char *name)
|
int SDLN_GetNameFromAddr (struct qsockaddr *addr, char *name)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
|
|
||||||
buf = (char *)SDLNet_ResolveIP(ipaddress);
|
buf = (char *)SDLNet_ResolveIP(ipaddress);
|
||||||
if (buf != NULL) {
|
if (buf != NULL)
|
||||||
Q_strncpy(name, buf, NET_NAMELEN - 1);
|
{
|
||||||
return 0;
|
Q_strncpy(name, buf, NET_NAMELEN - 1);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Q_strcpy(name, SDLN_AddrToString(addr));
|
Q_strcpy(name, SDLN_AddrToString(addr));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -457,7 +453,7 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
||||||
int addr;
|
int addr;
|
||||||
int num;
|
int num;
|
||||||
int mask;
|
int mask;
|
||||||
int tmp;
|
int tmp;
|
||||||
int run;
|
int run;
|
||||||
int port;
|
int port;
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
@ -477,9 +473,9 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
||||||
run = 0;
|
run = 0;
|
||||||
while (!( *b < '0' || *b > '9'))
|
while (!( *b < '0' || *b > '9'))
|
||||||
{
|
{
|
||||||
num = num*10 + *b++ - '0';
|
num = num*10 + *b++ - '0';
|
||||||
if (++run > 3)
|
if (++run > 3)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
|
if ((*b < '0' || *b > '9') && *b != '.' && *b != ':' && *b != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -494,43 +490,43 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
|
||||||
else
|
else
|
||||||
port = net_hostport;
|
port = net_hostport;
|
||||||
|
|
||||||
tmp = SDLNet_Read32(&myaddr.host);
|
tmp = SDLNet_Read32(&myaddr.host);
|
||||||
tmp = (tmp & mask) | addr;
|
tmp = (tmp & mask) | addr;
|
||||||
|
|
||||||
hostaddr->sa_family = AF_INET;
|
hostaddr->sa_family = AF_INET;
|
||||||
ipaddress = (IPaddress *)&(hostaddr->sa_data);
|
ipaddress = (IPaddress *)&(hostaddr->sa_data);
|
||||||
|
|
||||||
SDLNet_Write32(tmp, &ipaddress->host);
|
SDLNet_Write32(tmp, &ipaddress->host);
|
||||||
SDLNet_Write16(port, &ipaddress->port);
|
SDLNet_Write16(port, &ipaddress->port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_GetAddrFromName (char *name, struct qsockaddr *addr)
|
int SDLN_GetAddrFromName (char *name, struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
if (name[0] >= '0' && name[0] <= '9')
|
if (name[0] >= '0' && name[0] <= '9')
|
||||||
return PartialIPAddress (name, addr);
|
return PartialIPAddress (name, addr);
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
if (SDLNet_ResolveHost((IPaddress *)(&addr->sa_data), name, 26000) == -1)
|
if (SDLNet_ResolveHost((IPaddress *)(&addr->sa_data), name, 26000) == -1)
|
||||||
return -1;
|
|
||||||
|
|
||||||
addr->sa_family = AF_INET;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SDLN_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
|
|
||||||
{
|
|
||||||
IPaddress *ipaddr1;
|
|
||||||
IPaddress *ipaddr2;
|
|
||||||
|
|
||||||
if (addr1->sa_family != addr2->sa_family)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ipaddr1 = (IPaddress *)&(addr1->sa_data);
|
addr->sa_family = AF_INET;
|
||||||
ipaddr2 = (IPaddress *)&(addr2->sa_data);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDLN_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
|
||||||
|
{
|
||||||
|
IPaddress *ipaddr1;
|
||||||
|
IPaddress *ipaddr2;
|
||||||
|
|
||||||
|
if (addr1->sa_family != addr2->sa_family)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ipaddr1 = (IPaddress *)&(addr1->sa_data);
|
||||||
|
ipaddr2 = (IPaddress *)&(addr2->sa_data);
|
||||||
|
|
||||||
if (ipaddr1->host != ipaddr2->host)
|
if (ipaddr1->host != ipaddr2->host)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -541,21 +537,21 @@ int SDLN_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_GetSocketPort (struct qsockaddr *addr)
|
int SDLN_GetSocketPort (struct qsockaddr *addr)
|
||||||
{
|
{
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
return SDLNet_Read16(&ipaddress->port);
|
return SDLNet_Read16(&ipaddress->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDLN_SetSocketPort (struct qsockaddr *addr, int port)
|
int SDLN_SetSocketPort (struct qsockaddr *addr, int port)
|
||||||
{
|
{
|
||||||
IPaddress *ipaddress;
|
IPaddress *ipaddress;
|
||||||
|
|
||||||
ipaddress = (IPaddress *)&(addr->sa_data);
|
ipaddress = (IPaddress *)&(addr->sa_data);
|
||||||
SDLNet_Write16(port, &ipaddress->port);
|
SDLNet_Write16(port, &ipaddress->port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
170
Quake/sys_sdl.c
170
Quake/sys_sdl.c
|
@ -23,36 +23,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
|
|
||||||
#define CONSOLE_ERROR_TIMEOUT 60.0 // # of seconds to wait on Sys_Error running
|
#define CONSOLE_ERROR_TIMEOUT 60.0 /* # of seconds to wait on Sys_Error running */
|
||||||
qboolean isDedicated;
|
qboolean isDedicated;
|
||||||
static qboolean sc_return_on_enter = false;
|
static qboolean sc_return_on_enter = false;
|
||||||
|
|
||||||
#define MAX_HANDLES 32 //johnfitz -- was 10
|
#define MAX_HANDLES 32 /* johnfitz -- was 10 */
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
FILE *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=1 ; i<MAX_HANDLES ; i++)
|
for (i=1 ; i<MAX_HANDLES ; i++)
|
||||||
if (!sys_handles[i])
|
if (!sys_handles[i])
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
Sys_Error ("out of handles");
|
Sys_Error ("out of handles");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int filelength (FILE *f)
|
int filelength (FILE *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
pos = ftell (f);
|
pos = ftell (f);
|
||||||
fseek (f, 0, SEEK_END);
|
fseek (f, 0, SEEK_END);
|
||||||
end = ftell (f);
|
end = ftell (f);
|
||||||
fseek (f, pos, SEEK_SET);
|
fseek (f, pos, SEEK_SET);
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
@ -89,7 +89,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s: %s", path, strerror(errno));
|
Sys_Error ("Error opening %s: %s", path, strerror(errno));
|
||||||
|
|
||||||
sys_handles[i] = f;
|
sys_handles[i] = f;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,19 +114,19 @@ int Sys_FileWrite (int handle, void *data, int count)
|
||||||
return fwrite (data, 1, count, sys_handles[handle]);
|
return fwrite (data, 1, count, sys_handles[handle]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_mkdir (char *path)
|
void Sys_mkdir (char *path)
|
||||||
|
@ -144,7 +144,7 @@ void Sys_DebugLog(char *file, char *fmt, ...)
|
||||||
|
|
||||||
void Sys_Error (char *error, ...)
|
void Sys_Error (char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024], text2[1024];
|
char text[1024], text2[1024];
|
||||||
char *text3 = "Press Enter to exit\n";
|
char *text3 = "Press Enter to exit\n";
|
||||||
char *text4 = "***********************************\n";
|
char *text4 = "***********************************\n";
|
||||||
|
@ -157,48 +157,50 @@ void Sys_Error (char *error, ...)
|
||||||
if (!in_sys_error3)
|
if (!in_sys_error3)
|
||||||
{
|
{
|
||||||
in_sys_error3 = 1;
|
in_sys_error3 = 1;
|
||||||
// VID_ForceUnlockedAndReturnState (); TODO: see what this does
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: use OS messagebox here if possible (windows, os x and linux shouldn't be a problem)
|
//TODO: use OS messagebox here if possible
|
||||||
//implement this in pl_*, which contains all the platform dependent code
|
// (windows, os x and linux shouldn't be a problem)
|
||||||
|
//implement this in pl_*, which contains all the
|
||||||
|
// platform dependent code
|
||||||
|
|
||||||
va_start (argptr, error);
|
va_start (argptr, error);
|
||||||
vsprintf (text, error, argptr);
|
vsprintf (text, error, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
if (isDedicated) {
|
if (isDedicated)
|
||||||
sprintf (text2, "ERROR: %s\n", text);
|
{
|
||||||
printf ("%s", text5);
|
sprintf (text2, "ERROR: %s\n", text);
|
||||||
printf ("%s", text4);
|
printf ("%s", text5);
|
||||||
printf ("%s", text2);
|
printf ("%s", text4);
|
||||||
printf ("%s", text3);
|
printf ("%s", text2);
|
||||||
printf ("%s", text4);
|
printf ("%s", text3);
|
||||||
|
printf ("%s", text4);
|
||||||
|
|
||||||
starttime = Sys_FloatTime ();
|
starttime = Sys_FloatTime ();
|
||||||
sc_return_on_enter = true; // so Enter will get us out of here
|
sc_return_on_enter = true; // so Enter will get us out of here
|
||||||
|
|
||||||
while (!Sys_ConsoleInput () &&
|
while (!Sys_ConsoleInput () &&
|
||||||
((Sys_FloatTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
|
((Sys_FloatTime () - starttime) < CONSOLE_ERROR_TIMEOUT))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_sys_error1)
|
if (!in_sys_error1)
|
||||||
{
|
{
|
||||||
in_sys_error1 = 1;
|
in_sys_error1 = 1;
|
||||||
Host_Shutdown ();
|
Host_Shutdown ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PL_ErrorDialog(text);
|
PL_ErrorDialog(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// shut down QHOST hooks if necessary
|
// shut down QHOST hooks if necessary
|
||||||
if (!in_sys_error2)
|
if (!in_sys_error2)
|
||||||
{
|
{
|
||||||
in_sys_error2 = 1;
|
in_sys_error2 = 1;
|
||||||
//DeinitConProc (); TODO: check what this does
|
// DeinitConProc ();
|
||||||
}
|
}
|
||||||
|
|
||||||
exit (1);
|
exit (1);
|
||||||
|
@ -206,20 +208,19 @@ void Sys_Error (char *error, ...)
|
||||||
|
|
||||||
void Sys_Printf (char *fmt, ...)
|
void Sys_Printf (char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
// always print to the console
|
// always print to the console
|
||||||
// if (isDedicated)
|
// if (isDedicated)
|
||||||
// {
|
// {
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vprintf(fmt, argptr);
|
vprintf(fmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_Quit (void)
|
void Sys_Quit (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
Host_Shutdown();
|
Host_Shutdown();
|
||||||
|
|
||||||
// if (isDedicated)
|
// if (isDedicated)
|
||||||
|
@ -233,7 +234,7 @@ void Sys_Quit (void)
|
||||||
|
|
||||||
double Sys_FloatTime (void)
|
double Sys_FloatTime (void)
|
||||||
{
|
{
|
||||||
return SDL_GetTicks() / 1000.0;
|
return SDL_GetTicks() / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Sys_ConsoleInput (void)
|
char *Sys_ConsoleInput (void)
|
||||||
|
@ -241,31 +242,31 @@ char *Sys_ConsoleInput (void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Sys_Sleep (void)
|
void Sys_Sleep (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_SendKeyEvents (void)
|
void Sys_SendKeyEvents (void)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
while (SDL_PollEvent (&event))
|
while (SDL_PollEvent (&event))
|
||||||
{
|
{
|
||||||
switch (event.type) {
|
switch (event.type)
|
||||||
case SDL_KEYDOWN:
|
{
|
||||||
case SDL_KEYUP:
|
case SDL_KEYDOWN:
|
||||||
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
|
case SDL_KEYUP:
|
||||||
return;
|
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
|
||||||
case SDL_QUIT:
|
return;
|
||||||
Sys_Quit();
|
case SDL_QUIT:
|
||||||
break;
|
Sys_Quit();
|
||||||
default:
|
break;
|
||||||
SDL_PumpEvents();
|
default:
|
||||||
break;
|
SDL_PumpEvents();
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_LowFPPrecision (void)
|
void Sys_LowFPPrecision (void)
|
||||||
|
@ -279,3 +280,4 @@ void Sys_HighFPPrecision (void)
|
||||||
void Sys_SetFPCW (void)
|
void Sys_SetFPCW (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue