4 * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
5 * Copyright (c) 2017 by Eric S. Raymond
6 * SPDX-License-Identifier: BSD-2-clause
17 struct settings_t settings = {
23 struct game_t game = {
24 .dloc[1] = LOC_KINGHALL,
25 .dloc[2] = LOC_WESTBANK,
27 .dloc[4] = LOC_ALIKE3,
28 .dloc[5] = LOC_COMPLEX,
30 /* Sixth dwarf is special (the pirate). He always starts at his
31 * chest's eventual location inside the maze. This loc is saved
32 * in chloc for ref. The dead end in the other maze has its
33 * loc stored in chloc2. */
34 .dloc[6] = LOC_MAZEEND12,
35 .chloc = LOC_MAZEEND12,
36 .chloc2 = LOC_DEADEND13,
48 if (settings.oldstyle)
49 printf("Initialising...\n");
52 int seedval = (int)rand();
55 for (int i = 1; i <= NOBJECTS; i++) {
56 game.place[i] = LOC_NOWHERE;
59 for (int i = 1; i <= NLOCATIONS; i++) {
60 if (!(locations[i].description.big == 0 ||
63 if (travel[k].motion == HERE)
64 conditions[i] |= (1 << COND_FORCED);
68 /* Set up the game.atloc and game.link arrays.
69 * We'll use the DROP subroutine, which prefaces new objects on the
70 * lists. Since we want things in the other order, we'll run the
71 * loop backwards. If the object is in two locs, we drop it twice.
72 * Also, since two-placed objects are typically best described
73 * last, we'll drop them first. */
74 for (int i = NOBJECTS; i >= 1; i--) {
75 if (objects[i].fixd > 0) {
76 drop(i + NOBJECTS, objects[i].fixd);
77 drop(i, objects[i].plac);
81 for (int i = 1; i <= NOBJECTS; i++) {
82 int k = NOBJECTS + 1 - i;
83 game.fixed[k] = objects[k].fixd;
84 if (objects[k].plac != 0 && objects[k].fixd <= 0)
85 drop(k, objects[k].plac);
88 /* Treasure props are initially -1, and are set to 0 the first time
89 * they are described. game.tally keeps track of how many are
90 * not yet found, so we know when to close the cave. */
91 for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
92 if (objects[treasure].is_treasure) {
93 if (objects[treasure].inventory != 0)
94 game.prop[treasure] = STATE_NOTFOUND;
95 game.tally = game.tally - game.prop[treasure];
98 game.conds = setbit(COND_HBASE);