version 1.17 | | version 1.18 |
---|
| | |
/* | | /* |
* static char *rcsid_shop_c = | | * static char *rcsid_shop_c = |
* "$Id: shop.c,v 1.17 2003/01/08 08:39:20 mwedel Exp $"; | | * "$Id: shop.c,v 1.18 2003/01/09 20:22:11 garbled Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
void shop_listing(object *op) | | void shop_listing(object *op) |
{ | | { |
int i,j,numitems=0,numallocated=0; | | int i,j,numitems=0,numallocated=0; |
char *map_mark = (char *) malloc(MAP_SIZE(op->map)); | | |
object *stack; | | object *stack; |
shopinv *items; | | shopinv *items; |
| | |
| | |
| | |
new_draw_info(NDI_UNIQUE, 0, op, "\nThe shop contains:"); | | new_draw_info(NDI_UNIQUE, 0, op, "\nThe shop contains:"); |
| | |
memset(map_mark, 0, MAP_SIZE(op->map)); | | |
magic_mapping_mark(op, map_mark, 3); | | |
items=malloc(40*sizeof(shopinv)); | | items=malloc(40*sizeof(shopinv)); |
numallocated=40; | | numallocated=40; |
| | |
/* Find all the appropriate items */ | | /* Find all the appropriate items */ |
for (i=0; i<MAP_WIDTH(op->map); i++) { | | for (i=0; i<MAP_WIDTH(op->map); i++) { |
for (j=0; j<MAP_HEIGHT(op->map); j++) { | | for (j=0; j<MAP_HEIGHT(op->map); j++) { |
if (map_mark[i + MAP_WIDTH(op->map) * j]) { | | |
stack =get_map_ob(op->map,i,j); | | stack =get_map_ob(op->map,i,j); |
| | |
while (stack) { | | while (stack) { |
if (QUERY_FLAG(stack, FLAG_UNPAID)) { | | if (QUERY_FLAG(stack, FLAG_UNPAID)) { |
if (numitems==numallocated) { | | if (numitems==numallocated) { |
| | |
} | | } |
} | | } |
} | | } |
} | | |
free(map_mark); | | |
if (numitems == 0) { | | if (numitems == 0) { |
new_draw_info(NDI_UNIQUE, 0, op, "The shop is currently empty.\n"); | | new_draw_info(NDI_UNIQUE, 0, op, "The shop is currently empty.\n"); |
free(items); | | free(items); |