diff --git a/src/configuration.c b/src/configuration.c index 64675c5..130fe6d 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -1,4 +1,4 @@ -/* $Id: configuration.c,v 1.77 2005/07/08 15:19:34 stpohle Exp $ +/* $Id: configuration.c,v 1.78 2006/08/13 21:20:54 patty21 Exp $ * configuration */ #include @@ -658,9 +658,9 @@ void ReadPrgArgs (int argc, char **argv) { int i = 0; - + char s; while (argv[++i] != NULL) { - if (!strcmp (argv[i], "-help")) { + if (!strcmp (argv[i], "-h")||!strcmp (argv[i], "-help")||!strcmp (argv[i], "--help")) { printf ("BomberClone Version " VERSION "\n"); printf (" WebPage : http://www.bomberclone.de\n"); printf (" Bug Report to :\n"); @@ -682,24 +682,81 @@ ReadPrgArgs (int argc, char **argv) printf (" -autostart SECONDS - time before a game starts\n"); exit (0); } - if (!strcmp (argv[i], "-port")) - strncpy (bman.port, argv[++i], LEN_PORT); - if (!strcmp (argv[i], "-ogcport")) - strncpy (bman.ogc_port, argv[++i], LEN_PORT); - if (!strcmp (argv[i], "-name")) - strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); - if (!strcmp (argv[i], "-name2")) - strncpy (bman.player2name, argv[++i], LEN_PLAYERNAME); - if (!strcmp (argv[i], "-gamename")) - strncpy (bman.gamename, argv[++i], LEN_GAMENAME); - if (!strcmp (argv[i], "-ogc")) - bman.notifygamemaster = atoi (argv[++i]); - if (!strcmp (argv[i], "-broadcast")) - bman.broadcast = atoi (argv[++i]); - if (!strcmp (argv[i], "-debug")) - debug = atoi (argv[++i]); - if (!strcmp (argv[i], "-autostart")) - bman.autostart = atoi (argv[++i]); + } + i=0; + while (argv[++i] != NULL) { + if (argv[i][0]=='-') { + if (argv[i+1] != NULL) + s=argv[i+1][0]; + else + s='-'; + if (!strcmp (argv[i], "-port")) { + if (s!='-') + strncpy (bman.port, argv[++i], LEN_PORT); + else { + printf("Error: Parameter required for -port\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-ogcport")) { + if (s!='-') + strncpy (bman.ogc_port, argv[++i], LEN_PORT); + else { + printf("Error: Parameter required for -ogcport\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-name")) { + if (s!='-') + strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); + else { + printf("Error: Parameter required for -name\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-name2")) { + if (s!='-') + strncpy (bman.player2name, argv[++i], LEN_PLAYERNAME); + else { + printf("Error: Parameter required for -name2\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-gamename")) { + if (s!='-') + strncpy (bman.gamename, argv[++i], LEN_GAMENAME); + else { + printf("Error: Parameter required for -gamename\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-autostart")) { + if (s!='-') + bman.autostart = atoi (argv[++i]); + else { + printf("Error: Parameter required for -autostart\n"); + exit(1); + } + } + if (!strcmp (argv[i], "-ogc")) { + if (s!='-') + bman.notifygamemaster = atoi (argv[++i]); + else + bman.notifygamemaster = 1; + } + if (!strcmp (argv[i], "-broadcast")) { + if (s!='-') + bman.broadcast = atoi (argv[++i]); + else + bman.broadcast = 1; + } + if (!strcmp (argv[i], "-debug")) { + if (s!='-') + debug = atoi (argv[++i]); + else + debug = 1; + } + } } };