]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.options.c
1 /* $NetBSD: hack.options.c,v 1.4 1997/10/19 16:58:42 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.options.c,v 1.4 1997/10/19 16:58:42 christos Exp $");
21 flags
.time
= flags
.nonews
= flags
.notombstone
= flags
.end_own
=
22 flags
.standout
= flags
.nonull
= FALSE
;
23 flags
.no_rest_on_space
= TRUE
;
24 flags
.invlet_constant
= TRUE
;
27 flags
.female
= FALSE
; /* players are usually male */
29 if ((opts
= getenv("HACKOPTIONS")) != NULL
)
30 parseoptions(opts
, TRUE
);
34 parseoptions(opts
, from_env
)
42 if ((op
= strchr(opts
, ',')) != NULL
) {
44 parseoptions(op
, from_env
);
46 if ((op
= strchr(opts
, ' ')) != NULL
) {
55 while ((*opts
== '!') || !strncmp(opts
, "no", 2)) {
63 if (!strncmp(opts
, "standout", 8)) {
64 flags
.standout
= !negated
;
67 if (!strncmp(opts
, "null", 3)) {
68 flags
.nonull
= negated
;
71 if (!strncmp(opts
, "tombstone", 4)) {
72 flags
.notombstone
= negated
;
75 if (!strncmp(opts
, "news", 4)) {
76 flags
.nonews
= negated
;
79 if (!strncmp(opts
, "time", 4)) {
80 flags
.time
= !negated
;
84 if (!strncmp(opts
, "restonspace", 4)) {
85 flags
.no_rest_on_space
= negated
;
88 if (!strncmp(opts
, "fixinv", 4)) {
90 flags
.invlet_constant
= !negated
;
92 pline("The fixinvlet option must be in HACKOPTIONS.");
95 if (!strncmp(opts
, "male", 4)) {
96 flags
.female
= negated
;
99 if (!strncmp(opts
, "female", 6)) {
100 flags
.female
= !negated
;
104 if (!strncmp(opts
, "name", 4)) {
106 pline("The playername can be set only from HACKOPTIONS.");
109 op
= strchr(opts
, ':');
112 (void) strncpy(plname
, op
+ 1, sizeof(plname
) - 1);
115 /* endgame:5t[op] 5a[round] o[wn] */
116 if (!strncmp(opts
, "endgame", 3)) {
117 op
= strchr(opts
, ':');
124 /*###124 [cc] warning: implicit declaration of function `atoi'%%%*/
128 } else if (*op
== '!') {
137 flags
.end_around
= num
;
140 flags
.end_own
= !negated
;
145 while (letter(*++op
));
153 if (!strncmp(opts
, "help", 4)) {
155 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
156 "give the command 'o' followed by the line `<options>' while playing. ",
157 "Here <options> is a list of <option>s separated by commas.");
159 "Simple (boolean) options are rest_on_space, news, time, ",
160 "null, tombstone, (fe)male. ",
161 "These can be negated by prefixing them with '!' or \"no\".");
163 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\".");
165 "A compound option is endgame; it is followed by a description of what ",
166 "parts of the scorelist you want to see. You might for example say: ",
167 "`endgame:own scores/5 top scores/4 around my score'.");
170 pline("Bad option: %s.", opts
);
171 pline("Type `o help<cr>' for help.");
174 puts("Bad syntax in HACKOPTIONS.");
175 puts("Use for example:");
177 "HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\""
187 pline("What options do you want to set? ");
189 if (!buf
[0] || buf
[0] == '\033') {
190 (void) strcpy(buf
, "HACKOPTIONS=");
191 (void) strcat(buf
, flags
.female
? "female," : "male,");
193 (void) strcat(buf
, "standout,");
195 (void) strcat(buf
, "nonull,");
197 (void) strcat(buf
, "nonews,");
199 (void) strcat(buf
, "time,");
200 if (flags
.notombstone
)
201 (void) strcat(buf
, "notombstone,");
202 if (flags
.no_rest_on_space
)
203 (void) strcat(buf
, "!rest_on_space,");
204 if (flags
.end_top
!= 5 || flags
.end_around
!= 4 || flags
.end_own
) {
205 (void) sprintf(eos(buf
), "endgame: %u topscores/%u around me",
206 flags
.end_top
, flags
.end_around
);
208 (void) strcat(buf
, "/own scores");
210 char *eop
= eos(buf
);
216 parseoptions(buf
, FALSE
);