4 * SPDX-FileCopyrightText: 1977, 2005 by Will Crowther and Don Woods
5 * SPDX-FileCopyrightText: 2017 by Eric S. Raymond
6 * SPDX-License-Identifier: BSD-2-Clause
17 struct settings_t settings = {
23 struct game_t game = {
24 .dwarves[1].loc = LOC_KINGHALL,
25 .dwarves[2].loc = LOC_WESTBANK,
26 .dwarves[3].loc = LOC_Y2,
27 .dwarves[4].loc = LOC_ALIKE3,
28 .dwarves[5].loc = 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 .dwarves[6].loc = 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.objects[i].place = LOC_NOWHERE;
59 for (int i = 1; i <= NLOCATIONS; i++) {
60 if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
62 if (travel[k].motion == HERE)
63 conditions[i] |= (1 << COND_FORCED);
67 /* Set up the game.locs atloc and game.link arrays.
68 * We'll use the DROP subroutine, which prefaces new objects on the
69 * lists. Since we want things in the other order, we'll run the
70 * loop backwards. If the object is in two locs, we drop it twice.
71 * Also, since two-placed objects are typically best described
72 * last, we'll drop them first. */
73 for (int i = NOBJECTS; i >= 1; i--) {
74 if (objects[i].fixd > 0) {
75 drop(i + NOBJECTS, objects[i].fixd);
76 drop(i, objects[i].plac);
80 for (int i = 1; i <= NOBJECTS; i++) {
81 int k = NOBJECTS + 1 - i;
82 game.objects[k].fixed = objects[k].fixd;
83 if (objects[k].plac != 0 && objects[k].fixd <= 0)
84 drop(k, objects[k].plac);
87 /* Treasure props are initially STATE_NOTFOUND, and are set to
88 * STATE_FOUND the first time they are described. game.tally
89 * keeps track of how many are not yet found, so we know when to
91 for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
92 if (objects[treasure].is_treasure) {
94 if (objects[treasure].inventory != 0)
95 PROP_SET_NOT_FOUND(treasure);
98 game.conds = setbit(COND_HBASE);