annotate rogue5/daemons.c @ 291:5b6855d5d089

Fix a portability issue with md_hasclreol(). Some games' implementation of md_hasclreol() poked around in ncurses internals, which does not work for some ncurses build configuration. Most games did not actually call md_hasclreol(), so it was removed. There is a standard terminfo function which can retrieve the value of the clr_eol capability, so this was used for rogue5.
author John "Elwin" Edwards
date Wed, 27 Dec 2017 10:26:06 -0500
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 the daemon and fuse functions are in here
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 * @(#)daemons.c 4.24 (Berkeley) 02/05/99
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 <curses.h>
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 #include "rogue.h"
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 * doctor:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 * A healing daemon that restors hit points after rest
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 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 doctor(void)
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 int lv, ohp;
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 lv = pstats.s_lvl;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 ohp = pstats.s_hpt;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 quiet++;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 if (lv < 8)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 if (quiet + (lv << 1) > 20)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 pstats.s_hpt++;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 else
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 if (quiet >= 3)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 pstats.s_hpt += rnd(lv - 7) + 1;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 if (ISRING(LEFT, R_REGEN))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 pstats.s_hpt++;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 if (ISRING(RIGHT, R_REGEN))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 pstats.s_hpt++;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 if (ohp != pstats.s_hpt)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 if (pstats.s_hpt > max_hp)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 pstats.s_hpt = max_hp;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 quiet = 0;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47
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 * Swander:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 * Called when it is time to start rolling for wandering monsters
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 swander(void)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
54 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 start_daemon(rollwand, 0, BEFORE);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57
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 * rollwand:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 * Called to roll to see if a wandering monster starts up
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
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64 rollwand(void)
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
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 if (++between >= 4)
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 (roll(1, 6) == 4)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 wanderer();
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 kill_daemon(rollwand);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 fuse(swander, 0, WANDERTIME, BEFORE);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
74 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 between = 0;
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 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 * unconfuse:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 * Release the poor player from his confusion
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 unconfuse(void)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 player.t_flags &= ~ISHUH;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87 msg("you feel less %s now", choose_str("trippy", "confused"));
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 }
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 * unsee:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92 * Turn off the ability to see invisible
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 */
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 void
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 unsee(void)
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96 {
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 THING *th;
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 for (th = mlist; th != NULL; th = next(th))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 if (on(*th, ISINVIS) && see_monst(th))
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101 mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch);
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 player.t_flags &= ~CANSEE;
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
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
105 /*
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
106 * sight:
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
107 * He gets his sight back
f502bf60e6e4 Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset