Mercurial > hg > early-roguelike
annotate rogue3/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 |
---|---|
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 to deal with the pack |
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 * @(#)pack.c 3.6 (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 <ctype.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 #include "rogue.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 |
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 * add_pack: |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 * Pick up an object and add it to the pack. If the argument is non-null |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 * use it as the linked_list pointer instead of gettting it off the ground. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
22 void |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
23 add_pack(struct linked_list *item, int silent) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
24 { |
180 | 25 struct linked_list *ip, *lp = NULL; |
26 struct object *obj, *op = NULL; | |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
27 int exact, from_floor; |
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 if (item == NULL) |
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 from_floor = TRUE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
32 if ((item = find_obj(hero.y, hero.x)) == NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
33 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
34 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
35 else |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
36 from_floor = FALSE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 obj = (struct object *) ldata(item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 * Link it into the pack. Search the pack for a object of similar type |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
40 * if there isn't one, stuff it at the beginning, if there is, look for one |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
41 * that is exactly the same and just increment the count if there is. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
42 * it that. Food is always put at the beginning for ease of access, but |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 * is not ordered so that you can't tell good food from bad. First check |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 * to see if there is something in thr same group and if there is then |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 * increment the count. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 if (obj->o_group) |
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 for (ip = pack; ip != NULL; ip = next(ip)) |
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 op = (struct object *) ldata(ip); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
52 if (op->o_group == obj->o_group) |
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 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 * Put it in the pack and notify the user |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 op->o_count++; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 if (from_floor) |
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 detach(lvl_obj, item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 mvaddch(hero.y, hero.x, |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 (roomin(&hero) == NULL ? PASSAGE : FLOOR)); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
63 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 discard(item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
65 item = ip; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
66 goto picked_up; |
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 } |
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 * Check if there is room |
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 if (inpack == MAXPACK-1) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
74 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
75 msg("You can't carry anything else."); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
76 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
77 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
78 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
79 * Check for and deal with scare monster scrolls |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
80 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
81 if (obj->o_type == SCROLL && obj->o_which == S_SCARE) |
304 | 82 { |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
83 if (obj->o_flags & ISFOUND) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
84 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
85 msg("The scroll turns to dust as you pick it up."); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
86 detach(lvl_obj, item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
87 mvaddch(hero.y, hero.x, FLOOR); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 return; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
89 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
90 else |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 obj->o_flags |= ISFOUND; |
304 | 92 } |
0
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 inpack++; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
95 if (from_floor) |
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 detach(lvl_obj, item); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
98 mvaddch(hero.y, hero.x, (roomin(&hero) == NULL ? PASSAGE : FLOOR)); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 } |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
100 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
101 * Search for an object of the same type |
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 exact = FALSE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
104 for (ip = pack; ip != NULL; ip = next(ip)) |