Crossfire Server, Trunk
c_object.c File Reference
#include "global.h"
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "loader.h"
#include "shop.h"
#include "skills.h"
#include "sproto.h"
+ Include dependency graph for c_object.c:

Go to the source code of this file.

Data Structures

struct  matcher_params
 

Typedefs

typedef int(* item_matcher) (object *who, matcher_params *params, object *item)
 

Functions

void command_apply (object *op, const char *params)
 
void command_disarm (object *op, const char *params)
 
void command_drop (object *op, const char *params)
 
void command_dropall (object *op, const char *params)
 
void command_empty (object *op, const char *params)
 
void command_examine (object *op, const char *params)
 
void command_lock_item (object *op, const char *params)
 
void command_mark (object *op, const char *params)
 
void command_pickup (object *op, const char *params)
 
void command_rename_item (object *op, const char *params)
 
void command_rskill (object *pl, const char *params)
 
void command_search (object *op, const char *params)
 
void command_search_items (object *op, const char *params)
 
void command_take (object *op, const char *params)
 
void command_throw (object *op, const char *params)
 
void command_use (object *op, const char *params)
 
void command_uskill (object *pl, const char *params)
 
static void display_new_pickup (const object *op, int old)
 
static void do_skill_by_number (object *op, int skill_subtype, const char *params, const char *missing_message)
 
void drop (object *op, object *tmp)
 
objectdrop_object (object *op, object *tmp, uint32_t nrof)
 
static void empty_container (object *container, object *pl)
 
void examine (object *op, object *tmp)
 
void examine_monster (object *op, object *tmp, int level)
 
static objectfind_best_apply_object_match (object *start, object *pl, const char *params, int aflag)
 
static objectfind_best_object_match (object *pl, const char *params)
 
objectfind_marked_object (object *op)
 
static int get_pickup_mode_index (const char *name)
 
void inventory (object *op, object *inv)
 
static item_matcher make_matcher (object *who, const char *params, matcher_params *mp)
 
static int matcher_all (object *who, matcher_params *params, object *item)
 
static int matcher_name (object *who, matcher_params *params, object *item)
 
static int matcher_number (object *who, matcher_params *params, object *item)
 
static int matcher_pickup_type (object *who, matcher_params *params, object *item)
 
int object_matches_pickup_mode (const object *item, int mode)
 
void pick_up (object *op, object *alt)
 
static void pick_up_object (object *pl, object *op, object *tmp, int nrof)
 
void put_object_in_sack (object *op, object *sack, object *tmp, uint32_t nrof)
 
int sack_can_hold (const object *pl, const object *sack, const object *op, uint32_t nrof)
 
static void set_pickup_mode (const object *op, int i)
 

Variables

static const uint32_t pickup_modes []
 
static const char * pickup_names []
 

Detailed Description

Object commands, including picking/dropping, locking, etc.

Todo:
clean multiple variations of same stuff (pickup and such), or rename for less confusion.

Definition in file c_object.c.

Typedef Documentation

◆ item_matcher

typedef int(* item_matcher) (object *who, matcher_params *params, object *item)

Prototype for a function checking if an object matches some parameters.

Parameters
whoobject wanting to match another object.
paramswhat to match against.
itemobject to check for a match.
Returns
0 if the object does not match, 1 if matches.

Definition at line 731 of file c_object.c.

Function Documentation

◆ command_apply()

void command_apply ( object op,
const char *  params 
)

'apply' command.

Parameters
opplayer.
paramswhat to apply.

Definition at line 251 of file c_object.c.

References AP_APPLY, AP_NULL, AP_OPEN, AP_UNAPPLY, apply_by_living(), apply_by_living_below(), draw_ext_info_format(), find_best_apply_object_match(), commongive::inv, say::item, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, and manor::params.

Referenced by commands_init().

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

◆ command_disarm()

void command_disarm ( object op,
const char *  params 
)

'disarm' command.

Parameters
opplayer.
paramsunused.

Definition at line 224 of file c_object.c.

References do_skill_by_number(), give::op, manor::params, and SK_DISARM_TRAPS.

