-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpack.c
398 lines (394 loc) · 8.59 KB
/
pack.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
//#include <curses.h>
//#include <ctype.h>
#include "rogue.h"
#include "things.h"
/*
* Routines to deal with the pack
*
* @(#)pack.c 3.6 (Berkeley) 6/15/81
*/
/*
* add_pack:
* Pick up an object and add it to the pack. If the argument is non-null
* use it as the linked_list pointer instead of gettting it off the ground.
*/
//add_pack(item, silent)
//register struct linked_list *item;
//bool silent;
//{
// register struct linked_list *ip, *lp;
// register struct object *obj, *op;
// register char ch;
// register bool exact, from_floor;
//
// if (item == NULL)
// {
// from_floor = TRUE;
// if ((item = find_obj(hero.y, hero.x)) == NULL)
// return;
// }
// else
// from_floor = FALSE;
// obj = (struct object *) ldata(item);
// /*
// * Link it into the pack. Search the pack for a object of similar type
// * if there isn't one, stuff it at the beginning, if there is, look for one
// * that is exactly the same and just increment the count if there is.
// * it that. Food is always put at the beginning for ease of access, but
// * is not ordered so that you can't tell good food from bad. First check
// * to see if there is something in thr same group and if there is then
// * increment the count.
// */
// if (obj->o_group)
// {
// for (ip = pack; ip != NULL; ip = next(ip))
// {
// op = (struct object *) ldata(ip);
// if (op->o_group == obj->o_group)
// {
// /*
// * Put it in the pack and notify the user
// */
// op->o_count++;
// if (from_floor)
// {
// detach(lvl_obj, item);
// mvaddch(hero.y, hero.x,
// (roomin(&hero) == NULL ? PASSAGE : FLOOR));
// }
// discard(item);
// item = ip;
// goto picked_up;
// }
// }
// }
// /*
// * Check if there is room
// */
// if (inpack == MAXPACK-1)
// {
// msg("You can't carry anything else.");
// return;
// }
// /*
// * Check for and deal with scare monster scrolls
// */
// if (obj->o_type == SCROLL && obj->o_which == S_SCARE)
// if (obj->o_flags & ISFOUND)
// {
// msg("The scroll turns to dust as you pick it up.");
// detach(lvl_obj, item);
// mvaddch(hero.y, hero.x, FLOOR);
// return;
// }
// else
// obj->o_flags |= ISFOUND;
//
// inpack++;
// if (from_floor)
// {
// detach(lvl_obj, item);
// mvaddch(hero.y, hero.x, (roomin(&hero) == NULL ? PASSAGE : FLOOR));
// }
// /*
// * Search for an object of the same type
// */
// exact = FALSE;
// for (ip = pack; ip != NULL; ip = next(ip))
// {
// op = (struct object *) ldata(ip);
// if (obj->o_type == op->o_type)
// break;
// }
// if (ip == NULL)
// {
// /*
// * Put it at the end of the pack since it is a new type
// */
// for (ip = pack; ip != NULL; ip = next(ip))
// {
// op = (struct object *) ldata(ip);
// if (op->o_type != FOOD)
// break;
// lp = ip;
// }
// }
// else
// {
// /*
// * Search for an object which is exactly the same
// */
// while (ip != NULL && op->o_type == obj->o_type)
// {
// if (op->o_which == obj->o_which)
// {
// exact = TRUE;
// break;
// }
// lp = ip;
// if ((ip = next(ip)) == NULL)
// break;
// op = (struct object *) ldata(ip);
// }
// }
// if (ip == NULL)
// {
// /*
// * Didn't find an exact match, just stick it here
// */
// if (pack == NULL)
// pack = item;
// else
// {
// lp->l_next = item;
// item->l_prev = lp;
// item->l_next = NULL;
// }
// }
// else
// {
// /*
// * If we found an exact match. If it is a potion, food, or a
// * scroll, increase the count, otherwise put it with its clones.
// */
// if (exact && ISMULT(obj->o_type))
// {
// op->o_count++;
// discard(item);
// item = ip;
// goto picked_up;
// }
// if ((item->l_prev = prev(ip)) != NULL)
// item->l_prev->l_next = item;
// else
// pack = item;
// item->l_next = ip;
// ip->l_prev = item;
// }
//picked_up:
// /*
// * Notify the user
// */
// obj = (struct object *) ldata(item);
// if (notify && !silent)
// {
// if (!terse)
// addmsg("You now have ");
// msg("%s (%c)", inv_name(obj, !terse), pack_char(obj));
// }
// if (obj->o_type == AMULET)
// amulet = TRUE;
//}
//
///*
// * inventory:
// * list what is in the pack
// */
//inventory(list, type)
//struct linked_list *list;
//int type;
//{
// register struct object *obj;
// register char ch;
// register int n_objs;
// char inv_temp[80];
//
// n_objs = 0;
// for (ch = 'a'; list != NULL; ch++, list = next(list))
// {
// obj = (struct object *) ldata(list);
// if (type && type != obj->o_type && !(type == CALLABLE &&
// (obj->o_type == SCROLL || obj->o_type == POTION ||
// obj->o_type == RING || obj->o_type == STICK)))
// continue;
// switch (n_objs++)
// {
// /*
// * For the first thing in the inventory, just save the string
// * in case there is only one.
// */
// case 0:
// sprintf(inv_temp, "%c) %s", ch, inv_name(obj, FALSE));
// break;
// /*
// * If there is more than one, clear the screen, print the
// * saved message and fall through to ...
// */
// case 1:
// if (slow_invent)
// msg(inv_temp);
// else
// {
// wclear(hw);
// waddstr(hw, inv_temp);
// waddch(hw, '\n');
// }
// /*
// * Print the line for this object
// */
// default:
// if (slow_invent)
// msg("%c) %s", ch, inv_name(obj, FALSE));
// else
// wprintw(hw, "%c) %s\n", ch, inv_name(obj, FALSE));
// }
// }
// if (n_objs == 0)
// {
// if (terse)
// msg(type == 0 ? "Empty handed." :
// "Nothing appropriate");
// else
// msg(type == 0 ? "You are empty handed." :
// "You don't have anything appropriate");
// return FALSE;
// }
// if (n_objs == 1)
// {
// msg(inv_temp);
// return TRUE;
// }
// if (!slow_invent)
// {
// mvwaddstr(hw, LINES-1, 0, "--Press space to continue--");
// draw(hw);
// wait_for(' ');
// clearok(cw, TRUE);
// touchwin(cw);
// }
// return TRUE;
//}
/*
* pick_up:
* Add something to characters pack.
*/
void pick_up(char ch)
{
switch(ch)
{
case GOLD:
money();
break;
default:
break;
// debug("Where did you pick that up???");
// case ARMOR:
// case POTION:
// case FOOD:
// case WEAPON:
// case SCROLL:
// case AMULET:
// case RING:
// case STICK:
// add_pack(NULL, FALSE);
// break;
}
}
/*
* picky_inven:
* Allow player to inventory a single item
*/
//picky_inven()
//{
// register struct linked_list *item;
// register char ch, mch;
//
// if (pack == NULL)
// msg("You aren't carrying anything");
// else if (next(pack) == NULL)
// msg("a) %s", inv_name((struct object *) ldata(pack), FALSE));
// else
// {
// msg(terse ? "Item: " : "Which item do you wish to inventory: ");
// mpos = 0;
// if ((mch = readchar()) == ESCAPE)
// {
// msg("");
// return;
// }
// for (ch = 'a', item = pack; item != NULL; item = next(item), ch++)
// if (ch == mch)
// {
// msg("%c) %s",ch,inv_name((struct object *) ldata(item), FALSE));
// return;
// }
// if (!terse)
// msg("'%s' not in pack", unctrl(mch));
// msg("Range is 'a' to '%c'", --ch);
// }
//}
//
///*
// * get_item:
// * pick something out of a pack for a purpose
// */
//struct linked_list *
//get_item(purpose, type)
//char *purpose;
//int type;
//{
// register struct linked_list *obj;
// register char ch, och;
//
// if (pack == NULL)
// msg("You aren't carrying anything.");
// else
// {
// for (;;)
// {
// if (!terse)
// addmsg("Which object do you want to ");
// addmsg(purpose);
// if (terse)
// addmsg(" what");
// msg("? (* for list): ");
// ch = readchar();
// mpos = 0;
// /*
// * Give the poor player a chance to abort the command
// */
// if (ch == ESCAPE || ch == CTRL(G))
// {
// after = FALSE;
// msg("");
// return NULL;
// }
// if (ch == '*')
// {
// mpos = 0;
// if (inventory(pack, type) == 0)
// {
// after = FALSE;
// return NULL;
// }
// continue;
// }
// for (obj = pack, och = 'a'; obj != NULL; obj = next(obj), och++)
// if (ch == och)
// break;
// if (obj == NULL)
// {
// msg("Please specify a letter between 'a' and '%c'", och-1);
// continue;
// }
// else
// return obj;
// }
// }
// return NULL;
//}
//
//pack_char(obj)
//register struct object *obj;
//{
// register struct linked_list *item;
// register char c;
//
// c = 'a';
// for (item = pack; item != NULL; item = next(item))
// if ((struct object *) ldata(item) == obj)
// return c;
// else
// c++;
// return 'z';
//}