Mercurial > hg > early-roguelike
annotate rogue3/rings.c @ 215:1b73a8641b37
rogue4: fix most GCC5 warnings.
Converting all function definitions to ANSI style accounts for most of
the change. This has exposed other problems, such as daemons not
actually being their stated type, that will require more careful
solutions.
author | John "Elwin" Edwards |
---|---|
date | Wed, 27 Jan 2016 19:41:05 -0500 |
parents | 527e2150eaf0 |
children |
rev | line source |
---|---|
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
1 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
2 * routines dealing specifically with rings |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
3 * |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
4 * @(#)rings.c 3.17 (Berkeley) 6/15/81 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
5 * |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
8 * All rights reserved. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
9 * |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
11 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
12 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
13 #include "curses.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
14 #include <stdlib.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 #include <string.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 #include "rogue.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
17 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
18 void |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 ring_on() |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 struct object *obj; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
22 struct linked_list *item; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
23 int ring; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
24 str_t save_max; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
25 char buf[80]; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
26 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
27 item = get_item("put on", RING); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
28 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
29 * Make certain that it is somethings that we want to wear |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
30 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
31 if (item == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
32 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
33 obj = (struct object *) ldata(item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
34 if (obj->o_type != RING) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
35 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
36 if (!terse) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 msg("It would be difficult to wrap that around a finger"); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 else |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 msg("Not a ring"); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
40 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
41 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
42 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 * find out which hand to put it on |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 if (is_current(obj)) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
48 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
49 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
50 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
51 if ((ring = gethand()) < 0) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
52 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
53 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
54 else if (cur_ring[LEFT] == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 ring = LEFT; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 else if (cur_ring[RIGHT] == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 ring = RIGHT; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 else |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
59 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
60 if (!terse) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 msg("You already have a ring on each hand"); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 else |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
63 msg("Wearing two"); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
65 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
66 cur_ring[ring] = obj; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
67 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
68 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
69 * Calculate the effect it has on the poor guy. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
70 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
71 switch (obj->o_which) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
72 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
73 case R_ADDSTR: |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
74 save_max = max_stats.s_str; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
75 chg_str(obj->o_ac); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
76 max_stats.s_str = save_max; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
77 break; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
78 case R_SEEINVIS: |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
79 player.t_flags |= CANSEE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
80 light(&hero); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
81 mvwaddch(cw, hero.y, hero.x, PLAYER); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
82 break; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
83 case R_AGGR: |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
84 aggravate(); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
85 break; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
86 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
87 status(); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
89 if (obj->o_which >= MAXRINGS) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
90 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
92 if (r_know[obj->o_which] && r_guess[obj->o_which]) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
93 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
94 free(r_guess[obj->o_which]); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
95 r_guess[obj->o_which] = NULL; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
96 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
97 else if (!r_know[obj->o_which] && askme && r_guess[obj->o_which] == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
98 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 mpos = 0; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
100 msg(terse ? "Call it: " : "What do you want to call it? "); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
101 if (get_str(buf, cw) == NORM) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
102 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
103 r_guess[obj->o_which] = malloc(strlen(buf) + 1); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
104 if (r_guess[obj->o_which] != NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
105 strcpy(r_guess[obj->o_which], buf); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
106 } |