home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume12
/
torus
/
part01
/
opt.c
< prev
next >
Wrap
Text File
|
1991-05-15
|
3KB
|
120 lines
# include "robots.h"
/*
* opt.c: do a psuedo ROGUEOPTS sort of thing
*/
typedef struct Opt {
char *name;
int type;
} Opt;
Opt options[] = {
# define OPT_NAME 1
"name", OPT_NAME, /* Who am i boss ? */
# define OPT_MOVE_HEAP 2
"moveheaps", OPT_MOVE_HEAP, /* can push heaps */
# define OPT_NOMOVE_HEAP 3
"nomoveheaps", OPT_NOMOVE_HEAP,/* can't push heaps */
# define OPT_SHOW_HSCORE 4
"showhscore", OPT_SHOW_HSCORE,
# define OPT_NOSHOW_HSCORE 5
"noshowhscore", OPT_NOSHOW_HSCORE,
# define OPT_HSEW 6
"hsew", OPT_HSEW,
# define OPT_NOHSEW 7
"nohsew", OPT_NOHSEW,
# define OPT_VSEW 8
"vsew", OPT_VSEW,
# define OPT_NOVSEW 9
"novsew", OPT_NOVSEW,
# define OPT_WIMPY 10
"wimpy", OPT_WIMPY,
# define OPT_STUDLY 11
"studly", OPT_STUDLY,
# define OPT_CONT 12
"continuous", OPT_CONT,
# define OPT_NOCONT 13
"nocontinuous", OPT_NOCONT,
0, 0
};
/* get_robot_opts: Personalise robots to the users tastes. Model after
* the rogue/urogue type environment stuff.
*/
get_robot_opts(str)
char *str;
{
register char *p;
Opt *op;
int len, len2;
p = str;
while(*p)
{
while(*p && !isalpha(*p)) p++; /* skip non-alphas */
str = p;
while(isalpha(*p)) p ++; /* match longest word */
len = p - str;
for(op = options; op->name; op ++) /* see if defined */
if( strncmp(str, op->name, len) == 0)
break;
if( op->name == NULL)
continue;
switch(op->type) /* OK, now do something */
{
case OPT_NAME:
while(*p == '=') p++; /* skip ='s */
str = p; /* OK, now look for name */
while(*p && *p != ',') p++;
len2 = (MAXSTR - 1) -
(strlen(my_user_name) + 4);
len = p - str;
len = len < len2 ? len : len2;
(void) sprintf(whoami, "%.*s (%s)", len,
str, my_user_name);
break;
case OPT_MOVE_HEAP:
moveable_heaps = TRUE;
break;
case OPT_NOMOVE_HEAP:
moveable_heaps = FALSE;
break;
case OPT_SHOW_HSCORE:
show_highscore = TRUE;
break;
case OPT_NOSHOW_HSCORE:
show_highscore = FALSE;
break;
case OPT_HSEW:
hsew = TRUE;
break;
case OPT_NOHSEW:
hsew = FALSE;
break;
case OPT_VSEW:
vsew = TRUE;
break;
case OPT_NOVSEW:
vsew = FALSE;
break;
case OPT_WIMPY:
wimpy = TRUE;
break;
case OPT_STUDLY:
wimpy = FALSE;
break;
case OPT_CONT:
continuous = TRUE;
break;
case OPT_NOCONT:
continuous = FALSE;
break;
}
}
}