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:
Ozkan Sezer 2010-02-17 23:32:04 +00:00
parent 9d9354165c
commit 6c7d3d7205
9 changed files with 876 additions and 879 deletions

View file

@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#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 {
@ -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];
@ -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)))
@ -279,12 +276,16 @@ int VID_SetMode (int modenum)
{ {
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,
modelist[modenum].height,
modelist[modenum].bpp, flags);
stat = true; 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,
modelist[modenum].height,
modelist[modenum].bpp, flags);
stat = true; stat = true;
} }
modestate = MODE_WINDOWED; modestate = MODE_WINDOWED;
@ -293,8 +294,9 @@ int VID_SetMode (int modenum)
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,
modelist[modenum].bpp, flags);
stat = true; stat = true;
modestate = MODE_FULLSCREEN_DEFAULT; modestate = MODE_FULLSCREEN_DEFAULT;
} }
@ -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,11 +336,11 @@ 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;
@ -421,9 +423,9 @@ void VID_Restart (void)
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;
@ -438,7 +440,7 @@ void VID_Restart (void)
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));
@ -682,14 +684,18 @@ void GL_CheckExtensions (void)
// //
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) { 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"); 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");
} else if (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 // 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 (swap interval is -1.) 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");
} }
@ -785,7 +791,6 @@ void GL_Init (void)
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
@ -1045,7 +1050,7 @@ void VID_DescribeModes_f (void)
VID_InitDIB VID_InitDIB
================= =================
*/ */
void VID_InitDIB () void VID_InitDIB (void)
{ {
const SDL_VideoInfo *info; const SDL_VideoInfo *info;
@ -1088,7 +1093,7 @@ 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;
@ -1200,8 +1205,6 @@ 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) if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
Sys_Error("Could not initialize SDL Video"); Sys_Error("Could not initialize SDL Video");

View file

@ -270,26 +270,25 @@ void ExtraMaps_Init (void)
{ {
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")) if (!strstr(dir_t->d_name, ".bsp") && !strstr(dir_t->d_name, ".BSP"))
continue; 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);
@ -297,6 +296,9 @@ void ExtraMaps_Init (void)
} }
} }
} }
}
}
}
} }
void ExtraMaps_Clear (void) void ExtraMaps_Clear (void)
@ -402,36 +404,27 @@ void Modlist_Init (void)
{ {
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); sprintf(mod_dir_string, "%s%s/", dir_string, dir_t->d_name);
mod_dir_p = opendir(mod_dir_string); mod_dir_p = opendir(mod_dir_string);
if (mod_dir_p == NULL) if (mod_dir_p == NULL)
continue; continue;
progs_found = false; progs_found = false;
pak_found = false; pak_found = false;
// find progs.dat and pak file(s) // find progs.dat and pak file(s)
while ((mod_dir_t = readdir(mod_dir_p)) != NULL) while ((mod_dir_t = readdir(mod_dir_p)) != NULL)
{ {
if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0)) if ((strcmp(mod_dir_t->d_name, ".") == 0) || (strcmp(mod_dir_t->d_name, "..") == 0))
continue; continue;
if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") != -1) if (Q_strcasecmp(mod_dir_t->d_name, "progs.dat") != -1)
progs_found = true; progs_found = true;
if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK")) if (strstr(mod_dir_t->d_name, ".pak") || strstr(mod_dir_t->d_name, ".PAK"))
pak_found = true; pak_found = true;
if (progs_found || pak_found) if (progs_found || pak_found)
break; break;
} }
closedir(mod_dir_p); closedir(mod_dir_p);
if (!progs_found && !pak_found) if (!progs_found && !pak_found)
continue; continue;
Modlist_Add(dir_t->d_name); Modlist_Add(dir_t->d_name);
} }

View file

@ -31,7 +31,8 @@ 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_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
@ -105,7 +106,7 @@ void IN_Shutdown (void)
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
@ -166,3 +167,4 @@ void IN_Move (usercmd_t *cmd)
void IN_ClearStates (void) void IN_ClearStates (void)
{ {
} }

View file

