more fixes for deprecated conversion from string constant to char*:

handle the -safe command line switch using a new global safemode,
check for safemode in the related driver init functions and remove
the safeargvs & co from common.c and COM_InitArgv().


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@307 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2010-08-29 12:55:41 +00:00
parent cecbdc723c
commit b1585b3039
6 changed files with 15 additions and 25 deletions

View File

@ -512,7 +512,7 @@ int CDAudio_Init(void)
{
int i, sdl_num_drives;
if (COM_CheckParm("-nocdaudio"))
if (safemode || COM_CheckParm("-nocdaudio"))
return -1;
export_cddev_arg();

View File

@ -22,13 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h"
#define NUM_SAFE_ARGVS 7
static char *largv[MAX_NUM_ARGVS + 1];
static char argvdummy[] = " ";
static char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1];
static char *argvdummy = " ";
static char *safeargvs[NUM_SAFE_ARGVS] =
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-dibonly"};
int safemode;
cvar_t registered = {"registered","0"};
cvar_t cmdline = {"cmdline","", false, true};
@ -1126,7 +1123,6 @@ COM_InitArgv
*/
void COM_InitArgv (int argc, char **argv)
{
qboolean safe;
int i, j, n;
// reconstitute the command line for the cmdline externally visible cvar
@ -1152,24 +1148,11 @@ void COM_InitArgv (int argc, char **argv)
Con_Printf("Command line: %s\n", com_cmdline);
safe = false;
for (com_argc=0 ; (com_argc<MAX_NUM_ARGVS) && (com_argc < argc) ; com_argc++)
{
largv[com_argc] = argv[com_argc];
if (!Q_strcmp ("-safe", argv[com_argc]))
safe = true;
}
if (safe)
{
// force all the safe-mode switches. Note that we reserved extra space in
// case we need to add these, so we don't need an overflow check
for (i=0 ; i<NUM_SAFE_ARGVS ; i++)
{
largv[com_argc] = safeargvs[i];
com_argc++;
}
safemode = 1;
}
largv[com_argc] = argvdummy;

View File

@ -149,6 +149,13 @@ const char *COM_Parse (const char *data);
extern int com_argc;
extern char **com_argv;
extern int safemode;
/* safe mode: in true, the engine will behave as if one
of these arguments were actually on the command line:
-nosound, -nocdaudio, -nomidi, -stdvid, -dibonly,
-nomouse, -nojoy, -nolan
*/
int COM_CheckParm (const char *parm);
void COM_Init (const char *path);
void COM_InitArgv (int argc, char **argv);

View File

@ -105,7 +105,7 @@ void IN_Init (void)
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
if (COM_CheckParm("-nomouse"))
if (safemode || COM_CheckParm("-nomouse"))
{
no_mouse = true;
// discard all mouse events when input is deactivated

View File

@ -796,7 +796,7 @@ int Datagram_Init (void)
myDriverLevel = net_driverlevel;
Cmd_AddCommand ("net_stats", NET_Stats_f);
if (COM_CheckParm("-nolan"))
if (safemode || COM_CheckParm("-nolan"))
return -1;
num_inited = 0;

View File

@ -147,7 +147,7 @@ void S_Init (void)
Cvar_RegisterVariable(&_snd_mixahead, NULL);
Cvar_RegisterVariable(&sndspeed, NULL);
if (COM_CheckParm("-nosound"))
if (safemode || COM_CheckParm("-nosound"))
return;
Con_Printf("Sound Initialization\n");