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 $ */
14 flags.time = flags.nonews = flags.notombstone = flags.end_own =
15 flags.standout = flags.nonull = FALSE;
16 flags.no_rest_on_space = TRUE;
17 flags.invlet_constant = TRUE;
20 flags.female = FALSE; /* players are usually male */
22 if(opts = getenv("HACKOPTIONS"))
23 parseoptions(opts,TRUE);
26 parseoptions(opts, from_env)
34 if(op = index(opts, ',')) {
36 parseoptions(op, from_env);
38 if(op = index(opts, ' ')) {
41 if(*op != ' ') *op2++ = *op;
45 while((*opts == '!') || !strncmp(opts, "no", 2)) {
46 if(*opts == '!') opts++; else opts += 2;
50 if(!strncmp(opts,"standout",8)) {
51 flags.standout = !negated;
55 if(!strncmp(opts,"null",3)) {
56 flags.nonull = negated;
60 if(!strncmp(opts,"tombstone",4)) {
61 flags.notombstone = negated;
65 if(!strncmp(opts,"news",4)) {
66 flags.nonews = negated;
70 if(!strncmp(opts,"time",4)) {
71 flags.time = !negated;
76 if(!strncmp(opts,"restonspace",4)) {
77 flags.no_rest_on_space = negated;
81 if(!strncmp(opts,"fixinv",4)) {
83 flags.invlet_constant = !negated;
85 pline("The fixinvlet option must be in HACKOPTIONS.");
89 if(!strncmp(opts,"male",4)) {
90 flags.female = negated;
93 if(!strncmp(opts,"female",6)) {
94 flags.female = !negated;
99 if(!strncmp(opts,"name",4)) {
100 extern char plname[PL_NSIZ];
102 pline("The playername can be set only from HACKOPTIONS.");
105 op = index(opts,':');
107 (void) strncpy(plname, op+1, sizeof(plname)-1);
111 /* endgame:5t[op] 5a[round] o[wn] */
112 if(!strncmp(opts,"endgame",3)) {
113 op = index(opts,':');
120 while(digit(*op)) op++;
131 flags.end_around = num;
134 flags.end_own = !negated;
139 while(letter(*++op)) ;
146 if(!strncmp(opts, "help", 4)) {
148 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
149 "give the command 'o' followed by the line `<options>' while playing. ",
150 "Here <options> is a list of <option>s separated by commas." );
152 "Simple (boolean) options are rest_on_space, news, time, ",
153 "null, tombstone, (fe)male. ",
154 "These can be negated by prefixing them with '!' or \"no\"." );
156 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\"." );
158 "A compound option is endgame; it is followed by a description of what ",
159 "parts of the scorelist you want to see. You might for example say: ",
160 "`endgame:own scores/5 top scores/4 around my score'." );
163 pline("Bad option: %s.", opts);
164 pline("Type `o help<cr>' for help.");
167 puts("Bad syntax in HACKOPTIONS.");
168 puts("Use for example:");
170 "HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\""
179 pline("What options do you want to set? ");
181 if(!buf[0] || buf[0] == '\033') {
182 (void) strcpy(buf,"HACKOPTIONS=");
183 (void) strcat(buf, flags.female ? "female," : "male,");
184 if(flags.standout) (void) strcat(buf,"standout,");
185 if(flags.nonull) (void) strcat(buf,"nonull,");
186 if(flags.nonews) (void) strcat(buf,"nonews,");
187 if(flags.time) (void) strcat(buf,"time,");
188 if(flags.notombstone) (void) strcat(buf,"notombstone,");
189 if(flags.no_rest_on_space)
190 (void) strcat(buf,"!rest_on_space,");
191 if(flags.end_top != 5 || flags.end_around != 4 || flags.end_own){
192 (void) sprintf(eos(buf), "endgame: %u topscores/%u around me",
193 flags.end_top, flags.end_around);
194 if(flags.end_own) (void) strcat(buf, "/own scores");
196 char *eop = eos(buf);
197 if(*--eop == ',') *eop = 0;
201 parseoptions(buf, FALSE);