Mercurial > hg > early-roguelike
comparison rogue3/pack.c @ 0:527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Tue, 13 Oct 2009 13:33:34 +0000 |
| parents | |
| children | d9e44e18eeec |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:527e2150eaf0 |
|---|---|
| 1 /* | |
| 2 * Routines to deal with the pack | |
| 3 * | |
| 4 * @(#)pack.c 3.6 (Berkeley) 6/15/81 | |
| 5 * | |
| 6 * Rogue: Exploring the Dungeons of Doom | |
| 7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 11 */ | |
| 12 | |
| 13 #include "curses.h" | |
| 14 #include <ctype.h> | |
| 15 #include "rogue.h" | |
| 16 | |
| 17 /* | |
| 18 * add_pack: | |
| 19 * Pick up an object and add it to the pack. If the argument is non-null | |
| 20 * use it as the linked_list pointer instead of gettting it off the ground. | |
| 21 */ | |
| 22 void | |
| 23 add_pack(struct linked_list *item, int silent) | |
| 24 { | |
| 25 struct linked_list *ip, *lp; | |
| 26 struct object *obj, *op; | |
| 27 int exact, from_floor; | |
| 28 | |
| 29 if (item == NULL) | |
| 30 { | |
| 31 from_floor = TRUE; | |
| 32 if ((item = find_obj(hero.y, hero.x)) == NULL) | |
| 33 return; | |
| 34 } | |
| 35 else | |
| 36 from_floor = FALSE; | |
| 37 obj = (struct object *) ldata(item); | |
| 38 /* | |
| 39 * Link it into the pack. Search the pack for a object of similar type | |
| 40 * if there isn't one, stuff it at the beginning, if there is, look for one | |
| 41 * that is exactly the same and just increment the count if there is. | |
| 42 * it that. Food is always put at the beginning for ease of access, but | |
| 43 * is not ordered so that you can't tell good food from bad. First check | |
| 44 * to see if there is something in thr same group and if there is then | |
| 45 * increment the count. | |
| 46 */ | |
| 47 if (obj->o_group) | |
| 48 { | |
| 49 for (ip = pack; ip != NULL; ip = next(ip)) | |
| 50 { | |
| 51 op = (struct object *) ldata(ip); | |
| 52 if (op->o_group == obj->o_group) | |
| 53 { | |
| 54 /* | |
| 55 * Put it in the pack and notify the user | |
| 56 */ | |
| 57 op->o_count++; | |
| 58 if (from_floor) | |
| 59 { | |
| 60 detach(lvl_obj, item); | |
| 61 mvaddch(hero.y, hero.x, | |
| 62 (roomin(&hero) == NULL ? PASSAGE : FLOOR)); | |
| 63 } | |
| 64 discard(item); | |
| 65 item = ip; | |
| 66 goto picked_up; | |
| 67 } | |
| 68 } | |
| 69 } | |
| 70 /* | |
| 71 * Check if there is room | |
| 72 */ | |
| 73 if (inpack == MAXPACK-1) | |
| 74 { | |
| 75 msg("You can't carry anything else."); | |
| 76 return; |
