Mercurial > hg > early-roguelike
annotate rogue4/pack.c @ 317:aab761616489 default tip
Rearrange some Autoconf files.
Autoconf was failing to detect install-sh at the top level and needed
some explicit directions. It also wants config.guess and config.sub to
be provided too.
A few other macros have also been updated.
author | John "Elwin" Edwards |
---|---|
date | Tue, 05 Sep 2023 20:05:24 -0400 |
parents | e52a8a7ad4c5 |
children |
rev | line source |
---|---|
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
1 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
2 * Routines to deal with the pack |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
3 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
4 * @(#)pack.c 4.15 (Berkeley) 4/6/82 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
5 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
8 * All rights reserved. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
9 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
11 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
12 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
13 #include <curses.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
14 #include <ctype.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 #include "rogue.h" |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 |
215 | 17 void money(int value); |
18 | |
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 * update_mdest: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 * Called after picking up an object, before discarding it. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
22 * If this was the object of something's desire, that monster will |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
23 * get mad and run at the hero |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
24 */ |
215 | 25 void |
26 update_mdest(THING *obj) | |
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
27 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
28 register THING *mp; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
29 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
30 for (mp = mlist; mp != NULL; mp = next(mp)) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
31 if (mp->t_dest == &obj->o_pos) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
32 mp->t_dest = &hero; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
33 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
34 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
35 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
36 * add_pack: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 * Pick up an object and add it to the pack. If the argument is |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 * non-null use it as the linked_list pointer instead of gettting |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 * it off the ground. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
40 */ |
215 | 41 void |
42 add_pack(THING *obj, bool silent) | |
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 register THING *op, *lp = NULL; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 register bool exact, from_floor; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 register char floor; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 int discarded = 0; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
48 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
49 if (obj == NULL) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
50 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
51 from_floor = TRUE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
52 if ((obj = find_obj(hero.y, hero.x)) == NULL) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
53 return; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
54 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 from_floor = FALSE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 * Link it into the pack. Search the pack for a object of similar type |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
59 * if there isn't one, stuff it at the beginning, if there is, look for one |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
60 * that is exactly the same and just increment the count if there is. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 * it that. Food is always put at the beginning for ease of access, but |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 * is not ordered so that you can't tell good food from bad. First check |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
63 * to see if there is something in thr same group and if there is then |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 * increment the count. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
65 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
66 /* floor = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
67 if (proom) floor = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
68 else floor = FLOOR; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
69 if (obj->o_group) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
70 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
71 for (op = pack; op != NULL; op = next(op)) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
72 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
73 if (op->o_group == obj->o_group) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
74 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
75 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
76 * Put it in the pack and notify the user |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
77 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
78 op->o_count++; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
79 if (from_floor) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
80 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
81 detach(lvl_obj, obj); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
82 mvaddch(hero.y, hero.x, floor); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
83 chat(hero.y, hero.x) = floor; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
84 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
85 update_mdest(obj); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
86 discard(obj); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
87 obj = op; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 discarded = 1; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
89 goto picked_up; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
90 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
92 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
93 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
94 * Check if there is room |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
95 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
96 if (inpack == MAXPACK-1) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
97 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
98 msg("you can't carry anything else"); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 return; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
100 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
101 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
102 * Check for and deal with scare monster scrolls |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
103 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
104 if (obj->o_type == SCROLL && obj->o_which == S_SCARE) |