Crossfire Server, Branches 1.12  R18729
object.c File Reference
#include <stdlib.h>
#include <string.h>
#include <global.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <object.h>
#include <skills.h>
#include <loader.h>
#include <sproto.h>
#include "stringbuffer.h"
+ Include dependency graph for object.c:

Go to the source code of this file.

Functions

int absdir (int d)
 
void add_weight (object *op, signed long weight)
 
int can_merge (object *ob1, object *ob2)
 
int can_pick (const object *who, const object *item)
 
int can_see_monsterP (mapstruct *m, int x, int y, int dir)
 
int check_move_on (object *op, object *originator)
 
void clear_object (object *op)
 
void clear_owner (object *op)
 
static int compare_ob_value_lists (const object *, const object *)
 
static int compare_ob_value_lists_one (const object *, const object *)
 
void copy_object (object *op2, object *op)
 
void copy_object_with_inv (object *src_ob, object *dest_ob)
 
void copy_owner (object *op, object *clone)
 
int count_active (void)
 
int count_free (void)
 
int count_used (void)
 
objectdecrease_ob_nr (object *op, uint32 i)
 
int dirdiff (int dir1, int dir2)
 
int distance (const object *ob1, const object *ob2)
 
void dump_all_objects (void)
 
void dump_object (object *op, StringBuffer *sb)
 
static void expand_objects (void)
 
int find_dir (mapstruct *m, int x, int y, object *exclude)
 
int find_dir_2 (int x, int y)
 
int find_first_free_spot (const object *ob, mapstruct *m, int x, int y)
 
int find_free_spot (const object *ob, mapstruct *m, int x, int y, int start, int stop)
 
int find_multi_free_spot_around (object *ob, object *gen, int *hx, int *hy)
 
int find_multi_free_spot_within_radius (object *ob, object *gen, int *hx, int *hy)
 
objectfind_obj_by_type_subtype (const object *who, int type, int subtype)
 
objectfind_object (tag_t i)
 
objectfind_object_name (const char *str)
 
void fix_multipart_object (object *tmp)
 
void flag_inv (object *op, int flag)
 
void free_all_object_data (void)
 
void free_key_values (object *op)
 
void free_object (object *ob)
 
void free_object2 (object *ob, int free_inventory)
 
void get_multi_size (object *ob, int *sx, int *sy, int *hx, int *hy)
 
key_valueget_ob_key_link (const object *ob, const char *key)
 
const char * get_ob_key_value (const object *op, const char *const key)
 
objectget_object (void)
 
objectget_owner (object *op)
 
objectget_player_container (object *op)
 
void get_search_arr (int *search_arr)
 
objectget_split_ob (object *orig_ob, uint32 nr, char *err, size_t size)
 
static void increase_ob_nr (object *op, uint32 i)
 
objectinsert_ob_in_map (object *op, mapstruct *m, object *originator, int flag)
 
objectinsert_ob_in_map_at (object *op, mapstruct *m, object *originator, int flag, int x, int y)
 
objectinsert_ob_in_ob (object *op, object *where)
 
int item_matched_string (object *pl, object *op, const char *name)
 
objectmerge_ob (object *op, object *top)
 
void merge_spell (object *op, sint16 x, sint16 y)
 
objectobject_create_clone (object *asrc)
 
objectobject_get_env_recursive (object *op)
 
static void permute (int *, int, int)
 
objectpresent (uint8 type, mapstruct *m, int x, int y)
 
objectpresent_arch (const archetype *at, mapstruct *m, int x, int y)
 
objectpresent_arch_in_ob (const archetype *at, const object *op)
 
objectpresent_in_ob (uint8 type, const object *op)
 
objectpresent_in_ob_by_name (int type, const char *str, const object *op)
 
void remove_from_active_list (object *op)
 
void remove_ob (object *op)
 
void replace_insert_ob_in_map (const char *arch_string, object *op)
 
void reset_object (object *op)
 
void set_cheat (object *op)
 
int set_ob_key_value (object *op, const char *key, const char *value, int add_key)
 
static int set_ob_key_value_s (object *, const char *, const char *, int)
 
void set_owner (object *op, object *owner)
 
void sub_weight (object *op, signed long weight)
 
signed long sum_weight (object *op)
 
void unflag_inv (object *op, int flag)
 
void update_ob_speed (object *op)
 
void update_object (object *op, int action)
 
void update_turn_face (object *op)
 

Variables

objectactive_objects
 
objectfree_objects
 
short freearr_x [SIZEOFFREE]
 
short freearr_y [SIZEOFFREE]
 
int freedir [SIZEOFFREE]
 
int maxfree [SIZEOFFREE]
 
int nrofallocobjects = STARTMAX
 
int nroffreeobjects = STARTMAX
 
object objarray [STARTMAX]
 
objectobjects
 
static const int reduction_dir [SIZEOFFREE][3]
 

Detailed Description

Everything related to objects, in their basic form.

Definition in file object.c.

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

Referenced by check_spell_knockback(), common_process_projectile(), compute_path(), dist_att(), disthit_att(), fire_bolt(), fire_bullet(), flee_player(), forklightning(), hitrun_att(), monster_cast_spell(), monster_use_bow(), monster_use_range(), monster_use_scroll(), monster_use_skill(), move_ball_spell(), move_bolt(), move_bullet(), move_cone(), move_monster(), move_player(), move_swarm_spell(), path_to_player(), pet_move(), player_fire_bow(), pray_at_altar(), run_att(), spinner_type_move_on(), summon_object(), turn_transport(), wait_att(), and wait_att2().

+ Here is the caller graph for this function:

void add_weight ( object op,
signed long  weight 
)

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 sub_weight().

Definition at line 2486 of file object.c.

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

Referenced by increase_ob_nr(), insert_ob_in_ob(), and make_item_from_recipe().

+ Here is the caller graph for this function:

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

References obj::animation_id, obj::arch, obj::attacktype, can_merge(), 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, 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 can_merge(), cfapi_object_get_property(), insert_ob_in_map(), insert_ob_in_ob(), local_check_loaded_object(), merge_ob(), and START_TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References FLAG_ALIVE, FLAG_NO_PICK, obj::head, obj::invisible, obj::more, PLAYER, QUERY_FLAG, 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(), monster_can_pick(), and pick_up().

+ 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 3524 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(), find_nearest_living_creature(), and spell_find_dir().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int 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. insert_ob_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 2651 of file object.c.

References obj::above, obj::below, obj::count, FABS, find_skill_by_number(), FLAG_IS_HILLY, FLAG_IS_WOODED, FLAG_NO_APPLY, FLAG_NO_PICK, FLAG_WIZPASS, 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(), PLAYER, QUERY_FLAG, SK_CLIMBING, SK_WOODSMAN, obj::speed, obj::speed_left, obj::type, was_destroyed, obj::x, and obj::y.