@ -52,15 +52,13 @@ int main(int argc, char *argv[])
parms.memsize = Q_atoi(com_argv[t]) * 1024; parms.memsize = Q_atoi(com_argv[t]) * 1024;
} }
// TODO: dedicated server setup
parms.membase = malloc (parms.memsize); parms.membase = malloc (parms.memsize);
if (!parms.membase) if (!parms.membase)
Sys_Error ("Not enough memory free; check disk space\n"); Sys_Error ("Not enough memory free; check disk space\n");
// TODO: dedicated server setup
// S_BlockSound(); do I need this?
Con_Printf("\nFitzQuake Version %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION); Con_Printf("\nFitzQuake Version %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
Con_Printf("SDL port (c) Sleepwalkr, Baker, and OZ\n"); Con_Printf("SDL port (c) Sleepwalkr, Baker, and OZ\n");
Con_Printf("This version hacked by Stevenaaus and OZ\n"); Con_Printf("This version hacked by Stevenaaus and OZ\n");
@ -73,8 +71,10 @@ int main(int argc, char *argv[])
{ {
// TODO: dedicated server loop // TODO: dedicated server loop
while (!done && SDL_PollEvent (&event)) { while (!done && SDL_PollEvent (&event))
switch (event.type) { {
switch (event.type)
{
case SDL_ACTIVEEVENT: case SDL_ACTIVEEVENT:
if (event.active.state & SDL_APPACTIVE & SDL_APPINPUTFOCUS) if (event.active.state & SDL_APPACTIVE & SDL_APPINPUTFOCUS)
{ {
@ -94,8 +94,8 @@ int main(int argc, char *argv[])
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
switch (event.button.button)
switch (event.button.button) { {
case SDL_BUTTON_LEFT: case SDL_BUTTON_LEFT:
Key_Event(K_MOUSE1, event.button.type == SDL_MOUSEBUTTONDOWN); Key_Event(K_MOUSE1, event.button.type == SDL_MOUSEBUTTONDOWN);
break; break;
@ -143,7 +143,6 @@ int main(int argc, char *argv[])
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 // throttle the game loop just a little bit - noone needs more than 1000fps, I think
@ -156,3 +155,4 @@ int main(int argc, char *argv[])
Sys_Quit(); Sys_Quit();
return 0; return 0;
} }

View file

@ -110,3 +110,4 @@ net_landriver_t net_landrivers[MAX_NET_DRIVERS] =
}; };
int net_numlandrivers = 1; int net_numlandrivers = 1;

View file

@ -38,37 +38,35 @@ static int net_acceptsocket = -1;
static struct qsockaddr broadcastaddr; static struct qsockaddr broadcastaddr;
SDLNet_SocketSet acceptsocket_set; SDLNet_SocketSet acceptsocket_set;
IPaddress myaddr; 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)
@ -221,7 +219,6 @@ void SDLN_Listen (qboolean state)
int SDLN_OpenSocket (int port) int SDLN_OpenSocket (int port)
{ {
UDPsocket newsocket; UDPsocket newsocket;
static IPaddress address; static IPaddress address;
@ -315,7 +312,6 @@ int SDLN_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
} }
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)
@ -347,7 +343,6 @@ int SDLN_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
int SDLN_Broadcast (int socketid, byte *buf, int len) int SDLN_Broadcast (int socketid, byte *buf, int len)
{ {
if (socketid != net_broadcastsocket) if (socketid != net_broadcastsocket)
{ {
if (net_broadcastsocket != 0) if (net_broadcastsocket != 0)
@ -432,7 +427,8 @@ int SDLN_GetNameFromAddr (struct qsockaddr *addr, char *name)
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); Q_strncpy(name, buf, NET_NAMELEN - 1);
return 0; return 0;
} }

View file

@ -23,11 +23,11 @@ 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)
@ -157,17 +157,19 @@ 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); sprintf (text2, "ERROR: %s\n", text);
printf ("%s", text5); printf ("%s", text5);
printf ("%s", text4); printf ("%s", text4);
@ -198,7 +200,7 @@ void Sys_Error (char *error, ...)
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);
@ -208,7 +210,7 @@ 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);
@ -219,7 +221,6 @@ void Sys_Printf (char *fmt, ...)
void Sys_Quit (void) void Sys_Quit (void)
{ {
Host_Shutdown(); Host_Shutdown();
// if (isDedicated) // if (isDedicated)
@ -241,7 +242,6 @@ char *Sys_ConsoleInput (void)
return 0; return 0;
} }
void Sys_Sleep (void) void Sys_Sleep (void)
{ {
} }
@ -253,7 +253,8 @@ void Sys_SendKeyEvents (void)
SDL_PumpEvents(); SDL_PumpEvents();
while (SDL_PollEvent (&event)) while (SDL_PollEvent (&event))
{ {
switch (event.type) { switch (event.type)
{
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN); Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);
@ -279,3 +280,4 @@ void Sys_HighFPPrecision (void)
void Sys_SetFPCW (void) void Sys_SetFPCW (void)
{ {
} }