Referenced by commands_init().

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

◆ command_drop()

void command_drop ( object op,
const char *  params 
)

'drop' command.

Parameters
opplayer.
paramswhat to drop.

Definition at line 1354 of file c_object.c.

References CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), drop(), esrv_update_item(), fix_object(), FLAG_INV_LOCKED, FLAG_NO_DROP, FLAG_NO_FIX_PLAYER, FOR_INV_FINISH, FOR_INV_PREPARE, make_matcher(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, manor::params, PLAYER, QUERY_FLAG, SET_FLAG, Ice::tmp, and UPD_WEIGHT.

Referenced by commands_init(), and do_test().

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

◆ command_dropall()

void command_dropall ( object op,
const char *  params 
)

Command to drop all items that have not been locked.

Parameters
opplayer.
paramsoptional specifier, like 'armour', 'weapon' and such.

Definition at line 1230 of file c_object.c.

References AMULET, ARMOUR, ARMOUR_IMPROVER, ARROW, BOOK, BOOTS, BOW, BRACERS, CLEAR_FLAG, CLOAK, CONTAINER, disinfect::count, draw_ext_info(), DRINK, drop(), esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_INV_LOCKED, FLAG_NO_FIX_PLAYER, FLESH, FOOD, FOR_INV_FINISH, FOR_INV_PREPARE, GEM, GIRDLE, GLOVES, HELMET, KEY, MONEY, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, manor::params, PLAYER, POTION, QUERY_FLAG, RING, ROD, SCROLL, SET_FLAG, SHIELD, SPECIAL_KEY, SPELLBOOK, UPD_WEIGHT, WAND, WEAPON, and WEAPON_IMPROVER.

Referenced by commands_init().

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

◆ command_empty()

void command_empty ( object op,
const char *  params 
)

'empty' command.

Parameters
opplayer.
paramsitem specifier.

Definition at line 1450 of file c_object.c.

References CONTAINER, draw_ext_info(), empty_container(), find_best_object_match(), FOR_INV_FINISH, FOR_INV_PREPARE, commongive::inv, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, manor::params, and obj::type.

Referenced by commands_init().

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

◆ command_examine()

void command_examine ( object op,
const char *  params 
)

'examine' command.

Parameters
opplayer.
paramsoptional item specifier.

Definition at line 1489 of file c_object.c.

References draw_ext_info_format(), examine(), find_best_object_match(), FOR_BELOW_FINISH, FOR_BELOW_PREPARE, LOOK_OBJ, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, manor::params, and Ice::tmp.

Referenced by commands_init().

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

◆ command_lock_item()

void command_lock_item ( object op,
const char *  params 
)

Alternate way to lock/unlock items (command line).

Parameters
opplayer
paramssent command line.

Definition at line 2558 of file c_object.c.

References CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_best_object_match(), FLAG_INV_LOCKED, HUGE_BUF, say::item, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, give::name, NDI_UNIQUE, object_merge(), give::op, manor::params, QUERY_FLAG, query_short_name(), SET_FLAG, Ice::tmp, and UPD_FLAGS.

Referenced by commands_init().

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

◆ command_mark()

void command_mark ( object op,
const char *  params 
)

'mark' command, to mark an item for some effects (enchant armor, ...).

Parameters
opplayer.
paramsIf empty, we print out the currently marked object. Otherwise, try to find a matching object - try best match first.

Definition at line 1567 of file c_object.c.

References obj::count, draw_ext_info(), draw_ext_info_format(), find_best_object_match(), find_marked_object(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, give::name, NDI_UNIQUE, give::op, manor::params, and query_name().

Referenced by commands_init().

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

◆ command_pickup()

void command_pickup ( object op,
const char *  params 
)

'pickup' command.

Parameters
opplayer.
paramspickup mode. Can be empty to display the current mode.
Todo:
trash old pickup mode, merge with new pickup.

Definition at line 2210 of file c_object.c.

References display_new_pickup(), draw_ext_info(), draw_ext_info_format(), get_pickup_mode_index(), npc_dialog::index, llevDebug, LOG(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, manor::params, pickup_modes, PU_NEWMODE, and set_pickup_mode().

Referenced by commands_init().

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

◆ command_rename_item()

void command_rename_item ( object op,
const char *  params 
)

Changing the custom name of an item

Syntax is: rename <what object> to <new name>

  • if 'what object' is omitted, marked object is used
  • if 'to new name' is omitted, custom name is cleared

Names are considered for all purpose having a length <=127 (max length sent to client by server).

Parameters
opplayer.
paramshow to rename.

Definition at line 2373 of file c_object.c.

References buf, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_best_object_match(), find_marked_object(), FOR_INV_FINISH, FOR_INV_PREPARE, FREE_AND_CLEAR_STR, FREE_AND_COPY, commongive::inv, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, give::name, NDI_UNIQUE, object_merge(), give::op, manor::params, query_base_name(), Ice::tmp, UPD_NAME, and VERY_BIG_BUF.

Referenced by commands_init().

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

◆ command_rskill()

void command_rskill ( object pl,
const char *  params 
)

'ready_skill' command.

Parameters
plplayer.
paramsskill name.

Definition at line 161 of file c_object.c.

References change_skill(), draw_ext_info(), draw_ext_info_format(), find_skill_by_name(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, NDI_UNIQUE, and manor::params.

Referenced by commands_init().

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

◆ command_search()

void command_search ( object op,
const char *  params 
)

'search' command.

Parameters
opplayer.
paramsunused.

Definition at line 212 of file c_object.c.

References do_skill_by_number(), give::op, manor::params, and SK_FIND_TRAPS.

Referenced by commands_init().

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

◆ command_search_items()

void command_search_items ( object op,
const char *  params 
)

'search-items' command.

Parameters
opplayer.
paramsoptions.

Definition at line 2328 of file c_object.c.

References draw_ext_info(), draw_ext_info_format(), FALSE, fix_object(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, give::op, manor::params, Settings::search_items, and settings.

Referenced by commands_init(), and kill_player_not_permadeath().

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

◆ command_take()

void command_take ( object op,
const char *  params 
)

This takes (picks up) an item.

Parameters
opplayer who issued the command.
paramsstring to match against the item name.

Definition at line 845 of file c_object.c.

References CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), fix_object(), FLAG_NO_FIX_PLAYER, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, is_valid_types_gen::found, make_matcher(), matcher_params::missed, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, NDI_UNIQUE, give::op, manor::params, pick_up(), PLAYER, SET_FLAG, Ice::tmp, and UPD_WEIGHT.

Referenced by commands_init(), do_test(), and knowledge_alchemy_attempt().

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

◆ command_throw()

void command_throw ( object op,
const char *  params 
)

'throw' command.

A little special because we do want to pass the full params along as it includes the object to throw.

Parameters
opplayer.
paramswhat to throw.

Definition at line 239 of file c_object.c.

References do_skill_by_number(), give::op, manor::params, and SK_THROWING.

Referenced by commands_init().

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

◆ command_use()

void command_use ( object op,
const char *  params 
)

Try to use an item on another. Items are checked for key/values matching.

Parameters
opplayer.
paramssent string, with all parameters.
Todo:
handle multiple ingredients
Todo:
handle ingredient count, handle batches, and such

Definition at line 2601 of file c_object.c.

References obj::arch, recipestruct::arch_name, create_archetype(), draw_ext_info(), draw_ext_info_format(), find_best_object_match(), find_recipe_for_tool(), recipestruct::ingred, recipestruct::ingred_count, IS_PLAYER(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, linked_char::name, obj::name, archt::name, NDI_UNIQUE, obj::nrof, object_decrease_nrof_by_one, object_insert_in_ob(), give::op, manor::params, strlcpy(), and recipestruct::yield.

Referenced by commands_init().

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

◆ command_uskill()

void command_uskill ( object pl,
const char *  params 
)

'use_skill' command.

Parameters
plplayer.
paramsskill to use, and optional parameters.

Definition at line 144 of file c_object.c.

References draw_ext_info(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, manor::params, and use_skill().

Referenced by commands_init().

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

◆ display_new_pickup()

static void display_new_pickup ( const object op,
int  old 
)
static

Utility function to display the pickup mode for a player.

Parameters
opmust be a player.
oldprevious pickup mode.

Definition at line 2081 of file c_object.c.

References draw_ext_info(), draw_ext_info_format(), esrv_send_pickup(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_INFO, NDI_UNIQUE, give::op, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_CONTAINER, PU_CURSED, PU_DEBUG, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_INHIBIT, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, PU_MELEEWEAPON, PU_MISSILEWEAPON, PU_NEWMODE, PU_NOT_CURSED, PU_POTION, PU_RATIO, PU_READABLES, PU_SHIELD, PU_SKILLSCROLL, PU_SPELLBOOK, PU_STOP, and PU_VALUABLES.

Referenced by command_pickup().

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

◆ do_skill_by_number()

static void do_skill_by_number ( object op,
int  skill_subtype,
const char *  params,
const char *  missing_message 
)
static

Attempt to use a skill from its subtype. If multiple skills share the same, the first found is used.

Parameters
opwho is applying a skill.
skill_subtypeskill subtype.
paramsadditional parameters to the skill.
missing_messagemessage to display if op doesn't know the skill.

Definition at line 188 of file c_object.c.

References do_skill(), draw_ext_info(), find_skill_by_number(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, NDI_UNIQUE, give::op, and manor::params.

Referenced by command_disarm(), command_search(), and command_throw().

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

◆ drop()

void drop ( object op,
object tmp 
)

Drop an item, either on the floor or in a container.

Parameters
opwho is dropping an item.
tmpwhat object to drop.

Definition at line 1168 of file c_object.c.

References draw_ext_info(), drop_object(), FLAG_INV_LOCKED, FLAG_NO_DROP, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, object_free_drop_inventory(), object_remove(), give::op, PLAYER, put_object_in_sack(), QUERY_FLAG, and Ice::tmp.

Referenced by apply_handle_yield(), cfapi_object_drop(), command_drop(), command_dropall(), and empty_container().

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

◆ drop_object()

object* drop_object ( object op,
object tmp,
uint32_t  nrof 
)

Try to drop an object on the floor.

This function was part of drop, now is own function.

Parameters
opwho is dropping the item.
tmpitem to drop.
nrofif is non zero, then nrof objects is tried to be dropped.
Returns
object dropped, NULL if it was destroyed.
Todo:
shouldn't tmp be NULL if object_was_destroyed returns true?

Definition at line 1073 of file c_object.c.

References AP_NO_MERGE, AP_UNAPPLY, apply_special(), draw_ext_info(), draw_ext_info_format(), esrv_update_item(), EVENT_DROP, events_execute_object_event(), fix_object(), FLAG_APPLIED, FLAG_NO_DROP, FLAG_NO_FIX_PLAYER, FLAG_REMOVED, FLAG_STARTEQUIP, FLAG_UNPAID, INS_BELOW_ORIGINATOR, MAX_BUF, MONEY, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, give::name, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_split(), object_was_destroyed, give::op, PLAYER, QUERY_FLAG, query_name(), save_player(), SCRIPT_FIX_ALL, sell_item(), shop_contains(), Ice::tmp, and UPD_WEIGHT.

Referenced by drop(), esrv_move_object(), and transport_type_apply().

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

◆ empty_container()

static void empty_container ( object container,
object pl 
)
static

Put all contents of the container on the ground below the player or in opened container, except locked items.

Parameters
containerwhat to empty.
plplayer to drop for.

Definition at line 1412 of file c_object.c.

References draw_ext_info_format(), drop(), esrv_update_item(), FLAG_INV_LOCKED, FOR_INV_FINISH, FOR_INV_PREPARE, commongive::inv, obj::inv, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, give::name, NDI_UNIQUE, give::next, QUERY_FLAG, query_name(), and UPD_WEIGHT.

Referenced by command_empty().

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

◆ examine()

void examine ( object op,
object tmp 
)

Player examines some object. The item may be identified automatically if the player has the correct skill for that.

Parameters
opplayer.
tmpobject to examine.

Definition at line 1702 of file c_object.c.

References body_locations, BOOK, buf, change_exp(), CLEAR_FLAG, archt::clone, CLOSE_CON, CONTAINER, CORPSE, cost_approx_str(), cost_str(), detect_curse_on_item(), detect_magic_on_item(), draw_ext_info(), draw_ext_info_format(), examine_monster(), EXIT, find_skill_by_number(), FLAG_IDENTIFIED, FLAG_IS_BUILDABLE, FLAG_IS_CAULDRON, FLAG_IS_LINKED, FLAG_MONSTER, FLAG_NO_PICK, FLAG_NO_SKILL_IDENT, FLAG_STARTEQUIP, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, get_archetype_by_skill_name(), get_button_value(), get_typedata(), identify_object_with_skill(), typedata::identifyskill, typedata::identifyskill2, is_identifiable_type(), is_identified(), knowledge_item_can_be_used_alchemy(), llevError, LOG(), MAX_BUF, obj::msg, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, MSG_TYPE_SPELL, MSG_TYPE_SPELL_INFO, NDI_BLUE, NDI_UNIQUE, body_locations_struct::nonuse_name, NUM_BODY_LOCATIONS, ob_describe(), object_can_pick(), give::op, POTION, castle_read::prefix, QUERY_FLAG, ROD, SCROLL, shop_contains(), shop_price_buy(), shop_price_sell(), SK_DET_CURSE, SK_DET_MAGIC, SK_SUBTRACT_SKILL_EXP, SKILL, obj::skill, SKILL_TOOL, SKILLSCROLL, SPELLBOOK, stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), stringbuffer_trim_whitespace(), Ice::tmp, body_locations_struct::use_name, autojail::value, VERY_BIG_BUF, and WAND.

Referenced by command_examine(), examine_cmd(), and knowledge_alchemy_attempt().

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

◆ examine_monster()

void examine_monster ( object op,
object tmp,
int  level 
)

Player examine a monster.

Parameters
opplayer.
tmpmonster being examined.
levellevel of the probe, to have a persistant marker for some duration.

Definition at line 1614 of file c_object.c.

References add_string(), obj::arch, AT_ACID, obj::attacktype, create_archetype(), draw_ext_info(), fix_object(), FLAG_APPLIED, FLAG_PROBE, FLAG_UNDEAD, FORCE, FORCE_NAME, free_string(), HEAD, liv::hp, knowledge_show_monster_detail(), obj::level, level, liv::maxhp, mon, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, archt::name, NDI_UNIQUE, object_find_by_type_and_name(), object_insert_in_ob(), object_present_in_ob(), give::op, POISONING, probe(), QUERY_FLAG, SET_FLAG, obj::stats, and Ice::tmp.

Referenced by examine(), and probe().

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

◆ find_best_apply_object_match()

static object* find_best_apply_object_match ( object start,
object pl,
const char *  params,
int  aflag 
)
static

Search from start and through below for what matches best with params. we use object_matches_string above - this gives us consistent behaviour between many commands. Return the best match, or NULL if no match.

Parameters
startfirst object to start searching at.
plwhat object we're searching for.
paramswhat to search for.
aflagEither 0 or AP_APPLY or AP_UNAPPLY. Used with apply -u, and apply -a to only unapply applied, or apply unapplied objects.
Returns
matching object, or NULL if no suitable.

Definition at line 101 of file c_object.c.

References AP_APPLY, AP_UNAPPLY, FLAG_APPLIED, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, object_matches_string(), manor::params, QUERY_FLAG, and Ice::tmp.

Referenced by command_apply(), and find_best_object_match().

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

◆ find_best_object_match()

static object* find_best_object_match ( object pl,
const char *  params 
)
static

Shortcut to find_best_apply_object_match(pl->inv, pl, params, AF_NULL);

Parameters
plwho to search an item for.
paramswhat to search for.
Returns
matching object, or NULL if no suitable.

Definition at line 132 of file c_object.c.

References AP_NULL, find_best_apply_object_match(), and manor::params.

Referenced by command_empty(), command_examine(), command_lock_item(), command_mark(), command_rename_item(), and command_use().

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

◆ find_marked_object()

object* find_marked_object ( object op)

Return the object the player has marked with the 'mark' command below. If no match is found (or object has changed), we return NULL. We leave it up to the calling function to print messages if nothing is found.

Parameters
opobject. Should be a player.
Returns
marked object if still valid, NULL else.

Definition at line 1520 of file c_object.c.

References give::op.

Referenced by animate_weapon(), apply_map_builder(), armour_improver_type_apply(), cast_item_curse_or_curse(), cfapi_object_get_property(), command_mark(), command_rename_item(), find_throw_ob(), identify_altar_type_move_on(), lightable_type_apply(), lighter_type_apply(), recharge(), weapon_improver_type_apply(), and write_on_item().

+ Here is the caller graph for this function:

◆ get_pickup_mode_index()

static int get_pickup_mode_index ( const char *  name)
static

Return the pickup index in pickup_names and pickup_modes associated with the specified name. The name may be the start of a mode if no ambiguity exists, that is 'me' means 'melee', but 'm' will not match anything.

Parameters
namemode to get the index of.
Returns
index, -1 if the name is invalid.

Definition at line 58 of file c_object.c.

References give::name, and pickup_names.

Referenced by command_pickup(), and make_matcher().

+ Here is the caller graph for this function:

◆ inventory()

void inventory ( object op,
object inv 
)

Prints object's inventory.

Parameters
opwho to print for.
invif NULL then print op's inventory, else print the inventory of inv.

Definition at line 2016 of file c_object.c.

References CONTAINER, draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_WIZ, FOR_INV_FINISH, FOR_INV_PREPARE, commongive::inv, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_INVENTORY, give::name, NDI_UNIQUE, give::op, QUERY_FLAG, query_name(), query_weight(), and Ice::tmp.

Referenced by command_inventory(), and look_at().

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

◆ make_matcher()

static item_matcher make_matcher ( object who,
const char *  params,
matcher_params mp 
)
static

Parse parameters and sets up an item matcher based on them.

Parameters
whoobject wanting to match another object.
paramsmatching parameters.
[out]mpparsed parameters.
Returns
NULL if error in parameters, else an item matcher pointer.

Definition at line 806 of file c_object.c.

References draw_ext_info_format(), get_pickup_mode_index(), matcher_params::item_must_be_pickable, matcher_params::item_to_pick, matcher_all(), matcher_name(), matcher_number(), matcher_pickup_type(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, matcher_params::name, NDI_UNIQUE, manor::params, pickup_modes, matcher_params::pickup_type, and autojail::who.

Referenced by command_drop(), and command_take().

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

◆ matcher_all()

static int matcher_all ( object who,
matcher_params params,
object item 
)
static

Function allowing all objects.

Parameters
whounused.
paramsunused.
itemunused.
Returns
1.

Definition at line 740 of file c_object.c.

References manor::params, nlohmann::detail::void(), and autojail::who.

Referenced by make_matcher().

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

◆ matcher_name()

static int matcher_name ( object who,
matcher_params params,
object item 
)
static

Check if an item matches a string.

Parameters
whoobject wanting to match another object.
paramswhat to match against.
itemobject to check for a match.
Returns
0 if the object does not match, 1 if matches.

Definition at line 774 of file c_object.c.

References FLAG_IS_FLOOR, object_can_pick(), object_matches_string(), manor::params, QUERY_FLAG, and autojail::who.

Referenced by make_matcher().

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

◆ matcher_number()

static int matcher_number ( object who,
matcher_params params,
object item 
)
static

Check if an item is the one at the desired position.

Parameters
whounused.
paramswhat to match against.
itemunused.
Returns
0 if the object does not match, 1 if matches.

Definition at line 754 of file c_object.c.

References object_can_pick(), manor::params, and autojail::who.

Referenced by make_matcher().

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

◆ matcher_pickup_type()

static int matcher_pickup_type ( object who,
matcher_params params,
object item 
)
static

Check if an item matches a pickup type.

Parameters
whoobject wanting to match another object.
paramswhat to match against.
itemobject to check for a match.
Returns
0 if the object does not match, 1 if matches.

Definition at line 794 of file c_object.c.

References object_matches_pickup_mode(), manor::params, nlohmann::detail::void(), and autojail::who.

Referenced by make_matcher().

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

◆ object_matches_pickup_mode()

int object_matches_pickup_mode ( const object item,
int  mode 
)

Checks if an item matches a specific pickup mode.

Parameters
itemitem to check.
modeone value of Pickup modes, not a combination of modes.
Returns
0 if the item doesn't match, a non-zero value if it matches.

Definition at line 656 of file c_object.c.

References AMULET, ARMOUR, ARMOUR_IMPROVER, ARROW, BOOK, BOOTS, BOW, CLOAK, CONTAINER, DRINK, FLAG_IS_THROWN, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLESH, FOOD, GEM, GLOVES, HELMET, KEY, MONEY, POISON, POTION, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_CONTAINER, PU_CURSED, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, PU_MELEEWEAPON, PU_MISSILEWEAPON, PU_POTION, PU_READABLES, PU_SHIELD, PU_SKILLSCROLL, PU_SPELLBOOK, PU_VALUABLES, QUERY_FLAG, RING, ROD, SCROLL, SHIELD, SKILL_TOOL, SKILLSCROLL, SPECIAL_KEY, SPELLBOOK, WAND, WEAPON, and WEAPON_IMPROVER.

Referenced by check_pick(), and matcher_pickup_type().

+ Here is the caller graph for this function:

◆ pick_up()

void pick_up ( object op,
object alt 
)

Try to pick up an item.

Parameters
opobject trying to pick up.
altoptional object op is trying to pick. If NULL, try to pick first item under op.

Definition at line 519 of file c_object.c.

References CONTAINER, disinfect::count, draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_STARTEQUIP, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, INS_NO_MERGE, llevDebug, LOG(), MIMIC, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, obj::name, NDI_UNIQUE, object_can_pick(), object_insert_in_map(), give::op, pick_up_object(), PLAYER, QUERY_FLAG, obj::race, sack_can_hold(), stop_item(), Ice::tmp, and obj::type.

Referenced by attempt_steal(), cast_create_missile(), cfapi_object_pickup(), check_pick(), command_take(), and esrv_move_object().

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

◆ pick_up_object()

static void pick_up_object ( object pl,
object op,
object tmp,
int  nrof 
)
static

◆ put_object_in_sack()

void put_object_in_sack ( object op,
object sack,
object tmp,
uint32_t  nrof 
)

Something tries to put an object into another.

This function was part of drop(), now is own function.

Note
the 'sack' in question can now be a transport, so this function isn't named very good anymore.
Parameters
opwho is moving the item.
sackwhere to put the object.
tmpwhat to put into sack.
nrofif non zero, then nrof objects is tried to put into sack, else everything is put.

Definition at line 937 of file c_object.c.

References AP_NO_MERGE, AP_UNAPPLY, apply_special(), CLEAR_FLAG, CONTAINER, draw_ext_info(), draw_ext_info_format(), obj::env, esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_STARTEQUIP, FOR_INV_FINISH, FOR_INV_PREPARE, obj::map, MAX_BUF, obj::move_off, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, obj::nrof, object_insert_in_map_at(), object_insert_in_ob(), object_remove(), object_split(), give::op, PLAYER, QUERY_FLAG, query_name(), sack_can_hold(), set_object_face_main(), Ice::tmp, TRANSPORT, transport_can_hold(), obj::type, UPD_WEIGHT, obj::x, and obj::y.

Referenced by drop(), esrv_move_object(), knowledge_alchemy_attempt(), and START_TEST().

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

◆ sack_can_hold()

int sack_can_hold ( const object pl,
const object sack,
const object op,
uint32_t  nrof 
)

Check if an item op can be put into a sack. If pl exists then tell a player the reason of failure.

Parameters
plplayer.
sackcontainer to try to put into.
opwhat to put in the sack.
nrofnumber of objects (op) we want to put in. We specify it separately instead of using op->nrof because often times, a player may have specified a certain number of objects to drop, so we can pass that number, and not need to use split_ob() and stuff.
Returns
1 if it will fit, 0 if it will not.

Definition at line 317 of file c_object.c.

References obj::carrying, CONTAINER, draw_ext_info_format(), FLAG_APPLIED, liv::food, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, give::name, NDI_UNIQUE, give::op, QUERY_FLAG, query_name(), obj::race, obj::slaying, SPECIAL_KEY, obj::stats, liv::Str, and obj::weight_limit.

Referenced by esrv_move_object(), pick_up(), and put_object_in_sack().

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

◆ set_pickup_mode()

static void set_pickup_mode ( const object op,
int  i 
)
static

Sets the 'old' pickup mode.

Parameters
opplayer.
inew pickup mode.

Definition at line 2275 of file c_object.c.

References draw_ext_info(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, and give::op.

Referenced by command_pickup().

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

Variable Documentation

◆ pickup_modes

◆ pickup_names

const char* pickup_names[]
static
Initial value:
= {
"debug", "inhibit", "stop", "food", "drink",
"valuables", "bow", "arrow", "helmet", "shield",
"armour", "boots", "gloves", "cloak", "key",
"missile", "melee", "magical", "potion", "spellbook",
"skillscroll", "readables", "magicdevice", "notcursed", "jewels",
"flesh", "container", "cursed", NULL
}

Valid names for pickup types.

Definition at line 33 of file c_object.c.

Referenced by get_pickup_mode_index().

PU_BOOTS
#define PU_BOOTS
Definition: define.h:125
PU_NOT_CURSED
#define PU_NOT_CURSED
Definition: define.h:140
PU_ARROW
#define PU_ARROW
Definition: define.h:120
PU_INHIBIT
#define PU_INHIBIT
Definition: define.h:109
PU_FOOD
#define PU_FOOD
Definition: define.h:115
PU_BOW
#define PU_BOW
Definition: define.h:118
PU_MAGIC_DEVICE
#define PU_MAGIC_DEVICE
Definition: define.h:138
PU_MISSILEWEAPON
#define PU_MISSILEWEAPON
Definition: define.h:130
PU_FLESH
#define PU_FLESH
Definition: define.h:142
PU_READABLES
#define PU_READABLES
Definition: define.h:137
PU_POTION
#define PU_POTION
Definition: define.h:133
PU_GLOVES
#define PU_GLOVES
Definition: define.h:126
PU_CONTAINER
#define PU_CONTAINER
Definition: define.h:143
PU_KEY
#define PU_KEY
Definition: define.h:128
PU_STOP
#define PU_STOP
Definition: define.h:110
PU_VALUABLES
#define PU_VALUABLES
Definition: define.h:117
PU_SPELLBOOK
#define PU_SPELLBOOK
Definition: define.h:135
PU_MELEEWEAPON
#define PU_MELEEWEAPON
Definition: define.h:131
PU_MAGICAL
#define PU_MAGICAL
Definition: define.h:132
PU_HELMET
#define PU_HELMET
Definition: define.h:121
PU_CLOAK
#define PU_CLOAK
Definition: define.h:127
PU_JEWELS
#define PU_JEWELS
Definition: define.h:141
PU_ARMOUR
#define PU_ARMOUR
Definition: define.h:123
PU_CURSED
#define PU_CURSED
Definition: define.h:144
PU_DRINK
#define PU_DRINK
Definition: define.h:116
PU_SHIELD
#define PU_SHIELD
Definition: define.h:122
PU_DEBUG
#define PU_DEBUG
Definition: define.h:108
PU_SKILLSCROLL
#define PU_SKILLSCROLL
Definition: define.h:136