Crossfire Server, Trunk
object.cpp File Reference
#include "global.h"
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "loader.h"
#include "object.h"
#include "skills.h"
#include "sproto.h"
#include "stringbuffer.h"
+ Include dependency graph for object.cpp:

Go to the source code of this file.

Functions

int absdir (int d)
 
objectadd_force (object *op, const char *name, int duration)
 
static void ADD_STRINGLINE_ENTRY (StringBuffer *sb, const char *name, const char *value)
 
objectarch_present_in_ob (const archetype *at, const object *op)
 
int can_see_monsterP (mapstruct *m, int x, int y, int dir)
 
static int compare_ob_value_lists (const object *, const object *)
 
static int compare_ob_value_lists_one (const object *, const object *)
 
int dirdiff (int dir1, int dir2)
 
static void expand_objects (void)
 
static void FAST_SAVE_DOUBLE (StringBuffer *sb, const char *name, const double value)
 
static void FAST_SAVE_LONG (StringBuffer *sb, const char *name, const long value)
 
int find_dir_2 (int x, int y)
 
objectfind_force (object *op, const char *name)
 
static objectfind_insert_pos (object *op, const int flag)
 
int flags_differ (ob_flags *diff)
 
void get_ob_diff (StringBuffer *sb, const object *op, const object *op2)
 
void get_search_arr (int *search_arr)
 
static void get_string_move_type (StringBuffer *sb, MoveType mt)
 
void init_objects (void)
 
objectmap_find_by_archetype (mapstruct *m, int x, int y, const archetype *at)
 
objectmap_find_by_type (mapstruct *m, int x, int y, uint8_t type)
 
void object_add_weight (object *op, signed long weight)
 
int object_can_merge (object *ob1, object *ob2)
 
int object_can_pick (const object *who, const object *item)
 
int object_check_move_on (object *op, object *originator)
 
void object_clear (object *op)
 
void object_clear_owner (object *op)
 
void object_copy (const object *src_ob, object *dest_ob)
 
void object_copy_no_speed (const object *src_ob, object *dest_ob)
 
void object_copy_owner (object *op, object *clone)
 
void object_copy_with_inv (const object *src_ob, object *dest_ob, bool update_speed)
 
int object_count_active (void)
 
int object_count_free (void)
 
int object_count_used (void)
 
objectobject_create_clone (object *asrc)
 
objectobject_decrease_nrof (object *op, uint32_t i)
 
int object_distance (const object *ob1, const object *ob2)
 
void object_dump (const object *op, StringBuffer *sb)
 
void object_dump_all (void)
 
objectobject_find_by_arch_name (const object *who, const char *name)
 
objectobject_find_by_flag (const object *who, int flag)
 
objectobject_find_by_flag_applied (const object *who, int flag)
 
objectobject_find_by_name (const object *who, const char *name)
 
objectobject_find_by_name_global (const char *str)
 
objectobject_find_by_tag (const object *who, tag_t tag)
 
objectobject_find_by_tag_global (tag_t i)
 
objectobject_find_by_type (const object *who, int type)
 
objectobject_find_by_type2 (const object *who, int type1, int type2)
 
objectobject_find_by_type_and_arch_name (const object *who, int type, const char *name)
 
objectobject_find_by_type_and_name (const object *who, int type, const char *name)
 
objectobject_find_by_type_and_race (const object *who, int type, const char *race)
 
objectobject_find_by_type_and_skill (const object *who, int type, const char *skill)
 
objectobject_find_by_type_and_slaying (const object *who, int type, const char *slaying)
 
objectobject_find_by_type_applied (const object *who, int type)
 
objectobject_find_by_type_subtype (const object *who, int type, int subtype)
 
objectobject_find_by_type_without_flags (const object *who, int type, int *flags, int num_flags)
 
int object_find_first_free_spot (const object *ob, mapstruct *m, int x, int y)
 
int object_find_free_spot (const object *ob, mapstruct *m, int x, int y, int start, int stop)
 
int object_find_multi_free_spot_around (const object *ob, const object *gen, int16_t *hx, int16_t *hy)
 
int object_find_multi_free_spot_within_radius (const object *ob, const object *gen, int *hx, int *hy)
 
void object_fix_multipart (object *tmp)
 
void object_free (object *ob, int flags)
 
void object_free_all_data (void)
 
void object_free_drop_inventory (object *ob)
 
void object_free_inventory (object *ob)
 
void object_free_key_values (object *op)
 
objectobject_get_env_recursive (object *op)
 
key_valueobject_get_key_value (const object *ob, const char *key)
 
void object_get_multi_size (const object *ob, int *sx, int *sy, int *hx, int *hy)
 
objectobject_get_owner (object *op)
 
static const objectobject_get_owner_const (const object *op)
 
objectobject_get_player_container (object *op)
 
const char * object_get_value (const object *op, const char *const key)
 
void object_handle_death_animation (object *op)
 
static void object_increase_nrof (object *op, uint32_t i)
 
objectobject_insert_in_map (object *op, mapstruct *m, object *originator, int flag)
 
objectobject_insert_in_map_at (object *op, mapstruct *m, object *originator, int flag, int x, int y)
 
objectobject_insert_in_ob (object *op, object *where)
 
void object_insert_to_free_spot_or_free (object *op, mapstruct *map, int x, int y, int start, int stop, object *originator)
 
int object_matches_string (object *pl, object *op, const char *name)
 
objectobject_merge (object *op, object *top)
 
void object_merge_spell (object *op, int16_t x, int16_t y)
 
objectobject_new (void)
 
objectobject_present_in_ob (uint8_t type, const object *op)
 
objectobject_present_in_ob_by_name (int type, const char *str, const object *op)
 
void object_remove (object *op)
 
void object_remove_from_active_list (object *op)
 
void object_replace_insert_in_map (const char *arch_string, object *op)
 
void object_reset (object *op)
 
void object_set_cheat (object *op)
 
void object_set_enemy (object *op, object *enemy)
 
void object_set_flag_inv (object *op, int flag)
 
void object_set_msg (object *op, const char *msg)
 
void object_set_owner (object *op, object *owner)
 
int object_set_value (object *op, const char *key, const char *value, int add_key)
 
static int object_set_value_s (object *, const char *, const char *, int)
 
objectobject_split (object *orig_ob, uint32_t nr, char *err, size_t size)
 
void object_sub_weight (object *op, signed long weight)
 
signed long object_sum_weight (object *op)
 
void object_unset_flag_inv (object *op, int flag)
 
void object_update (object *op, int action)
 
void object_update_speed (object *op)
 
void object_update_turn_face (object *op)
 
bool object_value_set (const object *op, const char *const key)
 
bool object_value_set_shared (const object *op, sstring key)
 
static void permute (int *, int, int)
 
int save_object (FILE *fp, object *op, int flag)
 
void save_object_in_sb (StringBuffer *sb, object *op, const int flag)
 

Variables

objectactive_objects
 
static const char *const flag_names [NUM_FLAGS+1]
 
static objectfree_objects
 
short freearr_x [SIZEOFFREE]
 
short freearr_y [SIZEOFFREE]
 
int freedir [SIZEOFFREE]
 
int maxfree [SIZEOFFREE]
 
const char *const move_name []
 
int nrofallocobjects = STARTMAX
 
int nroffreeobjects = STARTMAX
 
static object objarray [STARTMAX]
 
objectobjects
 
static const int reduction_dir [SIZEOFFREE][3]
 
const char *const spell_mapping [SPELL_MAPPINGS]
 

Detailed Description

Everything related to objects, in their basic form.

Definition in file object.cpp.

Function Documentation

◆ absdir()

int absdir ( int  d)

Computes an absolute direction.

Parameters
ddirection to convert.
Returns
number between 1 and 8, which represent the "absolute" direction of a number (it actually takes care of "overflow" in previous calculations of a direction).

Definition at line 3707 of file object.cpp.

Referenced by adjust_dir(), check_spell_knockback(), common_process_projectile(), fire_arch_from_position(), fire_bolt(), flee_player(), forklightning(), get_randomized_dir(), monster_compute_path(), monster_dist_att(), monster_disthit_att(), monster_hitrun_att(), monster_move(), monster_run_att(), monster_wait_att(), monster_wait_att2(), move_ball_spell(), move_bolt(), move_bullet(), move_cone(), move_swarm_spell(), path_to_player(), pets_move(), pets_summon_object(), player_fire_bow(), pray_at_altar(), spinner_type_move_on(), and turn_transport().

+ Here is the caller graph for this function:

◆ add_force()

object* add_force ( object op,
const char *  name,
int  duration 
)

Add or return an existing force inside 'op' with the given 'name' and 'duration' in units of 100 ticks (12 seconds under default settings). If 'duration' is zero, the force will not expire by itself.

Definition at line 5416 of file object.cpp.

References add_string(), create_archetype(), find_force(), dragon_attune::force, FORCE_NAME, give::name, object_insert_in_ob(), object_update_speed(), and give::op.

