 |
Crossfire Server, Trunk
1.75.0
|
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)
96 items[*numitems].
nrof++;
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)
Gets the bottom object on a map.
@ llevError
Error, serious thing.
char * item_sort
Singular name.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define QUERY_FLAG(xyz, p)
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
struct mapstruct * map
Pointer to the map in which this object is present.
One item to list on the sign.
uint32_t nrof
Count of this items.
object * above
Pointer to the object stacked above this one.
Plugin animator file specs[Config] name
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
static void add_shop_item(object *tmp, shopinv *items, size_t *numitems)
Insert the item in the list.
uint8_t type
PLAYER, BULLET, etc.
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
static int shop_sort(const void *a1, const void *a2)
Sort routine for shopinv.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define MAP_WIDTH(m)
Map width.
#define MAX_BUF
Used for all kinds of things.
A buffer that will be expanded as content is added to it.
void init_type_shop_inventory(void)
Initializer for the SHOP_INVENTORY object type.
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
#define NDI_UNIQUE
Print immediately, don't buffer.
char * item_real
Plural name.
@ SHOP_INVENTORY
Mark Wedel (mark@pyramid.com) Shop inventories.
#define CLEAR_FLAG(xyz, p)
#define MSG_TYPE_SHOP_LISTING
Shop listings - inventory, what it deals in.
#define MAP_HEIGHT(m)
Map height.
int strcasecmp(const char *s1, const char *s2)
#define FLAG_UNPAID
Object hasn't been paid for yet.
uint32_t nrof
Number of objects.
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
static method_ret shop_inventory_type_apply(object *lighter, object *applier, int aflags)
Apply a shop inventory.