]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.options.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$Id: hack.options.c,v 1.2 1993/08/02 17:19:12 mycroft Exp $";
16 extern char *getenv();
18 flags
.time
= flags
.nonews
= flags
.notombstone
= flags
.end_own
=
19 flags
.standout
= flags
.nonull
= FALSE
;
20 flags
.no_rest_on_space
= TRUE
;
21 flags
.invlet_constant
= TRUE
;
24 flags
.female
= FALSE
; /* players are usually male */
26 if(opts
= getenv("HACKOPTIONS"))
27 parseoptions(opts
,TRUE
);
30 parseoptions(opts
, from_env
)
34 register char *op
,*op2
;
38 if(op
= index(opts
, ',')) {
40 parseoptions(op
, from_env
);
42 if(op
= index(opts
, ' ')) {
45 if(*op
!= ' ') *op2
++ = *op
;
49 while((*opts
== '!') || !strncmp(opts
, "no", 2)) {
50 if(*opts
== '!') opts
++; else opts
+= 2;
54 if(!strncmp(opts
,"standout",8)) {
55 flags
.standout
= !negated
;
59 if(!strncmp(opts
,"null",3)) {
60 flags
.nonull
= negated
;
64 if(!strncmp(opts
,"tombstone",4)) {
65 flags
.notombstone
= negated
;
69 if(!strncmp(opts
,"news",4)) {
70 flags
.nonews
= negated
;
74 if(!strncmp(opts
,"time",4)) {
75 flags
.time
= !negated
;
80 if(!strncmp(opts
,"restonspace",4)) {
81 flags
.no_rest_on_space
= negated
;
85 if(!strncmp(opts
,"fixinv",4)) {
87 flags
.invlet_constant
= !negated
;
89 pline("The fixinvlet option must be in HACKOPTIONS.");
93 if(!strncmp(opts
,"male",4)) {
94 flags
.female
= negated
;
97 if(!strncmp(opts
,"female",6)) {
98 flags
.female
= !negated
;
103 if(!strncmp(opts
,"name",4)) {
104 extern char plname
[PL_NSIZ
];
106 pline("The playername can be set only from HACKOPTIONS.");
109 op
= index(opts
,':');
111 (void) strncpy(plname
, op
+1, sizeof(plname
)-1);
115 /* endgame:5t[op] 5a[round] o[wn] */
116 if(!strncmp(opts
,"endgame",3)) {
117 op
= index(opts
,':');
124 while(digit(*op
)) op
++;
135 flags
.end_around
= num
;
138 flags
.end_own
= !negated
;
143 while(letter(*++op
)) ;
150 if(!strncmp(opts
, "help", 4)) {
152 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
153 "give the command 'o' followed by the line `<options>' while playing. ",
154 "Here <options> is a list of <option>s separated by commas." );
156 "Simple (boolean) options are rest_on_space, news, time, ",
157 "null, tombstone, (fe)male. ",
158 "These can be negated by prefixing them with '!' or \"no\"." );
160 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\"." );
162 "A compound option is endgame; it is followed by a description of what ",
163 "parts of the scorelist you want to see. You might for example say: ",
164 "`endgame:own scores/5 top scores/4 around my score'." );
167 pline("Bad option: %s.", opts
);
168 pline("Type `o help<cr>' for help.");
171 puts("Bad syntax in HACKOPTIONS.");
172 puts("Use for example:");
174 "HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\""
183 pline("What options do you want to set? ");
185 if(!buf
[0] || buf
[0] == '\033') {
186 (void) strcpy(buf
,"HACKOPTIONS=");
187 (void) strcat(buf
, flags
.female
? "female," : "male,");
188 if(flags
.standout
) (void) strcat(buf
,"standout,");
189 if(flags
.nonull
) (void) strcat(buf
,"nonull,");
190 if(flags
.nonews
) (void) strcat(buf
,"nonews,");
191 if(flags
.time
) (void) strcat(buf
,"time,");
192 if(flags
.notombstone
) (void) strcat(buf
,"notombstone,");
193 if(flags
.no_rest_on_space
)
194 (void) strcat(buf
,"!rest_on_space,");
195 if(flags
.end_top
!= 5 || flags
.end_around
!= 4 || flags
.end_own
){
196 (void) sprintf(eos(buf
), "endgame: %u topscores/%u around me",
197 flags
.end_top
, flags
.end_around
);
198 if(flags
.end_own
) (void) strcat(buf
, "/own scores");
200 register char *eop
= eos(buf
);
201 if(*--eop
== ',') *eop
= 0;
205 parseoptions(buf
, FALSE
);