Crossfire Server, Trunk  R20513
Macros | Functions | Variables
object.c File Reference

Everything related to objects, in their basic form. More...

#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.c:

Go to the source code of this file.

Macros

#define ADD_STRINGLINE_ENTRY(sb__, entryname__, entryvalue__)
 Adds a line to the buffer. More...
 
#define FAST_SAVE_DOUBLE(sb__, entryname__, entryvalue__)   stringbuffer_append_printf(sb__, "%s%f\n", entryname__, entryvalue__)
 Adds a double to the buffer. More...
 
#define FAST_SAVE_LONG(sb__, entryname__, entryvalue__)   stringbuffer_append_printf(sb__, "%s%ld\n", entryname__, (long int)entryvalue__)
 Adds a long to the buffer. More...
 

Functions

int absdir (int d)
 Computes an absolute direction. More...
 
objectarch_present_in_ob (const archetype *at, const object *op)
 Searches for any objects with a matching archetype in the inventory of the given object. More...
 
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. More...
 
static int compare_ob_value_lists (const object *ob1, const object *ob2)
 Compares two object lists. More...
 
static int compare_ob_value_lists_one (const object *wants, const object *has)
 Compares value lists. More...
 
int dirdiff (int dir1, int dir2)
 Computes a direction difference. More...
 
static void expand_objects (void)
 Allocates more objects for the list of unused objects. More...
 
int find_dir_2 (int x, int y)
 Computes a direction which you should travel to move of x and y. More...
 
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. More...
 
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. More...
 
static void get_string_move_type (StringBuffer *sb, MoveType mt)
 This returns a string of the integer movement type. More...
 
objectmap_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. More...
 
objectmap_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. More...
 
int map_find_dir (mapstruct *m, int x, int y, object *exclude)
 Search some close squares in the given map at the given coordinates for live objects. More...
 
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. More...
 
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. More...
 
int object_can_pick (const object *who, const object *item)
 Finds out if an object can be picked up. More...
 
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. More...
 
void object_clear (object *op)
 Frees everything allocated by an object, and also clears all variables and flags to default settings. More...
 
void object_clear_owner (object *op)
 Clears the owner of specified object. More...
 
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. More...
 
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). More...
 
void object_copy_with_inv (const object *src_ob, object *dest_ob)
 copy an object with an inventory... More...
 
int object_count_active (void)
 Objects statistics. More...
 
int object_count_free (void)
 Objects statistics. More...
 
int object_count_used (void)
 Object statistics. More...
 
objectobject_create_clone (object *asrc)
 Create clone from object to another. More...
 
objectobject_decrease_nrof (object *op, uint32_t i)
 Decreases a specified number from the amount of an object. More...
 
int object_distance (const object *ob1, const object *ob2)
 Return the square of the distance between the two given objects. More...
 
void object_dump (const object *op, StringBuffer *sb)
 Dumps an object. More...
 
void object_dump_all (void)
 Dumps all objects to console. More...
 
objectobject_find_by_arch_name (const object *who, const char *name)
 Find object in inventory by archetype name. More...
 
objectobject_find_by_flag (const object *who, int flag)
 Find object in inventory by flag. More...
 
objectobject_find_by_flag_applied (const object *who, int flag)
 Find applied object in inventory by flag. More...
 
objectobject_find_by_name (const object *who, const char *name)
 Finds an object in inventory name. More...
 
objectobject_find_by_name_global (const char *str)
 Finds an object by name. More...
 
objectobject_find_by_tag (const object *who, tag_t tag)
 Find object in inventory. More...
 
objectobject_find_by_tag_global (tag_t i)
 Returns the object which has the count-variable equal to the argument. More...
 
objectobject_find_by_type (const object *who, int type)
 Find object in inventory. More...
 
objectobject_find_by_type2 (const object *who, int type1, int type2)
 Find object in inventory. More...
 
objectobject_find_by_type_and_arch_name (const object *who, int type, const char *name)
 Find object in inventory by type and archetype name. More...
 
