annotate rogue5/misc.c @ 69:88dc6813e36a

arogue5: update the score list before prompting to exit.
author elwin
date Sat, 11 Aug 2012 20:58:24 +0000
parents f502bf60e6e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * All sorts of miscellaneous routines
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * @(#)misc.c 4.66 (Berkeley) 08/06/83
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * Rogue: Exploring the Dungeons of Doom
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * All rights reserved.
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 *
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * See the file LICENSE.TXT for full copyright and licensing information.
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 #include <stdlib.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 #include <curses.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 #include <string.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16 #include <ctype.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 #include "rogue.h"
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 * look:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 * A quick glance all around the player
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 #undef DEBUG
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 look(int wakeup)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 int x, y;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 chtype ch;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 THING *tp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 PLACE *pp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 struct room *rp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 int ey, ex;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 int passcount;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 int pfl, *fp, pch;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 int sy, sx, sumhero = 0, diffhero = 0;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 # ifdef DEBUG
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 static int done = FALSE;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 if (done)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 return;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 done = TRUE;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 # endif /* DEBUG */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 passcount = 0;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 rp = proom;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 if (!ce(oldpos, hero))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49 erase_lamp(&oldpos, oldrp);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 oldpos = hero;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 oldrp = rp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 ey = hero.y + 1;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
54 ex = hero.x + 1;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 sx = hero.x - 1;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 sy = hero.y - 1;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 if (door_stop && !firstmove && running)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 sumhero = hero.y + hero.x;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 diffhero = hero.y - hero.x;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 pp = INDEX(hero.y, hero.x);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 pch = pp->p_ch;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64 pfl = pp->p_flags;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
66 for (y = sy; y <= ey; y++)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 if (y > 0 && y < NUMLINES - 1) for (x = sx; x <= ex; x++)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
68 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69 if (x < 0 || x >= NUMCOLS)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 if (!on(player, ISBLIND))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 if (y == hero.y && x == hero.x)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
74 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
77 pp = INDEX(y, x);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78 ch = pp->p_ch;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 if (ch == ' ') /* nothing need be done with a ' ' */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 fp = &pp->p_flags;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 if (pch != DOOR && ch != DOOR)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 if ((pfl & F_PASS) != (*fp & F_PASS))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 if (((*fp & F_PASS) || ch == DOOR) &&
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 ((pfl & F_PASS) || pch == DOOR))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 if (hero.x != x && hero.y != y &&
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 !step_ok(chat(y, hero.x)) && !step_ok(chat(hero.y, x)))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 if ((tp = pp->p_monst) == NULL)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 ch = trip_ch(y, x, ch);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 else
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96 if (on(player, SEEMONST) && on(*tp, ISINVIS))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98 if (door_stop && !firstmove)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 running = FALSE;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 continue;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 else
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
103 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
104 if (wakeup)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
105 wake_monster(y, x);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
106 if (see_monst(tp))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
107 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
108 if (on(player, ISHALU))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
109 ch = rnd(26) + 'A';
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents: