summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2010-12-18 23:55:07 +0000
committerSimon Howard2010-12-18 23:55:07 +0000
commit463bcf013ce355398974953508d232ac88a6b2d6 (patch)
tree8f21093469f64e1d147bf22adc4acf6ad84b0310 /src
parent1ef81eb5f7c336972fe56f15285f389cafdc96f5 (diff)
downloadchocolate-doom-463bcf013ce355398974953508d232ac88a6b2d6.tar.gz
chocolate-doom-463bcf013ce355398974953508d232ac88a6b2d6.tar.bz2
chocolate-doom-463bcf013ce355398974953508d232ac88a6b2d6.zip
Add a M_CheckParmWithArgs function, that behaves like M_CheckParm but
also checks that extra options were provided on the command line (thanks Sander van Dijk). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2223
Diffstat (limited to 'src')
-rw-r--r--src/d_iwad.c2
-rw-r--r--src/d_main.c62
-rw-r--r--src/d_net.c2
-rw-r--r--src/g_game.c4
-rw-r--r--src/i_system.c2
-rw-r--r--src/i_video.c8
-rw-r--r--src/m_argv.c13
-rw-r--r--src/m_argv.h4
-rw-r--r--src/m_config.c8
-rw-r--r--src/net_client.c4
-rw-r--r--src/net_sdl.c4
-rw-r--r--src/net_server.c4
-rw-r--r--src/p_map.c2
-rw-r--r--src/p_spec.c4
14 files changed, 66 insertions, 57 deletions
diff --git a/src/d_iwad.c b/src/d_iwad.c
index 89a7fba3..c0d33707 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -658,7 +658,7 @@ char *D_FindIWAD(void)
// @arg <file>
//
- iwadparm = M_CheckParm("-iwad");
+ iwadparm = M_CheckParmWithArgs("-iwad", 1);
if (iwadparm)
{
diff --git a/src/d_main.c b/src/d_main.c
index 36382fb6..465ed45b 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -672,9 +672,9 @@ static void InitGameVersion(void)
// "ultimate" and "final".
//
- p = M_CheckParm("-gameversion");
+ p = M_CheckParmWithArgs("-gameversion", 1);
- if (p > 0)
+ if (p)
{
for (i=0; gameversions[i].description != NULL; ++i)
{
@@ -866,9 +866,9 @@ void D_DoomMain (void)
// address.
//
- p = M_CheckParm("-query");
+ p = M_CheckParmWithArgs("-query", 1);
- if (p && p < myargc-1)
+ if (p)
{
NET_QueryAddress(myargv[p+1]);
exit(0);
@@ -1019,7 +1019,7 @@ void D_DoomMain (void)
// into the main IWAD. Multiple files may be specified.
//
- p = M_CheckParm("-merge");
+ p = M_CheckParmWithArgs("-merge", 1);
if (p > 0)
{
@@ -1045,7 +1045,7 @@ void D_DoomMain (void)
// Simulates the behavior of NWT's -merge option. Multiple files
// may be specified.
- p = M_CheckParm("-nwtmerge");
+ p = M_CheckParmWithArgs("-nwtmerge", 1);
if (p > 0)
{
@@ -1070,7 +1070,7 @@ void D_DoomMain (void)
// the main IWAD directory. Multiple files may be specified.
//
- p = M_CheckParm("-af");
+ p = M_CheckParmWithArgs("-af", 1);
if (p > 0)
{
@@ -1093,7 +1093,7 @@ void D_DoomMain (void)
// into the main IWAD directory. Multiple files may be specified.
//
- p = M_CheckParm("-as");
+ p = M_CheckParmWithArgs("-as", 1);
if (p > 0)
{
@@ -1115,7 +1115,7 @@ void D_DoomMain (void)
// Equivalent to "-af <files> -as <files>".
//
- p = M_CheckParm("-aa");
+ p = M_CheckParmWithArgs("-aa", 1);
if (p > 0)
{
@@ -1139,7 +1139,7 @@ void D_DoomMain (void)
// Load the specified PWAD files.
//
- p = M_CheckParm ("-file");
+ p = M_CheckParmWithArgs("-file", 1);
if (p)
{
// the parms after p are wadfile/lump names,
@@ -1163,7 +1163,7 @@ void D_DoomMain (void)
//
// convenience hack to allow -wart e m to add a wad file
// prepend a tilde to the filename so wadfile will be reloadable
- p = M_CheckParm ("-wart");
+ p = M_CheckParmWithArgs("-wart", 1);
if (p)
{
myargv[p][4] = 'p'; // big hack, change to -warp
@@ -1200,7 +1200,7 @@ void D_DoomMain (void)
// Play back the demo named demo.lmp.
//
- p = M_CheckParm ("-playdemo");
+ p = M_CheckParmWithArgs ("-playdemo", 1);
if (!p)
{
@@ -1212,11 +1212,11 @@ void D_DoomMain (void)
// Play back the demo named demo.lmp, determining the framerate
// of the screen.
//
- p = M_CheckParm ("-timedemo");
+ p = M_CheckParmWithArgs("-timedemo", 1);
}
- if (p && p < myargc-1)
+ if (p)
{
if (!strcasecmp(myargv[p+1] + strlen(myargv[p+1]) - 4, ".lmp"))
{
@@ -1296,9 +1296,9 @@ void D_DoomMain (void)
// 0 disables all monsters.
//
- p = M_CheckParm ("-skill");
+ p = M_CheckParmWithArgs("-skill", 1);
- if (p && p < myargc-1)
+ if (p)
{
startskill = myargv[p+1][0]-'1';
autostart = true;
@@ -1311,9 +1311,9 @@ void D_DoomMain (void)
// Start playing on episode n (1-4)
//
- p = M_CheckParm ("-episode");
+ p = M_CheckParmWithArgs("-episode", 1);
- if (p && p < myargc-1)
+ if (p)
{
startepisode = myargv[p+1][0]-'0';
startmap = 1;
@@ -1330,9 +1330,9 @@ void D_DoomMain (void)
// For multiplayer games: exit each level after n minutes.
//
- p = M_CheckParm ("-timer");
+ p = M_CheckParmWithArgs("-timer", 1);
- if (p && p < myargc-1)
+ if (p)
{
timelimit = atoi(myargv[p+1]);
}
@@ -1346,7 +1346,7 @@ void D_DoomMain (void)
p = M_CheckParm ("-avg");
- if (p && p < myargc-1)
+ if (p)
{
timelimit = 20;
}
@@ -1359,9 +1359,9 @@ void D_DoomMain (void)
// (Doom 2)
//
- p = M_CheckParm ("-warp");
+ p = M_CheckParmWithArgs("-warp", 1);
- if (p && p < myargc-1)
+ if (p)
{
if (gamemode == commercial)
startmap = atoi (myargv[p+1]);
@@ -1405,9 +1405,9 @@ void D_DoomMain (void)
// Load the game in slot s.
//
- p = M_CheckParm ("-loadgame");
+ p = M_CheckParmWithArgs("-loadgame", 1);
- if (p && p < myargc-1)
+ if (p)
{
startloadgame = atoi(myargv[p+1]);
}
@@ -1507,24 +1507,24 @@ void D_DoomMain (void)
// Record a demo named x.lmp.
//
- p = M_CheckParm ("-record");
+ p = M_CheckParmWithArgs("-record", 1);
- if (p && p < myargc-1)
+ if (p)
{
G_RecordDemo (myargv[p+1]);
autostart = true;
}
- p = M_CheckParm ("-playdemo");
- if (p && p < myargc-1)
+ p = M_CheckParmWithArgs("-playdemo", 1);
+ if (p)
{
singledemo = true; // quit after one demo
G_DeferedPlayDemo (demolumpname);
D_DoomLoop (); // never returns
}
- p = M_CheckParm ("-timedemo");
- if (p && p < myargc-1)
+ p = M_CheckParmWithArgs("-timedemo", 1);
+ if (p)
{
G_TimeDemo (demolumpname);
D_DoomLoop (); // never returns
diff --git a/src/d_net.c b/src/d_net.c
index ae5a6d62..57fe2399 100644
--- a/src/d_net.c
+++ b/src/d_net.c
@@ -317,7 +317,7 @@ void D_CheckNetGame (void)
// address.
//
- i = M_CheckParm("-connect");
+ i = M_CheckParmWithArgs("-connect", 1);
if (i > 0)
{
diff --git a/src/g_game.c b/src/g_game.c
index 59550513..7790b83e 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -2068,8 +2068,8 @@ void G_RecordDemo (char* name)
// Specify the demo buffer size (KiB)
//
- i = M_CheckParm ("-maxdemo");
- if (i && i<myargc-1)
+ i = M_CheckParmWithArgs("-maxdemo", 1);
+ if (i)
maxsize = atoi(myargv[i+1])*1024;
demobuffer = Z_Malloc (maxsize,PU_STATIC,NULL);
demoend = demobuffer + maxsize;
diff --git a/src/i_system.c b/src/i_system.c
index afff1a95..9f599192 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -171,7 +171,7 @@ byte *I_ZoneBase (int *size)
// Specify the heap size, in MiB (default 16).
//
- p = M_CheckParm("-mb");
+ p = M_CheckParmWithArgs("-mb", 1);
if (p > 0)
{
diff --git a/src/i_video.c b/src/i_video.c
index ad4d7f39..55fd21e1 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1442,7 +1442,7 @@ static void CheckCommandLine(void)
// Specify the screen width, in pixels.
//
- i = M_CheckParm("-width");
+ i = M_CheckParmWithArgs("-width", 1);
if (i > 0)
{
@@ -1456,7 +1456,7 @@ static void CheckCommandLine(void)
// Specify the screen height, in pixels.
//
- i = M_CheckParm("-height");
+ i = M_CheckParmWithArgs("-height", 1);
if (i > 0)
{
@@ -1470,7 +1470,7 @@ static void CheckCommandLine(void)
// Specify the color depth of the screen, in bits per pixel.
//
- i = M_CheckParm("-bpp");
+ i = M_CheckParmWithArgs("-bpp", 1);
if (i > 0)
{
@@ -1497,7 +1497,7 @@ static void CheckCommandLine(void)
// Specify the screen mode (when running fullscreen) or the window
// dimensions (when running in windowed mode).
- i = M_CheckParm("-geometry");
+ i = M_CheckParmWithArgs("-geometry", 1);
if (i > 0)
{
diff --git a/src/m_argv.c b/src/m_argv.c
index 99295c6d..4d321bbc 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -47,19 +47,24 @@ char** myargv;
// or 0 if not present
//
-int M_CheckParm (char *check)
+int M_CheckParmWithArgs(char *check, int num_args)
{
- int i;
+ int i;
- for (i = 1;i<myargc;i++)
+ for (i = 1; i < myargc - num_args; i++)
{
- if ( !strcasecmp(check, myargv[i]) )
+ if (!strcasecmp(check, myargv[i]))
return i;
}
return 0;
}
+int M_CheckParm(char *check)
+{
+ return M_CheckParmWithArgs(check, 0);
+}
+
#define MAXARGVS 100
static void LoadResponseFile(int argv_index)
diff --git a/src/m_argv.h b/src/m_argv.h
index 315bb97b..f5b26f94 100644
--- a/src/m_argv.h
+++ b/src/m_argv.h
@@ -38,6 +38,10 @@ extern char** myargv;
// in the arg list (0 if not found).
int M_CheckParm (char* check);
+// Same as M_CheckParm, but checks that num_args arguments are available
+// following the specified argument.
+int M_CheckParmWithArgs(char *check, int num_args);
+
void M_FindResponseFile(void);
#endif
diff --git a/src/m_config.c b/src/m_config.c
index 3abe7c63..332b8b95 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1409,9 +1409,9 @@ void M_LoadDefaults (void)
// default.cfg.
//
- i = M_CheckParm ("-config");
+ i = M_CheckParmWithArgs("-config", 1);
- if (i && i<myargc-1)
+ if (i)
{
doom_defaults.filename = myargv[i+1];
printf (" default file: %s\n",doom_defaults.filename);
@@ -1431,9 +1431,9 @@ void M_LoadDefaults (void)
// of chocolate-doom.cfg.
//
- i = M_CheckParm("-extraconfig");
+ i = M_CheckParmWithArgs("-extraconfig", 1);
- if (i && i<myargc-1)
+ if (i)
{
extra_defaults.filename = myargv[i+1];
printf(" extra configuration file: %s\n",
diff --git a/src/net_client.c b/src/net_client.c
index 322869d7..e338362e 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -411,7 +411,7 @@ void NET_CL_StartGame(void)
// packets.
//
- i = M_CheckParm("-extratics");
+ i = M_CheckParmWithArgs("-extratics", 1);
if (i > 0)
settings.extratics = atoi(myargv[i+1]);
@@ -426,7 +426,7 @@ void NET_CL_StartGame(void)
// the amount of network bandwidth needed.
//
- i = M_CheckParm("-dup");
+ i = M_CheckParmWithArgs("-dup", 1);
if (i > 0)
settings.ticdup = atoi(myargv[i+1]);
diff --git a/src/net_sdl.c b/src/net_sdl.c
index 9c647cc9..2589540d 100644
--- a/src/net_sdl.c
+++ b/src/net_sdl.c
@@ -170,7 +170,7 @@ static boolean NET_SDL_InitClient(void)
// the default (2342).
//
- p = M_CheckParm("-port");
+ p = M_CheckParmWithArgs("-port", 1);
if (p > 0)
port = atoi(myargv[p+1]);
@@ -196,7 +196,7 @@ static boolean NET_SDL_InitServer(void)
{
int p;
- p = M_CheckParm("-port");
+ p = M_CheckParmWithArgs("-port", 1);
if (p > 0)
port = atoi(myargv[p+1]);
diff --git a/src/net_server.c b/src/net_server.c
index 4307e2e2..b3a9ea92 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1121,9 +1121,9 @@ void NET_SV_SendQueryResponse(net_addr_t *addr)
// When starting a network server, specify a name for the server.
//
- p = M_CheckParm("-servername");
+ p = M_CheckParmWithArgs("-servername", 1);
- if (p > 0 && p + 1 < myargc)
+ if (p > 0)
{
querydata.description = myargv[p + 1];
}
diff --git a/src/p_map.c b/src/p_map.c
index b50fff2c..1ac76349 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -1426,7 +1426,7 @@ static void SpechitOverrun(line_t *ld)
// Use the specified magic value when emulating spechit overruns.
//
- p = M_CheckParm("-spechit");
+ p = M_CheckParmWithArgs("-spechit", 1);
if (p > 0)
{
diff --git a/src/p_spec.c b/src/p_spec.c
index fa3ec335..90d0bb7c 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -1213,9 +1213,9 @@ static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic,
// system. The default (if this option is not specified) is to
// emulate the behavior when running under Windows 98.
- p = M_CheckParm("-donut");
+ p = M_CheckParmWithArgs("-donut", 2);
- if (p > 0 && p < myargc - 2)
+ if (p > 0)
{
// Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008
//