objectobject_find_by_type_and_name (const object *who, int type, const char *name)
 Find object in inventory by type and name. More...
 
objectobject_find_by_type_and_race (const object *who, int type, const char *race)
 Find object in inventory by type and race. More...
 
objectobject_find_by_type_and_skill (const object *who, int type, const char *skill)
 Find object in inventory by type and skill. More...
 
objectobject_find_by_type_and_slaying (const object *who, int type, const char *slaying)
 Find object in inventory by type and slaying. More...
 
objectobject_find_by_type_applied (const object *who, int type)
 Find applied object in inventory. More...
 
objectobject_find_by_type_subtype (const object *who, int type, int subtype)
 Find object in inventory. More...
 
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. More...
 
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. More...
 
int object_find_multi_free_spot_around (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, around gen. More...
 
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". More...
 
void object_fix_multipart (object *tmp)
 Ensures specified object has its more parts correctly inserted in map. More...
 
void object_free2 (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. More...
 
void object_free_all_data (void)
 Destroys all allocated objects. More...
 
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. More...
 
void object_free_key_values (object *op)
 Zero the key_values on op, decrementing the shared-string refcounts and freeing the links. More...
 
objectobject_get_env_recursive (object *op)
 Utility function. More...
 
key_valueobject_get_key_value (const object *ob, const char *key)
 Search for a field by key. More...
 
void object_get_multi_size (const object *ob, int *sx, int *sy, int *hx, int *hy)
 Computes the size of a multitile object. More...
 
objectobject_get_owner (object *op)
 Returns the object which this object marks as being the owner. More...
 
static const objectobject_get_owner_const (const object *op)
 Returns the object which this object marks as being the owner, constant version. More...
 
objectobject_get_player_container (object *op)
 Finds the player carrying an object. More...
 
const char * object_get_value (const object *op, const char *const key)
 Get an extra value by key. More...
 
static void object_increase_nrof (object *op, uint32_t i)
 Increase the count of an object. More...
 
objectobject_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. More...
 
objectobject_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. More...
 
objectobject_insert_in_ob (object *op, object *where)
 This function inserts the object op in the linked list inside the object environment. More...
 
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. More...
 
int object_matches_string (object *pl, object *op, const char *name)
 This is a subset of the parse_id command. More...
 
objectobject_merge (object *op, object *top)
 This function goes through all objects below and including top, and merges op to the first matching object. More...
 
void object_merge_spell (object *op, int16_t x, int16_t y)
 This sees if there are any objects on the space that can merge with op. More...
 
objectobject_new (void)
 Grabs an object from the list of unused objects, makes sure it is initialised, and returns it. More...
 
objectobject_present_in_ob (uint8_t type, const object *op)
 Searches for any objects with a matching type variable in the inventory of the given object. More...
 
objectobject_present_in_ob_by_name (int type, const char *str, const object *op)
 Searches for any objects with a matching type & name variable in the inventory of the given object. More...
 
void object_remove (object *op)
 This function removes the object op from the linked list of objects which it is currently tied to. More...
 
void object_remove_from_active_list (object *op)
 This function removes object 'op' from the list of active objects. More...
 
void object_replace_insert_in_map (const char *arch_string, object *op)
 This function inserts an object of a specified archetype in the map, but if it finds objects of its own type, it'll remove them first. More...
 
void object_reset (object *op)
 Sets to 0 vital variables in an object. More...
 
void object_set_cheat (object *op)
 object_set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recursively). More...
 
void object_set_enemy (object *op, object *enemy)
 Sets the enemy of an object. More...
 
void object_set_flag_inv (object *op, int flag)
 Activate recursively a flag on an object's inventory. More...
 
void object_set_msg (object *op, const char *msg)
 Set the message field of an object. More...
 
void object_set_owner (object *op, object *owner)
 Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects. More...
 
int object_set_value (object *op, const char *key, const char *value, int add_key)
 Updates the key in op to value. More...
 
static int object_set_value_s (object *op, const char *canonical_key, const char *value, int add_key)
 Updates or sets a key value. More...
 
objectobject_split (object *orig_ob, uint32_t nr, char *err, size_t size)
 object_split(ob,nr) splits up ob into two parts. More...
 
void object_sub_weight (object *op, signed long weight)
 Recursively (outwards) subtracts a number from the weight of an object (and what is carried by it's environment(s)). More...
 
signed long object_sum_weight (object *op)
 object_sum_weight() is a recursive function which calculates the weight an object is carrying. More...
 
void object_unset_flag_inv (object *op, int flag)
 Desactivate recursively a flag on an object inventory. More...
 
void object_update (object *op, int action)
 object_update() updates the array which represents the map. More...
 
void object_update_speed (object *op)
 Updates the speed of an object. More...
 
void object_update_turn_face (object *op)
 If an object with the IS_TURNABLE() flag needs to be turned due to the closest player being on the other side, this function can be called to update the face variable, and how it looks on the map. More...
 
static void permute (int *arr, int begin, int end)
 Randomly permutes an array. More...
 
int save_object (FILE *fp, object *op, int flag)
 Dumps all variables in an object to a file. More...
 

Variables

objectactive_objects
 List of active objects that need to be processed. More...
 
static const char *const flag_names [NUM_FLAGS+1]
 This is a list of pointers that correspond to the FLAG_. More...
 
objectfree_objects
 Pointer to the list of unused objects. More...
 
short freearr_x [SIZEOFFREE]
 X offset when searching around a spot. More...
 
short freearr_y [SIZEOFFREE]
 Y offset when searching around a spot. More...
 
int freedir [SIZEOFFREE]
 Direction we're pointing on this spot. More...
 
int maxfree [SIZEOFFREE]
 Number of spots around a location, including that location (except for 0) More...
 
const char *const move_name []
 Maps the MOVE_* values to names. More...
 
int nrofallocobjects = STARTMAX
 How many OBs allocated (free + used) More...
 
int nroffreeobjects = STARTMAX
 How many OBs allocated and free (free) More...
 
object objarray [STARTMAX]
 All objects, allocated this way at first. More...
 
objectobjects
 Pointer to the list of used objects. More...
 
static const int reduction_dir [SIZEOFFREE][3]
 Basically, this is a table of directions, and what directions one could go to go back to us. More...
 

Detailed Description

Everything related to objects, in their basic form.

Definition in file object.c.

Macro Definition Documentation

#define ADD_STRINGLINE_ENTRY (   sb__,
  entryname__,
  entryvalue__ 
)
Value:
do {\
stringbuffer_append_string(sb__, entryname__);\
stringbuffer_append_string(sb__, entryvalue__);\
} while (0)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.c:95

Adds a line to the buffer.

Definition at line 4820 of file object.c.

Referenced by get_ob_diff().

#define FAST_SAVE_DOUBLE (   sb__,
  entryname__,
  entryvalue__ 
)    stringbuffer_append_printf(sb__, "%s%f\n", entryname__, entryvalue__)

