Go to the documentation of this file.
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;
120 size_t i, j, numitems = 0, numallocated = 0;
130 "\nThe shop contains:");
132 items = malloc(40*
sizeof(
shopinv));
142 if (numitems == numallocated) {
143 items = realloc(items,
sizeof(
shopinv)*(numallocated+10));
145 LOG(
llevError,
"shop_inventory: couldn't allocate memory!\n");
152 stack = stack->
above;
158 "The shop is currently empty.\n");
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);
#define GET_MAP_OB(M, X, Y)
#define QUERY_FLAG(xyz, p)
static int shop_sort(const void *a1, const void *a2)
static void add_shop_item(object *tmp, shopinv *items, size_t *numitems)
void fatal(enum fatal_error err)
void init_type_shop_inventory(void)
void register_apply(int ob_type, apply_func method)
void LOG(LogLevel logLevel, const char *format,...)
void query_base_name(const object *op, int plural, char *buf, size_t size)
#define CLEAR_FLAG(xyz, p)
#define MSG_TYPE_SHOP_LISTING
int strcasecmp(const char *s1, const char *s2)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
static method_ret shop_inventory_type_apply(object *lighter, object *applier, int aflags)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)