61 static int shop_sort(
const void *a1,
const void *a2) {
64 if (s1->
type < s2->type)
66 if (s1->
type > s2->type)
91 items[*numitems].
nrof = tmp->nrof;
96 items[*numitems].
nrof++;
97 items[*numitems].
type = tmp->type;
122 size_t i, j, numitems = 0, numallocated = 0;
126 if (applier->type != PLAYER)
130 "\nThe shop contains:");
132 items = malloc(40*
sizeof(
shopinv));
136 for (i = 0; i <
MAP_WIDTH(applier->map); i++) {
137 for (j = 0; j <
MAP_HEIGHT(applier->map); j++) {
142 if (numitems == numallocated) {
143 items = realloc(items,
sizeof(
shopinv)*(numallocated+10));
148 stack = stack->above;
154 "The shop is currently empty.\n");
158 qsort(items, numitems,
sizeof(
shopinv), (
int (*)(
const void *,
const void *))
shop_sort);
160 for (i = 0; i < numitems; i++) {
162 if ((i+1) < numitems && !strcmp(items[i].
item_real, items[i+1].item_real)) {
165 free(items[i].item_real);
170 items[i].nrof == 1 ? items[i].
item_sort : items[i].item_real);
172 free(items[i].item_real);
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
#define MSG_TYPE_SHOP_LISTING
void query_base_name(const object *op, int plural, char *buf, size_t size)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
int strcasecmp(const char *s1, const char *s2)
static method_ret shop_inventory_type_apply(ob_methods *context, object *lighter, object *applier, int aflags)
void register_apply(int ob_type, apply_func method)
static int shop_sort(const void *a1, const void *a2)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
static void add_shop_item(object *tmp, shopinv *items, size_t *numitems)
void init_type_shop_inventory(void)
#define GET_MAP_OB(M, X, Y)