Referenced by change_abil(), and insert_ob_in_map().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clear_object ( object op)
void 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 544 of file object.c.

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

Referenced by set_owner(), START_TEST(), and stop_projectile().

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

References compare_ob_value_lists_one().

Referenced by 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 108 of file object.c.

References FALSE, get_ob_key_link(), _key_value::key, obj::key_values, _key_value::next, 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:

void copy_object ( object op2,
object op 
)

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
op2object that we copy.from
opobject that we copy to.

Definition at line 758 of file object.c.

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

Referenced by add_abilities(), cast_create_food(), cfapi_object_clone(), change_book(), command_create(), copy_object_with_inv(), do_learn_spell(), explosion(), first_arch_pass(), forklightning(), infect_object(), key_change_class(), local_check_loaded_object(), magic_wall(), make_throw_ob(), move_bolt(), move_cone(), object_create_clone(), pay_from_container(), place_alchemy_objects(), place_chest(), place_fountain_with_specials(), 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 copy_object_with_inv ( 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).

Definition at line 862 of file object.c.

References obj::below, copy_object(), get_object(), insert_ob_in_ob(), and obj::inv.

Referenced by arch_to_object(), do_harvest(), include_map_in_map(), and place_monsters().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References get_owner(), PLAYER, set_owner(), 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:

int count_active ( void  )

Objects statistics.

Returns
number of objects on the list of active objects.

Definition at line 1465 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 count_free ( void  )

Objects statistics.

Returns
number of objects on the list of free objects.

Definition at line 1433 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 count_used ( void  )

Object statistics.

Returns
number of objects on the list of used objects.

