Crossfire Server, Trunk  R22010
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)
 
object * drop_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 object * find_best_apply_object_match (object *start, object *pl, const char *params, int aflag)
 
static object * find_best_object_match (object *pl, const char *params)
 
object * find_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 719 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 250 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(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, and NDI_UNIQUE.

+ Here is the call graph for this function:

◆ command_disarm()

void command_disarm ( object *  op,
const char *  params 
)

'disarm' command.

Parameters
opplayer.
paramsunused.

Definition at line 223 of file c_object.c.

References do_skill_by_number(), and SK_DISARM_TRAPS.

+ Here is the call graph for this function:

◆ command_drop()

void command_drop ( object *  op,
const char *  params 
)

'drop' command.

Parameters
opplayer.
paramswhat to drop.

Definition at line 1342 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, QUERY_FLAG, SET_FLAG, and UPD_WEIGHT.

Referenced by 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 1218 of file c_object.c.

References CLEAR_FLAG, draw_ext_info(), drop(), esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_INV_LOCKED, FLAG_NO_FIX_PLAYER, FOR_INV_FINISH, FOR_INV_PREPARE, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, QUERY_FLAG, SET_FLAG, and UPD_WEIGHT.

+ Here is the call graph for this function:

◆ command_empty()

void command_empty ( object *  op,
const char *  params 
)

'empty' command.

Parameters
opplayer.
paramsitem specifier.

Definition at line 1439 of file c_object.c.

References draw_ext_info(), empty_container(), find_best_object_match(), FOR_INV_FINISH, FOR_INV_PREPARE, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, and NDI_UNIQUE.

+ Here is the call graph for this function:

◆ command_examine()

void command_examine ( object *  op,
const char *  params 
)

'examine' command.

Parameters
opplayer.
paramsoptional item specifier.

Definition at line 1478 of file c_object.c.

References draw_ext_info_format(), examine(), find_best_object_match(), FOR_BELOW_FINISH, FOR_BELOW_PREPARE, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, and NDI_UNIQUE.

+ Here is the call 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 2544 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, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, NDI_UNIQUE, object_merge(), QUERY_FLAG, query_short_name(), SET_FLAG, and UPD_FLAGS.

+ Here is the call 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 1556 of file c_object.c.

References 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, NDI_UNIQUE, and query_name().

+ Here is the call 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 2195 of file c_object.c.

References display_new_pickup(), draw_ext_info(), draw_ext_info_format(), get_pickup_mode_index(), llevDebug, LOG(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, pickup_modes, PU_NEWMODE, and set_pickup_mode().

+ Here is the call 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 2358 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, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, object_merge(), query_base_name(), snprintf, UPD_NAME, and VERY_BIG_BUF.

+ Here is the call graph for this function:

◆ command_rskill()

void command_rskill ( object *  pl,
const char *  params 
)

'ready_skill' command.

Parameters
plplayer.
paramsskill name.

Definition at line 160 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, and NDI_UNIQUE.

+ Here is the call graph for this function:

◆ command_search()

void command_search ( object *  op,
const char *  params 
)

'search' command.

Parameters
opplayer.
paramsunused.

Definition at line 211 of file c_object.c.

References do_skill_by_number(), and SK_FIND_TRAPS.

+ Here is the call 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 2313 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, Settings::search_items, and settings.

Referenced by 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 833 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, make_matcher(), matcher_params::missed, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, NDI_UNIQUE, pick_up(), SET_FLAG, and UPD_WEIGHT.

Referenced by 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 238 of file c_object.c.

References do_skill_by_number(), and SK_THROWING.

+ Here is the call 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 2587 of file c_object.c.

References 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, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, linked_char::name, NDI_UNIQUE, object_decrease_nrof_by_one, object_insert_in_ob(), strlcpy(), and recipestruct::yield.

+ Here is the call 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 143 of file c_object.c.

References draw_ext_info(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, and use_skill().

+ Here is the call 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 2070 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, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_CONTAINER, 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 187 of file c_object.c.

References do_skill(), draw_ext_info(), find_skill_by_number(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, and NDI_UNIQUE.

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 1156 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(), put_object_in_sack(), and QUERY_FLAG.

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 1061 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, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_split(), QUERY_FLAG, query_name(), save_player(), SCRIPT_FIX_ALL, sell_item(), shop_contains(), 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 1401 of file c_object.c.

References draw_ext_info_format(), drop(), esrv_update_item(), FLAG_INV_LOCKED, FOR_INV_FINISH, FOR_INV_PREPARE, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, 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()

◆ 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 1603 of file c_object.c.

References add_string(), AT_ACID, create_archetype(), draw_ext_info(), fix_object(), FLAG_APPLIED, FLAG_PROBE, FLAG_UNDEAD, FORCE_NAME, free_string(), knowledge_show_monster_detail(), level, mon, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, NDI_UNIQUE, object_find_by_type_and_name(), object_insert_in_ob(), object_present_in_ob(), probe(), QUERY_FLAG, and SET_FLAG.

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 100 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(), and QUERY_FLAG.

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 131 of file c_object.c.

References AP_NULL, and find_best_apply_object_match().

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 1509 of file c_object.c.

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(), 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 pickup_names, and set_pickup_mode().

Referenced by command_pickup(), and make_matcher().

+ Here is the call graph for this function:
+ 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 2005 of file c_object.c.

References draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_WIZ, FOR_INV_FINISH, FOR_INV_PREPARE, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_INVENTORY, NDI_UNIQUE, QUERY_FLAG, query_name(), and query_weight().

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 794 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, pickup_modes, and matcher_params::pickup_type.

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 728 of file c_object.c.

Referenced by make_matcher().

+ 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 762 of file c_object.c.

References FLAG_IS_FLOOR, matcher_params::missed, matcher_params::name, object_can_pick(), object_matches_string(), and QUERY_FLAG.

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 742 of file c_object.c.

References matcher_params::item_must_be_pickable, matcher_params::item_number, matcher_params::item_to_pick, and object_can_pick().

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 782 of file c_object.c.

References object_matches_pickup_mode(), and matcher_params::pickup_type.

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 646 of file c_object.c.

References FLAG_IS_THROWN, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_CONTAINER, 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, and QUERY_FLAG.

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 509 of file c_object.c.

References draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_STARTEQUIP, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, llevDebug, LOG(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, object_can_pick(), object_insert_in_map(), pick_up_object(), QUERY_FLAG, sack_can_hold(), and stop_item().

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

Try to pick up some item.

Parameters
plobject (player or monster) picking up.
opobject to put tmp into.
tmpobject to pick up.
nrofnumber of tmp to pick up (0 means all of them).

Definition at line 378 of file c_object.c.

References buf, cost_str(), draw_ext_info(), esrv_update_item(), EVENT_PICKUP, events_execute_object_event(), FALSE, fix_object(), FLAG_FREED, FLAG_NO_DROP, FLAG_REMOVED, FLAG_UNPAID, FLAG_WAS_WIZ, FLAG_WIZ, get_weight_limit(), HUGE_BUF, MAX_BUF, Settings::max_stat, MIN, MOVE_FLYING, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, object_free_drop_inventory(), object_get_player_container(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), object_split(), QUERY_FLAG, query_name(), Settings::real_wiz, SCRIPT_FIX_ALL, SET_FLAG, settings, shop_price_buy(), snprintf, and UPD_WEIGHT.

Referenced by pick_up().

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

◆ 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 925 of file c_object.c.

References AP_NO_MERGE, AP_UNAPPLY, apply_special(), CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_STARTEQUIP, FOR_INV_FINISH, FOR_INV_PREPARE, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, object_insert_in_map_at(), object_insert_in_ob(), object_remove(), object_split(), QUERY_FLAG, query_name(), sack_can_hold(), set_object_face_main(), transport_can_hold(), and UPD_WEIGHT.

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 316 of file c_object.c.

References draw_ext_info_format(), FLAG_APPLIED, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, QUERY_FLAG, and query_name().

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 2260 of file c_object.c.

References draw_ext_info(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, and NDI_UNIQUE.

Referenced by command_pickup(), and get_pickup_mode_index().

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

Variable Documentation

◆ pickup_modes

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

Value in Pickup modes associated with pickup_names.

Definition at line 43 of file c_object.c.

Referenced by command_pickup(), and make_matcher().

◆ 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", NULL
}

Valid names for pickup types.

Definition at line 33 of file c_object.c.

Referenced by get_pickup_mode_index().