-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisply.c
190 lines (165 loc) · 3.05 KB
/
disply.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* various display routines and flag checking functions
*
* @(#)disply.c 9.0 (rdk) 7/17/84
*
* Super-Rogue
* Copyright (C) 1984 Robert D. Kindelberger
* All rights reserved.
*
* See the file LICENSE.TXT for full copyright and licensing information.
*/
#include <ctype.h>
#include <curses.h>
#include <stddef.h>
#include "rogue.h"
#include "rogue.ext"
/*
* displevl:
* Display detailed level for wizard and scroll
*/
void displevl()
{
unsigned long ch, mch;
int i,j;
struct room *rp;
for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
rp->r_flags &= ~ISDARK;
for (i = 0; i < LINES - 2; i++) {
for (j = 0; j < COLS - 1; j++) {
ch = mvinch(i,j);
if (isatrap(ch)) {
struct trap *what;
what = trap_at(i, j);
if (what != NULL)
what->tr_flags |= ISFOUND;
}
else if (ch == SECRETDOOR) {
ch = DOOR;
mvaddch(i, j, ch);
}
else if (illeg_ch(ch)) {
ch = FLOOR;
mvaddch(i, j, ch);
}
if (mvwinch(mw, i, j) != ' ') {
struct linked_list *what;
struct thing *it;
what = find_mons(i, j);
if (what == NULL) {
ch = FLOOR;
mvaddch(i, j, ch);
}
else {
it = THINGPTR(what);
it->t_oldch = ch;
}
}
mch = mvwinch(cw, i, j);
if (isalpha(mch))
ch = mch;
mvwaddch(cw, i, j, ch);
}
}
nochange = FALSE; /* display status again */
draw(cw);
}
/*
* dispmons:
* Show monsters for wizard and potion
*/
void dispmons()
{
int ch, y, x;
struct thing *it;
struct linked_list *item;
for (item = mlist; item != NULL; item = next(item)) {
it = THINGPTR(item);
y = it->t_pos.y;
x = it->t_pos.x;
mvwaddch(cw, y, x, it->t_type);
it->t_flags |= ISFOUND;
if (it->t_type == 'M') /* if a mimic */
it->t_disguise = 'M'; /* give it away */
}
draw(cw);
}
/*
* winat:
* Get whatever character is at a location on the screen
*/
char winat(int y,int x)
{
unsigned long ch;
if (mvwinch(mw,y,x) == ' ')
ch = mvinch(y, x); /* non-monsters */
else
ch = winch(mw); /* monsters */
return ch;
}
/*
* cordok:
* Returns TRUE if coordinate is on usable screen
*/
bool cordok(int y,int x)
{
if (x < 0 || y < 0 || x >= COLS || y >= LINES - 1)
return FALSE;
return TRUE;
}
/*
* pl_on:
* Returns TRUE if the player's flag is set
*/
bool pl_on(long what)
{
return (player.t_flags & what);
}
/*
* pl_off:
* Returns TRUE when player's flag is reset
*/
bool pl_off(long what)
{
return (!(player.t_flags & what));
}
/*
* o_on:
* Returns TRUE in the objects flag is set
*/
bool o_on(struct object *what,long bit)
{
int flag;
flag = FALSE;
if (what != NULL)
flag = (what->o_flags & bit);
return flag;
}
/*
* o_off:
* Returns TRUE is the objects flag is reset
*/
bool o_off(struct object *what,long bit)
{
int flag;
flag = FALSE;
if (what != NULL)
flag = !(what->o_flags & bit);
return flag;
}
/*
* setoflg:
* Set the specified flag for the object
*/
void setoflg(struct object *what,long bit)
{
what->o_flags |= bit;
}
/*
* resoflg:
* Reset the specified flag for the object
*/
void resoflg(struct object *what,long bit)
{
what->o_flags &= ~bit;
}