1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.options.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.options.c,v 1.5 1999/11/16 02:57:08 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.options.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
15 flags.time = flags.nonews = flags.notombstone = flags.end_own =
16 flags.standout = flags.nonull = FALSE;
17 flags.no_rest_on_space = TRUE;
18 flags.invlet_constant = TRUE;
21 flags.female = FALSE; /* players are usually male */
23 if(opts = getenv("HACKOPTIONS"))
24 parseoptions(opts,TRUE);
27 parseoptions(opts, from_env)
35 if(op = index(opts, ',')) {
37 parseoptions(op, from_env);
39 if(op = index(opts, ' ')) {
42 if(*op != ' ') *op2++ = *op;
46 while((*opts == '!') || !strncmp(opts, "no", 2)) {
47 if(*opts == '!') opts++; else opts += 2;
51 if(!strncmp(opts,"standout",8)) {
52 flags.standout = !negated;
56 if(!strncmp(opts,"null",3)) {
57 flags.nonull = negated;
61 if(!strncmp(opts,"tombstone",4)) {
62 flags.notombstone = negated;
66 if(!strncmp(opts,"news",4)) {
67 flags.nonews = negated;
71 if(!strncmp(opts,"time",4)) {
72 flags.time = !negated;
77 if(!strncmp(opts,"restonspace",4)) {
78 flags.no_rest_on_space = negated;
82 if(!strncmp(opts,"fixinv",4)) {
84 flags.invlet_constant = !negated;
86 pline("The fixinvlet option must be in HACKOPTIONS.");
90 if(!strncmp(opts,"male",4)) {
91 flags.female = negated;
94 if(!strncmp(opts,"female",6)) {
95 flags.female = !negated;
100 if(!strncmp(opts,"name",4)) {
101 extern char plname[PL_NSIZ];
103 pline("The playername can be set only from HACKOPTIONS.");
106 op = index(opts,':');
108 (void) strncpy(plname, op+1, sizeof(plname)-1);
112 /* endgame:5t[op] 5a[round] o[wn] */
113 if(!strncmp(opts,"endgame",3)) {
114 op = index(opts,':');
121 while(digit(*op)) op++;
132 flags.end_around = num;
135 flags.end_own = !negated;
140 while(letter(*++op)) ;
147 if(!strncmp(opts, "help", 4)) {
149 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
150 "give the command 'o' followed by the line `<options>' while playing. ",
151 "Here <options> is a list of <option>s separated by commas." );
153 "Simple (boolean) options are rest_on_space, news, time, ",
154 "null, tombstone, (fe)male. ",
155 "These can be negated by prefixing them with '!' or \"no\"." );
157 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\"." );
159 "A compound option is endgame; it is followed by a description of what ",
160 "parts of the scorelist you want to see. You might for example say: ",
161 "`endgame:own scores/5 top scores/4 around my score'." );
164 pline("Bad option: %s.", opts);
165 pline("Type `o help<cr>' for help.");
168 puts("Bad syntax in HACKOPTIONS.");
169 puts("Use for example:");
171 "HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\""
180 pline("What options do you want to set? ");
182 if(!buf[0] || buf[0] == '\033') {
183 (void) strcpy(buf,"HACKOPTIONS=");
184 (void) strcat(buf, flags.female ? "female," : "male,");
185 if(flags.standout) (void) strcat(buf,"standout,");
186 if(flags.nonull) (void) strcat(buf,"nonull,");
187 if(flags.nonews) (void) strcat(buf,"nonews,");
188 if(flags.time) (void) strcat(buf,"time,");
189 if(flags.notombstone) (void) strcat(buf,"notombstone,");
190 if(flags.no_rest_on_space)
191 (void) strcat(buf,"!rest_on_space,");
192 if(flags.end_top != 5 || flags.end_around != 4 || flags.end_own){
193 (void) sprintf(eos(buf), "endgame: %u topscores/%u around me",
194 flags.end_top, flags.end_around);
195 if(flags.end_own) (void) strcat(buf, "/own scores");
197 char *eop = eos(buf);
198 if(*--eop == ',') *eop = 0;
202 parseoptions(buf, FALSE);