Mercurial > hg > early-roguelike
annotate arogue5/maze.c @ 290:2b452dbf0138
UltraRogue: fix options menu.
When displaying options, get_restr() did not position the cursor
correctly, resulting in values being duplicated.
author | John "Elwin" Edwards |
---|---|
date | Sun, 26 Nov 2017 11:34:45 -0500 |
parents | 56e748983fa8 |
children | 0250220d8cdd |
rev | line source |
---|---|
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
1 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
2 * maze |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * Advanced Rogue |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
8 * Based on "Super-Rogue" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * Copyright (C) 1984 Robert D. Kindelberger |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
12 * See the file LICENSE.TXT for full copyright and licensing information. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
13 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
14 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
15 #include <stdlib.h> |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
16 #include "curses.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
17 #include "rogue.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
18 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
19 struct cell { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 char y_pos; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
21 char x_pos; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
22 }; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
23 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
24 struct bordercells { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
25 char num_pos; /* number of frontier cells next to you */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
26 struct cell conn[4]; /* the y,x position of above cell */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
27 } border_cells; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
28 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
29 static char *frontier, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
30 *bits; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
31 static int maze_lines, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
32 maze_cols; |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
33 |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
34 void draw_maze(void); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
35 int findcells(int y, int x); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
36 char *foffset(int y, int x); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
37 char *moffset(int y, int x); |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
38 void rmwall(int newy, int newx, int oldy, int oldx); |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
42 * crankout: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
43 * Does actual drawing of maze to window |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 */ |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
45 void |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
46 crankout(void) |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 reg int x, y; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 for (y = 0; y < LINES - 3; y++) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 move(y + 1, 0); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 for (x = 0; x < COLS - 1; x++) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 if (*moffset(y, x)) { /* here is a wall */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 if(y==0 || y==LINES-4) /* top or bottom line */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 addch('-'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
56 else if(x==0 || x==COLS-2) /* left | right side */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
57 addch('|'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 else if (y % 2 == 0 && x % 2 == 0) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 if(*moffset(y, x-1) || *moffset(y, x+1)) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 addch('-'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 else |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 addch('|'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
63 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 else if (y % 2 == 0) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 addch('-'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 else |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
67 addch('|'); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
69 else |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 addch(FLOOR); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
76 * domaze: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
77 * Draw the maze on this level. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
78 */ |
218
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
79 void |
56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents:
63
diff
changeset
|
80 do_maze(void) |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
81 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
82 reg int least; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
83 reg struct room *rp; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
84 reg struct linked_list *item; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
85 reg struct object *obj; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
86 int cnt; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
87 bool treas; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
88 coord tp; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
89 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
90 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
91 rp->r_flags = ISGONE; /* kill all rooms */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
92 rp->r_fires = NULL; /* no fires */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
93 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
94 rp = &rooms[0]; /* point to only room */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
95 rp->r_flags = ISDARK; /* mazes always dark */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
96 rp->r_pos.x = 0; /* room fills whole screen */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
97 rp->r_pos.y = 1; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
98 rp->r_max.x = COLS - 1; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
99 rp->r_max.y = LINES - 3; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
100 draw_maze(); /* put maze into window */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
101 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
102 * add some gold to make it worth looking for |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
103 */ |
218 |