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;
145 if (numitems == numallocated) {
146 items =
static_cast<shopinv *
>(realloc(items,
sizeof(
shopinv)*(numallocated+10)));
148 LOG(
llevError,
"shop_inventory: couldn't allocate memory!\n");
155 stack = stack->
above;
168 qsort(items, numitems,
sizeof(
shopinv), (
int (*)(
const void *,
const void *))
shop_sort);
170 for (i = 0; i < numitems; i++) {
172 if ((i+1) < numitems && !strcmp(items[i].item_real, items[i+1].item_real)) {
174 free(items[i].item_sort);
175 free(items[i].item_real);
179 items[i].nrof ? items[i].nrof : 1,
180 items[i].nrof == 1 ? items[i].item_sort : items[i].item_real);
181 free(items[i].item_sort);
182 free(items[i].item_real);
#define GET_MAP_OB(M, X, Y)
void LOG(LogLevel logLevel, const char *format,...)
#define QUERY_FLAG(xyz, p)
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
StringBuffer * stringbuffer_new(void)
void register_apply(int ob_type, apply_func method)
char * stringbuffer_finish(StringBuffer *sb)
static void add_shop_item(object *tmp, shopinv *items, size_t *numitems)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
static int shop_sort(const void *a1, const void *a2)
void fatal(enum fatal_error err)
void init_type_shop_inventory(void)
#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)
void query_base_name(const object *op, int plural, char *buf, size_t size)
static method_ret shop_inventory_type_apply(object *lighter, object *applier, int aflags)