Definition at line 1449 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* decrease_ob_nr ( object op,
uint32  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 2345 of file object.c.

References obj::above, obj::container, obj::contr, obj::env, esrv_update_item(), first_player, FLAG_REMOVED, free_object(), GET_MAP_OB, get_player_container(), obj::map, pl::next, obj::nrof, pl::ob, QUERY_FLAG, remove_ob(), pl::socket, sub_weight(), 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(), get_split_ob(), operate_altar(), save_throw_object(), and START_TEST().

+ 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 3434 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:

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

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

Referenced by cfapi_object_distance(), keyplace(), and play_sound_map().

+ Here is the caller graph for this function:

void dump_all_objects ( 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 416 of file object.c.

References obj::count, dump_object(), llevDebug, LOG(), obj::next, 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:

void dump_object ( 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 372 of file object.c.

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

Referenced by animate_object(), command_dump(), command_dumpbelow(), dump_all_objects(), dump_arch(), free_object2(), gate_type_process(), insert_ob_in_map(), insert_ob_in_ob(), process_events(), remove_ob(), and START_TEST().

+ Here is the call graph for this function:

+ 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 get_object() if the unused list is empty.

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

Definition at line 880 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 get_object().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int 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.

Definition at line 3313 of file object.c.

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

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

Referenced by enter_map(), get_rangevector(), get_rangevector_from_mapcoord(), monster_use_bow(), monster_use_range(), monster_use_skill(), and pet_move().

+ Here is the caller graph for this function:

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

find_first_free_spot(archetype, mapstruct, x, y) works like 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 3240 of file object.c.

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

Referenced by cfapi_object_teleport(), change_object(), find_enclosed_spot(), hit_player(), 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 find_free_spot ( const object ob,
mapstruct m,
int  x,
int  y,
int  start,
int  stop 
)

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, insert_ob_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 3200 of file object.c.

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

Referenced by animate_weapon(), command_summon(), command_teleport(), do_harvest(), enter_map(), follow_owner(), free_object2(), gate_type_process(), polymorph_living(), process_players1(), shop_mat_type_move_on(), summon_golem(), summon_object(), teleport(), and transfer_ob().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int find_multi_free_spot_around ( object ob,
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.

Definition at line 2935 of file object.c.

References get_multi_size(), obj::head, obj::map, MAP_HEIGHT, MAP_WIDTH, ob_blocked(), obj::x, and obj::y.

+ Here is the call graph for this function:

int find_multi_free_spot_within_radius ( object ob,
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 3052 of file object.c.

References get_map_flags(), get_multi_size(), get_ob_key_value(), obj::head, obj::map, ob_blocked(), P_OUT_OF_MAP, strtol(), 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:

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

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

Referenced by cast_word_of_recall(), cfapi_object_find(), cftimer_create(), deep_swamp_type_process(), and do_hidden_move().

+ Here is the caller graph for this function:

object* find_object ( 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 439 of file object.c.

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

Referenced by cfapi_object_find(), 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_object_name ( 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 459 of file object.c.

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fix_multipart_object ( 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 4007 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, insert_ob_in_map(), llevError, LOG(), obj::map, obj::more, archt::more, obj::name, 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 flag_inv ( object op,
int  flag 
)

Activate recursively a flag on an object's inventory

Parameters
opobject to recurse. Can have an empty inventory.
flagflag to set.

Definition at line 2876 of file object.c.

References obj::below, flag_inv(), obj::inv, and SET_FLAG.

Referenced by flag_inv(), local_check_loaded_object(), and set_cheat().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void free_all_object_data ( void  )

Destroys all allocated objects.

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

Definition at line 479 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 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 659 of file object.c.

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

Referenced by clear_object(), copy_object(), free_arch(), free_artifact(), and free_object2().

+ Here is the caller graph for this function:

void free_object ( 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 remove_ob() 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 1238 of file object.c.

References free_object2().

Referenced by add_abilities(), adjust_sign_msg(), alchemy(), alchemy_failure_effect(), alchemy_object(), apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_builder_wall(), apply_builder_window(), arrow_type_process(), artifact_msg(), auto_apply(), become_follower(), blindness_type_process(), cast_cause_disease(), cast_create_missile(), cast_create_town_portal(), cast_dust(), cast_raise_dead_spell(), cast_smite_spell(), cfapi_object_delete(), cfapi_object_insert(), change_book(), change_object(), check_bullet(), check_special_prayers(), clean_object(), command_arrest(), command_cast_spell(), command_create(), command_free(), command_goto(), command_kill_pets(), command_learn_spell_or_prayer(), command_reset(), command_summon(), command_teleport(), common_process_projectile(), convert_item(), counterspell(), cure_disease(), decay_objects(), decrease_ob_nr(), delete_unique_items(), destroy_object(), dispel_rune(), do_forget_spell(), do_turn(), drop(), drop_object(), eat_special_food(), enter_exit(), enter_map(), enter_player_savebed(), execute_event(), execute_word_of_recall(), explode_bullet(), explosion(), fire_arch_from_position(), fire_bolt(), fire_bow(), fire_bullet(), first_arch_pass(), fix_generated_item(), fix_stopped_arrow(), fix_walls(), follower_remove_given_items(), free_all_objects(), free_object2(), free_player(), generate_treasure(), give_initial_items(), god_intervention(), hit_player(), hit_with_arrow(), insert_ob_in_map(), insert_ob_in_ob(), insert_objects(), key_change_class(), kill_object(), kill_player(), load_objects(), locate_recipe_artifact(), lock_and_hide_doors(), loot_object(), merge_ob(), merge_spell(), monster_move_no_enemy(), move_aura(), move_bolt(), move_bullet(), move_cone(), move_creator(), move_disease(), move_duplicator(), move_golem(), move_marker(), move_missile(), move_monster(), move_player_mover(), move_swarm_spell(), move_symptom(), move_teleporter(), nuke_map_region(), pay_from_container(), pet_move(), pick_up_object(), place_chest(), place_exits(), place_fountain_with_specials(), player_apply(), poisoning_type_process(), polymorph_item(), polymorph_living(), polymorph_melt(), potion_type_apply(), prayer_failure(), print_monsters(), process_events(), process_object(), receive_play_again(), recharge(), remove_adjacent_doors(), remove_all_pets(), remove_contents(), remove_door(), remove_force(), remove_locked_door(), remove_marking_runes(), remove_monsters(), remove_symptoms(), remove_unpaid_objects(), replace_insert_ob_in_map(), retrofit_joined_wall(), rune_attack(), save_life(), save_throw_object(), scroll_failure(), second_arch_pass(), spell_effect_type_move_on(), spell_failure(), spring_trap(), START_TEST(), stop_item(), stop_projectile(), summon_golem(), tailor_god_spell(), tear_down_wall(), terminate_all_pets(), thrown_object_type_process(), and write_scroll().

+ Here is the call graph for this function:

void free_object2 ( object ob,
int  free_inventory 
)

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 remove_ob() first for this function to succeed.

Parameters
obobject to free. Will become invalid when function returns.
free_inventoryif set, free inventory as well. Else drop items in inventory to the ground.
Warning
the object's archetype should be a valid pointer, or NULL.

Definition at line 1258 of file object.c.

References obj::arch, obj::below, obj::count, obj::discrete_damage, dump_object(), EVENT_DESTROY, execute_event(), find_free_spot(), FLAG_ALIVE, FLAG_FREED, FLAG_FRIENDLY, FLAG_IS_A_TEMPLATE, FLAG_NO_DROP, FLAG_REMOVED, FLAG_STARTEQUIP, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_arch(), free_dialog_information(), free_key_values(), free_object(), free_object2(), free_objects, freearr_x, freearr_y, GET_MAP_MOVE_BLOCK, mapdef::in_memory, insert_ob_in_map(), 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, obj::prev, QUERY_FLAG, obj::race, archt::reference_count, remove_friendly_object(), remove_ob(), RUNE, SCRIPT_FIX_NOTHING, SET_FLAG, SIZEOFFREE, obj::skill, obj::slaying, obj::speed, obj::spell_tags, stringbuffer_finish(), stringbuffer_new(), obj::title, TRAP, obj::type, update_ob_speed(), obj::x, and obj::y.

Referenced by free_no_drop(), free_object(), free_object2(), and god_gives_present().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void get_multi_size ( 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 4066 of file object.c.

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

Referenced by find_multi_free_spot_around(), find_multi_free_spot_within_radius(), process_map(), and update_transport_block().

+ Here is the caller graph for this function:

key_value* get_ob_key_link ( 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 3676 of file object.c.

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

Referenced by compare_ob_value_lists_one(), and set_ob_key_value_s().

+ Here is the caller graph for this function:

const char* get_ob_key_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 3701 of file object.c.

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

Referenced by apply_special(), cfapi_object_get_key(), check_race_restrictions(), check_spell_expiry(), command_use(), do_harvest(), find_multi_free_spot_within_radius(), follower_remove_given_items(), generate_monster(), generate_monster_arch(), generate_monster_inv(), god_enchants_weapon(), handle_apply_yield(), kill_object(), query_cost(), set_object_face_main(), set_object_face_other(), transport_type_apply(), and turn_transport().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* get_object ( void  )

Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.

If there are no free objects, expand_objects() is called to get more.

Returns
cleared and ready to use object*.
Note
will never fail, as expand_objects() will fatal() if memory allocation error.

Definition at line 921 of file object.c.

References obj::active_next, obj::active_prev, clear_object(), obj::count, obj::discrete_damage, expand_objects(), FLAG_FREED, FLAG_REMOVED, free_objects, llevError, LOG(), obj::lore, obj::materialname, obj::msg, obj::name, obj::name_pl, obj::next, nroffreeobjects, ob_count, objects, obj::prev, QUERY_FLAG, obj::race, SET_FLAG, obj::skill, obj::slaying, obj::spell_tags, and obj::title.

Referenced by add_abilities(), arch_to_object(), artifact_msg(), cast_create_food(), cfapi_object_clone(), cfapi_object_create(), command_goto(), command_reset(), command_summon(), command_teleport(), copy_object_with_inv(), create_singularity(), do_harvest(), do_learn_spell(), enter_player_savebed(), explosion(), first_arch_pass(), forklightning(), generate_treasure(), get_jail_exit(), infect_object(), key_change_class(), load_objects(), magic_wall(), make_throw_ob(), move_bolt(), move_cone(), object_create_clone(), pay_from_container(), place_alchemy_objects(), place_fountain_with_specials(), place_special_exit(), polymorph_item(), 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:

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.

Changed 2004-02-12 - if the player is setting at the play again prompt, he is removed, and we don't want to treat him as an owner of anything, so check removed flag. I don't expect that this should break anything - once an object is removed, it is basically dead anyways.

Parameters
opitem to search owner of.
Returns
owner, or NULL if not found.
Todo:
a side effect of this function is to clean owner chain for not existing anymore owner. This is not the place to do such a cleaning

Definition at line 524 of file object.c.

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

Referenced by adj_attackroll(), attack_message(), attack_ob_simple(), blind_living(), cast_spell(), cfapi_object_get_property(), command_kill_pets(), command_showpets(), copy_owner(), explode_bullet(), find_target_for_friendly_spell(), fire_arch_from_position(), fix_summon_pet(), friendly_fire(), get_pet_enemy(), get_real_owner(), hit_player(), hit_with_one_attacktype(), infect_object(), kill_object(), monster_cast_spell(), monster_use_bow(), monster_use_range(), monster_use_scroll(), monster_use_skill(), move_ball_spell(), move_golem(), move_missile(), move_monster(), move_player_attack(), move_swarm_spell(), peacemaker_type_process(), pet_move(), poison_living(), polymorph_living(), push_ob(), remove_all_pets(), scare_creature(), START_TEST(), steal(), summon_golem(), summon_object(), tailor_god_spell(), terminate_all_pets(), and use_oratory().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by cfapi_object_find(), cfapi_object_set_property(), decrease_ob_nr(), drain_wand_charge(), identify(), increase_ob_nr(), insert_ob_in_ob(), lamp_type_apply(), lighter_type_apply(), pick_up_object(), remove_force(), remove_ob(), send_changed_object(), and START_TEST().

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

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

Referenced by find_nearest_living_creature(), and get_pet_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* get_split_ob ( object orig_ob,
uint32  nr,
char *  err,
size_t  size 
)

get_split_ob(ob,nr) splits up ob into two parts. The part which is returned contains nr objects, and the remaining parts contains the rest (or is removed and freed if that number is 0). On failure, NULL is returned, and the reason LOG()ed.

This function will send an update to the client if the remaining object is in a player inventory.

Parameters
orig_obobject from which to split.
nrnumber of elements to split.
errbuffer that will contain failure reason if NULL is returned. Can be NULL.
sizeerr's size
Returns
split object, or NULL on failure.
Todo:
handle case orig_ob->nrof == 0 (meaning 1).

Definition at line 2313 of file object.c.

References decrease_ob_nr(), llevDebug, LOG(), obj::name, obj::nrof, object_create_clone(), and snprintf().

Referenced by animate_weapon(), apply_container(), apply_special(), cfapi_object_split(), do_throw(), drop_object(), fire_bow(), improve_armour(), lamp_type_apply(), lighter_type_apply(), loot_object(), pick_up_object(), put_object_in_sack(), and START_TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void increase_ob_nr ( object op,
uint32  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 2423 of file object.c.

References obj::above, add_weight(), obj::container, obj::contr, obj::env, esrv_update_item(), first_player, FLAG_REMOVED, GET_MAP_OB, get_player_container(), obj::map, pl::next, obj::nrof, pl::ob, QUERY_FLAG, pl::socket, UPD_NROF, socket_struct::update_look, obj::weight, obj::x, and obj::y.

Referenced by insert_ob_in_ob(), and merge_ob().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References obj::above, obj::below, can_merge(), check_move_on(), CLEAR_FLAG, obj::contr, pl::do_los, dump_object(), FLAG_ALIVE, FLAG_APPLIED, FLAG_FREED, FLAG_INV_LOCKED, FLAG_IS_FLOOR, FLAG_NO_PICK, FLAG_NO_STEAL, FLAG_OVERLAY_FLOOR, FLAG_REMOVED, free_object(), get_map_from_coord(), GET_MAP_OB, GET_MAP_TOP, obj::glow_radius, obj::head, pl::hidden, INS_ABOVE_FLOOR_ONLY, INS_BELOW_ORIGINATOR, INS_MAP_LOAD, INS_NO_MERGE, INS_NO_WALK_ON, insert_ob_in_map(), LAMP, llevError, LOG(), obj::map, MAP_DARKNESS, merge_spell(), obj::more, MOVE_FLY_HIGH, MOVE_FLY_LOW, obj::move_type, obj::nrof, obj::other_arch, out_of_map(), OUT_OF_REAL_MAP, obj::ox, obj::oy, PLAYER, mapdef::players, QUERY_FLAG, obj::range, remove_ob(), SET_MAP_OB, SET_MAP_TOP, pl::socket, obj::speed, obj::speed_left, SPELL_EFFECT, stringbuffer_finish(), stringbuffer_new(), pl::transport, obj::type, UP_OBJ_INSERT, update_all_los(), socket_struct::update_look, update_object(), obj::x, and obj::y.

Referenced by alchemy_failure_effect(), animate_bomb(), animate_weapon(), auto_apply(), cast_cause_disease(), cast_cone(), cast_consecrate(), cast_create_obj(), cast_create_town_portal(), cast_destruction(), cast_detection(), cast_light(), cast_magic_storm(), cast_polymorph(), cast_raise_dead_spell(), cast_smite_spell(), cfapi_object_insert(), change_object(), charge_mana_effect(), command_create(), command_reset(), common_process_projectile(), cone_drop(), converter_type_move_on(), create_bomb(), dimension_door(), do_harvest(), do_throw(), drop_object(), enter_map(), explode_bullet(), explosion(), fire_arch_from_position(), fire_bolt(), fire_bow(), fire_bullet(), fire_swarm(), fix_multipart_object(), fix_stopped_item(), follow_owner(), forklightning(), free_object2(), gate_type_process(), generate_monster_arch(), handle_apply_yield(), hit_player(), hit_with_arrow(), insert_multisquare_ob_in_map(), insert_ob_in_map(), insert_ob_in_map_at(), key_change_class(), keyplace(), kill_object(), kill_player(), load_objects(), lock_and_hide_doors(), loot_object(), magic_wall(), make_map_floor(), make_map_walls(), mood_change(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_cone(), move_missile(), move_ob(), move_symptom(), pick_up(), place_alchemy_objects(), place_chest(), place_exits(), place_fountain_with_specials(), place_special_exit(), polymorph_item(), polymorph_living(), potion_type_apply(), push_ob(), put_a_monster(), put_decor(), put_doors(), put_floor(), put_treasure(), recharge(), remove_door(), remove_force(), remove_locked_door(), remove_unpaid_objects(), replace_insert_ob_in_map(), 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(), summon_golem(), summon_object(), 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_ob_in_map_at ( object op,
mapstruct m,
object originator,
int  flag,
int  x,
int  y 
)

Same as insert_ob_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 1761 of file object.c.

References obj::arch, archt::clone, obj::head, insert_ob_in_map(), obj::map, obj::more, obj::x, and obj::y.

Referenced by apply_builder_floor(), apply_builder_item(), apply_builder_wall(), apply_builder_window(), apply_container(), cfapi_object_insert(), cfapi_object_teleport(), cfapi_object_transfer(), command_create(), convert_item(), fix_walls(), generate_monster_inv(), move_creator(), process_players1(), put_object_in_sack(), START_TEST(), and turn_one_transport().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References obj::above, add_weight(), obj::below, can_merge(), obj::carrying, CLEAR_FLAG, CONTAINER, obj::contr, obj::count, dump_object(), obj::env, esrv_send_item(), fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_OBJ_ORIGINAL, FLAG_REMOVED, free_object(), get_player_container(), obj::glow_radius, obj::head, increase_ob_nr(), obj::inv, llevDebug, llevError, LOG(), obj::map, MAP_DARKNESS, obj::more, obj::name, obj::nrof, obj::ox, obj::oy, P_NEED_UPDATE, QUERY_FLAG, SET_FLAG, SET_MAP_FLAGS, SKILL, stringbuffer_finish(), stringbuffer_new(), obj::type, update_all_los(), update_position(), obj::weight, obj::x, and obj::y.

Referenced by add_abilities(), alchemy_failure_effect(), animate_weapon(), apply_container(), apply_special(), attempt_recipe(), auto_apply(), blind_living(), cast_bless(), cast_change_ability(), cast_create_town_portal(), cast_curse(), cast_word_of_recall(), cfapi_object_insert(), change_luck(), change_object(), command_create(), command_insert_into(), command_use(), confuse_living(), copy_object_with_inv(), create_aura(), do_harvest(), do_learn_spell(), do_symptoms(), do_throw(), do_turn(), dragon_ability_gain(), drain_specific_stat(), eat_special_food(), find_or_create_connection_for_map(), fix_container(), fix_generated_item(), give_skill_by_name(), god_gives_present(), grant_immunity(), handle_apply_yield(), hit_with_arrow(), improve_armour(), infect_object(), insert_objects(), keyplace(), kill_player(), lamp_type_apply(), lighter_type_apply(), local_check_loaded_object(), magic_wall(), make_object_glow(), make_throw_ob(), monster_check_pickup(), move_aura(), move_marker(), object_create_clone(), pick_up_object(), place_chest(), poison_living(), potion_type_apply(), put_object_in_sack(), put_treasure(), remove_force(), save_throw_object(), second_arch_pass(), sell_item(), slow_living(), START_TEST(), stick_arrow(), swap_random_stats(), transmute_item_to_flower(), transport_type_apply(), write_note(), write_rune(), and write_scroll().

+ Here is the call graph for this function:

int item_matched_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 3901 of file object.c.

References obj::contr, pl::count, obj::custom_name, FLAG_CURSED, FLAG_DAMNED, FLAG_INV_LOCKED, FLAG_KNOWN_CURSED, FLAG_UNPAID, HUGE_BUF, MAX_BUF, obj::name, obj::name_pl, PLAYER, query_base_name(), QUERY_FLAG, query_name(), query_short_name(), strcasecmp(), strncasecmp(), and obj::type.

Referenced by check_pick(), command_drop(), command_take(), find_best_apply_object_match(), START_TEST(), and write_rune().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* merge_ob ( object op,
object top 
)

This function goes through all objects below and including top, and merges op to the first matching object.

Will correctly send updated objects to client if needed.

Parameters
opobject to merge.
topfrom which item to merge. If NULL, it is calculated.
Returns
pointer to object if it succeded in the merge, otherwise NULL

Definition at line 1724 of file object.c.

References obj::above, obj::below, can_merge(), free_object(), increase_ob_nr(), obj::nrof, remove_ob(), and obj::weight.

Referenced by cfapi_object_merge(), command_lock_item(), command_rename_item(), fix_stopped_item(), get_payment(), hit_with_arrow(), lock_item_cmd(), stop_projectile(), and unapply_special().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void merge_spell ( object op,
sint16  x,
sint16  y 
)

This sees if there are any objects on the space that can merge with op. Note that op does not need to actually be inserted on the map (when called from insert_ob_in_map, it won't be), but op->map should be set correctly.

Note that even if we find a match on the space, we keep progressing looking for more. This is because op->range is set to 0 in explosion, so what may not have been mergable now is.

Parameters
opobject to try to merge into.
x
ycoordinates to look at for merging.

Definition at line 1792 of file object.c.

References obj::above, obj::attacktype, liv::dam, obj::direction, obj::duration, FREE_AND_CLEAR, free_object(), GET_MAP_OB, obj::level, llevError, LOG(), obj::map, MAX, liv::maxhp, OB_SPELL_TAG_HASH, OB_SPELL_TAG_MATCH, obj::other_arch, obj::owner, obj::ownercount, obj::range, remove_ob(), obj::speed, obj::speed_left, Statistics::spell_hash_full, Statistics::spell_merges, SPELL_TAG_SIZE, obj::spell_tags, statistics, obj::stats, obj::subtype, obj::type, and liv::wc.

Referenced by explosion(), and insert_ob_in_map().

+ Here is the call graph for this function:

+ 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, get_object() calls fatal().

Definition at line 3608 of file object.c.

References copy_object(), get_object(), obj::head, insert_ob_in_ob(), obj::more, and object_create_clone().

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

+ Here is the call graph for this function:

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

References obj::env.

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

+ Here is the caller graph for this function:

static void permute ( int *  arr,
int  begin,
int  end 
)
static

Randomly permutes an array.

Parameters
arrarray to permute.
begin
endfirst and last (exclusive) indexes to permute.

Definition at line 3259 of file object.c.

Referenced by get_search_arr().

+ Here is the caller graph for this function:

object* present ( uint8  type,
mapstruct m,
int  x,
int  y 
)

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

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

Definition at line 2782 of file object.c.

References obj::above, GET_MAP_OB, llevError, LOG(), out_of_map(), and obj::type.

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:

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

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

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

Definition at line 2755 of file object.c.

References obj::above, obj::arch, GET_MAP_OB, llevError, LOG(), and out_of_map().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* present_arch_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 2859 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(), perceive_self(), poison_living(), potion_type_apply(), slow_living(), and START_TEST().

+ Here is the caller graph for this function:

object* present_in_ob ( uint8  type,
const object op 
)

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

Parameters
typetype to search for.
opobject to search into.
Returns
first matching object, or NULL if none matches.

Definition at line 2806 of file object.c.

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

Referenced by blind_living(), cfapi_object_get_property(), and examine_monster().

+ Here is the caller graph for this function:

object* 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. This is mostly used by spell effect code, so that we only have one spell effect at a time. type can be used to narrow the search - if type is set, the type must also match. -1 can be passed for the type, in which case the type does not need to pass. str is the string to match against. Note that we match against the object name, not the archetype name. this is so that the spell code can use one object type (force), but change it's name to be unique.

Parameters
typeobject type to search for. -1 means to ignore it.
strobject name to search for.
opwhere to search.
Returns
first matching object, or NULL if none matches.
Todo:
use add_string() hack to avoid the strcmp?

Definition at line 2840 of file object.c.

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

Referenced by become_follower(), cast_heal(), cfapi_object_get_property(), and confuse_living().

+ Here is the caller graph for this function:

void remove_from_active_list ( object op)

This function removes object 'op' from the list of active objects. This should only be used for style maps or other such reference maps where you don't want an object that isn't in play chewing up cpu time getting processed. The reverse of this is to call update_ob_speed, which will do the right thing based on the speed of the object.

Parameters
opobject to remove.

Definition at line 1070 of file object.c.

References obj::active_next, and obj::active_prev.

Referenced by load_objects(), and START_TEST().

+ Here is the caller graph for this function:

void remove_ob ( object op)

This function removes the object op from the linked list of objects which it is currently tied to. When this function is done, the object will have no environment. If the object previously had an environment, the x and y coordinates will be updated to the previous environment.

Will inform the client of the removal if needed.

Parameters
opobject to remove. Must not be removed yet, else abort() is called.
Todo:
this function is a piece of overbloated crap or at lest look like need cleanup it does to much different things.

Definition at line 1515 of file object.c.

References obj::above, obj::arch, obj::below, obj::carrying, CLEAR_FLAG, obj::container, CONTAINER, obj::contr, obj::count, dump_object(), obj::env, esrv_del_item(), fix_object(), FLAG_APPLIED, FLAG_BLOCKSVIEW, FLAG_NO_APPLY, FLAG_NO_FIX_PLAYER, FLAG_REMOVED, get_map_from_coord(), GET_MAP_OB, get_player_container(), obj::glow_radius, obj::head, pl::hidden, mapdef::in_memory, obj::inv, llevError, LOG(), LOOK_OBJ, obj::map, MAP_SAVING, obj::more, obj::move_block, obj::move_off, obj::move_type, obj::name, archt::name, obj::nrof, ob_move_on(), obj::ox, obj::oy, P_NEED_UPDATE, mapdef::path, PLAYER, mapdef::players, QUERY_FLAG, remove_ob(), SET_FLAG, SET_MAP_FLAGS, SET_MAP_OB, SET_MAP_TOP, pl::socket, stringbuffer_finish(), stringbuffer_new(), sub_weight(), obj::type, UP_OBJ_REMOVE, update_all_los(), socket_struct::update_look, update_object(), update_position(), was_destroyed, obj::weight, obj::x, and obj::y.

Referenced by add_abilities(), adjust_sign_msg(), alchemy_object(), animate_bomb(), animate_weapon(), apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_builder_wall(), apply_builder_window(), apply_savebed(), arrow_type_process(), attempt_jump(), auto_apply(), become_follower(), blindness_type_process(), cast_consecrate(), cast_create_town_portal(), cast_dust(), cast_raise_dead_spell(), cfapi_object_insert(), cfapi_object_remove(), cfapi_object_teleport(), change_object(), check_altar_sacrifice(), check_bullet(), check_login(), check_special_prayers(), clean_object(), command_cast_spell(), command_free(), command_insert_into(), command_kick(), command_kill_pets(), command_remove(), command_reset(), common_process_projectile(), convert_item(), counterspell(), cure_disease(), decay_objects(), decrease_ob_nr(), delete_unique_items(), destroy_object(), dimension_door(), dispel_rune(), do_forget_spell(), do_harvest(), do_server(), do_throw(), do_turn(), drop(), drop_object(), enter_exit(), enter_map(), execute_event(), execute_word_of_recall(), explode_bullet(), explosion(), fire_bow(), fix_generated_item(), fix_stopped_arrow(), fix_walls(), follow_owner(), follower_remove_given_items(), free_all_objects(), free_no_drop(), free_object2(), free_player(), gate_type_process(), generate_treasure(), give_initial_items(), god_intervention(), hit_player(), hit_with_arrow(), insert_ob_in_map(), key_change_class(), key_confirm_quit(), kill_object(), kill_player(), lock_and_hide_doors(), loot_object(), merge_ob(), merge_spell(), monster_check_pickup(), monster_move_no_enemy(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_cone(), move_disease(), move_duplicator(), move_golem(), move_marker(), move_missile(), move_monster(), move_ob(), move_player_mover(), move_swarm_spell(), move_symptom(), move_teleporter(), nuke_map_region(), pay_from_container(), pet_move(), pick_up_object(), place_exits(), play_again(), player_apply(), poisoning_type_process(), polymorph_item(), polymorph_living(), polymorph_melt(), potion_type_apply(), process_object(), process_players1(), push_ob(), put_object_in_sack(), recharge(), remove_adjacent_doors(), remove_contents(), remove_door(), remove_force(), remove_locked_door(), remove_marking_runes(), remove_monsters(), remove_ob(), remove_symptoms(), remove_unpaid_objects(), replace_insert_ob_in_map(), retrofit_joined_wall(), roll_ob(), rune_attack(), save_life(), save_throw_object(), shop_mat_type_move_on(), spell_effect_type_move_on(), spring_trap(), START_TEST(), stick_arrow(), stop_item(), stop_projectile(), summon_golem(), tear_down_wall(), teleport(), terminate_all_pets(), thrown_object_type_process(), transfer_ob(), transmute_item_to_flower(), transport_type_apply(), treasure_type_apply(), turn_one_transport(), and write_scroll().

+ Here is the call graph for this function:

void replace_insert_ob_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.

Parameters
arch_stringobject's archetype to insert.
opobject to insert it under: supplies x and the map.

Definition at line 2271 of file object.c.

References obj::above, obj::arch, arch_to_object(), find_archetype(), free_object(), GET_MAP_OB, INS_BELOW_ORIGINATOR, insert_ob_in_map(), obj::map, archt::name, remove_ob(), obj::x, and obj::y.

Referenced by save_throw_object(), and START_TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void reset_object ( object op)

Sets to 0 vital variables in an object.

Parameters
opobject to reset.
Note
this doesn't free associated memory for object.

Definition at line 639 of file object.c.

References clear_object(), obj::lore, obj::materialname, obj::msg, obj::name, obj::name_pl, obj::race, obj::skill, obj::slaying, and obj::title.

Referenced by cfapi_object_reset(), check_login(), init_artifacts(), and START_TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void set_cheat ( object op)

set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recursively). If checksums are used, a player will get set_cheat called for him/her-self and all object carried by a call to this function.

Parameters
opobject for which to set the flag.

Definition at line 2913 of file object.c.

References flag_inv(), FLAG_WAS_WIZ, and SET_FLAG.

Referenced by cfapi_object_set_property().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int set_ob_key_value ( object op,
const char *  key,
const char *  value,
int  add_key 
)

Updates the key in op to value.

Parameters
opobject we're considering.
keykey to set or update. Doesn't need to be a shared string.
valuevalue to set. Doesn't need to be a shared string.
add_keyif 0, will not add the key if it doesn't exist in op.
Returns
TRUE if key was updated or added, FALSE else.
Note
This function is merely a wrapper to set_ob_key_value_s() to ensure the key is a shared string.
In general, should be little reason FALSE is ever passed in for add_key

Definition at line 3826 of file object.c.

References add_string(), FALSE, find_string(), free_string(), set_ob_key_value_s(), and TRUE.

Referenced by cfapi_object_set_key(), do_harvest(), generate_monster(), generate_monster_arch(), generate_monster_inv(), god_enchants_weapon(), god_gives_present(), set_object_face_other(), and store_spell_expiry().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int set_ob_key_value_s ( object op,
const char *  canonical_key,
const char *  value,
int  add_key 
)
static

Updates or sets a key value.

Parameters
opobject we're considering.
canonical_keykey to set or update. Must be a shared string.
valuevalue to set. Doesn't need to be a shared string.
add_keyif 0, will not add the key if it doesn't exist in op.
Returns
TRUE if key was updated or added, FALSE else.

Definition at line 3741 of file object.c.

References add_refcount(), add_string(), obj::arch, archt::clone, FALSE, FREE_AND_CLEAR_STR, get_ob_key_link(), _key_value::key, obj::key_values, llevDebug, LOG(), _key_value::next, TRUE, and _key_value::value.

Referenced by set_ob_key_value().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void set_owner ( object op,
object owner 
)

Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects.

Parameters
opobject of which to set the owner
ownernew owner for object. Can be NULL, in which case it's equivalent of calling clear_owner(op)
Todo:
replace owner serching loop with a call to get_owner()?

Definition at line 564 of file object.c.

References clear_owner(), obj::count, llevError, LOG(), obj::owner, and obj::ownercount.

Referenced by animate_weapon(), cast_cause_disease(), cast_cone(), cast_smite_spell(), cfapi_object_set_property(), cone_drop(), copy_owner(), create_aura(), create_bomb(), do_mood_floor(), do_symptoms(), do_throw(), fire_arch_from_position(), fire_bolt(), fire_bow(), fire_bullet(), fire_swarm(), fix_summon_pet(), hit_player(), infect_object(), magic_wall(), mood_change(), polymorph_living(), START_TEST(), summon_golem(), summon_object(), use_oratory(), and write_rune().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void 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)).

Takes into account the container's weight reduction.

Parameters
opobject to which weight is substracted.
weightweight to remove.
Todo:
check if not mergeable with add_weight().

Definition at line 1489 of file object.c.

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

Referenced by decrease_ob_nr(), make_item_from_recipe(), remove_ob(), and START_TEST().

+ Here is the caller graph for this function:

signed long sum_weight ( object op)

sum_weight() is a recursive function which calculates the weight an object is carrying. It goes through in figures out how much containers are carrying, and sums it up.

This takes into account the container's weight reduction.

Parameters
opobject we want the weight of.
Returns
weight of this item and all its inventory.
Note
The object's carrying field is updated.

Definition at line 317 of file object.c.

References obj::below, obj::carrying, CONTAINER, obj::inv, obj::nrof, obj::stats, liv::Str, sum_weight(), obj::type, and obj::weight.

Referenced by cfapi_object_set_property(), check_login(), command_fix_me(), fix_container(), fix_weight(), load_objects(), START_TEST(), sum_weight(), and transport_type_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unflag_inv ( object op,
int  flag 
)

Desactivate recursively a flag on an object inventory

Parameters
opobject to recurse. Can have an empty inventory.
flagflag to unset.

Definition at line 2894 of file object.c.

References obj::below, CLEAR_FLAG, obj::inv, and unflag_inv().

Referenced by convert_item(), generate_monster_inv(), move_creator(), and unflag_inv().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void update_ob_speed ( object op)

Updates the speed of an object. If the speed changes from 0 to another value, or vice versa, then add/remove the object from the active list. This function needs to be called whenever the speed of an object changes.

Parameters
opobject to update. Must not be freed and still have a speed.
Todo:
check fixme & todo

Definition at line 1008 of file object.c.

References obj::active_next, active_objects, obj::active_prev, arch_init, FABS, FLAG_FREED, llevError, LOG(), MIN_ACTIVE_SPEED, obj::name, QUERY_FLAG, and obj::speed.

Referenced by add_abilities(), animate_weapon(), apply_savebed(), cast_word_of_recall(), cfapi_object_set_property(), check_login(), check_trigger(), command_remove(), copy_object(), do_auto_apply(), do_throw(), drain_wand_charge(), eat_special_food(), find_or_create_connection_for_map(), fire_bow(), fix_auto_apply(), fix_object(), fix_stopped_arrow(), free_object2(), gate_type_process(), kill_object(), local_check_loaded_object(), move_cone(), move_detector(), move_hole(), move_marker(), power_crystal_type_apply(), process_events(), recharge(), remove_door(), remove_locked_door(), setup(), START_TEST(), swap_random_stats(), timed_gate_type_process(), transmute_item_to_flower(), trigger_connected(), and trigger_move().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void update_object ( object op,
int  action 
)

update_object() updates the array which represents the map.

It takes into account invisible objects (and represent squares covered by invisible objects by whatever is below them (unless it's another invisible object, etc...)

If the object being updated is beneath a player, the look-window of that player is updated (this might be a suboptimal way of updating that window, though, since update_object() is called often)

Parameters
opobject to update
actionHint of what the caller believes need to be done. One of UP_OBJ_xxx values. For example, if the only thing that has changed is the face (due to an animation), we don't need to call update_position until that actually comes into view of a player. OTOH, many other things, like addition/removal of walls or living creatures may need us to update the flags now.
Todo:
this function should be renamed to something like update_object_map, update_object is a too general term Also it might be worth moving it to map.c

Definition at line 1112 of file object.c.

References obj::contr, obj::env, esrv_update_item(), FLAG_ALIVE, FLAG_BLOCKSVIEW, FLAG_CLIENT_ANIM_RANDOM, FLAG_CLIENT_ANIM_SYNC, FLAG_DAMNED, FLAG_NO_MAGIC, flags, GET_MAP_FLAGS, GET_MAP_MOVE_BLOCK, GET_MAP_MOVE_OFF, GET_MAP_MOVE_ON, GET_MAP_MOVE_SLOW, GET_MAP_PLAYER, mapdef::in_memory, llevDebug, llevError, LOG(), obj::map, MAP_HEIGHT, MAP_SAVING, MAP_WIDTH, obj::more, obj::move_allow, obj::move_block, obj::move_off, obj::move_on, obj::move_slow, P_BLOCKSVIEW, P_IS_ALIVE, P_NEED_UPDATE, P_NO_CLERIC, P_NO_ERROR, P_NO_MAGIC, P_PLAYER, PLAYER, QUERY_FLAG, SET_MAP_FLAGS, pl::socket, obj::type, UP_OBJ_CHANGE, UP_OBJ_FACE, UP_OBJ_INSERT, UP_OBJ_REMOVE, UPD_FACE, socket_struct::update_look, update_object(), update_position(), obj::x, and obj::y.

Referenced by animate_object(), animate_trigger(), animate_turning(), cast_invisible(), cf_handle_type_apply(), cfapi_object_set_property(), cfapi_object_update(), check_trigger(), command_invisible(), common_trap_type_process(), do_skill_attack(), fix_stopped_arrow(), gate_type_process(), hide(), hit_map(), identify(), insert_ob_in_map(), key_change_class(), make_visible(), move_golem(), move_hole(), remove_ob(), tear_down_wall(), trapdoor_type_move_on(), trigger_connected(), trigger_type_process(), unblock_exits(), update_button(), update_object(), and update_turn_face().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void 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.

Parameters
opobject to update.

Definition at line 990 of file object.c.

References obj::arch, obj::direction, FLAG_IS_TURNABLE, QUERY_FLAG, SET_ANIMATION, UP_OBJ_FACE, and update_object().

Referenced by director_type_move_on(), forklightning(), move_bolt(), move_bullet(), spinner_type_move_on(), and START_TEST().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

object* active_objects

List of active objects that need to be processed

Definition at line 72 of file object.c.

Referenced by cast_invisible(), count_active(), init_objects(), process_events(), and update_ob_speed().

object* free_objects

Pointer to the list of unused objects

Definition at line 71 of file object.c.

Referenced by count_free(), free_object2(), get_object(), and init_objects().

short freearr_x[SIZEOFFREE]
Initial value:
= {
0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1,
0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1
}

X offset when searching around a spot.

Definition at line 75 of file object.c.

Referenced by animate_bomb(), animate_weapon(), apply_builder_floor(), apply_builder_remove(), apply_map_builder(), attempt_jump(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_spell(), cast_transfer(), change_object(), command_summon(), command_teleport(), common_process_projectile(), communicate(), compute_path(), counterspell(), CREAnimationControl::CREAnimationControl(), create_bomb(), dimension_door(), dispel_rune(), do_harvest(), do_skill_ident(), do_throw(), enter_map(), expand_sight(), explosion(), find_closest_monster(), find_dir(), find_doors_in_room_recursive(), find_enclosed_spot(), find_first_free_spot(), find_free_spot(), find_monster_in_room_recursive(), find_nearest_living_creature(), find_spot_in_room_recursive(), find_target_for_friendly_spell(), find_traps(), fire_bullet(), fix_summon_pet(), follow_owner(), forklightning(), free_object2(), gate_type_process(), get_pet_enemy(), get_pointed_target(), hideability(), hit_map(), hit_player(), keyplace(), magic_wall(), monster_use_bow(), move_aura(), move_ball_spell(), move_bolt(), move_cone(), move_golem(), move_ob(), move_player_attack(), move_player_mover(), move_swarm_spell(), path_to_player(), pet_move(), pick_arrow_target(), pick_lock(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), player_fire_bow(), probe(), process_players1(), push_ob(), put_a_monster(), remove_adjacent_doors(), remove_door(), remove_locked_door(), remove_trap(), roll_ob(), shop_mat_type_move_on(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), steal(), summon_golem(), summon_object(), surround_by_doors(), teleport(), transfer_ob(), turn_one_transport(), use_oratory(), and write_rune().

short freearr_y[SIZEOFFREE]
Initial value:
= {
0, -1, -1, 0, 1, 1, 1, 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2,
-3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3
}

Y offset when searching around a spot.

Definition at line 81 of file object.c.

Referenced by animate_weapon(), apply_builder_floor(), apply_builder_remove(), apply_map_builder(), attempt_jump(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_spell(), cast_transfer(), change_object(), command_summon(), command_teleport(), common_process_projectile(), communicate(), compute_path(), counterspell(), CREAnimationControl::CREAnimationControl(), create_bomb(), dimension_door(), dispel_rune(), do_harvest(), do_skill_ident(), do_throw(), enter_map(), expand_sight(), explosion(), find_closest_monster(), find_dir(), find_doors_in_room_recursive(), find_enclosed_spot(), find_first_free_spot(), find_free_spot(), find_monster_in_room_recursive(), find_nearest_living_creature(), find_spot_in_room_recursive(), find_target_for_friendly_spell(), find_traps(), fire_bullet(), fix_summon_pet(), follow_owner(), forklightning(), free_object2(), gate_type_process(), get_pet_enemy(), get_pointed_target(), hideability(), hit_map(), hit_player(), keyplace(), magic_wall(), monster_use_bow(), move_aura(), move_ball_spell(), move_bolt(), move_cone(), move_golem(), move_ob(), move_player_attack(), move_player_mover(), move_swarm_spell(), path_to_player(), pet_move(), pick_arrow_target(), pick_lock(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), player_fire_bow(), probe(), process_players1(), push_ob(), put_a_monster(), remove_adjacent_doors(), remove_door(), remove_locked_door(), remove_trap(), roll_ob(), shop_mat_type_move_on(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), steal(), summon_golem(), summon_object(), surround_by_doors(), teleport(), transfer_ob(), turn_one_transport(), use_oratory(), and write_rune().

int freedir[SIZEOFFREE]
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 7, 8, 8, 8,
1, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 8
}

Direction we're pointing on this spot.

Definition at line 93 of file object.c.

Referenced by find_dir(), spell_find_dir(), and summon_object().

int maxfree[SIZEOFFREE]
Initial value:
= {
0, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 36, 37, 39, 39, 42, 43, 44, 45,
48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
}

Number of spots around a location, including that location (except for 0)

Definition at line 87 of file object.c.

Referenced by find_dir(), and find_free_spot().

int nrofallocobjects = STARTMAX

How many OBs allocated (free + used)

Definition at line 67 of file object.c.

Referenced by expand_objects(), free_all_object_data(), and swap_below_max().

int nroffreeobjects = STARTMAX

How many OBs allocated and free (free)

Definition at line 66 of file object.c.

Referenced by expand_objects(), free_all_object_data(), free_object2(), get_object(), and swap_below_max().

object objarray[STARTMAX]

All objects, allocated this way at first

Definition at line 65 of file object.c.

Referenced by init_objects().

object* objects

Pointer to the list of used objects

Definition at line 70 of file object.c.

Referenced by count_used(), free_all_objects(), get_object(), and init_objects().

const int reduction_dir[SIZEOFFREE][3]
static

Basically, this is a table of directions, and what directions one could go to go back to us. Eg, entry 15 below is 4, 14, 16. This basically means that if direction is 15, then it could either go direction 4, 14, or 16 to get back to where we are. Moved from spell_util.c to object.c with the other related direction functions.

peterm: do LOS stuff for ball lightning. Go after the closest VISIBLE monster.

Definition at line 3454 of file object.c.

Referenced by can_see_monsterP().