Adds a double to the buffer.

entryname__ must have a space at the end.

Definition at line 4829 of file object.c.

Referenced by get_ob_diff().

#define FAST_SAVE_LONG (   sb__,
  entryname__,
  entryvalue__ 
)    stringbuffer_append_printf(sb__, "%s%ld\n", entryname__, (long int)entryvalue__)

Adds a long to the buffer.

entryname__ must have a space at the end.

Definition at line 4826 of file object.c.

Referenced by get_ob_diff(), and save_object().

Function Documentation

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 3637 of file object.c.

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:

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.
Note
present_arch_in_ob() has been renamed to arch_present_in_ob()

Definition at line 3061 of file object.c.

References obj::arch, obj::below, and obj::inv.

Referenced by cast_heal(), cfapi_object_find_archetype_inside(), cfapi_object_get_property(), change_luck(), create_aura(), drain_specific_stat(), god_intervention(), kill_player(), kill_player_not_permadeath(), perceive_self(), poison_living(), remove_depletion(), slow_living(), and START_TEST().

Here is the caller graph for this function:

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 3745 of file object.c.

References can_see_monsterP(), freearr_x, freearr_y, get_map_flags(), P_BLOCKSVIEW, P_OUT_OF_MAP, and reduction_dir.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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 139 of file object.c.

References compare_ob_value_lists_one().

Referenced by object_can_merge().

Here is the call graph for this function:

Here is the caller graph for this function:

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 98 of file object.c.

References FALSE, _key_value::key, obj::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:

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 3655 of file object.c.

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

Here is the caller graph for this function:

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 993 of file object.c.

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

Referenced by object_new().

Here is the call graph for this function:

Here is the caller graph for this function:

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 3600 of file object.c.

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

Here is the caller graph for this function:

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 4845 of file object.c.

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

Referenced by add_one_item(), command_diff(), object_dump(), save_object(), CREArtifactPanel::setItem(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

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 3501 of file object.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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 4776 of file object.c.

References 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:

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.
Note
present_arch() has been renamed to map_find_by_archetype()

Definition at line 2944 of file object.c.

References FOR_MAP_FINISH, FOR_MAP_PREPARE, llevError, LOG(), and out_of_map().

Referenced by cast_create_town_portal(), cfapi_map_find_by_archetype_name(), and save_throw_object().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
present() has been renamed to map_find_by_type()

Definition at line 2974 of file object.c.

References FOR_MAP_FINISH, FOR_MAP_PREPARE, llevError, LOG(), and out_of_map().

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

Here is the call graph for this function:

Here is the caller graph for this function:

int map_find_dir ( mapstruct m,
int  x,
int  y,
object exclude 
)

Search some close squares in the given map at the given coordinates for live objects.

Parameters
m
x
yorigin from which to search.
excludean object that will be ignored. Can be NULL.
Returns
direction toward the first/closest live object if it finds any, otherwise 0.
Note
Perhaps incorrectly, but I'm making the assumption that exclude is actually want is going to try and move there. We need this info because we have to know what movement the thing looking to move there is capable of.
find_dir() has been renamed to map_find_dir()

Definition at line 3534 of file object.c.

References FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, freedir, get_map_flags(), GET_MAP_MOVE_BLOCK, obj::head, maxfree, MOVE_ALL, obj::move_type, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, and SIZEOFFREE.

Here is the call graph for this function:

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().
Note
add_weight() has been renamed to object_add_weight()

Definition at line 2663 of file object.c.

References obj::carrying, CONTAINER, obj::env, obj::stats, liv::Str, and obj::type.

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:

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.
Note
can_merge() has been renamed to object_can_merge()
Todo:
check the function at places marked.

Definition at line 171 of file object.c.

References obj::animation_id, obj::arch, obj::attacktype, obj::client_type, compare_ob_value_lists(), obj::custom_name, FABS, FLAG_ANIMATE, FLAG_APPLIED, FLAG_BEEN_APPLIED, FLAG_IDENTIFIED, obj::flags, obj::inv, obj::item_power, obj::key_values, obj::level, obj::lore, obj::magic, obj::map_layer, obj::materialname, MIN_ACTIVE_SPEED, obj::move_allow, obj::move_block, obj::move_off, obj::move_on, obj::move_slow, obj::move_slow_penalty, obj::move_type, obj::msg, obj::name, obj::nrof, object_can_merge(), QUERY_FLAG, obj::resist, SCROLL, SET_FLAG, obj::skill, obj::slaying, obj::speed, obj::stats, obj::subtype, obj::title, obj::type, obj::value, and obj::weight.

Referenced by cfapi_object_get_property(), 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:

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.
can_pick() has been renamed to object_can_pick()

Definition at line 3793 of file object.c.

References obj::carrying, FLAG_ALIVE, FLAG_NO_PICK, get_weight_limit(), obj::head, obj::invisible, obj::more, PLAYER, QUERY_FLAG, obj::stats, liv::Str, obj::type, and obj::weight.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
check_move_on() has been renamed to object_check_move_on()

Definition at line 2835 of file object.c.

References obj::above, obj::count, 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, obj::map, obj::move_block, MOVE_FLY_LOW, obj::move_on, obj::move_slow, obj::move_slow_penalty, obj::move_type, MOVE_WALK, ob_move_on(), object_was_destroyed, PLAYER, QUERY_FLAG, SK_CLIMBING, SK_WOODSMAN, obj::speed, obj::speed_left, obj::type, obj::x, and obj::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:

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
Note
clear_object() has been renamed to object_clear()

Definition at line 759 of file object.c.

References obj::above, obj::active_next, obj::active_prev, obj::attacked_by_count, obj::below, blank_face, Settings::casting_time, obj::casting_time, obj::container, obj::contr, obj::discrete_damage, obj::env, obj::expmul, obj::face, FLAG_FRIENDLY, FLAG_REMOVED, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_dialog_information(), obj::head, obj::inv, obj::lore, obj::map, obj::materialname, obj::more, obj::msg, obj::name, obj::name_pl, object_free_key_values(), offsetof, QUERY_FLAG, obj::race, remove_friendly_object(), SET_FLAG, settings, obj::skill, obj::slaying, and obj::title.

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:

void object_clear_owner ( object op)

Clears the owner of specified object.

Parameters
opobject we want to clear the owner of. Can be NULL.
Note
clear_owner() has been renamed to object_clear_owner()

Definition at line 581 of file object.c.

References obj::owner, and obj::ownercount.

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:

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.

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

Definition at line 838 of file object.c.

References add_refcount(), obj::anim_suffix, obj::arch, obj::artifact, CLEAR_FLAG, obj::custom_name, obj::discrete_damage, FLAG_DIALOG_PARSED, FLAG_FREED, FLAG_REMOVED, FREE_AND_CLEAR, free_dialog_information(), free_string(), _key_value::key, obj::key_values, obj::lore, obj::materialname, obj::msg, obj::name, obj::name_pl, _key_value::next, NROFATTACKS, object_free_key_values(), object_update_speed(), offsetof, QUERY_FLAG, obj::race, RANDOM, archt::reference_count, SET_FLAG, obj::skill, obj::slaying, obj::speed, obj::speed_left, SPELL_TAG_SIZE, obj::spell_tags, obj::title, and _key_value::value.

Referenced by add_abilities(), apply_race_and_class(), cast_create_food(), cfapi_object_clone(), change_book(), command_create(), do_learn_spell(), 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(), polymorph_living(), put_decor(), put_doors(), sell_item(), setup(), START_TEST(), write_note(), write_rune(), and write_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
copy_owner() has been renamed to object_copy_owner()

Definition at line 657 of file object.c.

References object_get_owner(), object_set_owner(), PLAYER, and obj::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:

void object_copy_with_inv ( const object src_ob,
object dest_ob 
)

copy an object with an inventory...

i.e., duplicate the inv too.

Parameters
src_obobject to copy.
dest_obwhere to copy.
Todo:
replace with a function in common library (there is certainly one).
Note
copy_object_with_inv() has been renamed to object_copy_with_inv()

Definition at line 975 of file object.c.

References FOR_INV_FINISH, FOR_INV_PREPARE, object_copy(), object_copy_with_inv(), object_insert_in_ob(), and object_new().

Referenced by arch_to_object(), do_harvest(), include_map_in_map(), object_copy_with_inv(), place_chest(), place_fountain_with_specials(), and place_monsters().

Here is the call graph for this function:

Here is the caller graph for this function:

int object_count_active ( void  )

Objects statistics.

Returns
number of objects on the list of active objects.
Note
count_active() has been renamed to object_count_active()

Definition at line 1598 of file object.c.

References obj::active_next, and active_objects.

Referenced by malloc_info(), and START_TEST().

Here is the caller graph for this function:

int object_count_free ( void  )

Objects statistics.

Returns
number of objects on the list of free objects.
Note
count_free() has been renamed to object_count_free()

Definition at line 1560 of file object.c.

References free_objects, and obj::next.

Referenced by malloc_info(), and START_TEST().

Here is the caller graph for this function:

int object_count_used ( void  )

Object statistics.

Returns
number of objects on the list of used objects.
Note
count_used() has been renamed to object_count_used()

Definition at line 1579 of file object.c.

References obj::next, and objects.

Referenced by malloc_info(), and START_TEST().

Here is the caller graph for this function:

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 3832 of file object.c.

References FOR_INV_FINISH, FOR_INV_PREPARE, obj::head, HEAD, obj::more, object_copy(), object_create_clone(), object_insert_in_ob(), and object_new().

Referenced by cfapi_object_clone(), convert_item(), 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* 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.
Note
decrease_ob_nr() has been renamed to object_decrease_nrof()

Definition at line 2505 of file object.c.

References obj::container, obj::env, esrv_update_item(), first_player, fix_object(), FLAG_REMOVED, FOR_MAP_FINISH, FOR_MAP_PREPARE, obj::map, pl::next, obj::nrof, pl::ob, object_add_weight(), object_free_drop_inventory(), object_get_player_container(), object_remove(), object_sub_weight(), QUERY_FLAG, pl::socket, UPD_NROF, socket_struct::update_look, obj::weight, obj::x, and obj::y.

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:

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.
Note
distance() has been renamed to object_distance()

Definition at line 3584 of file object.c.

References obj::x, and obj::y.

Referenced by cfapi_object_distance().

Here is the caller graph for this function:

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.
Note
dump_object() has been renamed to object_dump()

Definition at line 394 of file object.c.

References obj::arch, obj::artifact, archt::clone, obj::count, empty_archetype, obj::env, get_ob_diff(), obj::head, obj::inv, obj::more, obj::name, archt::name, object_get_owner_const(), stringbuffer_append_printf(), and stringbuffer_append_string().

Referenced by animate_object(), command_dump(), command_dumpbelow(), dump_arch(), gate_type_process(), object_dump_all(), object_free2(), object_insert_in_map(), object_insert_in_ob(), object_remove(), process_events(), CREArchetypePanel::setItem(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

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)

Note
dump_all_objects() has been renamed to object_dump_all()

Definition at line 450 of file object.c.

References obj::count, llevDebug, LOG(), obj::next, object_dump(), 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* 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 4143 of file object.c.

References obj::arch, obj::below, obj::inv, and archt::name.

Referenced by cfapi_object_find_by_arch_name(), and dragon_ability_gain().

Here is the caller graph for this function:

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 4097 of file object.c.

References obj::below, obj::inv, and QUERY_FLAG.

Referenced by use_alchemy().

Here is the caller graph for this function:

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 4120 of file object.c.

References obj::below, FLAG_APPLIED, obj::inv, and QUERY_FLAG.

Referenced by save_life().

Here is the caller graph for this function:

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 3879 of file object.c.

References add_string(), obj::below, free_string(), obj::inv, and obj::name.

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* 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.
Note
find_object_name() has been renamed to object_find_by_name_global()

Definition at line 499 of file object.c.

References add_string(), free_string(), obj::name, and obj::next.

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* 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 3951 of file object.c.

References obj::below, obj::count, and obj::inv.

Referenced by command_cast_spell().

Here is the caller graph for this function:

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.
Note
find_object() has been renamed to object_find_by_tag_global()

Definition at line 476 of file object.c.

References obj::count, and obj::next.

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* 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 3903 of file object.c.

References obj::below, obj::inv, and obj::type.

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

Here is the caller graph for this function:

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 3928 of file object.c.

References obj::below, obj::inv, and obj::type.

Referenced by dispel_rune(), and hit_player().

Here is the caller graph for this function:

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 4168 of file object.c.

References obj::arch, obj::below, obj::inv, archt::name, and obj::type.

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* 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 3999 of file object.c.

References obj::below, obj::inv, obj::name, and obj::type.

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* 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 4024 of file object.c.

References obj::below, obj::inv, obj::race, and obj::type.

Referenced by monster_check_apply().

Here is the caller graph for this function:

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 4074 of file object.c.

References obj::below, obj::inv, SKILL, obj::skill, and obj::type.

Referenced by do_skill().

Here is the caller graph for this function:

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 4049 of file object.c.

References obj::below, obj::inv, obj::slaying, and obj::type.

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

Here is the caller graph for this function:

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 3974 of file object.c.

References obj::below, FLAG_APPLIED, obj::inv, QUERY_FLAG, and obj::type.

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* 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.
find_obj_by_type_subtype() has been renamed to object_find_by_type_subtype()

Definition at line 4195 of file object.c.

References obj::below, obj::inv, obj::subtype, and obj::type.

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

Here is the caller graph for this function:

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)
Note
find_first_free_spot() has been renamed to object_find_first_free_spot()

Definition at line 3458 of file object.c.

References freearr_x, freearr_y, ob_blocked(), and SIZEOFFREE.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.
find_free_spot() has been renamed to object_find_free_spot()

Definition at line 3415 of file object.c.

References AB_NO_PASS, freearr_x, freearr_y, maxfree, ob_blocked(), RANDOM, and SIZEOFFREE.

Referenced by animate_weapon(), cfapi_object_insert(), command_summon(), command_teleport(), do_harvest(), enter_map(), gate_type_process(), object_insert_to_free_spot_or_free(), pets_follow_owner(), pets_summon_golem(), pets_summon_object(), polymorph_living(), process_players1(), 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:

int object_find_multi_free_spot_around ( 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, 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.
find_multi_free_spot_around() has been renamed to object_find_multi_free_spot_around()

Definition at line 3147 of file object.c.

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

Here is the call graph for this function:

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.
find_multi_free_spot_within_radius() has been renamed to object_find_multi_free_spot_within_radius()

Definition at line 3266 of file object.c.

References get_map_flags(), HEAD, obj::map, ob_blocked(), object_get_multi_size(), object_get_value(), P_OUT_OF_MAP, RANDOM, obj::x, and obj::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:

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.
Note
fix_multipart_object() has been renamed to object_fix_multipart()

Definition at line 4564 of file object.c.

References add_string(), obj::arch, arch_to_object(), free_string(), obj::head, INS_ABOVE_FLOOR_ONLY, INS_NO_MERGE, INS_NO_WALK_ON, llevError, LOG(), obj::map, obj::more, archt::more, obj::name, object_insert_in_map(), obj::title, obj::x, and obj::y.

Referenced by generate_monster_inv(), and link_multipart_objects().

Here is the call graph for this function:

Here is the caller graph for this function:

void object_free2 ( 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.
Note
free_object2() has been renamed to object_free2()

Definition at line 1391 of file object.c.

References obj::arch, obj::artifact, obj::count, obj::discrete_damage, EVENT_DESTROY, execute_event(), FLAG_ALIVE, FLAG_FREED, FLAG_FRIENDLY, FLAG_IS_A_TEMPLATE, FLAG_NO_DROP, FLAG_REMOVED, FLAG_STARTEQUIP, FOR_INV_FINISH, FOR_INV_PREPARE, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, 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, mapdef::in_memory, INS_ABOVE_FLOOR_ONLY, obj::inv, llevDebug, llevError, llevMonster, LOG(), obj::lore, obj::map, MAP_IN_MEMORY, obj::materialname, obj::more, MOVE_ALL, obj::msg, obj::name, obj::name_pl, obj::next, nroffreeobjects, object_dump(), object_free2(), 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(), obj::prev, QUERY_FLAG, obj::race, RANDOM, archt::reference_count, remove_friendly_object(), RUNE, SCRIPT_FIX_NOTHING, SET_FLAG, SIZEOFFREE, obj::skill, obj::slaying, obj::speed, obj::spell_tags, stringbuffer_finish(), stringbuffer_new(), obj::title, TRAP, obj::x, and obj::y.

Referenced by add_one_item(), alchemy_object(), apply_auto(), apply_by_living(), apply_race_and_class(), CREArtifactPanel::artifactChanged(), cast_create_missile(), cast_create_town_portal(), cfapi_object_insert(), command_create(), command_goto(), command_learn_spell_or_prayer(), command_reset(), command_summon(), command_teleport(), counterspell(), do_execute_event(), do_forget_spell(), enter_exit(), enter_player_savebed(), CRECombatSimulator::fight(), free_no_drop(), god_gives_present(), knowledge_alchemy_face(), monsterFight(), object_free2(), object_free_drop_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(), save_object(), scroll_failure(), START_TEST(), stop_projectile(), and write_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
free_all_object_data() has been renamed to object_free_object_data()

Definition at line 522 of file object.c.

References FLAG_FREED, llevDebug, LOG(), obj::name, obj::next, nrofallocobjects, nroffreeobjects, QUERY_FLAG, and STARTMAX.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
free_object() has been renamed to object_free_drop_inventory()

Definition at line 1368 of file object.c.

References object_free2().

Referenced by add_abilities(), 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(), 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_all_objects(), 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(), kill_player_not_permadeath(), 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_free2(), object_insert_to_free_spot_or_free(), object_merge_spell(), object_replace_insert_in_map(), CREMainWindow::onReportSpellDamage(), pay_from_container(), pets_move(), pets_move_golem(), pets_remove_all(), 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(), retrofit_joined_wall(), rune_attack(), save_life(), save_throw_object(), second_arch_pass(), 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:

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.
Note
free_key_values() has been renamed to object_free_key_values()

Definition at line 727 of file object.c.

References FREE_AND_CLEAR_STR, _key_value::key, obj::key_values, _key_value::next, and _key_value::value.

Referenced by free_arch(), free_artifact(), object_clear(), object_copy(), and object_free2().

Here is the caller graph for this function:

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 333 of file object.c.

References obj::env.

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:

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.
Note
get_ob_key_link() has been renamed to object_get_key_value()

Definition at line 4218 of file object.c.

References _key_value::key, obj::key_values, and _key_value::next.

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:

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 :)
Note
get_multi_size() has been renamed to object_get_multi_size()

Definition at line 4626 of file object.c.

References obj::arch, archt::clone, HEAD, archt::more, obj::x, and obj::y.

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

Here is the caller graph for this function:

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 559 of file object.c.

References obj::count, FLAG_FREED, FLAG_REMOVED, object_clear_owner(), obj::owner, obj::ownercount, and QUERY_FLAG.

Referenced by adj_attackroll(), attack_message(), attack_ob_simple(), blind_living(), cast_spell(), cfapi_object_get_property(), change_object(), command_kill_pets(), command_showpets(), 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(), 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_get_enemy(), pets_move(), pets_move_golem(), pets_remove_all(), pets_summon_golem(), pets_summon_object(), pets_terminate_all(), poison_living(), polymorph_living(), push_ob(), remove_trap(), save_object(), save_objects(), scare_creature(), START_TEST(), steal(), tailor_god_spell(), trap_disarm(), and use_oratory().

Here is the call graph for this function:

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 370 of file object.c.

References obj::count, FLAG_FREED, FLAG_REMOVED, llevError, LOG(), obj::owner, obj::ownercount, and QUERY_FLAG.

Referenced by object_dump().

Here is the call graph for this function:

Here is the caller graph for this function:

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.
Note
get_player_container() has been renamed to object_get_player_container()

Definition at line 353 of file object.c.

References obj::env, PLAYER, and obj::type.

Referenced by cfapi_object_set_property(), drain_wand_charge(), identify(), lamp_type_apply(), lighter_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:

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.
get_ob_key_value() has been renamed to object_get_value()

Definition at line 4246 of file object.c.

References find_string(), _key_value::key, obj::key_values, _key_value::next, and _key_value::value.

Referenced by add_abilities(), append_spell(), apply_check_personalized_blessings(), apply_check_race_restrictions(), apply_handle_yield(), cfapi_object_get_key(), change_book(), check_spell_expiry(), command_cast_spell(), create_player_cmd(), do_exit_map(), do_harvest(), esrv_add_spells(), fix_player(), follower_remove_given_items(), generate_monster(), generate_monster_arch(), generate_monster_inv(), god_enchants_weapon(),