Referenced by commit_crime(), and move_marker().

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

◆ ADD_STRINGLINE_ENTRY()

static void ADD_STRINGLINE_ENTRY ( StringBuffer sb,
const char *  name,
const char *  value 
)
inlinestatic

Adds a line to the buffer.

Definition at line 4929 of file object.cpp.

References give::name, stringbuffer_append_string(), and autojail::value.

Referenced by get_ob_diff(), and save_object_in_sb().

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

◆ arch_present_in_ob()

object* arch_present_in_ob ( const archetype at,
const object op 
)

Searches for any objects with a matching archetype in the inventory of the given object.

Parameters
atarchetype to search for.
opwhere to search.
Returns
first matching object, or NULL if none matches.

Definition at line 3215 of file object.cpp.

References give::op, and Ice::tmp.

Referenced by cast_heal(), cfapi_object_find_archetype_inside(), cfapi_object_get_property(), change_luck(), create_aura(), drain_specific_stat(), kill_player_not_permadeath(), perceive_self(), poison_living(), remove_depletion(), restore_player(), slow_living_by(), and START_TEST().

+ Here is the caller graph for this function:

◆ can_see_monsterP()

int can_see_monsterP ( mapstruct m,
int  x,
int  y,
int  dir 
)

Recursive routine to see if we can find a path to a certain point.

Modified to be map tile aware -.MSW

Parameters
mmap we're on
x
yorigin coordinates
dirdirection we're going to. Must be less than SIZEOFFREE.
Returns
1 if we can see a direct way to get it
Todo:
better document, can't figure what it does :)

Definition at line 3815 of file object.cpp.

References can_see_monsterP(), freearr_x, freearr_y, get_map_flags(), m, P_BLOCKSVIEW, P_OUT_OF_MAP, reduction_dir, diamondslots::x, and diamondslots::y.

Referenced by can_see_monsterP(), do_skill_ident(), monster_find_nearest_enemy(), and spell_find_dir().

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

◆ compare_ob_value_lists()

static int compare_ob_value_lists ( const object ob1,
const object ob2 
)
static

Compares two object lists.

Parameters
ob1
ob2objects to compare.
Returns
TRUE if ob1 has the same key_values as ob2.

Definition at line 404 of file object.cpp.

References compare_ob_value_lists_one(), guildbuy::ob1, and guildbuy::ob2.

Referenced by object_can_merge().

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

◆ compare_ob_value_lists_one()

static int compare_ob_value_lists_one ( const object wants,
const object has 
)
static

Compares value lists.

Parameters
wantswhat to search
haswhere to search.
Returns
TRUE if every key_values in wants has a partner with the same value in has.

Definition at line 363 of file object.cpp.

References FALSE, key_value::key, object::key_values, key_value::next, object_get_key_value(), TRUE, and key_value::value.

Referenced by compare_ob_value_lists().

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

◆ dirdiff()

int dirdiff ( int  dir1,
int  dir2 
)

Computes a direction difference.

Parameters
dir1
dir2directions to compare.
Returns
how many 45-degrees differences there is between two directions (which are expected to be absolute (see absdir())

Definition at line 3725 of file object.cpp.

Referenced by monster_cast_spell(), monster_use_range(), monster_use_scroll(), and monster_use_skill().

+ Here is the caller graph for this function:

◆ expand_objects()

static void expand_objects ( void  )
static

Allocates more objects for the list of unused objects.

It is called from object_new() if the unused list is empty.

If there is not enough memory, fatal() is called.

Definition at line 1231 of file object.cpp.

References CALLOC, fatal(), FLAG_FREED, FLAG_REMOVED, free_objects, object::next, nrofallocobjects, nroffreeobjects, OBJ_EXPAND, OUT_OF_MEMORY, object::prev, and SET_FLAG.

Referenced by object_new().

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

◆ FAST_SAVE_DOUBLE()

static void FAST_SAVE_DOUBLE ( StringBuffer sb,
const char *  name,
const double  value 
)
inlinestatic

Adds a double to the buffer. name must have a space at the end.

Definition at line 4943 of file object.cpp.

References give::name, stringbuffer_append_printf(), and autojail::value.

Referenced by get_ob_diff().

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

◆ FAST_SAVE_LONG()

static void FAST_SAVE_LONG ( StringBuffer sb,
const char *  name,
const long  value 
)
inlinestatic

Adds a long to the buffer. name must have a space at the end.

Definition at line 4936 of file object.cpp.

References give::name, stringbuffer_append_char(), stringbuffer_append_int64(), stringbuffer_append_string(), and autojail::value.

Referenced by get_ob_diff(), and save_object_in_sb().

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

◆ find_dir_2()

int find_dir_2 ( int  x,
int  y 
)

Computes a direction which you should travel to move of x and y.

Parameters
x
ydelta.
Returns
direction

Definition at line 3670 of file object.cpp.

References item::q, diamondslots::x, and diamondslots::y.

Referenced by enter_map(), get_rangevector(), and get_rangevector_from_mapcoord().

+ Here is the caller graph for this function:

◆ find_force()

object* find_force ( object op,
const char *  name 
)

Find a force with the given 'name' in the slaying field. These forces are used as markers that may expire, for example, in the marker type. This is a thin wrapper around object_find_by_type_and_slaying().

Definition at line 5411 of file object.cpp.

References FORCE, give::name, object_find_by_type_and_slaying(), and give::op.

Referenced by add_force(), is_criminal(), and move_marker().

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

◆ find_insert_pos()

static object* find_insert_pos ( object op,
const int  flag 
)
static

◆ flags_differ()

int flags_differ ( ob_flags diff)

Return the index of the first difference in the given object flag difference set (computed by compare_flags) or -1 if there is no difference. Then modify the difference set so that the subsequent call on the same set returns the next difference.

Definition at line 4953 of file object.cpp.

Referenced by get_ob_diff().

+ Here is the caller graph for this function:

◆ get_ob_diff()

void get_ob_diff ( StringBuffer sb,
const object op,
const object op2 
)

Returns a pointer to a static string which contains all variables which are different in the two given objects.

This function is typically used to dump objects (op2=empty object), or to save objects

Parameters
sbbuffer that will contain the difference.
opwhat object the different values will be taken from.
op2object's original archetype.

Definition at line 4979 of file object.cpp.

References living::ac, ADD_STRINGLINE_ENTRY(), object::anim_suffix, object::animation, object::attack_movement, object::attacktype, object::body_info, body_locations, object::carrying, living::Cha, object::client_type, compare_flags(), living::Con, living::dam, object::dam_modifier, living::Dex, object::direction, object::duration, object::duration_modifier, living::exp, object::expmul, object::face, FAST_SAVE_DOUBLE(), FAST_SAVE_LONG(), FLAG_ANIMATE, FLAG_IS_LINKED, flag_names, flags_differ(), FMT64, living::food, object::gen_sp_armour, get_button_value(), get_string_move_type(), object::glow_radius, living::grace, living::hp, living::Int, object::invisible, object::item_power, key_value::key, object::last_eat, object::last_grace, object::last_heal, object::last_sp, object::level, object::lore, living::luck, object::magic, object::map_layer, map_layer_name, object::material, object::materialname, living::maxgrace, living::maxhp, living::maxsp, object::move_allow, object::move_block, object::move_off, object::move_on, object::move_slow, object::move_slow_penalty, object::move_status, object::move_type, object::msg, object::name, object::name_pl, key_value::next, object::nrof, NROFATTACKS, NUM_BODY_LOCATIONS, object_get_key_value(), give::op, object::other_arch, object::path_attuned, object::path_denied, object::path_repelled, object::pick_up, living::Pow, QUERY_FLAG, object::race, object::randomitems, object::range, object::range_modifier, object::resist, resist_save, object::run_away, object::skill, object::slaying, object::smoothlevel, living::sp, object::speed, object::speed_left, object::state, object::stats, living::Str, stringbuffer_append_string(), object::subtype, object::title, Ice::tmp, object::total_exp, object::type, key_value::value, object::value, living::wc, object::weapon_speed, object::weapon_speed_left, object::weapontype, object::weight, object::weight_limit, object::will_apply, living::Wis, object::x, and object::y.

Referenced by add_one_item(), command_diff(), doWrite(), object_dump(), Archetypes::recursive_update(), save_object_in_sb(), START_TEST(), ArtifactPanel::updateItem(), and ArtifactWriter::write().

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

◆ get_search_arr()

void get_search_arr ( int *  search_arr)

New function to make monster searching more efficient, and effective! This basically returns a randomized array (in the passed pointer) of the spaces to find monsters. In this way, it won't always look for monsters to the north first. However, the size of the array passed covers all the spaces, so within that size, all the spaces within the 3x3 area will be searched, just not in a predictable order.

Parameters
search_arrarray that will be initialized. Must contain at least SIZEOFFREE elements.

Definition at line 3635 of file object.cpp.

References permute(), SIZEOFFREE, SIZEOFFREE1, and SIZEOFFREE2.

Referenced by monster_find_nearest_enemy(), pets_get_enemy(), and spell_find_dir().

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

◆ get_string_move_type()

static void get_string_move_type ( StringBuffer sb,
MoveType  mt 
)
static

This returns a string of the integer movement type

Parameters
sbbuffer that will contain the description. Must not be NULL.
mtmove to describe.

Definition at line 4885 of file object.cpp.

References disinfect::count, MAX_BUF, MOVE_ALL, move_name, and stringbuffer_append_string().

Referenced by get_ob_diff().

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

◆ init_objects()

void init_objects ( void  )

Sets up and initialises the linked list of free and used objects. Allocates a certain chunk of objects and puts them on the free list. Called by init_library();

Definition at line 327 of file object.cpp.

References active_objects, FLAG_FREED, FLAG_REMOVED, free_objects, object::next, objarray, objects, object::prev, SET_FLAG, and STARTMAX.

Referenced by cctk_init_std_archetypes(), and init_library().

+ Here is the caller graph for this function:

◆ map_find_by_archetype()

object* map_find_by_archetype ( mapstruct m,
int  x,
int  y,
const archetype at 
)

Searches for any objects with a matching archetype at the given map and coordinates.

Parameters
m
x
ywhere to search. Must be valid position.
atarchetype to search for.
Returns
first matching object, or NULL if none matches.

Definition at line 3111 of file object.cpp.

References FOR_MAP_FINISH, FOR_MAP_PREPARE, llevError, LOG(), m, OUT_OF_REAL_MAP, Ice::tmp, diamondslots::x, and diamondslots::y.

Referenced by cfapi_map_find_by_archetype_name(), put_in_icecube(), and town_portal_destroy_existing().

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

◆ map_find_by_type()

object* map_find_by_type ( mapstruct m,
int  x,
int  y,
uint8_t  type 
)

Searches for any objects with a matching type variable at the given map and coordinates.

Parameters
m
x
ywhere to search. Must be valid position.
typetype to get.
Returns
first matching object, or NULL if none matches.

Definition at line 3138 of file object.cpp.

References FOR_MAP_FINISH, FOR_MAP_PREPARE, m, OUT_OF_REAL_MAP, Ice::tmp, is_valid_types_gen::type, diamondslots::x, and diamondslots::y.

Referenced by identify(), remove_door(), and remove_locked_door().

+ Here is the caller graph for this function:

◆ object_add_weight()

void object_add_weight ( object op,
signed long  weight 
)

object_add_weight(object, weight) adds the specified weight to an object, and also updates how much the environment(s) is/are carrying.

Takes container weight reduction into account.

Parameters
opobject to which we add weight.
weightweight to add.
Todo:
check if mergeable with object_sub_weight().

Definition at line 2827 of file object.cpp.

References CONTAINER, and give::op.

Referenced by make_item_from_recipe(), object_decrease_nrof(), object_increase_nrof(), and object_insert_in_ob().

+ Here is the caller graph for this function:

◆ object_can_merge()

int object_can_merge ( object ob1,
object ob2 
)

Examines the 2 objects given to it, and returns true if they can be merged together, including inventory.

Note that this function appears a lot longer than the macro it replaces - this is mostly for clarity - a decent compiler should hopefully reduce this to the same efficiency.

Check nrof variable before calling object_can_merge()

Improvements made with merge: Better checking on potion, and also check weight

Parameters
ob1
ob2objects to try to merge.
Returns
TRUE if they can be merged, FALSE else.
Todo:
check the function at places marked.

Definition at line 433 of file object.cpp.

References compare_ob_value_lists(), FABS, FLAG_ANIMATE, FLAG_APPLIED, FLAG_BEEN_APPLIED, FLAG_IDENTIFIED, MIN_ACTIVE_SPEED, guildbuy::ob1, guildbuy::ob2, object_can_merge(), QUERY_FLAG, SCROLL, and SET_FLAG.

Referenced by cfapi_object_get_property(), check_loaded_object(), give_initial_items(), local_check_loaded_object(), object_can_merge(), object_insert_in_map(), object_insert_in_ob(), object_merge(), and START_TEST().

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

◆ object_can_pick()

int object_can_pick ( const object who,
const object item 
)

Finds out if an object can be picked up.

Add a check so we can't pick up invisible objects (0.93.8)

Parameters
whowho is trying to pick up. Can be a monster or a player.
itemitem we're trying to pick up.
Returns
1 if it can be picked up, otherwise 0.
Note
this introduces a weight limitation for monsters.

Definition at line 3860 of file object.cpp.

References FLAG_ALIVE, FLAG_NO_PICK, get_weight_limit(), PLAYER, QUERY_FLAG, TRANSPORT, and autojail::who.

Referenced by cfapi_object_get_property(), check_pick(), do_skill_detect_curse(), do_skill_detect_magic(), esrv_move_object(), examine(), matcher_name(), matcher_number(), monster_can_pick(), and pick_up().

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

◆ object_check_move_on()

int object_check_move_on ( object op,
object originator 
)

Checks if any objects has a move_type that matches objects that effect this object on this space. Call apply() to process these events.

Any speed-modification due to SLOW_MOVE() of other present objects will affect the speed_left of the object. 4-21-95 added code to check if appropriate skill was readied - this will permit faster movement by the player through this terrain. -b.t.

MSW 2001-07-08: Check all objects on space, not just those below object being inserted. object_insert_in_map may not put new objects on top.

Parameters
opobject that may trigger something.
originatorplayer, monster or other object that caused 'op' to be inserted into 'map'. May be NULL.
Returns
1 if 'op' was destroyed, 0 otherwise.

Definition at line 3005 of file object.cpp.

References FABS, find_skill_by_number(), FLAG_IS_HILLY, FLAG_IS_WOODED, FLAG_NO_APPLY, FLAG_NO_PICK, FLAG_WIZPASS, FOR_OB_AND_ABOVE_FINISH, FOR_OB_AND_ABOVE_PREPARE, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, GET_MAP_MOVE_BLOCK, GET_MAP_MOVE_ON, GET_MAP_MOVE_SLOW, GET_MAP_OB, m, MOVE_FLY_LOW, MOVE_WALK, ob_move_on(), object_was_destroyed, give::op, PLAYER, QUERY_FLAG, SK_CLIMBING, SK_WOODSMAN, CFweardisguise::tag, Ice::tmp, diamondslots::x, and diamondslots::y.

Referenced by change_abil(), and object_insert_in_map().

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

◆ object_clear()

void object_clear ( object op)

Frees everything allocated by an object, and also clears all variables and flags to default settings.

Parameters
opobject to clear

Definition at line 983 of file object.cpp.

References blank_face, Settings::casting_time, FLAG_FRIENDLY, FLAG_REMOVED, FREE_AND_CLEAR_STR, free_dialog_information(), give::name, object_free_key_values(), offsetof, give::op, QUERY_FLAG, remove_friendly_object(), SET_FLAG, and settings.

Referenced by cfapi_object_clear(), get_archetype_struct(), object_new(), object_reset(), and START_TEST().

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

◆ object_clear_owner()

void object_clear_owner ( object op)

Clears the owner of specified object.

Parameters
opobject we want to clear the owner of. Can be NULL.

Definition at line 823 of file object.cpp.

References give::op.

Referenced by do_mood_floor(), fix_stopped_arrow(), object_get_owner(), object_set_owner(), START_TEST(), and stop_projectile().

+ Here is the caller graph for this function:

◆ object_copy()

void object_copy ( const object src_ob,
object dest_ob 
)

Copy object first frees everything allocated by the second object, and then copies the contents of the first object into the second object, allocating what needs to be allocated. Basically, any data that is malloc'd needs to be re-malloc/copied. Otherwise, if the first object is freed, the pointers in the new object will point at garbage. Will call object_update_speed() on the copied object.

Parameters
src_obobject that we copy.from
dest_obobject that we copy to.

Definition at line 1192 of file object.cpp.

References object_copy_no_speed(), and object_update_speed().

Referenced by add_abilities(), apply_race_and_class(), cast_create_food(), cfapi_object_clone(), change_book(), check_loaded_object(), command_create(), do_learn_spell(), enter_exit(), explosion(), forklightning(), infect_object(), key_change_class(), local_check_loaded_object(), magic_wall(), make_throw_ob(), move_bolt(), move_cone(), object_copy_with_inv(), object_create_clone(), pay_from_container(), place_special_exit(), polymorph_item(), put_decor(), put_doors(), sell_item(), setup(), START_TEST(), while(), write_note(), write_rune(), and write_scroll().

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

◆ object_copy_no_speed()

void object_copy_no_speed ( const object src_ob,
object dest_ob 
)

Copy object first frees everything allocated by the second object, and then copies the contents of the first object into the second object, allocating what needs to be allocated. Basically, any data that is malloc'd needs to be re-malloc/copied. Otherwise, if the first object is freed, the pointers in the new object will point at garbage. Will not call object_update_speed() on the copied object.

Parameters
src_obobject that we copy.from
dest_obobject that we copy to.

Definition at line 1061 of file object.cpp.

References add_refcount(), object::anim_suffix, object::arch, object::artifact, BITMASK_VALID, CLEAR_FLAG, object::event_bitmask, FLAG_DIALOG_PARSED, FLAG_FREED, FLAG_REMOVED, FREE_AND_CLEAR, free_dialog_information(), free_string(), key_value::key, object::key_values, object::lore, object::materialname, object::msg, give::name, object::name, object::name_pl, key_value::next, object_free_key_values(), offsetof, QUERY_FLAG, object::race, RANDOM, archetype::reference_count, SET_FLAG, object::skill, object::slaying, object::speed, object::speed_left, SPELL_TAG_SIZE, object::spell_tags, object::title, key_value::value, and nlohmann::detail::void().

Referenced by object_copy(), object_copy_with_inv(), and while().

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

◆ object_copy_owner()

void object_copy_owner ( object op,
object clone 
)

Set the owner to clone's current owner and set the skill and experience objects to clone's objects (typically those objects that where the owner's current skill and experience objects at the time when clone's owner was set - not the owner's current skill and experience objects).

Use this function if player created an object (e.g. fire bullet, swarm spell), and this object creates further objects whose kills should be accounted for the player's original skill, even if player has changed skills meanwhile.

Parameters
opobject to update.
cloneobject from which to get the owner.

Definition at line 893 of file object.cpp.

References object_get_owner(), object_set_owner(), give::op, PLAYER, and object::type.

Referenced by animate_bomb(), explode_bullet(), fire_arch_from_position(), poison_living(), and START_TEST().

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

◆ object_copy_with_inv()

void object_copy_with_inv ( const object src_ob,
object dest_ob,
bool  update_speed 
)

Copy an object with an inventory, duplicate the inv too.

Parameters
src_obobject to copy.
dest_obwhere to copy.
update_speedif true then call update_speed() on the duplicated objects, else don't.
Todo:
replace with a function in common library (there is certainly one).

Definition at line 1208 of file object.cpp.

References FOR_INV_FINISH, FOR_INV_PREPARE, object_copy(), object_copy_no_speed(), object_copy_with_inv(), object_insert_in_ob(), object_new(), and Ice::tmp.

Referenced by arch_to_object(), do_harvest(), include_map_in_map(), object_copy_with_inv(), place_chest(), place_fountain_with_specials(), place_monsters(), Archetypes::recursive_update(), and Archetypes::replace().

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

◆ object_count_active()

int object_count_active ( void  )

Objects statistics.

Returns
number of objects on the list of active objects.

Definition at line 1783 of file object.cpp.

References active_objects, and Ice::tmp.

Referenced by malloc_info(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_count_free()

int object_count_free ( void  )

Objects statistics.

Returns
number of objects on the list of free objects.

Definition at line 1751 of file object.cpp.

References free_objects, and Ice::tmp.

Referenced by malloc_info(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_count_used()

int object_count_used ( void  )

Object statistics.

Returns
number of objects on the list of used objects.

Definition at line 1767 of file object.cpp.

References objects, and Ice::tmp.

Referenced by malloc_info(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_create_clone()

object* object_create_clone ( object asrc)

Create clone from object to another.

Parameters
asrcobject to clone.
Returns
clone of asrc, including inventory and 'more' body parts.
Note
this function will return NULL only if asrc is NULL. If there is a memory allocation error, object_new() calls fatal().

Definition at line 3902 of file object.cpp.

References FOR_INV_FINISH, FOR_INV_PREPARE, HEAD, object_copy(), object_create_clone(), object_insert_in_ob(), object_new(), Ice::tmp, and nlohmann::detail::void().

Referenced by cfapi_object_clone(), convert_item(), generate_monster_arch(), generate_monster_inv(), move_creator(), object_create_clone(), and object_split().

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

◆ object_decrease_nrof()

object* object_decrease_nrof ( object op,
uint32_t  i 
)

Decreases a specified number from the amount of an object. If the amount reaches 0, the object is subsequently removed and freed.

This function will send an update to client if op is in a player inventory.

Parameters
opobject to decrease.
inumber to remove.
Returns
'op' if something is left, NULL if the amount reached 0.

Definition at line 2670 of file object.cpp.

References esrv_update_item(), first_player, fix_object(), FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, object_add_weight(), object_free_drop_inventory(), object_get_player_container(), object_remove(), object_sub_weight(), give::op, altar_valkyrie::pl, QUERY_FLAG, Ice::tmp, UPD_NROF, and UPD_WEIGHT.

Referenced by cfapi_object_set_property(), check_altar_sacrifice(), convert_item(), eat_item(), object_split(), operate_altar(), save_throw_object(), spell_consume_items(), and START_TEST().

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

◆ object_distance()

int object_distance ( const object ob1,
const object ob2 
)

Return the square of the distance between the two given objects.

Parameters
ob1
ob2objects we want to compute the distance of.

Definition at line 3654 of file object.cpp.

References guildbuy::ob1, and guildbuy::ob2.

Referenced by cfapi_object_distance().

+ Here is the caller graph for this function:

◆ object_dump()

void object_dump ( const object op,
StringBuffer sb 
)

Dumps an object.

Parameters
opobject to dump. Can be NULL.
sbbuffer that will contain object information. Must not be NULL.

Definition at line 645 of file object.cpp.

References archetype::clone, object::count, empty_archetype, get_ob_diff(), object_get_owner_const(), give::op, stringbuffer_append_printf(), and stringbuffer_append_string().

Referenced by animate_object(), ArchetypeWrapper::ArchetypeWrapper(), command_dump(), do_dump(), dump_arch(), gate_type_process(), object_dump_all(), object_free(), object_insert_in_map(), object_insert_in_ob(), object_remove(), process_events(), and START_TEST().

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

◆ object_dump_all()

void object_dump_all ( void  )

Dumps all objects to console.

This is really verbose...Can be triggered by the dumpallobjects command while in DM mode.

All objects are dumped to stderr (or alternate logfile, if in server-mode)

Definition at line 704 of file object.cpp.

References llevDebug, LOG(), object_dump(), objects, give::op, stringbuffer_finish(), and stringbuffer_new().

Referenced by command_dumpallobjects(), and START_TEST().

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

◆ object_find_by_arch_name()

object* object_find_by_arch_name ( const object who,
const char *  name 
)

Find object in inventory by archetype name.

Parameters
whowhere to search.
namewhat to search.
Returns
first object in who's inventory that has the archetype name match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4245 of file object.cpp.

References give::name, Ice::tmp, and autojail::who.

Referenced by annotate_ob(), cfapi_object_find_by_arch_name(), and dragon_ability_gain().

+ Here is the caller graph for this function:

◆ object_find_by_flag()

object* object_find_by_flag ( const object who,
int  flag 
)

Find object in inventory by flag.

Parameters
whowhere to search.
flagwhat to search.
Returns
first object in who's inventory that has the flag set. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4199 of file object.cpp.

References QUERY_FLAG, Ice::tmp, and autojail::who.

Referenced by use_alchemy().

+ Here is the caller graph for this function:

◆ object_find_by_flag_applied()

object* object_find_by_flag_applied ( const object who,
int  flag 
)

Find applied object in inventory by flag.

Parameters
whowhere to search.
flagwhat to search.
Returns
first object in who's inventory that has the flag set and is applied. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4222 of file object.cpp.

References FLAG_APPLIED, QUERY_FLAG, Ice::tmp, and autojail::who.

Referenced by save_life().

+ Here is the caller graph for this function:

◆ object_find_by_name()

object* object_find_by_name ( const object who,
const char *  name 
)

Finds an object in inventory name.

Parameters
whothe object to search
namename to search for
Returns
the first object which has a name equal to the argument, NULL if none found.

Definition at line 3949 of file object.cpp.

References add_string(), free_string(), give::name, Ice::tmp, and autojail::who.

Referenced by apply_changes_to_player(), cfapi_object_find_by_name(), is_old_wraith_pl(), is_wraith_pl(), and move_detector().

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

◆ object_find_by_name_global()

object* object_find_by_name_global ( const char *  str)

Finds an object by name.

Used only by the patch command, but not all that useful. Enables features like "patch name-of-other-player food 999"

Parameters
strname to search for. Must not be allocated by add_string().
Returns
the first object which has a name equal to the argument.

Definition at line 747 of file object.cpp.

References add_string(), free_string(), give::name, objects, give::op, and make_face_from_files::str.

Referenced by command_possess(), find_object_both(), and START_TEST().

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

◆ object_find_by_tag()

object* object_find_by_tag ( const object who,
tag_t  tag 
)

Find object in inventory.

Parameters
whowhere to search.
tagwhat to search.
Returns
first object in who's inventory that has the given tag. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4053 of file object.cpp.

References CFweardisguise::tag, Ice::tmp, and autojail::who.

Referenced by command_cast_spell().

+ Here is the caller graph for this function:

◆ object_find_by_tag_global()

object* object_find_by_tag_global ( tag_t  i)

Returns the object which has the count-variable equal to the argument.

Parameters
itag.
Returns
matching object, NULL if not found.

Definition at line 727 of file object.cpp.

References objects, and give::op.

Referenced by cftimer_process_event(), command_diff(), command_insert_into(), command_inventory(), command_possess(), command_stack_list(), dm_stack_peek(), find_object_both(), get_dm_object(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_find_by_type()

object* object_find_by_type ( const object who,
int  type 
)

Find object in inventory.

Parameters
whowhere to search.
typewhat to search.
Returns
first object in who's inventory that has the same type match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 3973 of file object.cpp.

References Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by fire_bow(), has_ability(), and transport_type_apply().

+ Here is the caller graph for this function:

◆ object_find_by_type2()

object* object_find_by_type2 ( const object who,
int  type1,
int  type2 
)

Find object in inventory.

Parameters
whowhere to search.
type1what to search.
type2what to search.
Returns
first object in who's inventory that has either type match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4030 of file object.cpp.

References Ice::tmp, and autojail::who.

Referenced by dispel_rune(), and hit_player().

+ Here is the caller graph for this function:

◆ object_find_by_type_and_arch_name()

object* object_find_by_type_and_arch_name ( const object who,
int  type,
const char *  name 
)

Find object in inventory by type and archetype name.

Parameters
whowhere to search.
typewhat to search.
namewhat to search.
Returns
first object in who's inventory that has the type and archetype name match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4270 of file object.cpp.

References give::name, Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by check_login(), command_resistances(), dragon_eat_flesh(), dragon_focus_type_apply(), dragon_level_gain(), and perceive_self().

+ Here is the caller graph for this function:

◆ object_find_by_type_and_name()

object* object_find_by_type_and_name ( const object who,
int  type,
const char *  name 
)

Find object in inventory by type and name.

Parameters
whowhere to search.
typewhat to search.
namewhat to search
Returns
first object in who's inventory that has the same type and name match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4101 of file object.cpp.

References give::name, Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by check_probe(), check_spell_known(), describe_monster(), do_symptoms(), examine_monster(), find_symptom(), grant_immunity(), infect_object(), and old_describe_monster().

+ Here is the caller graph for this function:

◆ object_find_by_type_and_race()

object* object_find_by_type_and_race ( const object who,
int  type,
const char *  race 
)

Find object in inventory by type and race.

Parameters
whowhere to search.
typewhat to search.
racewhat to search
Returns
first object in who's inventory that has the same type and race match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4126 of file object.cpp.

References Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by monster_check_apply().

+ Here is the caller graph for this function:

◆ object_find_by_type_and_skill()

object* object_find_by_type_and_skill ( const object who,
int  type,
const char *  skill 
)

Find object in inventory by type and skill.

Parameters
whowhere to search.
typewhat to search.
skillwhat to search
Returns
first object in who's inventory that has the same type and skill match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4176 of file object.cpp.

References Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by do_skill().

+ Here is the caller graph for this function:

◆ object_find_by_type_and_slaying()

object* object_find_by_type_and_slaying ( const object who,
int  type,
const char *  slaying 
)

Find object in inventory by type and slaying.

Parameters
whowhere to search.
typewhat to search.
slayingwhat to search
Returns
first object in who's inventory that has the same type and slaying match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4151 of file object.cpp.

References Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by attempt_recipe(), enter_exit(), find_force(), find_key(), move_detector(), and op_on_battleground().

+ Here is the caller graph for this function:

◆ object_find_by_type_applied()

object* object_find_by_type_applied ( const object who,
int  type 
)

Find applied object in inventory.

Parameters
whowhere to search.
typewhat to search.
Returns
first object in who's inventory that has the same type match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4076 of file object.cpp.

References FLAG_APPLIED, QUERY_FLAG, Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by apply_can_apply_object(), attack_hth(), cast_create_missile(), do_skill_attack(), god_enchants_weapon(), monster_check_good_armour(), and monster_check_good_weapon().

+ Here is the caller graph for this function:

◆ object_find_by_type_subtype()

object* object_find_by_type_subtype ( const object who,
int  type,
int  subtype 
)

Find object in inventory.

Parameters
whowhere to search.
type
subtypewhat to search.
Returns
first object in who's inventory that has the same type and subtype match. NULL if no match.
Note
will not search in inventory of items in inventory.

Definition at line 4294 of file object.cpp.

References Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by become_follower(), cast_word_of_recall(), cftimer_create(), deep_swamp_type_process(), determine_god(), do_hidden_move(), eventListener(), god_examines_priest(), and monster_can_pick().

+ Here is the caller graph for this function:

◆ object_find_by_type_without_flags()

object* object_find_by_type_without_flags ( const object who,
int  type,
int *  flags,
int  num_flags 
)

Find an object in inventory that does not have any of the provided flags set.

Parameters
whowhere to search.
typewhat to search.
flagsArray of integers corresponding to the set of flags that cannot have any set on the found item.
num_flagsThe size of the array flags above
Returns
first object in inventory that matches type and lacks any of the specified flags

Definition at line 3997 of file object.cpp.

References flags, QUERY_FLAG, Ice::tmp, is_valid_types_gen::type, and autojail::who.

Referenced by find_key().

+ Here is the caller graph for this function:

◆ object_find_first_free_spot()

int object_find_first_free_spot ( const object ob,
mapstruct m,
int  x,
int  y 
)

object_find_first_free_spot(archetype, mapstruct, x, y) works like object_find_free_spot(), but it will search max number of squares. It will return the first available spot, not a random choice. Changed 0.93.2: Have it return -1 if there is no free spot available.

Parameters
obobject to insert.
m
x
ywhere to insert the object.
Returns
index into freearr_x and freearr_y, -1 if no spot available (dir 0 = x,y)

Definition at line 3592 of file object.cpp.

References freearr_x, freearr_y, m, guildjoin::ob, ob_blocked(), SIZEOFFREE, diamondslots::x, and diamondslots::y.

Referenced by find_enclosed_spot(), keyplace(), object_teleport(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), polymorph_living(), put_a_monster(), and transfer_ob().

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

◆ object_find_free_spot()

int object_find_free_spot ( const object ob,
mapstruct m,
int  x,
int  y,
int  start,
int  stop 
)

object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coordinates which will be able to contain the given object.

It returns a random choice among the alternatives found.

Parameters
obobject to insert.
m
x
ywhere to insert the object.
start
stopfirst (inclusive) and last (exclusive) positions, in the freearr_ arrays, to search.
Returns
index into freearr_x and freearr_y, -1 if no spot available (dir 0 = x,y)
Note
this only checks to see if there is space for the head of the object - if it is a multispace object, this should be called for all pieces.
This function does correctly handle tiled maps, but does not inform the caller. However, object_insert_in_map will update as necessary, so the caller shouldn't need to do any special work.
Updated to take an object instead of archetype - this is necessary because arch_blocked (now ob_blocked) needs to know the movement type to know if the space in question will block the object. We can't use the archetype because that isn't correct if the monster has been customized, changed states, etc.

Definition at line 3552 of file object.cpp.

References AB_NO_PASS, freearr_x, freearr_y, npc_dialog::index, m, maxfree, guildjoin::ob, ob_blocked(), RANDOM, SIZEOFFREE, roll-o-matic::stop(), diamondslots::x, and diamondslots::y.

Referenced by animate_weapon(), cfapi_object_insert(), command_summon(), command_teleport(), do_follow(), do_harvest(), enter_map(), gate_type_process(), mimic_type_apply(), object_insert_to_free_spot_or_free(), pets_follow_owner(), pets_summon_golem(), pets_summon_object(), shop_mat_type_move_on(), teleport(), and transfer_ob().

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

◆ object_find_multi_free_spot_around()

int object_find_multi_free_spot_around ( const object ob,
const object gen,
int16_t *  hx,
int16_t *  hy 
)

Sets hx and hy to the coords to insert a possibly multi-tile ob at, around gen.

Parameters
obobject to insert. Must not be NULL.
genwhere to insert. Must not be NULL.
[out]hx
[out]hycoordinates at which insertion is possible.
Returns
0 for success and -1 for failure.
Note
This function assumes that multi-tile objects are rectangular.

Definition at line 3289 of file object.cpp.

References HEAD, object::map, MAP_HEIGHT, MAP_WIDTH, guildjoin::ob, ob_blocked(), object_get_multi_size(), RANDOM, object::x, and object::y.

Referenced by change_object().

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

◆ object_find_multi_free_spot_within_radius()

int object_find_multi_free_spot_within_radius ( const object ob,
const object gen,
int *  hx,
int *  hy 
)

Sets hx and hy to the coords to insert a possibly multi-tile ob at, within radius of generator, which is stored in key_value "generator_radius". Radius defaults to 1.

Parameters
obobject to insert. Must not be NULL.
genwhere to insert. Must not be NULL.
[out]hx
[out]hycoordinates at which insertion is possible.
Returns
0 for success and -1 for failure.
Note
This function assumes that multi-tile objects are rectangular.

Definition at line 3405 of file object.cpp.

References get_map_flags(), HEAD, object::map, guildjoin::ob, ob_blocked(), object_get_multi_size(), object_get_value(), P_OUT_OF_MAP, RANDOM, autojail::value, diamondslots::x, object::x, diamondslots::y, and object::y.

Referenced by generate_monster_arch(), and generate_monster_inv().

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

◆ object_fix_multipart()

void object_fix_multipart ( object tmp)

Ensures specified object has its more parts correctly inserted in map.

Extracted from common/map.c:link_multipart_objects

Parameters
tmpobject we want to fix. Must be on a map.

Definition at line 4678 of file object.cpp.

References add_string(), arch_to_object(), free_string(), INS_ABOVE_FLOOR_ONLY, INS_NO_MERGE, INS_NO_WALK_ON, llevError, LOG(), object::more, archetype::more, object_insert_in_map(), give::op, and Ice::tmp.

Referenced by change_object(), generate_monster_inv(), link_multipart_objects(), and object_handle_death_animation().

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

◆ object_free()

void object_free ( object ob,
int  flags 
)

Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects. The IS_FREED() flag is set in the object.

The object must have been removed by object_remove() first for this function to succeed.

Parameters
obobject to free. Will become invalid when function returns.
flagsthe flags; see FREE_OBJ_xxx constants.
Warning
the object's archetype should be a valid pointer, or NULL.

Definition at line 1592 of file object.cpp.

References EVENT_DESTROY, events_execute_object_event(), FLAG_ALIVE, FLAG_FREED, FLAG_FRIENDLY, FLAG_IS_A_TEMPLATE, FLAG_NO_DROP, FLAG_REMOVED, FLAG_STARTEQUIP, flags, FOR_INV_FINISH, FOR_INV_PREPARE, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, FREE_AND_CLEAR_STR_IF, free_arch(), free_dialog_information(), FREE_OBJ_DROP_ABOVE_FLOOR, FREE_OBJ_FREE_INVENTORY, FREE_OBJ_NO_DESTROY_CALLBACK, free_objects, GET_MAP_MOVE_BLOCK, INS_ABOVE_FLOOR_ONLY, llevError, llevMonster, LOG(), object::map, MAP_IN_MEMORY, object::more, MOVE_ALL, nroffreeobjects, guildjoin::ob, object_dump(), object_free(), object_free_drop_inventory(), object_free_key_values(), object_insert_in_map_at(), object_insert_to_free_spot_or_free(), object_remove(), object_update_speed(), objects, give::op, object::prev, QUERY_FLAG, RANDOM, remove_friendly_object(), RUNE, SCRIPT_FIX_NOTHING, SET_FLAG, SIZEOFFREE, stringbuffer_finish(), stringbuffer_new(), TRAP, object::x, and object::y.

Referenced by add_one_item(), alchemy_object(), apply_auto(), apply_by_living(), apply_race_and_class(), ArtifactPanel::artifactChanged(), cast_create_missile(), cast_create_town_portal(), cfapi_object_insert(), clear_player(), command_create(), command_learn_spell_or_prayer(), command_reset(), command_summon(), command_teleport(), counterspell(), do_execute_event(), do_forget_spell(), do_goto(), do_harvest(), do_single_item(), enter_exit(), enter_player_savebed(), eventListener(), CRECombatSimulator::fight(), free_all_objects(), free_no_drop(), god_gives_present(), monsterFight(), move_aura(), object_free(), object_free_drop_inventory(), object_free_inventory(), object_insert_in_map(), object_insert_in_ob(), object_merge(), object_split(), CRETreasurePanel::onGenerate(), peacemaker_type_process(), player_arrest(), polymorph_item(), polymorph_living(), polymorph_melt(), process_events(), process_object(), recharge(), recipe_get_face(), save_object_in_sb(), scroll_failure(), START_TEST(), stop_projectile(), town_portal_destroy_existing(), town_portal_find_force(), and write_scroll().

+ Here is the call graph for this function:

◆ object_free_all_data()

void object_free_all_data ( void  )

Destroys all allocated objects.

Note
free() is called instead of object_free_drop_inventory() as the object's memory has already by cleaned.
Warning
this should be the last method called.

Definition at line 767 of file object.cpp.

References FLAG_FREED, free_objects, llevDebug, LOG(), give::next, nrofallocobjects, nroffreeobjects, objects, give::op, QUERY_FLAG, and STARTMAX.

Referenced by cleanup().

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

◆ object_free_drop_inventory()

void object_free_drop_inventory ( object ob)

Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects. The IS_FREED() flag is set in the object. The object must have been removed by object_remove() first for this function to succeed.

Inventory will be dropped on the ground if in a map, else freed too.

Parameters
obobject to free. Will become invalid when function returns.

Definition at line 1560 of file object.cpp.

References guildjoin::ob, and object_free().

Referenced by add_abilities(), add_npc_to_point(), add_npc_to_zone(), adjust_sign_msg(), alchemy_failure_effect(), apply_auto(), apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_builder_wall(), apply_builder_window(), arrow_type_process(), artifact_describe(), become_follower(), blindness_type_process(), cast_cause_disease(), cast_dust(), cast_raise_dead_spell(), cast_smite_spell(), cfapi_object_delete(), cfapi_object_insert(), change_book(), change_object(), check_bullet(), clean_object(), command_cast_spell(), command_free(), command_kill_pets(), common_process_projectile(), convert_item(), cure_disease(), decay_objects(), delete_unique_items(), destroy_object(), dispel_rune(), do_turn(), drop(), drop_object(), eat_special_food(), enter_map(), eventListener(), execute_word_of_recall(), explode_bullet(), explosion(), fire_arch_from_position(), fire_bolt(), fire_bow(), fix_generated_item(), fix_stopped_arrow(), fix_walls(), follower_remove_given_items(), free_player(), generate_monster(), generate_treasure(), give_initial_items(), god_intervention(), hit_player(), hit_with_arrow(), insert_objects(), key_change_class(), kill_object(), kill_player_permadeath(), load_objects(), locate_recipe_artifact(), lock_and_hide_doors(), loot_object(), monster_move(), monster_move_no_enemy(), move_aura(), move_bolt(), move_bullet(), move_cone(), move_creator(), move_disease(), move_duplicator(), move_marker(), move_missile(), move_player_mover(), move_swarm_spell(), move_symptom(), move_teleporter(), nuke_map_region(), object_decrease_nrof(), object_free(), object_insert_to_free_spot_or_free(), object_merge_spell(), object_replace_insert_in_map(), pay_from_container(), pets_attempt_follow(), pets_move(), pets_move_golem(), pets_summon_golem(), pets_terminate_all(), pick_up_object(), place_chest(), place_exits(), place_fountain_with_specials(), poisoning_type_process(), prayer_failure(), print_monsters(), receive_play_again(), remove_adjacent_doors(), remove_contents(), remove_depletion(), remove_door(), remove_force(), remove_locked_door(), remove_marking_runes(), remove_monsters(), remove_special_prayers(), remove_symptoms(), remove_unpaid_objects(), restore_player(), retrofit_joined_wall(), rune_attack(), save_life(), save_throw_object(), spell_effect_type_move_on(), spell_failure(), spring_trap(), START_TEST(), stop_item(), stop_projectile(), tailor_god_spell(), tear_down_wall(), and thrown_object_type_process().

+ Here is the call graph for this function:

◆ object_free_inventory()

void object_free_inventory ( object ob)

Frees the inventory of an object, without any callback.

Parameters
obobject to free the inventory of.

Definition at line 1568 of file object.cpp.

References FREE_OBJ_FREE_INVENTORY, FREE_OBJ_NO_DESTROY_CALLBACK, commongive::inv, guildjoin::ob, object_free(), and object_remove().

Referenced by asset_destroy(), Archetypes::recursive_update(), and Archetypes::replace().

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

◆ object_free_key_values()

void object_free_key_values ( object op)

Zero the key_values on op, decrementing the shared-string refcounts and freeing the links.

Parameters
opobject to clear.

Definition at line 954 of file object.cpp.

References FREE_AND_CLEAR_STR, key_value::key, key_value::next, give::next, give::op, and key_value::value.

Referenced by free_arch(), free_artifact(), object_clear(), object_copy_no_speed(), and object_free().

+ Here is the caller graph for this function:

◆ object_get_env_recursive()

object* object_get_env_recursive ( object op)

Utility function.

Parameters
opobject we want the environment of. Can't be NULL.
Returns
the outermost environment object for a given object. Will not be NULL.

Definition at line 590 of file object.cpp.

References give::op.

Referenced by animate_bomb(), cfapi_object_set_property(), do_execute_event(), explode_bullet(), spring_trap(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_get_key_value()

key_value* object_get_key_value ( const object ob,
const char *  key 
)

Search for a field by key.

Parameters
obobject where search
keykey to search. Must be a passed in shared string - otherwise, this won't do the desired thing.
Returns
the link from the list if ob has a field named key, otherwise NULL.

Definition at line 4314 of file object.cpp.

References key_value::key, castle_read::key, key_value::next, and guildjoin::ob.

Referenced by compare_ob_value_lists_one(), get_ob_diff(), object_set_value_s(), and process_object().

+ Here is the caller graph for this function:

◆ object_get_multi_size()

void object_get_multi_size ( const object ob,
int *  sx,
int *  sy,
int *  hx,
int *  hy 
)

Computes the size of a multitile object.

Parameters
obobject we compute the size of.
[out]sx
[out]sywill contain the coords of the bottom right tail relative to the head. Must not be NULL.
[out]hx
[out]hywill contain the coords of the head tile relative to the top left tile. Can be NULL.
Todo:
either check for sx/sy everywhere or remove the check :)

Definition at line 4737 of file object.cpp.

References archetype::clone, HEAD, archetype::more, guildjoin::ob, object::x, and object::y.

Referenced by object_find_multi_free_spot_around(), object_find_multi_free_spot_within_radius(), object_on_exit(), process_map(), and update_transport_block().

+ Here is the caller graph for this function:

◆ object_get_owner()

object* object_get_owner ( object op)

Returns the object which this object marks as being the owner.

A id-scheme is used to avoid pointing to objects which have been freed and are now reused. If this is detected, the owner is set to NULL, and NULL is returned.

Parameters
opitem to search owner of.
Returns
owner, or NULL if not found.

Definition at line 804 of file object.cpp.

References FLAG_FREED, FLAG_REMOVED, object_clear_owner(), give::op, and QUERY_FLAG.

Referenced by adj_attackroll(), attack_message(), attack_ob_simple(), blame(), blind_living(), cast_spell(), cfapi_object_get_property(), change_object(), command_kill_pets(), common_process_projectile(), common_projectile_move_on(), cone_drop(), counterspell(), do_mood_floor(), do_symptoms(), explode_bullet(), find_target_for_friendly_spell(), find_traps(), fire_arch_from_position(), fix_summon_pet(), friendly_fire(), get_real_owner(), hit_player(), hit_with_one_attacktype(), infect_object(), is_enemy(), kill_object(), monster_cast_spell(), monster_check_enemy(), monster_move(), monster_use_bow(), monster_use_range(), monster_use_scroll(), monster_use_skill(), move_ball_spell(), move_missile(), move_player_attack(), move_swarm_spell(), object_copy_owner(), object_set_owner(), peacemaker_type_process(), pets_attempt_follow(), pets_get_enemy(), pets_move(), pets_move_golem(), pets_summon_golem(), pets_summon_object(), poison_living(), polymorph_living(), push_ob(), remove_trap(), save_object_in_sb(), save_objects(), scare_creature(), START_TEST(), steal(), tailor_god_spell(), trap_disarm(), and use_oratory().

+ Here is the call graph for this function:

◆ object_get_owner_const()

static const object* object_get_owner_const ( const object op)
static

Returns the object which this object marks as being the owner, constant version. Mostly written for object_dump, which takes a const object.

Parameters
opitem to search owner of.
Returns
owner, or NULL if not found.

Definition at line 624 of file object.cpp.

References FLAG_FREED, FLAG_REMOVED, llevError, LOG(), give::op, and QUERY_FLAG.

Referenced by object_dump().

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

◆ object_get_player_container()

object* object_get_player_container ( object op)

Finds the player carrying an object.

Parameters
opitem for which we want the carrier (player).
Returns
the player, or NULL if not in an inventory.
Todo:
this function is badly named. Fix patching on the fly.

Definition at line 607 of file object.cpp.

References give::op, and PLAYER.

Referenced by cfapi_object_set_property(), do_light(), drain_wand_charge(), identify(), lamp_type_apply(), object_decrease_nrof(), object_increase_nrof(), object_insert_in_ob(), object_remove(), pick_up_object(), remove_force(), send_changed_object(), and START_TEST().

+ Here is the caller graph for this function:

◆ object_get_value()

const char* object_get_value ( const object op,
const char *const  key 
)

Get an extra value by key.

Parameters
opobject we're considering
keykey of which to retrieve the value. Doesn't need to be a shared string.
Returns
the value of op has in an extra_field for key, or NULL if it doesn't have the key.
Note
The returned string is shared.

Definition at line 4339 of file object.cpp.

References find_string(), key_value::key, castle_read::key, key_value::next, give::op, and key_value::value.

Referenced by add_abilities(), add_object_to_socklist(), adjust_sign_msg(), append_spell(), apply_check_personalized_blessings(), apply_check_race_restrictions(), apply_handle_yield(), ResourcesManager::archetypeUse(), calculate_difficulty(), cfapi_object_get_key(), cfapi_object_get_property(), change_book(), check_spell_expiry(), command_cast_spell(), command_rename_item(), create_player_cmd(), do_exit_map(), do_harvest(), do_monster(), esrv_add_spells(), esrv_update_item(), eventListener(), examine(), fix_player(), follower_remove_given_items(), generate_monster(), generate_monster_arch(), generate_monster_inv(), god_enchants_weapon(), knowledge_monster_validate(), knowledge_read(), monster_move_randomly(), monster_npc_call_help(), mood_change(), move_aura(), object_find_multi_free_spot_within_radius(), object_give_identified_properties(), object_handle_death_animation(), object_matches_string(), object_try_get_value(), object_value_set(), CREMainWindow::onReportDuplicate(), price_base(), reportSummon(), send_arch_info(), set_object_face_main(), set_object_face_other(), shop_price_buy(), shop_price_sell(), SP_level_wc_adjust(), spell_consume_items(), transport_type_apply(), and ArchetypeWrapper::uses().

+ Here is the call graph for this function:

◆ object_handle_death_animation()

void object_handle_death_animation ( object op)

Definition at line 5396 of file object.cpp.

References object::arch, create_archetype(), archetype::more, object_fix_multipart(), object_get_value(), object_insert_in_map_at(), give::op, and sstring.

Referenced by generate_monster(), and kill_object().

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

◆ object_increase_nrof()

static void object_increase_nrof ( object op,
uint32_t  i 
)
static

Increase the count of an object.

This function will send an update to client if needed.

Parameters
opobject to increase.
inumber to add.

Definition at line 2757 of file object.cpp.

References esrv_update_item(), first_player, FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, object_add_weight(), object_get_player_container(), object_sub_weight(), give::op, altar_valkyrie::pl, QUERY_FLAG, Ice::tmp, and UPD_NROF.

Referenced by object_insert_in_ob(), and object_merge().

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

◆ object_insert_in_map()

object* object_insert_in_map ( object op,
mapstruct m,
object originator,
int  flag 
)

This function inserts the object in the two-way linked list which represents what is on a map.

It will update player count if the op is a player.

Player ground window will be updated if needed.

Parameters
opobject to insert. Must be removed. Its coordinates must be valid for the map.
mmap to insert into. Must not be NULL.
originatorplayer, monster or other object that caused 'op' to be inserted into 'm'. May be NULL.
flagbitmask about special things to do (or not do) when this function is called. See the object.h file for the INS_xxx values. Passing 0 for flag gives proper default values, so flag really only needs to be set if special handling is needed.
Returns
  • new object if 'op' was merged with other object.
  • NULL if 'op' was destroyed
  • just 'op' otherwise
Todo:
this function is a mess, and should be cleaned.

Definition at line 2359 of file object.cpp.

References object::below, CLEAR_FLAG, object::contr, find_insert_pos(), FLAG_ALIVE, FLAG_APPLIED, FLAG_FREED, FLAG_INV_LOCKED, FLAG_NO_STEAL, FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, FOR_OB_AND_ABOVE_FINISH, FOR_OB_AND_ABOVE_PREPARE, FREE_OBJ_FREE_INVENTORY, FREE_OBJ_NO_DESTROY_CALLBACK, get_map_from_coord(), GET_MAP_OB, INS_BELOW_ORIGINATOR, INS_MAP_LOAD, INS_NO_MERGE, INS_NO_WALK_ON, LAMP, llevError, LOG(), m, object::map, MAP_DARKNESS, object_can_merge(), object_check_move_on(), object_dump(), object_free(), object_insert_in_map(), object_merge_spell(), object_remove(), object_update(), give::op, out_of_map(), OUT_OF_REAL_MAP, object::ox, object::oy, PLAYER, QUERY_FLAG, SET_MAP_OB, SET_MAP_TOP, SPELL_EFFECT, stringbuffer_finish(), stringbuffer_new(), Ice::tmp, give::top, player::transport, UP_OBJ_INSERT, update_all_los(), diamondslots::x, object::x, diamondslots::y, and object::y.

Referenced by change_object(), fix_stopped_item(), object_fix_multipart(), object_insert_in_map(), object_insert_in_map_at(), pick_up(), and START_TEST().

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

◆ object_insert_in_map_at()

object* object_insert_in_map_at ( object op,
mapstruct m,
object originator,
int  flag,
int  x,
int  y 
)

Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing multi-part monsters.

Parameters
opobject to insert.
mmap to insert into.
originatorwhat caused op to be inserted.
flagCombination of INS_xxx values.
x
ycoordinates to insert at.

Definition at line 2098 of file object.cpp.

References HEAD, m, object_insert_in_map(), give::op, Ice::tmp, diamondslots::x, and diamondslots::y.

Referenced by alchemy_failure_effect(), animate_bomb(), animate_weapon(), apply_auto(), apply_builder_floor(), apply_builder_item(), apply_builder_wall(), apply_builder_window(), apply_container(), apply_handle_yield(), cast_bless(), cast_cause_disease(), cast_change_ability(), cast_cone(), cast_consecrate(), cast_create_obj(), cast_create_town_portal(), cast_curse(), cast_destruction(), cast_detection(), cast_heal(), cast_light(), cast_magic_storm(), cast_polymorph(), cast_raise_dead_spell(), cast_smite_spell(), cfapi_object_insert(), cfapi_object_transfer(), charge_mana_effect(), command_create(), command_reset(), common_process_projectile(), cone_drop(), convert_item(), converter_type_move_on(), create_bomb(), dimension_door(), do_follow(), do_harvest(), do_test(), do_throw(), drop_object(), eat_special_food(), enter_map(), explode_bullet(), explosion(), CRECombatSimulator::fight(), fire_arch_from_position(), fire_bolt(), fire_bow(), fire_swarm(), fix_walls(), forklightning(), gate_type_process(), generate_monster_arch(), generate_monster_inv(), hit_with_arrow(), identify_object_with_skill(), include_map_in_map(), key_change_class(), keyplace(), kill_player(), kill_player_not_permadeath(), kill_player_permadeath(), load_objects(), lock_and_hide_doors(), loot_object(), magic_wall(), make_map_floor(), make_map_walls(), mimic_type_apply(), monsterFight(), mood_change(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_cone(), move_creator(), move_missile(), move_ob(), move_symptom(), object_free(), object_handle_death_animation(), object_insert_to_free_spot_or_free(), object_replace_insert_in_map(), object_teleport(), pets_follow_owner(), pets_summon_golem(), pets_summon_object(), pick_up_object(), place_alchemy_objects(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), polymorph_item(), polymorph_living(), potion_type_apply(), push_ob(), put_a_monster(), put_decor(), put_doors(), put_floor(), put_in_icecube(), put_object_in_sack(), put_treasure(), recharge(), remove_door(), remove_force(), remove_locked_door(), remove_unpaid_objects(), retrofit_joined_wall(), roll_ob(), save_throw_object(), setup(), shop_mat_type_move_on(), spell_effect(), spell_failure(), spring_trap(), START_TEST(), stop_jump(), stop_projectile(), surround_by_doors(), teleport(), transfer_ob(), transport_type_apply(), trap_show(), treasure_type_apply(), turn_one_transport(), write_mark(), and write_rune().

+ Here is the call graph for this function:

◆ object_insert_in_ob()

object* object_insert_in_ob ( object op,
object where 
)

This function inserts the object op in the linked list inside the object environment.

It will send to client where is a player.

Parameters
opobject to insert. Must be removed and not NULL. Must not be multipart. May become invalid after return, so use return value of the function.
whereobject to insert into. Must not be NULL. Should be the head part.
Returns
pointer to inserted item, which will be different than op if object was merged.

Definition at line 2851 of file object.cpp.

References BITMASK_EVENT, CLEAR_FLAG, CONTAINER, object::contr, esrv_send_item(), EVENT_CONNECTOR, fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_OBJ_ORIGINAL, FLAG_REMOVED, FOR_ABOVE_FINISH, FOR_ABOVE_PREPARE, FOR_INV_FINISH, FOR_INV_PREPARE, FREE_OBJ_FREE_INVENTORY, FREE_OBJ_NO_DESTROY_CALLBACK, HEAD, llevDebug, llevError, LOG(), MAP_DARKNESS, object_add_weight(), object_can_merge(), object_dump(), object_free(), object_get_player_container(), object_increase_nrof(), give::op, P_NEED_UPDATE, altar_valkyrie::pl, QUERY_FLAG, SET_FLAG, SET_MAP_FLAGS, SKILL, stringbuffer_finish(), stringbuffer_new(), Ice::tmp, update_all_los(), update_position(), and python_pickup::where.

Referenced by add_abilities(), add_force(), alchemy_failure_effect(), animate_weapon(), apply_auto(), apply_container(), apply_handle_yield(), apply_special(), attempt_recipe(), blind_living(), cast_bless(), cast_change_ability(), cast_create_town_portal(), cast_curse(), cast_word_of_recall(), cfapi_object_insert(), change_luck(), change_object(), check_loaded_object(), command_create(), command_insert_into(), command_use(), confuse_living(), create_aura(), create_player_cmd(), do_harvest(), do_learn_spell(), do_symptoms(), do_test(), do_throw(), do_turn(), dragon_ability_gain(), drain_specific_stat(), eat_special_food(), examine_monster(), find_or_create_connection_for_map(), fix_generated_item(), get_npc(), give_skill_by_name(), god_gives_present(), grant_immunity(), hit_with_arrow(), identify_object_with_skill(), improve_armour(), infect_object(), insert_objects(), keyplace(), kill_player_not_permadeath(), lamp_type_apply(), lighter_type_apply(), local_check_loaded_object(), magic_wall(), make_object_glow(), make_throw_ob(), mimic_type_apply(), monster_check_pickup(), monsterFight(), move_aura(), msgfile_msg(), object_copy_with_inv(), object_create_clone(), pick_up_object(), place_chest(), poison_living(), potion_type_apply(), put_in_icecube(), put_object_in_sack(), put_treasure(), remove_force(), save_throw_object(), sell_item(), slow_living_by(), START_TEST(), stick_arrow(), swap_random_stats(), town_portal_find_force(), transmute_item_to_flower(), transport_type_apply(), while(), write_note(), write_rune(), and write_scroll().

+ Here is the call graph for this function:

◆ object_insert_to_free_spot_or_free()

void object_insert_to_free_spot_or_free ( object op,
mapstruct map,
int  x,
int  y,
int  start,
int  stop,
object originator 
)

Inserts an object into its map. The object is inserted into a free spot (as returned by object_find_free_spot()). If no free spot can be found, the object is freed.

Parameters
opthe object to insert or free
mapthe map to insert into
xthe x-coordinate to insert into
ythe y-coordinate to insert into
startfirst (inclusive) position in the freearr_ arrays to search
stoplast (exclusive) position in the freearr_ arrays to search
originatorwhat caused op to be inserted.

Definition at line 4784 of file object.cpp.

References freearr_x, freearr_y, disinfect::map, object_find_free_spot(), object_free_drop_inventory(), object_insert_in_map_at(), give::op, roll-o-matic::stop(), diamondslots::x, and diamondslots::y.

Referenced by change_object(), and object_free().

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

◆ object_matches_string()

int object_matches_string ( object pl,
object op,
const char *  name 
)

This is a subset of the parse_id command. Basically, name can be a string seperated lists of things to match, with certain keywords. pl is the player (only needed to set count properly) op is the item we are trying to match. Calling function takes care of what action might need to be done and if it is valid (pickup, drop, etc.) Return NONZERO if we have a match. A higher value means a better match. 0 means no match.

Brief outline of the procedure: We take apart the name variable into the individual components. cases for 'all' and unpaid are pretty obvious. Next, we check for a count (either specified in name, or in the player object.) If count is 1, make a quick check on the name. IF count is >1, we need to make plural name. Return if match. Last, make a check on the full name.

Details on values output (highest is output):

match type return value

nothing 0 'all' 1 'unpaid' 2 'cursed' 2 'unlocked' 2 partial custom name 3 op->name with count >1 4 op->name with count <2 6 op->name_pl with count >1 6 inside base name 12 inside short name 12 begin of base name 14 custom name 15 base name 16 short name 18 full name 20 (note, count is extracted from begin of name parameter or from pl->contr->count, name has priority)

Parameters
plobject we're searching an item for. Must not be NULL.
opobject we're considering. Must not be NULL.
namestring we're searching.
Returns
matching weight. The higher, the more the object matches.
Todo:
is the player->contr->count hack used?? Try to reduce buffers/calls to query_ functions.

Definition at line 4567 of file object.cpp.

References disinfect::count, CUSTOM_NAME_FIELD, FLAG_CURSED, FLAG_DAMNED, FLAG_INV_LOCKED, FLAG_KNOWN_CURSED, FLAG_UNPAID, HUGE_BUF, MAX_BUF, give::name, object_get_value(), give::op, altar_valkyrie::pl, PLAYER, query_base_name(), QUERY_FLAG, query_name(), query_short_name(), safe_strncpy, sstring, and strcasecmp().

Referenced by check_pick(), find_best_apply_object_match(), matcher_name(), START_TEST(), and write_rune().

+ Here is the call graph for this function: