1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.options.c - version 1.0.3 */
13 flags.time = flags.nonews = flags.notombstone = flags.end_own =
14 flags.standout = flags.nonull = FALSE;
15 flags.no_rest_on_space = TRUE;
16 flags.invlet_constant = TRUE;
19 flags.female = FALSE; /* players are usually male */
21 if(opts = getenv("HACKOPTIONS"))
22 parseoptions(opts,TRUE);
25 parseoptions(opts, from_env)
29 register char *op,*op2;
33 if(op = index(opts, ',')) {
35 parseoptions(op, from_env);
37 if(op = index(opts, ' ')) {
40 if(*op != ' ') *op2++ = *op;
44 while((*opts == '!') || !strncmp(opts, "no", 2)) {
45 if(*opts == '!') opts++; else opts += 2;
49 if(!strncmp(opts,"standout",8)) {
50 flags.standout = !negated;
54 if(!strncmp(opts,"null",3)) {
55 flags.nonull = negated;
59 if(!strncmp(opts,"tombstone",4)) {
60 flags.notombstone = negated;
64 if(!strncmp(opts,"news",4)) {
65 flags.nonews = negated;
69 if(!strncmp(opts,"time",4)) {
70 flags.time = !negated;
75 if(!strncmp(opts,"restonspace",4)) {
76 flags.no_rest_on_space = negated;
80 if(!strncmp(opts,"fixinv",4)) {
82 flags.invlet_constant = !negated;
84 pline("The fixinvlet option must be in HACKOPTIONS.");
88 if(!strncmp(opts,"male",4)) {
89 flags.female = negated;
92 if(!strncmp(opts,"female",6)) {
93 flags.female = !negated;
98 if(!strncmp(opts,"name",4)) {
99 extern char plname[PL_NSIZ];
101 pline("The playername can be set only from HACKOPTIONS.");
104 op = index(opts,':');
106 (void) strncpy(plname, op+1, sizeof(plname)-1);
110 /* endgame:5t[op] 5a[round] o[wn] */
111 if(!strncmp(opts,"endgame",3)) {
112 op = index(opts,':');
119 while(digit(*op)) op++;
130 flags.end_around = num;
133 flags.end_own = !negated;
138 while(letter(*++op)) ;
145 if(!strncmp(opts, "help", 4)) {
147 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
148 "give the command 'o' followed by the line `<options>' while playing. ",
149 "Here <options> is a list of <option>s separated by commas." );
151 "Simple (boolean) options are rest_on_space, news, time, ",
152 "null, tombstone, (fe)male. ",
153 "These can be negated by prefixing them with '!' or \"no\"." );
155 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\"." );
157 "A compound option is endgame; it is followed by a description of what ",
158 "parts of the scorelist you want to see. You might for example say: ",
159 "`endgame:own scores/5 top scores/4 around my score'." );
162 pline("Bad option: %s.", opts);
163 pline("Type `o help<cr>' for help.");
166 puts("Bad syntax in HACKOPTIONS.");
167 puts("Use for example:");
169 "HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\""
178 pline("What options do you want to set? ");
180 if(!buf[0] || buf[0] == '\033') {
181 (void) strcpy(buf,"HACKOPTIONS=");
182 (void) strcat(buf, flags.female ? "female," : "male,");
183 if(flags.standout) (void) strcat(buf,"standout,");
184 if(flags.nonull) (void) strcat(buf,"nonull,");
185 if(flags.nonews) (void) strcat(buf,"nonews,");
186 if(flags.time) (void) strcat(buf,"time,");
187 if(flags.notombstone) (void) strcat(buf,"notombstone,");
188 if(flags.no_rest_on_space)
189 (void) strcat(buf,"!rest_on_space,");
190 if(flags.end_top != 5 || flags.end_around != 4 || flags.end_own){
191 (void) sprintf(eos(buf), "endgame: %u topscores/%u around me",
192 flags.end_top, flags.end_around);
193 if(flags.end_own) (void) strcat(buf, "/own scores");
195 register char *eop = eos(buf);
196 if(*--eop == ',') *eop = 0;
200 parseoptions(buf, FALSE);