Crossfire Server, Trunk
shop_inventory.cpp File Reference
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "ob_methods.h"
#include "ob_types.h"
#include "sounds.h"
#include "sproto.h"
+ Include dependency graph for shop_inventory.cpp:

Go to the source code of this file.

Data Structures

struct  shopinv
 

Functions

static void add_shop_item (object *tmp, shopinv *items, size_t *numitems)
 
void init_type_shop_inventory (void)
 
static method_ret shop_inventory_type_apply (object *lighter, object *applier, int aflags)
 
static int shop_sort (const void *a1, const void *a2)
 

Detailed Description

Implementation of the shop inventory class of objects.

Definition in file shop_inventory.cpp.

Function Documentation

◆ add_shop_item()

static void add_shop_item ( object tmp,
shopinv items,
size_t *  numitems 
)
static

Insert the item in the list.

Parameters
tmpobject to insert. Must have FLAG_UNPAID set.
itemsarray of items, should have (*numitems)+1 items allocated.
numitemshow many items items contains.

Definition at line 83 of file shop_inventory.cpp.

References CLEAR_FLAG, FLAG_UNPAID, shopinv::item_real, shopinv::item_sort, MAX_BUF, give::name, shopinv::nrof, query_base_name(), SET_FLAG, strdup_local, Ice::tmp, and shopinv::type.

Referenced by shop_inventory_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_type_shop_inventory()

void init_type_shop_inventory ( void  )

Initializer for the SHOP_INVENTORY object type.

Definition at line 34 of file shop_inventory.cpp.

References register_apply(), SHOP_INVENTORY, and shop_inventory_type_apply().

Referenced by register_all_ob_types().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shop_inventory_type_apply()

static method_ret shop_inventory_type_apply ( object lighter,
object applier,
int  aflags 
)
static

Apply a shop inventory.

Parameters
lighterapplied object to apply.
applierobject attempting to apply the inventory. Should be a player.
aflagsspecial flags (always apply/unapply).
Returns
METHOD_OK if applier is a player, METHOD_UNHANDLED else.

Definition at line 119 of file shop_inventory.cpp.

References object::above, add_shop_item(), buf, draw_ext_info(), fatal(), FLAG_UNPAID, GET_MAP_OB, llevError, LOG(), object::map, MAP_HEIGHT, MAP_WIDTH, METHOD_OK, METHOD_UNHANDLED, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, NDI_UNIQUE, shopinv::nrof, OUT_OF_MEMORY, PLAYER, QUERY_FLAG, shop_sort(), make_face_from_files::str, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), object::type, and nlohmann::detail::void().

Referenced by init_type_shop_inventory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shop_sort()

static int shop_sort ( const void *  a1,
const void *  a2 
)
static

Sort routine for shopinv. There are a lot of extra casts in here just to suppress warnings - it makes it look uglier than it really it. The format of the strings we get is type:name. So we first want to sort by type (numerical) - if the same type, then sort by name.

Parameters
a1
a2items to compare.
Returns
-1 is a1 is less than a2, 1 if the opposite, 0 if equals.

Definition at line 61 of file shop_inventory.cpp.

References shopinv::item_sort, strcasecmp(), and shopinv::type.

Referenced by shop_inventory_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: