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 $ */
7 static void parseoptions(char *, bool);
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);
27 parseoptions(char *opts, bool from_env)
33 if ((op = strchr(opts, ',')) != NULL) {
35 parseoptions(op, from_env);
37 if ((op = strchr(opts, ' ')) != NULL) {
46 while ((*opts == '!') || !strncmp(opts, "no", 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)) {
105 pline("The playername can be set only from HACKOPTIONS.");
108 op = strchr(opts, ':');
111 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, ':');
127 } else if (*op == '!') {
136 flags.end_around = num;
139 flags.end_own = !negated;
144 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:");
176 puts("HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\"");
185 pline("What options do you want to set? ");
187 if (!buf[0] || buf[0] == '\033') {
188 strcpy(buf, "HACKOPTIONS=");
189 strcat(buf, flags.female ? "female," : "male,");
191 strcat(buf, "standout,");
193 strcat(buf, "nonull,");
195 strcat(buf, "nonews,");
197 strcat(buf, "time,");
198 if (flags.notombstone)
199 strcat(buf, "notombstone,");
200 if (flags.no_rest_on_space)
201 strcat(buf, "!rest_on_space,");
202 if (flags.end_top != 5 || flags.end_around != 4 || flags.end_own) {
203 sprintf(eos(buf), "endgame: %u topscores/%u around me",
204 flags.end_top, flags.end_around);
206 strcat(buf, "/own scores");
208 char *eop = eos(buf);
214 parseoptions(buf, FALSE);