65 static int shop_sort(
const void *a1,
const void *a2) {
68 if (s1->
type < s2->type)
70 if (s1->
type > s2->type)
100 items[*numitems].
nrof++;
126 size_t i, j, numitems = 0, numallocated = 0;
134 "\nThe shop contains:", NULL);
136 items = malloc(40*
sizeof(
shopinv));
146 if (numitems == numallocated) {
147 items = realloc(items,
sizeof(
shopinv)*(numallocated+10));
152 stack = stack->
above;
158 "The shop is currently empty.\n", NULL);
162 qsort(items, numitems,
sizeof(
shopinv), (
int (*)(
const void *,
const void *))
shop_sort);
164 for (i = 0; i < numitems; i++) {
166 if ((i+1) < numitems && !strcmp(items[i].item_real, items[i+1].item_real)) {
168 free(items[i].item_sort);
169 free(items[i].item_real);
173 items[i].nrof ? items[i].nrof : 1,
174 items[i].nrof == 1 ? items[i].item_sort : items[i].item_real);
175 free(items[i].item_sort);
176 free(items[i].item_real);
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 type, uint8 subtype, const char *message, const char *oldmessage)
#define MSG_TYPE_SHOP_LISTING
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
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)
char * strdup_local(const char *str)
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)
int strcasecmp(const char *s1, const char *s2)