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 $ */
4 /* $DragonFly: src/games/hack/hack.options.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
8 static void parseoptions(char *, bool);
15 flags.time = flags.nonews = flags.notombstone = flags.end_own =
16 flags.standout = flags.nonull = FALSE;
17 flags.no_rest_on_space = TRUE;
18 flags.invlet_constant = TRUE;
21 flags.female = FALSE; /* players are usually male */
23 if ((opts = getenv("HACKOPTIONS")))
24 parseoptions(opts,TRUE);
28 parseoptions(char *opts, bool from_env)
34 if ((op = strchr(opts, ',')) != NULL) {
36 parseoptions(op, from_env);
38 if ((op = strchr(opts, ' ')) != NULL) {
47 while ((*opts == '!') || !strncmp(opts, "no", 2)) {
55 if (!strncmp(opts, "standout", 8)) {
56 flags.standout = !negated;
60 if (!strncmp(opts, "null", 3)) {
61 flags.nonull = negated;
65 if (!strncmp(opts, "tombstone", 4)) {
66 flags.notombstone = negated;
70 if (!strncmp(opts, "news", 4)) {
71 flags.nonews = negated;
75 if (!strncmp(opts, "time", 4)) {
76 flags.time = !negated;
81 if (!strncmp(opts, "restonspace", 4)) {
82 flags.no_rest_on_space = negated;
86 if (!strncmp(opts, "fixinv", 4)) {
88 flags.invlet_constant = !negated;
90 pline("The fixinvlet option must be in HACKOPTIONS.");
94 if (!strncmp(opts, "male", 4)) {
95 flags.female = negated;
98 if (!strncmp(opts, "female", 6)) {
99 flags.female = !negated;
104 if (!strncmp(opts, "name", 4)) {
106 pline("The playername can be set only from HACKOPTIONS.");
109 op = strchr(opts, ':');
112 strncpy(plname, op + 1, sizeof(plname) - 1);
116 /* endgame:5t[op] 5a[round] o[wn] */
117 if (!strncmp(opts, "endgame", 3)) {
118 op = strchr(opts, ':');
128 } else if (*op == '!') {
137 flags.end_around = num;
140 flags.end_own = !negated;
145 while (letter(*++op))
154 if (!strncmp(opts, "help", 4)) {
156 "To set options use `HACKOPTIONS=\"<options>\"' in your environment, or ",
157 "give the command 'o' followed by the line `<options>' while playing. ",
158 "Here <options> is a list of <option>s separated by commas.");
160 "Simple (boolean) options are rest_on_space, news, time, ",
161 "null, tombstone, (fe)male. ",
162 "These can be negated by prefixing them with '!' or \"no\".");
164 "A string option is name, as in HACKOPTIONS=\"name:Merlin-W\".");
166 "A compound option is endgame; it is followed by a description of what ",
167 "parts of the scorelist you want to see. You might for example say: ",
168 "`endgame:own scores/5 top scores/4 around my score'.");
171 pline("Bad option: %s.", opts);
172 pline("Type `o help<cr>' for help.");
175 puts("Bad syntax in HACKOPTIONS.");
176 puts("Use for example:");
177 puts("HACKOPTIONS=\"!restonspace,notombstone,endgame:own/5 topscorers/4 around me\"");
186 pline("What options do you want to set? ");
188 if (!buf[0] || buf[0] == '\033') {
189 strcpy(buf, "HACKOPTIONS=");
190 strcat(buf, flags.female ? "female," : "male,");
192 strcat(buf, "standout,");
194 strcat(buf, "nonull,");
196 strcat(buf, "nonews,");
198 strcat(buf, "time,");
199 if (flags.notombstone)
200 strcat(buf, "notombstone,");
201 if (flags.no_rest_on_space)
202 strcat(buf, "!rest_on_space,");
203 if (flags.end_top != 5 || flags.end_around != 4 || flags.end_own) {
204 sprintf(eos(buf), "endgame: %u topscores/%u around me",
205 flags.end_top, flags.end_around);
207 strcat(buf, "/own scores");
209 char *eop = eos(buf);
215 parseoptions(buf, FALSE);