4 * SPDX-FileCopyrightText: Copright 1977, 2005 by Will Crowther and Don Woodsm, Copyright 2017 by Eric S. Raymond
5 * SPDX-License-Identifier: BSD-2-Clause
17 struct settings_t settings = {
23 struct game_t game = {
24 /* Last dwarf is special (the pirate). He always starts at his
25 * chest's eventual location inside the maze. This loc is saved
26 * in chloc for ref. The dead end in the other maze has its
27 * loc stored in chloc2. */
28 .chloc = LOC_MAZEEND12,
29 .chloc2 = LOC_DEADEND13,
41 if (settings.oldstyle)
42 printf("Initialising...\n");
45 int seedval = (int)rand();
48 for (int i = 1; i <= NDWARVES; i++) {
49 game.dwarves[i].loc = dwarflocs[i-1];
52 for (int i = 1; i <= NOBJECTS; i++) {
53 game.objects[i].place = LOC_NOWHERE;
56 for (int i = 1; i <= NLOCATIONS; i++) {
57 if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
59 if (travel[k].motion == HERE)
60 conditions[i] |= (1 << COND_FORCED);
64 /* Set up the game.locs atloc and game.link arrays.
65 * We'll use the DROP subroutine, which prefaces new objects on the
66 * lists. Since we want things in the other order, we'll run the
67 * loop backwards. If the object is in two locs, we drop it twice.
68 * Also, since two-placed objects are typically best described
69 * last, we'll drop them first. */
70 for (int i = NOBJECTS; i >= 1; i--) {
71 if (objects[i].fixd > 0) {
72 drop(i + NOBJECTS, objects[i].fixd);
73 drop(i, objects[i].plac);
77 for (int i = 1; i <= NOBJECTS; i++) {
78 int k = NOBJECTS + 1 - i;
79 game.objects[k].fixed = objects[k].fixd;
80 if (objects[k].plac != 0 && objects[k].fixd <= 0)
81 drop(k, objects[k].plac);
84 /* Treasure props are initially STATE_NOTFOUND, and are set to
85 * STATE_FOUND the first time they are described. game.tally
86 * keeps track of how many are not yet found, so we know when to
88 for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
89 if (objects[treasure].is_treasure) {
91 if (objects[treasure].inventory != 0)
92 PROP_SET_NOT_FOUND(treasure);
95 game.conds = setbit(COND_HBASE);