annotate urogue/rooms.c @ 292:ebf49a933e51

UltraRogue: ask about unidentified magic items by default.
author John "Elwin" Edwards
date Fri, 29 Dec 2017 14:16:24 -0500
parents c495a4f288c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
256
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2 rooms.c - Draw the nine rooms on the screen
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
4 UltraRogue: The Ultimate Adventure in the Dungeons of Doom
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
5 Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
6 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
7
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
8 Based on "Advanced Rogue"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
10 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
11
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
12 Based on "Rogue: Exploring the Dungeons of Doom"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
14 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
15
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
16 See the file LICENSE.TXT for full copyright and licensing information.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
17 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
18
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
19 #include <stdlib.h>
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
20 #include "rogue.h"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
21
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
22 void
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
23 do_rooms(void)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
24 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
25 int i;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
26 struct room *rp;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
27 struct linked_list *item;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
28 struct thing *tp;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
29 int left_out;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
30 coord top;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
31 coord bsze;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
32 coord mp;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
33
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
34 /* bsze is the maximum room size */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
35
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
36 bsze.x = COLS / 3;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
37 bsze.y = (LINES - 2) / 3;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
38
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
39 /* Clear things for a new level */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
40
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
41 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
42 rp->r_nexits = rp->r_flags = rp->r_fires = 0;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
43
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
44 /* Put the gone rooms, if any, on the level */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
45
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
46 left_out = rnd(3);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
47
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
48 for (i = 0; i < left_out; i++)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
49 rooms[rnd_room()].r_flags |= ISGONE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
50
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
51 /* dig and populate all the rooms on the level */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
52
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
53 for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
54 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
55 int has_gold = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
56
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
57 /* Find upper left corner of box that this room goes in */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
58
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
59 top.x = (i % 3) * bsze.x;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
60 top.y = i / 3 * bsze.y + 1;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
61
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
62 if (rp->r_flags & ISGONE)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
63 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
64 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
65 * Place a gone room. Make certain that there is a
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
66 * blank line for passage drawing.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
67 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
68
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
69 do
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
70 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
71 rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
72 rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
73 rp->r_max.x = -COLS;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
74 rp->r_max.x = -LINES;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
75 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
76 while (rp->r_pos.y < 1 || rp->r_pos.y > LINES - 3);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
77
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
78 continue;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
79 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
80
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
81 if (rnd(40) < level - 5)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
82 rp->r_flags |= ISDARK;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
83
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
84 /* Find a place and size for a random room */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
85
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
86 do
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 rp->r_max.x = rnd(bsze.x - 4) + 4;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
89 rp->r_max.y = rnd(bsze.y - 4) + 4;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90 rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 while (rp->r_pos.y == 0);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff