Crossfire Server, Branch 1.12  R12190
Functions
libproto.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int absdir (int d)
 Computes an absolute direction.
void add_abilities (object *op, object *change)
 Used in artifact generation.
void add_button_link (object *button, mapstruct *map, int connected)
 Links specified object in the map.
void add_friendly_object (object *op)
 Add a new friendly object to the linked list of friendly objects.
sstring add_refcount (sstring str)
 This will increase the refcount of the string str.
void add_statbonus (object *op)
 Adds stat-bonuses given by the class which the player has chosen.
sstring add_string (const char *str)
 This will add 'str' to the hash table.
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.
int allowed_class (const object *op)
 Returns true if the given player is a legal class.
void animate_object (object *op, int dir)
 Updates the face-variable of an object.
void animate_turning (object *op)
 Animates one step of object.
void apply_anim_suffix (object *who, sstring suffix)
 Applies a compound animation to an object.
void apply_death_exp_penalty (object *op)
 Applies a death penalty experience, the size of this is defined by the settings death_penalty_percentage and death_penalty_levels, and by the amount of permenent experience, whichever gives the lowest loss.
void arch_info (object *op)
 Stores debug-information about how efficient the hashtable used for archetypes has been in the static errmsg array.
object * arch_to_object (archetype *at)
 Creates and returns a new object which is a copy of the given archetype.
int atnr_is_dragon_enabled (int attacknr)
 Determine if the attacktype represented by the specified attack-number is enabled for dragon players.
void bitstostring (long bits, int num, char *str)
 Writes num ones and zeros to the given string based on the bits variable.
int blocked_link (object *ob, mapstruct *m, int sx, int sy)
 Returns true if the given coordinate is blocked except by the object passed is not blocking.
int book_overflow (const char *buf1, const char *buf2, size_t booksize)
 Checks if buf1 and buf2 can be combined.
int buf_overflow (const char *buf1, const char *buf2, size_t bufsize)
 We don't want to exceed the buffer size of buf1 by adding on buf2!
int calc_item_power (const object *op, int flag)
 This takes an object 'op' and figures out what its item_power rating should be.
void calc_perm_exp (object *op)
 Ensure that the permanent experience requirements in an exp object are met.
int calculate_difficulty (mapstruct *m)
 This routine is supposed to find out the difficulty of the map.
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.
int can_pick (const object *who, const object *item)
 Finds out if an object can be picked up.
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.
int change_abil (object *op, object *tmp)
 Permanently alters an object's stats/flags based on another object.
void change_attr_value (living *stats, int attr, sint8 value)
 Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat.
void change_exp (object *op, sint64 exp, const char *skill_name, int flag)
 Changes experience to a player/monster.
void change_luck (object *op, int value)
 Alter the object's luck.
int change_map_light (mapstruct *m, int change)
 Used to change map light level (darkness) up or down.
int check_altar_sacrifice (const object *altar, const object *sacrifice, int remove_others, int *toremove)
 Checks whether the altar has enough to sacrifice.
sint64 check_exp_adjust (const object *op, sint64 exp)
 Returns the maximum experience the object can gain or lose.
sint64 check_exp_loss (const object *op, sint64 exp)
 This function checks to make sure that object 'op' can lose 'exp' experience.
void check_generators (void)
void check_inv (object *op, object *trig)
 Function to search the inventory, of a player and then based on a set of conditions, the square will activate connected items.
object * check_inv_recursive (object *op, const object *trig)
 Checks object and its inventory for specific item.
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.
int check_path (const char *name, int prepend_dir)
 This function checks if a file with the given path exists.
void check_stat_bounds (living *stats)
 Ensures that all stats (str/dex/con/wis/cha/int) are within the 1-30 stat limit.
int check_trigger (object *op, object *cause)
void clean_friendly_list (void)
 It traverses the friendly list removing objects that should not be here (ie, do not have friendly flag set, freed, etc)
void clean_object (object *op)
 Remove and free all objects in the inventory of the given object.
void clean_tmp_map (mapstruct *m)
 Removse the temporary file used by the map.
void clear_archetable (void)
 Initialise the hashtable used by the archetypes.
void clear_los (object *op)
 Clears/initialises the los-array associated to the player controlling the object.
void clear_object (object *op)
 Frees everything allocated by an object, and also clears all variables and flags to default settings.
void clear_owner (object *op)
 Clears the owner of specified object.
void clear_player (player *pl)
 Clears data in player structure.
void close_and_delete (FILE *fp, int compressed)
 Closes specified file.
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.
void copy_object_with_inv (object *src_ob, object *dest_ob)
 copy an object with an inventory...
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).
int count_active (void)
 Objects statistics.
int count_free (void)
 Objects statistics.
int count_used (void)
 Object statistics.
object * create_archetype (const char *name)
 Finds which archetype matches the given name, and returns a new object containing a copy of the archetype.
object * create_archetype_by_object_name (const char *name)
 Creates an object given the name that appears during the game (for example, "writing pen" instead of "stylus").
void create_overlay_pathname (const char *name, char *buf, size_t size)
 Same as create_pathname(), but for the overlay maps.
char * create_pathname (const char *name, char *buf, size_t size)
 This makes a path absolute outside the world of Crossfire.
object * create_singularity (const char *name)
 Creates a dummy object.
void create_template_pathname (const char *name, char *buf, size_t size)
 same as create_pathname(), but for the template maps.
void create_treasure (treasurelist *t, object *op, int flag, int difficulty, int tries)
 This calls the appropriate treasure creation function.
void decay_objects (mapstruct *m)
 Decay and destroy persihable items in a map.
object * decrease_ob_nr (object *op, uint32 i)
 Decreases a specified number from the amount of an object.
void delete_map (mapstruct *m)
 Frees the map, including the mapstruct.
void describe_item (const object *op, const object *owner, char *retbuf, size_t size)
 Describes an item, in all its details.
void describe_monster (const object *op, char *retbuf, size_t size)
 Describes a monster.
void describe_resistance (const object *op, int newline, char *buf, size_t size)
 Generates the visible naming for resistances.
int did_make_save (const object *op, int level, int bonus)
 This function takes an object (monster/player, op), and determines if it makes a basic save throw by looking at the save_throw table.
int die_roll (int num, int size, const object *op, int goodbad)
 Roll a number of dice (2d3, 4d6).
int dirdiff (int dir1, int dir2)
 Computes a direction difference.
int distance (const object *ob1, const object *ob2)
 Return the square of the distance between the two given objects.
void drain_specific_stat (object *op, int deplete_stats)
 Drain a specified stat from op.
void drain_stat (object *op)
 Drains a random stat from op.
void dump_abilities (void)
 Dump to standard out the abilities of all monsters.
void dump_alchemy (void)
 Dumps alchemy recipes to output.
void dump_alchemy_costs (void)
 Dumps to output all costs of recipes.
void dump_all_archetypes (void)
 Dumps _all_ archetypes to debug-level output.
void dump_all_maps (void)
 Prints out debug-information about all maps.
void dump_all_objects (void)
 Dumps all objects to console.
void dump_arch (archetype *at, StringBuffer *sb)
 Dumps an archetype to buffer.
void dump_artifacts (void)
 For debugging purposes.
void dump_experience (void)
 Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format of the exp_table is correct.
void dump_friendly_objects (void)
 Dumps all friendly objects.
void dump_gods (void)
 Prints all gods to stderr.
void dump_map (const mapstruct *m)
 Prints out debug-information about a map.
void dump_monster_treasure (const char *name)
 For debugging purposes.
void dump_object (object *op, StringBuffer *sb)
 Dumps an object.
int enough_elapsed_time (void)
 Checks elapsed time since last tick.
void fatal (int err)
 fatal() is meant to be called whenever a fatal signal is intercepted.
int find_animation (const char *name)
 Finds the animation id that matches name.
archetype * find_archetype (const char *name)
 Finds, using the hashtable, which archetype matches the given name.
archetype * find_archetype_by_object_name (const char *name)
 This function retrieves an archetype given the name that appears during the game (for example, "writing pen" instead of "stylus").
archetype * find_archetype_by_object_type_name (int type, const char *name)
 This function retrieves an archetype by type and name that appears during the game.
artifactlistfind_artifactlist (int type)
 Searches the artifact lists and returns one that has the same type of objects on it.
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.
int find_dir_2 (int x, int y)
 Computes a direction which you should travel to move of x and y.
unsigned find_face (const char *name, unsigned error)
 This returns an the face number of face 'name'.
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.
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.
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.
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".
object * find_obj_by_type_subtype (const object *who, int type, int subtype)
 Find object in inventory.
object * find_object (tag_t i)
 Returns the object which has the count-variable equal to the argument.
object * find_object_name (const char *str)
 Finds an object by name.
int find_smooth (uint16 face, uint16 *smoothed)
 Find the smooth face for a given face.
sstring find_string (const char *str)
 Searches a string in the shared strings.
archetype * find_treasure_by_name (const treasure *t, const char *name, int depth)
 Find a treasure with a matching name.
treasurelistfind_treasurelist (const char *name)
 Searches for the given treasurelist in the globally linked list of treasurelists which has been built by load_treasures().
void fix_container (object *container)
 When the map is loaded, load_object() does not actually insert objects into inventory, but just links them.
void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags)
 fix_generated_item(): This is called after an item is generated, in order to set it up right.
void fix_multipart_object (object *tmp)
 Ensures specified object has its more parts correctly inserted in map.
void fix_object (object *op)
 Updates all abilities given by applied objects in the inventory of the given object.
void flag_inv (object *op, int flag)
 Activate recursively a flag on an object's inventory.
void free_all_anim (void)
 Clears all animation-related memory.
void free_all_archs (void)
 Frees all memory allocated to archetypes.
void free_all_god (void)
 Frees all god information.
void free_all_images (void)
 Deallocates memory allocated by read_bmap_names() and read_smooth().
void free_all_maps (void)
 Frees all allocated maps.
void free_all_object_data (void)
 Destroys all allocated objects.
void free_all_readable (void)
void free_all_recipes (void)
 Frees all memory allocated to recipes and recipes lists.
void free_all_treasures (void)
 Free all treasure-related memory.
void free_arch (archetype *at)
 Frees archetype.
void free_dialog_information (object *op)
 Frees obj::dialog_information.
void free_experience (void)
 Frees experience-related memory.
void free_globals (void)
 Cleans all memory allocated for global variables.
void free_key_values (object *op)
 Zero the key_values on op, decrementing the shared-string refcounts and freeing the links.
void free_loader (void)
void free_map (mapstruct *m)
 Frees everything allocated by the given mapstructure.
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.
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.
void free_objectlink (objectlink *ol)
 Recursively frees all objectlinks.
void free_objectlinkpt (oblinkpt *obp)
 Recursively frees all linked list of objectlink pointers.
void free_player (player *pl)
 Clears player structure, including pointed object (through free_object()).
void free_socket_images (void)
 Frees all faceset information.
void free_string (sstring str)
 This will reduce the refcount, and if it has reached 0, str will be freed.
void generate_artifact (object *op, int difficulty)
 Decides randomly which artifact the object should be turned into.
object * generate_treasure (treasurelist *t, int difficulty)
 This is similar to the old generate treasure function.
archetype * get_archetype_by_skill_name (const char *skill, int type)
 Retrieves an archetype by skill name and type.
archetype * get_archetype_by_type_subtype (int type, int subtype)
 Retrieves an archetype by type and subtype.
archetype * get_archetype_struct (void)
 Allocates, initialises and returns the pointer to an archetype structure.
sint8 get_attr_value (const living *stats, int attr)
 Gets the value of a stat.
int get_button_value (const object *button)
 Returns the first value linked to this button.
client_spellget_client_spell_state (player *pl, object *spell)
 Gets the (client-side) spell state for specified spell.
int get_dialog_message (object *op, const char *text, struct_dialog_message **message, struct_dialog_reply **reply)
 Tries to find a message matching the said text.
mapstructget_empty_map (int sizex, int sizey)
 Creates and returns a map of the specific size.
int get_face_fallback (int faceset, int imageno)
 This returns the set we will actually use when sending a face.
recipelistget_formulalist (int i)
 Gets a formula list by ingredients count.
object * get_jail_exit (object *op)
 Returns an object which is an exit through which the player represented by op should be sent in order to be imprisoned.
int get_language (object *op)
 Returns the i18n language index associated with the given object.
void get_levelnumber (int i, char *buf, size_t size)
 Formats a level.
mapstructget_linked_map (void)
 Allocates, initialises, and returns a pointer to a mapstruct.
int get_map_flags (mapstruct *oldmap, mapstruct **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny)
 This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
mapstructget_map_from_coord (mapstruct *m, sint16 *x, sint16 *y)
 This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coordinates out of bounds and no tiled map), otherwise it returns the map as that the coordinates are really on, and updates x and y to be the localized coordinates.
const char * get_month_name (const int index)
 give access to month names
void get_multi_size (object *ob, int *sx, int *sy, int *hx, int *hy)
 Computes the size of a multitile object.
const char * get_name_of_region_for_map (const mapstruct *m)
 Gets the name of a region for a map.
void get_ob_diff (StringBuffer *sb, object *op, object *op2)
key_value * get_ob_key_link (const object *ob, const char *key)
 Search for a field by key.
const char * get_ob_key_value (const object *op, const char *const key)
 Get an extra value by key.
object * get_object (void)
 Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.
objectlink * get_objectlink (void)
 Allocates a new objectlink structure, initialises it, and returns a pointer to it.
oblinkpt * get_objectlinkpt (void)
 Allocates a new oblinkpt structure, initialises it, and returns a pointer to it.
object * get_owner (object *op)
 Returns the object which this object marks as being the owner.
const char * get_periodofday (const int index)
 give access to weekday names
object * get_player_container (object *op)
 Finds the player carrying an object.
int get_power_from_ench (int ench)
godlinkget_rand_god (void)
 Returns a random god.
object * get_random_mon (int level)
 Returns a random monster selected from linked list of all monsters in the current game.
recipeget_random_recipe (recipelist *rpl)
 Gets a random recipe from a list, based on chance.
void get_rangevector (object *op1, const object *op2, rv_vector *retval, int flags)
 From map.c This is used by get_player to determine where the other creature is.
void get_rangevector_from_mapcoord (const mapstruct *m, int x, int y, const object *op2, rv_vector *retval, int flags)
 This is basically the same as get_rangevector() above, but instead of the first parameter being an object, it instead is the map and x,y coordinates - this is used for path to player - since the object is not infact moving but we are trying to traverse the path, we need this.
const readable_message_typeget_readable_message_type (object *readable)
 Get the readable type for an object (hopefully book).
regionget_region_by_map (mapstruct *m)
 Gets a region from a map.
regionget_region_by_name (const char *region_name)
 Gets a region by name.
regionget_region_from_string (const char *name)
 Tries to find a region that 'name' corresponds to.
const char * get_region_longname (const region *r)
 Gets the longname of a region.
const char * get_region_msg (const region *r)
 Gets a message for a region.
regionget_region_struct (void)
 Allocates and zeros a region struct, this isn't free()'d anywhere, so might be a memory leak, but it shouldn't matter too much since it isn't called that often....
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.
const char * get_season_name (const int index)
 give access to season names
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.
void get_tod (timeofday_t *tod)
 Computes the ingame time of the day.
const typedataget_typedata (int itemtype)
const typedataget_typedata_by_name (const char *name)
const char * get_weekday (const int index)
 give access to weekday names
void give_artifact_abilities (object *op, object *artifact)
 Fixes the given object, giving it the abilities and titles it should have due to the second artifact-template.
object * give_skill_by_name (object *op, const char *skill_name)
 Given the skill name skill_name, we find the skill archetype/object, set appropriate values, and insert it into the object (op) that is passed.
int has_ability (const object *ob)
 Checks whether object has innate abilities (spell/spellbook in inventory).
mapstructhas_been_loaded (const char *name)
 Checks whether map has been loaded.
int has_carried_lights (const object *op)
 Checks if op has a light source.
void i18n_init (void)
 Initializes the i18n subsystem.
const char * i18n_translate (int language, int id)
 Translates a given i18n string into the provided language.
void identify (object *op)
 Identifies an item.
void init_anim (void)
 Loads the lib/animations file.
void init_archetype_pointers (void)
 Initialize global archtype pointers:
void init_archetypes (void)
 Initialises the internal linked list of archetypes (read from file).
void init_artifacts (void)
 Builds up the lists of artifacts from the file in the libdir.
void init_block (void)
 initialises the array used by the LOS routines.
void init_experience (void)
 This loads the experience table from the exp_table file.
void init_formulae (void)
 Builds up the lists of formula from the file in the libdir.
void init_globals (void)
 Initialises all global variables.
void init_gods (void)
 This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD)
void init_hash_table (void)
 Initialises the hash-table used by the shared string library.
void init_library (void)
 It is vital that init_library() is called by any functions using this library.
void init_ob_method_struct (ob_methods *methods, ob_methods *fallback)
 Initializes a ob_methods struct.
void init_ob_types (ob_methods *base_type)
 Initializes the object system.
void init_objects (void)
 Sets up and initialises the linked list of free and used objects.
void init_readable (void)
 Initialize linked lists utilized by message functions in tailor_readable_ob()
void init_regions (void)
 Initialises regions from the regions file.
void init_vars (void)
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.
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.
object * insert_ob_in_ob (object *op, object *where)
 This function inserts the object op in the linked list inside the object environment.
int is_dragon_pl (const object *op)
 Checks if player is a dragon.
int is_friendly (const object *op)
 Checks if the given object is already in the friendly list or not Lauwenmark - 31/07/05.
int is_magical (const object *op)
 Checks whether object is magical.
int is_old_wraith_pl (object *op)
 Checks if player is a wraith without the 'wraith feed' skill.
int is_valid_faceset (int fsn)
 Checks specified faceset is valid.
int is_wraith_pl (object *op)
 Tests if a player is a wraith.
int isqrt (int n)
 Computes the square root.
int item_matched_string (object *pl, object *op, const char *name)
 This is a subset of the parse_id command.
int legal_artifact_combination (object *op, artifact *art)
 Checks if op can be combined with art.
sint64 level_exp (int level, double expmul)
 Returns how much experience is needed for a player to become the given level.
int lex_load (int *depth, object **items, int maxdepth, int map_flags, int linemode)
int load_object (FILE *fp, object *op, int bufstate, int map_flags)
mapstructload_original_map (const char *filename, int flags)
 Opens the file "filename" and reads information about the map from the given file, and stores it in a newly allocated mapstruct.
void load_treasures (void)
 Opens LIBDIR/treasure and reads all treasure-declarations from it.
artifactlocate_recipe_artifact (const recipe *rp, size_t idx)
 Finds an artifact for a recipe.
void LOG (LogLevel logLevel, const char *format,...)
 Logs a message to stderr, or to file.
void make_list_like (char *input)
 Taking a string as an argument, mutate it into a string that looks like a list.
void make_path_to_file (const char *filename)
 Checks if any directories in the given path doesn't exist, and creates if necessary.
void make_sure_not_seen (const object *op)
 The object which is supposed to be visible through walls has just been removed from the map, so update the los of any players within its range.
void make_sure_seen (const object *op)
 The object is supposed to be visible through walls, thus check if any players are nearby, and edit their LOS array.
void map_remove_unique_files (const mapstruct *map)
 Remove files containing the map's unique items.
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.
void merge_spell (object *op, sint16 x, sint16 y)
 This sees if there are any objects on the space that can merge with op.
materialtype_tname_to_material (const char *name)
 Convert materialname to materialtype_t.
int need_identify (const object *op)
 This function really should not exist - by default, any item not identified should need it.
sint64 new_exp (const object *ob)
 Alternative way to calculate experience based on the ability of a monster.
method_ret ob_apply (object *op, object *applier, int aflags)
 Applies an object.
int ob_blocked (const object *ob, mapstruct *m, sint16 x, sint16 y)
 Returns true if the given object can't fit in the given spot.
char * ob_describe (const object *op, const object *observer, char *buf, size_t size)
 Returns the description of an object, as seen by the given observer.
method_ret ob_move_on (object *op, object *victim, object *originator)
 Makes an object move on top of another one.
method_ret ob_process (object *op)
 Processes an object, giving it the opportunity to move or react.
method_ret ob_trigger (object *op, object *cause, int state)
 An object is triggered by another one.
object * object_create_arch (archetype *at)
 Create a full object using the given archetype.
object * object_create_clone (object *asrc)
 Create clone from object to another.
object * object_get_env_recursive (object *op)
 Utility function.
int on_same_map (const object *op1, const object *op2)
 Checks whether 2 objects are on the same map or not.
FILE * open_and_uncompress (const char *name, int flag, int *compressed)
 open_and_uncompress() first searches for the original filename.
int operate_altar (object *altar, object **sacrifice)
 Checks if sacrifice was accepted and removes sacrificed objects.
int out_of_map (mapstruct *m, int x, int y)
 this returns TRUE if the coordinates (x,y) are out of map m.
char * path_combine (const char *src, const char *dst, char *path, size_t size)
 Combines 2 paths, which can be relative.
char * path_combine_and_normalize (const char *src, const char *dst, char *path, size_t size)
 Combines the 2 paths.
void path_normalize (char *path)
 Cleans specified path.
void player_lvl_adj (object *who, object *op)
 For the new exp system.
const object * pntr_to_god_obj (godlink *godlnk)
 Returns a pointer to the object We need to be VERY careful about using this, as we are returning a pointer to the CLONE object.
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.
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.
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.
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.
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.
void print_los (object *op)
 Debug-routine which dumps the array which specifies the visible area of a player.
void print_monsters (void)
 As dump_abilities(), but with an alternative way of output.
void push_button (object *op)
 Push the specified object.
void query_base_name (const object *op, int plural, char *buf, size_t size)
 Query a short name for the item.
void query_name (const object *op, char *buf, size_t size)
 Describes an item.
int query_refcount (sstring str)
 This will return the refcount of the string str.
void query_short_name (const object *op, char *buf, size_t size)
 query_short_name(object) is similar to query_name(), but doesn't contain any information about object status (worn/cursed/etc.)
void query_weight (const object *op, char *buf, size_t size)
 Formats the item's weight.
int random_roll (int min, int max, const object *op, int goodbad)
 Roll a random number between min and max.
sint64 random_roll64 (sint64 min, sint64 max, const object *op, int goodbad)
 This is a 64 bit version of random_roll() above.
const char * re_cmp (const char *str, const char *regexp)
 re-cmp - get regular expression match.
void read_bmap_names (void)
 This reads the bmaps file to get all the bitmap names and stuff.
void read_client_images (void)
 Loads all the image types into memory.
int read_smooth (void)
 Reads the smooth file to know how to smooth datas.
mapstructready_map_name (const char *name, int flags)
 Makes sure the given map is loaded and swapped in.
int region_is_child_of_region (const region *child, const region *r)
 Checks if a region is a child of another.
void register_apply (int ob_type, apply_func method)
 Registers the apply method for the given type.
void register_describe (int ob_type, describe_func method)
 Registers the describe method for the given type.
void register_move_on (int ob_type, move_on_func method)
 Registers the move_on method for the given type.
void register_process (int ob_type, process_func method)
 Registers the process method for the given type.
void register_trigger (int ob_type, trigger_func method)
 Registers the trigger method for the given type.
void remove_button_link (object *op)
 Remove the object from the linked lists of buttons in the map.
void remove_directory (const char *path)
 This function removes everything in the directory, and the directory itself.
void remove_friendly_object (object *op)
 Removes the specified object from the linked list of friendly objects.
void remove_from_active_list (object *op)
 This function removes object 'op' from the list of active objects.
void remove_ob (object *op)
 This function removes the object op from the linked list of objects which it is currently tied to.
void remove_statbonus (object *op)
 Subtracts stat-bonuses given by the class which the player has chosen.
void replace (const char *src, const char *key, const char *replacement, char *result, size_t resultsize)
 Replace in string src all occurrences of key by replacement.
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.
void replace_unprintable_chars (char *buf)
 Replaces any unprintable character in the given buffer with a space.
void reset_object (object *op)
 Sets to 0 vital variables in an object.
void reset_sleep (void)
 Initialise all variables used in the timing routines.
int rndm (int min, int max)
 Returns a number between min and max.
int save_map (mapstruct *m, int flag)
 Saves a map to file.
int save_object (FILE *fp, object *op, int flag)
long seconds (void)
 Gets the seconds.
void set_abs_magic (object *op, int magic)
 Sets magical bonus in an object, and recalculates the effect on the armour variable, and the effect on speed of armour.
void set_attr_value (living *stats, int attr, sint8 value)
 Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW).
void set_cheat (object *op)
 set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recursively).
void set_dragon_name (object *pl, const object *abil, const object *skin)
 Set the new dragon name after gaining levels or changing ability focus (later this can be extended to eventually change the player's face and animation)
void set_map_reset_time (mapstruct *map)
 Updates the map's timeout.
void set_materialname (object *op, int difficulty, materialtype_t *nmt)
 Set the materialname and type for an item.
void set_max_time (long t)
 Sets the max speed.
int set_ob_key_value (object *op, const char *key, const char *value, int add_key)
 Updates the key in op to value.
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.
int set_variable (object *op, char *buf)
void share_exp (object *op, sint64 exp, const char *skill, int flag)
 Gives experience to a player/monster, sharing it with party if applicable.
void sleep_delta (void)
 sleep_delta checks how much time has elapsed since last tick.
void ss_dump_statistics (char *buf, size_t size)
 A call to this function will cause the statistics to be dumped into specified buffer.
char * ss_dump_table (int what, char *buf, size_t size)
 Dump the contents of the share string tables.
const char * strcasestr_local (const char *s, const char *find)
 Finds a substring in a string, in a case-insensitive manner.
char * strdup_local (const char *str)
 A replacement of strdup(), since it's not defined at some unix variants.
char * strerror_local (int errnum, char *buf, size_t size)
 This takes an err number and returns a string with a description of the error.
void stringbuffer_append_printf (StringBuffer *sb, const char *format,...)
void stringbuffer_append_string (StringBuffer *sb, const char *str)
void stringbuffer_append_stringbuffer (StringBuffer *sb, const StringBuffer *sb2)
char * stringbuffer_finish (StringBuffer *sb)
sstring stringbuffer_finish_shared (StringBuffer *sb)
void stringbuffer_finish_socklist (StringBuffer *sb, SockList *sl)
StringBufferstringbuffer_new (void)
void strip_endline (char *buf)
 Removes endline from buffer (modified in place).
void strip_media_tag (char *message)
 Strip out the media tags from a String.
const char * strrstr (const char *haystack, const char *needle)
 Finds a string in a string.
int strtoint (const char *buf)
 Convert buf into an integer equal to the coadded sum of the (lowercase) character.
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)).
signed long sum_weight (object *op)
 sum_weight() is a recursive function which calculates the weight an object is carrying.
void tailor_readable_ob (object *book, int msg_type)
 The main routine.
char * tempnam_local (const char *dir, const char *pfx)
 A replacement for the tempnam() function since it's not defined at some unix variants.
FILE * tempnam_secure (const char *dir, const char *pfx, char **filename)
 A replacement for the tempnam_local() function since that one is not very secure.
void time_info (object *op)
 Players wants to know the time.
void transmute_materialname (object *op, const object *change)
 When doing transmutation of objects, we have to recheck the resistances, as some that did not apply previously, may apply now.
void trigger_connected (objectlink *ol, object *cause, const int state)
 Trigger every object in an objectlink.
int try_find_animation (const char *name)
 Tries to find the animation id that matches name, don't LOG() an error if not found.
archetype * try_find_archetype (const char *name)
 Finds, using the hashtable, which archetype matches the given name.
void unflag_inv (object *op, int flag)
 Desactivate recursively a flag on an object inventory.
void update_all_los (const mapstruct *map, int x, int y)
 This function makes sure that update_los() will be called for all players on the given map within the next frame.
void update_all_map_los (mapstruct *map)
 update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are.
void update_button (object *op)
 Updates everything connected with the button op.
void update_buttons (mapstruct *m)
 Updates every button on the map (by calling update_button() for them).
void update_los (object *op)
 Recalculates the array which specifies what is visible for the given player-object.
void update_ob_speed (object *op)
 Updates the speed of an object.
void update_object (object *op, int action)
 update_object() updates the array which represents the map.
void update_position (mapstruct *m, int x, int y)
 This function updates various attributes about a specific space on the map (what it looks like, whether it blocks magic, has a living creatures, prevents people from passing through, etc)
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.
void use_trigger (object *op)
 Toggles the state of specified button.
void verify_button_links (const mapstruct *map)
 This does a minimal check of the button link consistency for object map.
void write_book_archive (void)
 Write out the updated book archive to bookarch file.
void write_todclock (void)
 Write out the current time to the file so time does not reset every time the server reboots.
void yyfree (void *ptr)
int yyget_debug (void)
FILE * yyget_in (void)
int yyget_leng (void)
int yyget_lineno (void)
FILE * yyget_out (void)
char * yyget_text (void)
int yylex_destroy (void)
void yypop_buffer_state (void)
void yyrestart (FILE *input_file)
void yyset_debug (int bdebug)
void yyset_in (FILE *in_str)
void yyset_lineno (int line_number)
void yyset_out (FILE *out_str)

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_abilities ( object *  op,
object *  change 
)

Used in artifact generation.

The bonuses of the first object is modified by the bonuses of the second object.

Definition at line 1653 of file treasure.c.

References add_refcount(), animate_object(), arch_to_object(), blank_face, change_attr_value(), CLEAR_FLAG, copy_object(), FLAG_ALIVE, FLAG_ANIMATE, FLAG_BLIND, FLAG_CURSED, FLAG_DAMNED, FLAG_LIFESAVE, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STAND_STILL, FLAG_STEALTH, FLAG_XRAYS, free_object(), free_string(), get_attr_value(), get_object(), HORN, insert_ob_in_ob(), llevDebug, LOG(), NROFATTACKS, NUM_STATS, POTION, QUERY_FLAG, remove_ob(), set_abs_magic(), SET_FLAG, and update_ob_speed().

Referenced by artifact_msg(), and give_artifact_abilities().

Here is the call graph for this function:

Here is the caller graph for this function:

void add_button_link ( object *  button,
mapstruct map,
int  connected 
)

Links specified object in the map.

Parameters:
buttonobject to link. Must not be NULL.
mapmap we are on. Should not be NULL.
connectedconnection value for the item.

Definition at line 663 of file button.c.

References mapdef::buttons, FLAG_IS_LINKED, free_objectlink(), get_objectlink(), get_objectlinkpt(), llevError, LOG(), and SET_FLAG.

Referenced by apply_builder_item(), and include_map_in_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void add_friendly_object ( object *  op)

Add a new friendly object to the linked list of friendly objects.

Will log an error if the object is already on that list.

Parameters:
opobject to add to the list.

Definition at line 43 of file friend.c.

References first_friendly_object, get_objectlink(), is_friendly(), llevError, and LOG().

Referenced by add_player(), animate_weapon(), cfapi_object_set_property(), do_mood_floor(), fix_summon_pet(), hit_player(), mood_change(), polymorph_living(), receive_play_again(), summon_golem(), summon_object(), and use_oratory().

Here is the call graph for this function:

Here is the caller graph for this function:

This will increase the refcount of the string str.

Parameters:
strstring which *must *have been returned from a previous add_string().
Returns:
str

Definition at line 202 of file shstr.c.

References GATHER, and SS.

Referenced by add_abilities(), adjust_sign_msg(), animate_bomb(), attack_ob_simple(), cast_bless(), cast_change_ability(), cast_curse(), cast_invisible(), cone_drop(), copy_object(), do_symptoms(), explode_bullet(), fire_bolt(), fire_bow(), fire_bullet(), fix_object(), hit_with_arrow(), identify(), infect_object(), init_skills(), move_monster(), poison_living(), receive_play_again(), set_ob_key_value_s(), set_spell_skill(), and START_TEST().

Here is the caller graph for this function:

void add_statbonus ( object *  op)

Adds stat-bonuses given by the class which the player has chosen.

Parameters:
opobject which must be a player with contr not NULL.

Definition at line 863 of file living.c.

Referenced by key_change_class(), and key_roll_stat().

Here is the caller graph for this function:

sstring add_string ( const char *  str)

This will add 'str' to the hash table.

If there's no entry for this string, a copy will be allocated, and a pointer to that is returned.

Parameters:
strstring to share.
Returns:
pointer to string identical to str, but shared.

Definition at line 116 of file shstr.c.

References _shared_string::array, GATHER, hashstr(), new_shared_string(), _shared_string::next, _shared_string::previous, _shared_string::refcount, _shared_string::string, TOPBIT, and _shared_string::u.

Referenced by add_author(), add_book_to_list(), add_god_to_list(), add_to_racelist(), adjust_sign_msg(), alchemy_failure_effect(), animate_weapon(), become_follower(), cast_bless(), cast_create_town_portal(), cast_word_of_recall(), cctk_set_object_strings(), cfapi_system_add_string(), change_abil(), change_book(), change_treasure(), check_output_buffers(), command_follow(), command_goto(), command_reset(), command_summon(), command_teleport(), confuse_living(), create_singularity(), determine_god(), do_symptoms(), do_throw(), enter_player_savebed(), enter_random_map(), find_archetype_by_object_name(), find_object_name(), find_or_create_connection_for_map(), fire_bow(), fix_container_multipart(), fix_generated_item(), fix_multipart_object(), fix_stopped_arrow(), get_jail_exit(), get_player(), give_artifact_abilities(), god_enchants_weapon(), grant_immunity(), init_anim(), init_artifacts(), init_book_archive(), init_formulae(), init_globals(), init_msgfile(), init_races(), init_skills(), key_change_class(), keyplace(), kill_player(), load_materials(), load_treasure(), load_treasures(), local_check_loaded_object(), lock_and_hide_doors(), main(), make_formula_book(), move_marker(), new_text_name(), place_chest(), place_exits(), place_fountain_with_specials(), place_special_exit(), receive_play_again(), set_materialname(), set_ob_key_value(), set_ob_key_value_s(), START_TEST(), stringbuffer_finish_shared(), summon_golem(), tailor_god_spell(), tailor_readable_ob(), write_mark(), write_note(), and write_rune().

Here is the call 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 CONTAINER.

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

Here is the caller graph for this function:

int allowed_class ( const object *  op)

Returns true if the given player is a legal class.

The function to add and remove class-bonuses to the stats doesn't check if the stat becomes negative, thus this function merely checks that all stats are 1 or more, and returns false otherwise.

Parameters:
opobject to check.
Returns:
1 if allowed, 0 else.

Definition at line 1543 of file living.c.

Referenced by key_change_class().

Here is the caller graph for this function:

void animate_object ( object *  op,
int  dir 
)

Updates the face-variable of an object.

If the object is the head of a multi-object, all objects are animated. The object's state is not changed, but merely updated if needed (out of bounds of new animation, reached end of animation, ...)

Parameters:
opis the object to animate.
diris the direction the object is facing. This is generally same as op->direction, but in some cases, op->facing is used instead - the caller has a better idea which one it really wants to be using, so let it pass along the right one.

Definition at line 186 of file anim.c.

References animate_object(), blank_face, CLEAR_FLAG, dump_object(), FLAG_ALIVE, llevError, LOG(), NUM_ANIMATIONS, NUM_FACINGS, PLAYER, QUERY_FLAG, SET_ANIMATION, SET_FLAG, stringbuffer_finish(), stringbuffer_new(), and update_object().

Referenced by add_abilities(), animate_object(), apply_anim_suffix(), apply_changes_to_player(), dragon_ability_gain(), monster_use_scroll(), move_hole(), move_monster(), move_player(), process_events(), process_object(), turn_one_transport(), and turn_transport().

Here is the call graph for this function:

Here is the caller graph for this function:

void animate_turning ( object *  op)

Animates one step of object.

Parameters:
opobject to animate.
Note:
animate_object() should be used instead of this, but it can't handle animations in the 8 directions
Todo:
check if object is really animated?

Definition at line 284 of file button.c.

References NUM_ANIMATIONS, SET_ANIMATION, and update_object().

Referenced by legacy_ob_process(), and trigger_connected().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_anim_suffix ( object *  who,
sstring  suffix 
)

Applies a compound animation to an object.

Parameters:
whoobject to apply the animation to. Must not be NULL.
suffixanimation suffix to apply. Must not be NULL.

Definition at line 289 of file anim.c.

References animate_object(), animations, animations_struct::facings, MAX_BUF, animations_struct::name, animations_struct::num_animations, snprintf(), and try_find_animation().

Referenced by attack_ob_simple(), cast_spell(), do_skill(), and player_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_death_exp_penalty ( object *  op)

Applies a death penalty experience, the size of this is defined by the settings death_penalty_percentage and death_penalty_levels, and by the amount of permenent experience, whichever gives the lowest loss.

Parameters:
opvictim of the penalty. Must not be NULL.

Definition at line 2073 of file living.c.

References check_exp_loss(), Settings::death_penalty_level, Settings::death_penalty_ratio, levels, MAX, MIN, player_lvl_adj(), settings, and SKILL.

Referenced by kill_player().

Here is the call graph for this function:

Here is the caller graph for this function:

void arch_info ( object *  op)

Stores debug-information about how efficient the hashtable used for archetypes has been in the static errmsg array.

Definition at line 209 of file arch.c.

References arch_cmp, arch_search, draw_ext_info_format(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, and NDI_UNIQUE.

Referenced by command_archs().

Here is the call graph for this function:

Here is the caller graph for this function:

object* arch_to_object ( archetype *  at)

Creates and returns a new object which is a copy of the given archetype.

This function returns NULL if given a NULL pointer, else an object.

Parameters:
atarchetype from which to get an object.
Returns:
object of specified type.
Note:
get_object() will either allocate memory or call fatal(), so returned value is never NULL.

Definition at line 576 of file arch.c.

References copy_object_with_inv(), get_object(), llevError, LOG(), and warn_archetypes.

Referenced by add_abilities(), animate_bomb(), animate_weapon(), apply_builder_floor(), apply_builder_window(), cast_cause_disease(), cast_cone(), cast_consecrate(), cast_create_town_portal(), cast_destruction(), cast_detection(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_smite_spell(), change_luck(), change_object(), command_create(), cone_drop(), create_all_treasures(), create_archetype(), create_archetype_by_object_name(), create_aura(), create_bomb(), create_one_treasure(), do_turn(), dragon_ability_gain(), drain_specific_stat(), explode_bullet(), fire_arch_from_position(), fire_bolt(), fire_bullet(), fire_swarm(), fix_container_multipart(), fix_multipart_object(), fix_summon_pet(), fix_walls(), generate_monster_arch(), get_player(), get_spell_by_name(), give_skill_by_name(), god_gives_present(), hit_player(), include_map_in_map(), insert_multisquare_ob_in_map(), kill_player(), magic_wall(), make_map_floor(), make_map_walls(), mood_change(), move_aura(), move_ball_spell(), move_symptom(), object_create_arch(), pick_joined_wall(), place_chest(), place_exits(), place_monsters(), poison_living(), print_monsters(), put_a_monster(), put_decor(), put_doors(), put_floor(), remove_door(), remove_locked_door(), replace_insert_ob_in_map(), retrofit_joined_wall(), save_throw_object(), slow_living(), spell_effect(), spring_trap(), START_TEST(), summon_object(), write_mark(), and write_rune().

Here is the call graph for this function:

int atnr_is_dragon_enabled ( int  attacknr)

Determine if the attacktype represented by the specified attack-number is enabled for dragon players.

A dragon player (quetzal) can gain resistances for all enabled attacktypes.

Parameters:
attacknrattacktype to check
Returns:
TRUE if player can gain resistances in that, FALSE else.

Definition at line 106 of file player.c.

References ATNR_ACID, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_MAGIC, and ATNR_POISON.

Referenced by command_resistances(), describe_item(), describe_resistance(), dragon_eat_flesh(), dragon_level_gain(), and set_dragon_name().

Here is the caller graph for this function:

void bitstostring ( long  bits,
int  num,
char *  str 
)

Writes num ones and zeros to the given string based on the bits variable.

Parameters:
bitsvariable to convert to binary string
numnumber of bits to dump. Values above 32 will be ignored.
strstring to write to. Must be long enough.
Note:
no check is done whether str has enough space to write or not. Final \0 is appended to str.

Definition at line 110 of file info.c.

Referenced by print_monsters().

Here is the caller graph for this function:

int blocked_link ( object *  ob,
mapstruct m,
int  sx,
int  sy 
)

Returns true if the given coordinate is blocked except by the object passed is not blocking.

This is used with multipart monsters - if we want to see if a 2x2 monster can move 1 space to the left, we don't want its own area to block it from moving there.

Parameters:
obobject we ignore. Must not be NULL.
mmap we're considering.
sx
sytarget coordinates
Returns:
TRUE if the space is blocked by something other than ob.
Note:
the coordinates & map passed in should have been updated for tiling by the caller.

Definition at line 373 of file map.c.

References CHECK_INV, check_inv_recursive(), DOOR, draw_ext_info(), FLAG_ALIVE, FLAG_WIZ, MapSpace::flags, GET_MAP_MOVE_BLOCK, GET_MAP_OB, llevError, LOG(), MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_NOKEY, NDI_NAVY, NDI_UNIQUE, OB_MOVE_BLOCK, OB_TYPE_MOVE_BLOCK, OUT_OF_REAL_MAP, P_IS_ALIVE, PLAYER, QUERY_FLAG, mapdef::spaces, TRANSPORT, and mapdef::width.

Referenced by move_ob(), and path_to_player().

Here is the call graph for this function:

Here is the caller graph for this function:

int book_overflow ( const char *  buf1,
const char *  buf2,
size_t  booksize 
)

Checks if buf1 and buf2 can be combined.

Parameters:
buf1
buf2buffer we plan on combining.
booksizemaximum book size.
Returns:
0 if buffers can be combined, 1 else.

Definition at line 696 of file readable.c.

References BOOK_BUF, and buf_overflow().

Referenced by artifact_msg(), god_info_msg(), mon_info_msg(), msgfile_msg(), spellpath_msg(), and write_note().

Here is the call graph for this function:

Here is the caller graph for this function:

int buf_overflow ( const char *  buf1,
const char *  buf2,
size_t  bufsize 
)

We don't want to exceed the buffer size of buf1 by adding on buf2!

Parameters:
buf1
buf2buffers we plan on concatening. Can be NULL.
bufsizesize of buf1. Can be NULL.
Returns:
true if overflow will occur.
Todo:
This could maybe overflow. Make sure it doesn't.

Definition at line 393 of file shstr.c.

Referenced by book_overflow(), init_msgfile(), and START_TEST().

Here is the caller graph for this function:

int calc_item_power ( const object *  op,
int  flag 
)

This takes an object 'op' and figures out what its item_power rating should be.

This should only really be used by the treasure generation code, and when loading legacy objects. It returns the item_power it calculates. If flag is 1, we return the number of enchantment, and not the the power. This is used in the treasure code.

Parameters:
opobject of which to compute the item_power
flagunused
Todo:
fix function, and remove unused flag variable.

Definition at line 264 of file item.c.

References AMULET, ARMOUR, BOOTS, BRACERS, CLOAK, FLAG_LIFESAVE, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_XRAYS, get_attr_value(), get_power_from_ench(), GIRDLE, GLOVES, HELMET, NROFATTACKS, NRSPELLPATHS, NUM_STATS, QUERY_FLAG, RING, SHIELD, and WEAPON.

Referenced by add_one_item(), fix_generated_item(), and local_check_loaded_object().

Here is the call graph for this function:

Here is the caller graph for this function:

void calc_perm_exp ( object *  op)

Ensure that the permanent experience requirements in an exp object are met.

This really just checks 'op to make sure the perm_exp value is within proper range. Note that the checking of what is passed through has been reduced. Since there is now a proper field for perm_exp, this can now work on a much larger set of objects.

Parameters:
opobject to check.

Definition at line 1804 of file living.c.

References MAX_EXPERIENCE, Settings::permanent_exp_ratio, and settings.

Referenced by add_player_exp(), and command_addexp().

Here is the caller graph for this function:

This routine is supposed to find out the difficulty of the map.

Difficulty does not have a lot to do with character level, but does have a lot to do with treasure on the map.

Difficulty can now be set by the map creature. If the value stored in the map is zero, then use this routine. Maps should really have a difficulty set than using this function - human calculation is much better than this functions guesswork.

Parameters:
mmap for which to compute difficulty.
Returns:
difficulty of the map.

Definition at line 1917 of file map.c.

References FLAG_GENERATOR, FLAG_MONSTER, GENERATE_TYPE, get_archetype_by_type_subtype(), GET_MAP_OB, level_exp(), MAP_DIFFICULTY, MAP_HEIGHT, MAP_WIDTH, and QUERY_FLAG.

Referenced by cfapi_map_get_map_property(), generate_random_map(), and load_original_map().

Here is the call graph for this function:

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 can_merge(), compare_ob_value_lists(), FABS, FLAG_ANIMATE, FLAG_APPLIED, FLAG_BEEN_APPLIED, FLAG_IDENTIFIED, MIN_ACTIVE_SPEED, QUERY_FLAG, SCROLL, and SET_FLAG.

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, PLAYER, and QUERY_FLAG.

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 change_abil ( object *  op,
object *  tmp 
)

Permanently alters an object's stats/flags based on another object.

Returns:
1 if we sucessfully changed a stat, 0 if nothing was changed.
Note:
flag is set to 1 if we are applying the object, -1 if we are removing the object.
It is the calling functions responsibilty to check to see if the object can be applied or not. The main purpose of calling this function is the messages that are displayed - fix_object should really always be called after this when removing an object - that is because it is impossible to know if some object is the only source of an attacktype or spell attunement, so this function will clear the bits, but the player may still have some other object that gives them that ability.
Todo:
check logic, and things like that. Is the call to fix_object always required?

Definition at line 443 of file living.c.

References add_string(), AT_CONFUSION, ATNR_PHYSICAL, BOW, change_attr_value(), change_resist_msg, check_move_on(), check_stat_bounds(), CLEAR_FLAG, DIFF_MSG, draw_ext_info(), draw_ext_info_format(), EXPERIENCE, fix_object(), FLAG_APPLIED, FLAG_BLIND, FLAG_LIFESAVE, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_UNDEAD, FLAG_WIZ, FLAG_XRAYS, free_string(), gain_msg, get_attr_value(), lose_msg, MOVE_FLY_HIGH, MOVE_FLY_LOW, MOVE_SWIM, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_ATTACKTYPE_GAIN, MSG_TYPE_ATTRIBUTE_ATTACKTYPE_LOSS, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START, MSG_TYPE_ATTRIBUTE_GOOD_EFFECT_END, MSG_TYPE_ATTRIBUTE_GOOD_EFFECT_START, MSG_TYPE_ATTRIBUTE_MOVE, MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN, MSG_TYPE_ATTRIBUTE_PROTECTION_LOSS, MSG_TYPE_ATTRIBUTE_RACE, MSG_TYPE_ATTRIBUTE_STAT_GAIN, MSG_TYPE_ATTRIBUTE_STAT_LOSS, NDI_BLUE, NDI_UNIQUE, NROFATTACKS, NUM_STATS, PLAYER, POTION, QUERY_FLAG, set_attr_value(), SET_FLAG, and SKILL.

Referenced by apply_special(), become_follower(), blind_living(), blindness_type_process(), cast_bless(), cast_change_ability(), cast_curse(), cfapi_object_change_abil(), eat_special_food(), potion_type_apply(), remove_force(), swap_random_stats(), and unapply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

void change_attr_value ( living stats,
int  attr,
sint8  value 
)

Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat.

Parameters:
statsitem to modify. Must not be NULL.
attrattribute to change.
valuedelta (can be positive).
Todo:
check if attr is valid? Checks result valus is valid?

Definition at line 336 of file living.c.

References CHA, liv::Cha, CON, liv::Con, DEX, liv::Dex, INT, liv::Int, llevError, LOG(), POW, liv::Pow, STR, liv::Str, WIS, and liv::Wis.

Referenced by add_abilities(), alchemy_failure_effect(), apply_changes_to_player(), change_abil(), drain_specific_stat(), fix_object(), and kill_player().

Here is the call graph for this function:

Here is the caller graph for this function:

void change_exp ( object *  op,
sint64  exp,
const char *  skill_name,
int  flag 
)

Changes experience to a player/monster.

This does bounds checking to make sure we don't overflow the max exp.

The exp passed is typically not modified much by this function - it is assumed the caller has modified the exp as needed. skill_name is the skill that should get the exp added. flag is what to do if player doesn't have the skill. these last two values are only used for players.

Parameters:
opvictim to alter.
expexperience to gain (positive) or lose (negative).
skill_nameskill to change. Can be NULL.
flag
  • if experience gain, what to do if player doesn't have the skill
  • if experience loss, whether to remove from all skills or only specified skill
See also:
share_exp() for a party-aware version.

Definition at line 2015 of file living.c.

References add_player_exp(), FABS, FLAG_ALIVE, llevDebug, llevError, LOG(), MAX_BUF, MAX_EXPERIENCE, PLAYER, QUERY_FLAG, query_name(), and subtract_player_exp().

Referenced by attempt_do_alchemy(), book_type_apply(), cfapi_object_change_exp(), cure_disease(), do_harvest(), do_hidden_move(), do_skill(), god_examines_priest(), hit_with_one_attacktype(), pay_for_item(), peacemaker_type_process(), pray_at_altar(), scroll_type_apply(), sell_item(), share_exp(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void change_luck ( object *  op,
int  value 
)

Alter the object's luck.

Parameters:
opobject to altar.
valuedelta to apply. 0 indicates timeout (moves luck towards 0), otherwise change the luck of the object via an applied bad_luck object in inventory.

Definition at line 791 of file living.c.

References arch_to_object(), FABS, find_archetype(), FLAG_APPLIED, insert_ob_in_ob(), llevError, LOG(), present_arch_in_ob(), and SET_FLAG.

Referenced by fix_luck(), and kill_object().

Here is the call graph for this function:

Here is the caller graph for this function:

int change_map_light ( mapstruct m,
int  change 
)

Used to change map light level (darkness) up or down.

It should now be possible to change a value by more than 1.

Move this from los.c to map.c since this is more related to maps than los. postive values make it darker, negative make it brighter

Will inform players on the map.

Parameters:
mmap to change.
changedelta of light.
Returns:
TRUE if light changed, FALSE else.

Definition at line 2000 of file map.c.

References mapdef::darkness, ext_info_map(), MAX_DARKNESS, MSG_SUBTYPE_NONE, MSG_TYPE_MISC, NDI_BLACK, and update_all_map_los().

Referenced by cast_change_map_lightlevel(), cfapi_map_change_light(), dawn_to_dusk(), and set_darkness_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int check_altar_sacrifice ( const object *  altar,
const object *  sacrifice,
int  remove_others,
int *  toremove 
)

Checks whether the altar has enough to sacrifice.

Function put in (0.92.1) so that identify altars won't grab money unnecessarily - we can see if there is sufficient money, see if something needs to be identified, and then remove money if needed.

0.93.4: Linked objects (ie, objects that are connected) can not be sacrificed. This fixes a bug of trying to put multiple altars/related objects on the same space that take the same sacrifice.

The function will now check for all items sitting on the altar, so that the player can put various matching but non merging items on the altar.

This function can potentially remove other items, if remove_others is set.

Parameters:
altaritem to which there is a sacrifice
sacrificeobject that may be sacrifed
remove_othersif 1, will remove enough items apart sacrifice to compensate for not having enough in sacrifice itself.
[out]toremovewill contain the nrof of sacrifice to really remove to finish operating. Will be set if not NULL only if the function returns 1.
Returns:
1 if the sacrifice meets the needs of the altar, 0 else

Definition at line 355 of file button.c.

References ARCH_SACRIFICE, decrease_ob_nr(), FLAG_UNPAID, llevError, LOG(), matches_sacrifice(), NROF_SACRIFICE, QUERY_FLAG, and remove_ob().

Referenced by identify_altar_type_move_on(), and operate_altar().

Here is the call graph for this function:

Here is the caller graph for this function:

sint64 check_exp_adjust ( const object *  op,
sint64  exp 
)

Returns the maximum experience the object can gain or lose.

Parameters:
opobject which will be the victim.
expexperience to gain or lose.
Returns:
maximum value op can gain or lose (can be positive or negative).

Definition at line 1937 of file living.c.

References check_exp_loss(), MAX_EXPERIENCE, and MIN.

Referenced by command_addexp().

Here is the call graph for this function:

Here is the caller graph for this function:

sint64 check_exp_loss ( const object *  op,
sint64  exp 
)

This function checks to make sure that object 'op' can lose 'exp' experience.

It basically makes adjustments based on permanent exp and the like. This function should always be used for losing experience - the 'exp' value passed should be positive - this is the amount that should get subtract from the player.

Parameters:
opobject to which to substract.
expexperience to lose.
Returns:
the amount of exp object 'op' can in fact lose -

Definition at line 1915 of file living.c.

References PERM_EXP_MAX_LOSS_RATIO, Settings::permanent_exp_ratio, and settings.

Referenced by apply_death_exp_penalty(), check_exp_adjust(), kill_object(), and subtract_player_exp().

Here is the caller graph for this function:

void check_generators ( void  )

Referenced by load_archetypes().

Here is the caller graph for this function:

void check_inv ( object *  op,
object *  trig 
)

Function to search the inventory, of a player and then based on a set of conditions, the square will activate connected items.

Monsters can't trigger this square (for now) Values are: last_sp = 1/0 obj/no obj triggers last_heal = 1/0 remove/dont remove obj if triggered -b.t. (thomas@nomad.astro.psu.edu

Parameters:
opobject to check. Must be a player.
trigtrigger object that may be activated.

Definition at line 828 of file button.c.

References check_inv_recursive(), decrease_ob, PLAYER, and use_trigger().

Referenced by cfapi_object_check_inventory(), and check_inv_type_move_on().

Here is the call graph for this function:

Here is the caller graph for this function:

object* check_inv_recursive ( object *  op,
const object *  trig 
)

Checks object and its inventory for specific item.

It will descend through containers to find the object. slaying = match object slaying flag race = match object archetype name flag hp = match object type (excpt type '0'== PLAYER) title = match object title Searching by title only is not recommended, as it can be a rather slow operation; use it in combination with archetype or type.

Parameters:
opobject of which to search inventory
trigwhat to search
Returns:
object that matches, or NULL if none matched.

Definition at line 788 of file button.c.

References check_inv_recursive().

Referenced by blocked_link(), cast_create_town_portal(), cfapi_object_check_inventory(), check_inv(), and check_inv_recursive().

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 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, MOVE_FLY_LOW, MOVE_WALK, ob_move_on(), PLAYER, QUERY_FLAG, SK_CLIMBING, and SK_WOODSMAN.

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:

int check_path ( const char *  name,
int  prepend_dir 
)

This function checks if a file with the given path exists.

It tries out all the compression suffixes listed in the uncomp[] array, except for Windows which checks an exact file.

Parameters:
namemap path to check.
prepend_dirIf set, then we call create_pathname (which prepends libdir & mapdir). Otherwise, we assume the name given is fully complete.
Returns:
-1 if it fails, otherwise the mode of the file is returned.
Note:
Only the editor actually cares about the writablity of this - the rest of the code only cares that the file is readable. when the editor goes away, the call to stat should probably be replaced by an access instead (similar to the windows one, but that seems to be missing the prepend_dir processing

Definition at line 216 of file map.c.

References create_pathname(), MAX_BUF, NROF_COMPRESS_METHODS, S_IRGRP, S_IROTH, S_IRUSR, S_ISREG, S_IWGRP, S_IWOTH, S_IWUSR, snprintf(), and uncomp.

Referenced by cfapi_system_check_path(), check_login(), and load_map_header().

Here is the call graph for this function:

Here is the caller graph for this function:

void check_stat_bounds ( living stats)

Ensures that all stats (str/dex/con/wis/cha/int) are within the 1-30 stat limit.

Parameters:
statsattributes to check.

Definition at line 404 of file living.c.

References get_attr_value(), MAX_STAT, MIN_STAT, NUM_STATS, and set_attr_value().

Referenced by change_abil(), fix_object(), and kill_player().

Here is the call graph for this function:

Here is the caller graph for this function:

int check_trigger ( object *  op,
object *  cause 
)
Todo:
document properly cause != NULL: something has moved on top of op

cause == NULL: nothing has moved, we have been called from animate_trigger().

TRIGGER_ALTAR: Returns 1 if 'cause' was destroyed, 0 if not.

TRIGGER: Returns 1 if handle could be moved, 0 if not.

TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0.

Definition at line 525 of file button.c.

References llevDebug, LOG(), NUM_ANIMATIONS, operate_altar(), PLAYER, push(), SET_ANIMATION, TRIGGER, TRIGGER_ALTAR, TRIGGER_BUTTON, trigger_move(), TRIGGER_PEDESTAL, update_ob_speed(), and update_object().

Referenced by animate_trigger(), cfapi_object_check_trigger(), do_auto_apply(), fix_auto_apply(), trigger_altar_type_move_on(), trigger_button_type_move_on(), trigger_pedestal_type_move_on(), trigger_type_apply(), and trigger_type_process().

Here is the call graph for this function:

Here is the caller graph for this function:

void clean_friendly_list ( void  )

It traverses the friendly list removing objects that should not be here (ie, do not have friendly flag set, freed, etc)

Definition at line 124 of file friend.c.

References first_friendly_object, FLAG_FREED, FLAG_FRIENDLY, llevDebug, LOG(), and QUERY_FLAG.

Referenced by do_specials().

Here is the call graph for this function:

Here is the caller graph for this function:

void clean_object ( object *  op)

Remove and free all objects in the inventory of the given object.

Parameters:
opobject to clean.
Todo:
move to common/object.c ?

Definition at line 1640 of file map.c.

References clean_object(), FLAG_IS_LINKED, free_object(), QUERY_FLAG, remove_button_link(), and remove_ob().

Referenced by cfapi_object_clean_object(), clean_object(), delete_unique_items(), and free_all_objects().

Here is the call graph for this function:

Here is the caller graph for this function:

void clean_tmp_map ( mapstruct m)

Removse the temporary file used by the map.

Parameters:
mmap, which mustn't be NULL but can have no temporary file set.

Definition at line 1959 of file map.c.

References mapdef::tmpname, and unlink.

Referenced by clean_tmp_files(), flush_old_maps(), and ready_map_name().

Here is the caller graph for this function:

void clear_archetable ( void  )

Initialise the hashtable used by the archetypes.

Definition at line 219 of file arch.c.

References arch_table, and ARCHTABLE.

Referenced by free_all_archs(), load_archetypes(), and START_TEST().

Here is the caller graph for this function:

void clear_los ( object *  op)

Clears/initialises the los-array associated to the player controlling the object.

Parameters:
opplayer's object.
Todo:
use player *instead of object *to show it must be a player?

Definition at line 258 of file los.c.

References MAP_CLIENT_X, and MAP_CLIENT_Y.

Referenced by do_wizard_dm(), get_player(), and update_los().

Here is the caller graph for this function:

void clear_object ( object *  op)

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

Parameters:
opobject to clear

Definition at line 688 of file object.c.

References blank_face, Settings::casting_time, FLAG_FRIENDLY, FLAG_REMOVED, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_dialog_information(), free_key_values(), offsetof, QUERY_FLAG, remove_friendly_object(), SET_FLAG, and settings.

Referenced by cfapi_object_clear(), first_arch_pass(), get_archetype_struct(), get_object(), reset_object(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

Here is the caller graph for this function:

void clear_player ( player pl)

Clears data in player structure.

Socket isn't touched. Nor is anything that doesn't need to be freed. So you may need to do a memset() to clear out values.

Parameters:
plplayer to clear. Pointer is still valid, and can be reused for "play again".

Definition at line 45 of file player.c.

References client_spell::next, pl::spell_state, pl::stack_items, and pl::stack_position.

Referenced by free_player(), and get_player().

Here is the caller graph for this function:

void close_and_delete ( FILE *  fp,
int  compressed 
)
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(), CLEAR_FLAG, FLAG_DIALOG_PARSED, FLAG_FREED, FLAG_REMOVED, FREE_AND_CLEAR, free_dialog_information(), free_key_values(), free_string(), NROFATTACKS, offsetof, QUERY_FLAG, SET_FLAG, and update_ob_speed().

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 copy_object(), get_object(), and insert_ob_in_ob().

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

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

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

Referenced by malloc_info(), and START_TEST().

Here is the caller graph for this function:

object* create_archetype ( const char *  name)
object* create_archetype_by_object_name ( const char *  name)

Creates an object given the name that appears during the game (for example, "writing pen" instead of "stylus").

Parameters:
namethe name we're searching for (ex: "writing pen"), must not be null
Returns:
a corresponding object if found; a singularity object if not found.
Note:
Note by MSW - it appears that it takes the full name and keeps shortening it until it finds a match. I re-wrote this so that it doesn't malloc it each time - not that this function is used much, but it otherwise had a big memory leak.

Definition at line 173 of file arch.c.

References arch_to_object(), create_singularity(), find_archetype_by_object_name(), and MAX_BUF.

Referenced by god_intervention(), local_check_loaded_object(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void create_overlay_pathname ( const char *  name,
char *  buf,
size_t  size 
)

Same as create_pathname(), but for the overlay maps.

/

Parameters:
namepath of the overlay map.
bufbuffer that will contain the full path.
sizebuffer's length.

Definition at line 135 of file map.c.

References Settings::localdir, Settings::mapdir, settings, and snprintf().

Referenced by cfapi_map_create_path(), command_overlay_reset(), load_original_map(), load_overlay_map(), and save_map().

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_pathname ( const char *  name,
char *  buf,
size_t  size 
)

This makes a path absolute outside the world of Crossfire.

In other words, it prepends LIBDIR/MAPDIR/ to the given path and returns the pointer to a static array containing the result. it really should be called create_mapname

Parameters:
namepath of the map.
bufbuffer that will contain the full path.
sizebuffer's length.
Returns:
buf.

Definition at line 114 of file map.c.

References Settings::datadir, Settings::mapdir, settings, and snprintf().

Referenced by cfapi_map_create_path(), check_path(), enter_fixed_template_map(), enter_unique_map(), load_original_map(), process_map(), ready_map_name(), and save_map().

Here is the call graph for this function:

Here is the caller graph for this function:

object* create_singularity ( const char *  name)

Creates a dummy object.

This function is called by get_archetype() if it fails to find the appropriate archetype. Thus get_archetype() will be guaranteed to always return an object, and never NULL.

Parameters:
namename to give the dummy object.
Returns:
object of specified name. It fill have the FLAG_NO_PICK flag set.
Note:
get_object() will either allocate memory or call fatal(), so returned value is never NULL.

Definition at line 603 of file arch.c.

References add_string(), FLAG_NO_PICK, get_object(), MAX_BUF, SET_FLAG, and snprintf().

Referenced by create_archetype(), create_archetype_by_object_name(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void create_template_pathname ( const char *  name,
char *  buf,
size_t  size 
)

same as create_pathname(), but for the template maps.

Parameters:
namepath of the template map.
bufbuffer that will contain the full path.
sizebuf's length

Definition at line 155 of file map.c.

References Settings::localdir, settings, snprintf(), and Settings::templatedir.

Referenced by enter_fixed_template_map(), and enter_random_template_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void decay_objects ( mapstruct m)

Decay and destroy persihable items in a map.

Definition at line 187 of file utils.c.

References CLOAK, FLAG_IS_FLOOR, FLAG_OBJ_ORIGINAL, FLAG_OVERLAY_FLOOR, FLAG_UNIQUE, FLAG_UNPAID, FOOD, free_object(), GET_MAP_OB, GIRDLE, GLOVES, IS_ARMOR, IS_LIVE, IS_SHIELD, IS_WEAPON, M_ADAMANT, M_BONE, M_CLOTH, M_GLASS, M_ICE, M_IRON, M_LEATHER, M_LIQUID, M_ORGANIC, M_PAPER, M_SOFT_METAL, M_STONE, M_WOOD, MAP_HEIGHT, MAP_WIDTH, QUERY_FLAG, remove_ob(), rndm(), and mapdef::unique.

Referenced by ready_map_name().

Here is the call graph for this function:

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 esrv_update_item(), first_player, FLAG_REMOVED, free_object(), GET_MAP_OB, get_player_container(), pl::next, pl::ob, QUERY_FLAG, remove_ob(), sub_weight(), and UPD_NROF.

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:

void delete_map ( mapstruct m)

Frees the map, including the mapstruct.

This deletes all the data on the map (freeing pointers) and then removes this map from the global linked list of maps.

Parameters:
mpointer to mapstruct, if NULL no action. Will be invalid after this function.

Definition at line 1745 of file map.c.

References first_map, free_map(), mapdef::in_memory, llevError, LOG(), MAP_IN_MEMORY, MAP_SAVING, mapdef::next, mapdef::path, mapdef::tile_map, and mapdef::tmpname.

Referenced by cfapi_map_delete_map(), flush_old_maps(), free_all_maps(), free_style_maps(), init_dynamic(), key_confirm_quit(), load_original_map(), load_overlay_map(), load_temporary_map(), process_map(), ready_map_name(), START_TEST(), and swap_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void describe_item ( const object *  op,
const object *  owner,
char *  retbuf,
size_t  size 
)

Describes an item, in all its details.

  • If it is a monster, lots of information about its abilities will be returned.
  • If it is an item, lots of information about which abilities will be gained about its user will be returned.
  • If it is a player, it writes out the current abilities of the player, which is usually gained by the items applied.

It would be really handy to actually pass another object pointer on who is examining this object. Then, you could reveal certain information depending on what the examiner knows, eg, wouldn't need to use the SEE_INVISIBLE flag to know it is a dragon player examining food. Could have things like a dwarven axe, in which the full abilities are only known to dwarves, etc.

Add 'owner' who is the person examining this object. owner can be null if no one is being associated with this item (eg, debug dump or the like)

Parameters:
opobject to describe. Must not be NULL.
ownerplayer examining the object.
retbufbuffer that will contain the description. Must not be NULL.
sizesize of buffer.
Note:
This function is really much more complicated than it should be, because different objects have different meanings for the same field (eg, wands use 'food' for charges). This means these special cases need to be worked out.
Todo:
Check whether owner is really needed. Use safe string functions. Check spurious food logic.

Definition at line 1018 of file item.c.

References AMULET, ARMOUR, ARMOUR_SPEED, ARMOUR_SPELLS, ARROW, atnr_is_dragon_enabled(), BOOTS, BOW, BRACERS, change_resist_msg, CLOAK, DESCRIBE_ABILITY_SAFE, describe_monster(), DESCRIBE_PATH_SAFE, describe_resistance(), DRINK, FLAG_BEEN_APPLIED, FLAG_CURSED, FLAG_IDENTIFIED, FLAG_LIFESAVE, FLAG_MONSTER, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_XRAYS, FLESH, FOOD, FORCE, get_attr_value(), GIRDLE, GLOVES, HELMET, HORN, is_dragon_pl(), LAMP, MOVE_FLY_HIGH, MOVE_FLY_LOW, MOVE_SWIM, need_identify(), NUM_STATS, PLAYER, POWER_CRYSTAL, QUERY_FLAG, RING, ring_desc(), ROD, SHIELD, short_stat_name, SKILL, SKILL_TOOL, snprintf(), WAND, WEAPON, and WEAPON_SPEED.

Referenced by artifact_msg(), cfapi_object_describe(), common_ob_describe(), dump_abilities(), mon_desc(), perceive_self(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void describe_monster ( const object *  op,
char *  retbuf,
size_t  size 
)

Describes a monster.

Parameters:
opmonster to describe. Must not be NULL.
retbufbuffer that will contain the description. Must not be NULL.
sizebuffer size.
Note:
Break this off from describe_item - that function was way too long, making it difficult to read. This function deals with describing the monsters & players abilities. It should only be called with monster & player objects.
Todo:
Rename to describe_living (or equivalent) since called for player too. Use safe string functions. Fix weird sustenance logic.

Definition at line 840 of file item.c.

References DESCRIBE_ABILITY_SAFE, DESCRIBE_PATH_SAFE, FABS, FLAG_CAN_USE_SKILL, FLAG_CAST_SPELL, FLAG_FRIENDLY, FLAG_HITBACK, FLAG_SEE_INVISIBLE, FLAG_STEALTH, FLAG_UNAGGRESSIVE, FLAG_UNDEAD, FLAG_USE_ARMOUR, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_RING, FLAG_USE_SCROLL, FLAG_USE_WEAPON, is_dragon_pl(), treasurestruct::item, MIN_ACTIVE_SPEED, treasurestruct::next, NROFATTACKS, PLAYER, QUERY_FLAG, resist_plus, SKILL, snprintf(), and SPELL.

Referenced by describe_item().

Here is the call graph for this function:

Here is the caller graph for this function:

void describe_resistance ( const object *  op,
int  newline,
char *  buf,
size_t  size 
)

Generates the visible naming for resistances.

Parameters:
opobject we want information about.
newlineIf TRUE, we don't put parens around the description but do put a newline at the end. Useful when dumping to files
[out]bufbuffer that will receive the description.
sizebuffer size.

Definition at line 399 of file item.c.

References atnr_is_dragon_enabled(), FLESH, NROFATTACKS, resist_plus, and snprintf().

Referenced by describe_item(), dump_gods(), god_info_msg(), and ring_desc().

Here is the call graph for this function:

Here is the caller graph for this function:

int did_make_save ( const object *  op,
int  level,
int  bonus 
)

This function takes an object (monster/player, op), and determines if it makes a basic save throw by looking at the save_throw table.

Parameters:
oppotential victim.
levelthe effective level to make the save at
bonusany plus/bonus (typically based on resistance to particular attacktype).
Returns:
1 if op makes his save, 0 if he failed

Definition at line 2121 of file living.c.

References MAX_SAVE_LEVEL, PREFER_HIGH, random_roll(), and savethrow.

Referenced by flee_player(), hit_player(), hit_with_one_attacktype(), mood_change(), and polymorph_living().

Here is the call graph for this function:

Here is the caller graph for this function:

int die_roll ( int  num,
int  size,
const object *  op,
int  goodbad 
)

Roll a number of dice (2d3, 4d6).

Uses op to determine luck, If goodbad is non-zero, luck increases the roll, if zero, it decreases. Generally, op should be the player/caster/hitter requesting the roll, not the recipient (ie, the poor slob getting hit). The args are num D size (ie 4d6) [garbled 20010916]

Definition at line 134 of file utils.c.

References llevError, LOG(), MAX, MIN, and PLAYER.

Referenced by attempt_hide(), attempt_pick_lock(), attempt_steal(), do_skill_ident2(), fire_swarm(), pick_arrow_target(), player_lvl_adj(), scroll_type_apply(), spellbook_type_apply(), and summon_object().

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.

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

Here is the caller graph for this function:

void drain_specific_stat ( object *  op,
int  deplete_stats 
)

Drain a specified stat from op.

Parameters:
opvictim to drain.
deplete_statsstatistic to drain.

Definition at line 760 of file living.c.

References arch_to_object(), change_attr_value(), drain_msg, draw_ext_info(), find_archetype(), fix_object(), FLAG_APPLIED, insert_ob_in_ob(), llevError, LOG(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_STAT_LOSS, NDI_UNIQUE, present_arch_in_ob(), and SET_FLAG.

Referenced by cfapi_object_drain(), drain_stat(), and write_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

void drain_stat ( object *  op)

Drains a random stat from op.

Stat draining by Vick 930307 (Feeling evil, I made it work as well now. -Frank 8)

Parameters:
opobject to drain.

Definition at line 748 of file living.c.

References drain_specific_stat(), and NUM_STATS.

Referenced by hit_with_one_attacktype(), and potion_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_abilities ( void  )

Dump to standard out the abilities of all monsters.

Definition at line 40 of file info.c.

References describe_item(), first_archetype, FLAG_CHANGING, FLAG_MONSTER, bmappair::name, QUERY_FLAG, and VERY_BIG_BUF.

Referenced by init_beforeplay().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_alchemy ( void  )
void dump_alchemy_costs ( void  )
void dump_all_archetypes ( void  )

Dumps _all_ archetypes to debug-level output.

If you run crossfire with debug, and enter DM-mode, you can trigger this with the "dumpallarchetypes" command.

Definition at line 252 of file arch.c.

References dump_arch(), first_archetype, llevDebug, LOG(), stringbuffer_finish(), and stringbuffer_new().

Referenced by command_dumpallarchetypes().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_all_maps ( void  )

Prints out debug-information about all maps.

This basically just goes through all the maps and calls dump_map() on each one. Can be used by a DM with the dumpallmaps command.

Definition at line 298 of file map.c.

References dump_map(), first_map, and mapdef::next.

Referenced by command_dumpallmaps().

Here is the call graph for this function:

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 dump_object(), llevDebug, LOG(), objects, 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_arch ( archetype *  at,
StringBuffer sb 
)

Dumps an archetype to buffer.

Parameters:
atarchetype to dump. Must not be NULL.
sbbuffer that will contain dumped information.

Definition at line 243 of file arch.c.

References dump_object().

Referenced by dump_all_archetypes().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_artifacts ( void  )
void dump_experience ( void  )

Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format of the exp_table is correct.

Definition at line 257 of file exp.c.

References levels, logfile, Settings::max_level, and settings.

void dump_friendly_objects ( void  )

Dumps all friendly objects.

Invoked in DM-mode with dumpfriendlyobjects command.

Note:
logs at the error level.

Definition at line 113 of file friend.c.

References first_friendly_object, llevError, and LOG().

Referenced by command_dumpfriendlyobjects().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_gods ( void  )

Prints all gods to stderr.

Todo:
use LOG instead of fprintf().

Definition at line 161 of file holy.c.

References DESCRIBE_ABILITY, DESCRIBE_PATH, describe_resistance(), first_god, FLAG_BLIND, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_UNDEAD, FLAG_USE_ARMOUR, FLAG_USE_WEAPON, FLAG_XRAYS, HUGE_BUF, glnk::next, pntr_to_god_obj(), QUERY_FLAG, and snprintf().

Referenced by init_beforeplay().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_map ( const mapstruct m)

Prints out debug-information about a map.

Dumping these at llevError doesn't seem right, but is necessary to make sure the information is in fact logged. Can be used by a DM with the dumpmap command.

Parameters:
mmap to dump.

Definition at line 275 of file map.c.

References mapdef::darkness, mapdef::difficulty, mapdef::in_memory, llevError, LOG(), MAP_ENTER_X, MAP_ENTER_Y, MAP_HEIGHT, MAP_WIDTH, mapdef::maplore, mapdef::msg, mapdef::path, and mapdef::tmpname.

Referenced by command_dumpmap(), and dump_all_maps().

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_monster_treasure ( const char *  name)

For debugging purposes.

Dumps all treasures for a given monster. Created originally by Raphael Quinet for debugging the alchemy code.

Definition at line 1515 of file treasure.c.

References dump_monster_treasure_rec(), first_archetype, logfile, and strcasecmp().

Referenced by init_beforeplay().

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 empty_archetype, get_ob_diff(), 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:

int enough_elapsed_time ( void  )

Checks elapsed time since last tick.

Returns:
true if the time passed since last tick is more than max-time.

Definition at line 175 of file time.c.

References GETTIMEOFDAY, last_time, log_time(), and max_time.

Here is the call graph for this function:

void fatal ( int  err)
int find_animation ( const char *  name)

Finds the animation id that matches name.

Will LOG() an error if not found.

Parameters:
namethe animation's name.
Returns:
animation number, or 0 if no match found (animation 0 is initialized as the 'bug' face).
See also:
try_find_animation

Definition at line 146 of file anim.c.

References llevError, LOG(), and try_find_animation().

Referenced by cfapi_system_find_animation(), and transport_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

archetype* find_archetype ( const char *  name)
archetype* find_archetype_by_object_name ( const char *  name)

This function retrieves an archetype given the name that appears during the game (for example, "writing pen" instead of "stylus").

It does not use the hashtable system, but browse the whole archlist each time. I suggest not to use it unless you really need it because of performance issue. It is currently used by scripting extensions (create-object). Params:

Parameters:
namethe name we're searching for (ex: "writing pen")
Returns:
the archetype found or NULL if nothing was found

Definition at line 70 of file arch.c.

References add_string(), first_archetype, and free_string().

Referenced by cfapi_object_create(), command_create(), create_archetype_by_object_name(), CREArtifactPanel::setArtifact(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

archetype* find_archetype_by_object_type_name ( int  type,
const char *  name 
)

This function retrieves an archetype by type and name that appears during the game.

It is basically the same as find_archetype_by_object_name() except that it considers only items of the given type.

Parameters:
typeitem type we're searching
namethe name we're searching for (ex: "writing pen")

Definition at line 96 of file arch.c.

References first_archetype.

Referenced by cast_create_food(), and START_TEST().

Here is the caller graph for this function:

Searches the artifact lists and returns one that has the same type of objects on it.

Returns:
NULL if no suitable list found.

Definition at line 1431 of file treasure.c.

References first_artifactlist, artifactliststruct::next, and artifactliststruct::type.

Referenced by artifact_msg(), cast_create_missile(), command_create(), generate_artifact(), init_artifacts(), and locate_recipe_artifact().

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 FLAG_MONSTER, freearr_x, freearr_y, freedir, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, maxfree, MOVE_ALL, P_IS_ALIVE, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, and SIZEOFFREE.

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:

unsigned find_face ( const char *  name,
unsigned  error 
)

This returns an the face number of face 'name'.

Number is constant during an invocation, but not necessarily between versions (this is because the faces are arranged in alphabetical order, so if a face is removed or added, all faces after that will now have a different number.

Parameters:
nameface to search for
errorvalue to return if face was not found.
Note:
If a face is not found, then error is returned. This can be useful if you want some default face used, or can be set to negative so that it will be known that the face could not be found (needed in client, so that it will know to request that image from the server)

Definition at line 324 of file image.c.

References compar(), bmappair::name, nroffiles, and bmappair::number.

Referenced by cfapi_system_find_face(), init_anim(), read_bmap_names(), read_face_data(), read_smooth(), set_object_face_main(), set_object_face_other(), and transport_type_apply().

Here is the call graph for this function:

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(), MAP_HEIGHT, MAP_WIDTH, and ob_blocked().

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(), ob_blocked(), P_OUT_OF_MAP, and strtol().

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.

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

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

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:

int find_smooth ( uint16  face,
uint16 smoothed 
)

Find the smooth face for a given face.

Parameters:
facethe face to find the smoothing face for
smoothedreturn value: set to smooth face
Returns:
1=smooth face found, 0=no smooth face found

Definition at line 401 of file image.c.

References nrofpixmaps, and new_face_struct::smoothface.

Referenced by send_smooth().

Here is the caller graph for this function:

sstring find_string ( const char *  str)

Searches a string in the shared strings.

Parameters:
strstring to search for.
Returns:
pointer to identical string or NULL

Definition at line 228 of file shstr.c.

References GATHER, hashstr(), _shared_string::next, and _shared_string::string.

Referenced by cfapi_system_find_string(), find_treasurelist(), get_ob_key_value(), set_ob_key_value(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

archetype* find_treasure_by_name ( const treasure t,
const char *  name,
int  depth 
)

Find a treasure with a matching name.

The 'depth' parameter is only there to prevent infinite loops in treasure lists (a list referencing another list pointing back to the first one).

Parameters:
titem of treasure list to search from
namename we're trying to find. Doesn't need to be a shared string.
depthcurrent depth. Code will exit if greater than 10.
Returns:
archetype with name, or NULL if nothing found.

Definition at line 365 of file recipe.c.

References find_treasure_by_name(), find_treasurelist(), treasurestruct::item, treasureliststruct::items, treasurestruct::name, treasurestruct::next, treasurestruct::next_no, treasurestruct::next_yes, and strcasecmp().

Referenced by find_ingred_cost(), and find_treasure_by_name().

Here is the call graph for this function:

Here is the caller graph for this function:

void fix_container ( object *  container)

When the map is loaded, load_object() does not actually insert objects into inventory, but just links them.

What this does is go through and insert them properly.

Parameters:
containerobject that contains the inventory. This is needed so that we can update the containers weight.
Todo:
This is unusued, should it be used somewhere?

Definition at line 580 of file map.c.

References fix_container(), insert_ob_in_ob(), and sum_weight().

Referenced by fix_container().

Here is the call graph for this function:

Here is the caller graph for this function:

void fix_generated_item ( object *  op,
object *  creator,
int  difficulty,
int  max_magic,
int  flags 
)

fix_generated_item(): This is called after an item is generated, in order to set it up right.

This produced magical bonuses, puts spells into scrolls/books/wands, makes it unidentified, hides the value, etc.

4/28/96 added creator object from which op may now inherit properties based on op->type. Right now, which stuff the creator passes on is object type dependant. I know this is a spagetti manuever, but is there a cleaner way to do this? b.t.

Parameters:
opobject to fix.
creatorfor who op was created. Can be NULL.
difficultydifficulty level.
max_magicmaximum magic for the item.
flags
  • GT_ENVIRONMENT: if not set, calls fix_flesh_item().
  • GT_STARTEQUIP: Sets ::FLAG_STARTEQIUP on item if appropriate, or clears the item's value.
  • GT_MINIMAL: Does minimal processing on the object - just enough to make it a working object - don't change magic, value, etc, but set it material type as appropriate, for objects that need spell objects, set those, etc

Definition at line 1070 of file treasure.c.

References add_string(), AMULET, amulet_arch, ARMOUR, BOOK, BRACERS, calc_item_power(), CHANCE_FOR_ARTIFACT, CLOAK, CONTAINER, create_archetype(), create_treasure(), crown_arch, DICE2, fix_flesh_item(), FLAG_ALIVE, FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IS_THROWN, FLAG_MONSTER, FLAG_NO_PICK, FLAG_STARTEQUIP, FREE_AND_COPY, free_object(), generate_artifact(), GET_ANIM_ID, get_power_from_ench(), GT_ENVIRONMENT, GT_MINIMAL, GT_ONLY_GOOD, GT_STARTEQUIP, HELMET, HORN, insert_ob_in_ob(), level_for_item(), llevDebug, LOG(), MAX, MONEY, NUM_ANIMATIONS, POTION, QUERY_FLAG, remove_ob(), RING, ring_arch, rndm(), ROD, RUNE, SCROLL, SET_ANIMATION, SET_FLAG, set_magic(), set_materialname(), set_ring_bonus(), SHIELD, special_potion(), SPELL, spell_mapping, SPELLBOOK, tailor_readable_ob(), TRAP, trap_adjust(), WAND, and WEAPON.

Referenced by convert_item(), create_all_treasures(), create_one_treasure(), god_gives_present(), move_creator(), and polymorph_item().

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(), arch_to_object(), free_string(), insert_ob_in_map(), llevError, and LOG().

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 fix_object ( object *  op)

Updates all abilities given by applied objects in the inventory of the given object.

This functions starts from base values (archetype or player object) and then adjusts them according to what the player/monster has equipped.

Note that a player always has stats reset to their initial value.

July 95 - inserted stuff to handle new skills/exp system - b.t. spell system split, grace points now added to system --peterm

November 2006: max armor speed is always taken into account, no exception.

Parameters:
opobject to reset.
Todo:
this function is too long, and should be cleaned / split.

Definition at line 900 of file living.c.

References add_refcount(), AMULET, ARMOUR, ARMOUR_SPEED, AT_PHYSICAL, ATNR_PHYSICAL, BOOTS, BOW, BRACERS, change_attr_value(), check_stat_bounds(), CLEAR_FLAG, CLOAK, CLOSE_CON, con_bonus, CONTAINER, dam_bonus, dex_bonus, DISEASE, esrv_update_spells(), EXPERIENCE, FLAG_APPLIED, FLAG_BLIND, FLAG_LIFESAVE, FLAG_MAKE_INVIS, FLAG_READY_WEAPON, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_UNDEAD, FLAG_USE_ARMOUR, FLAG_WIZ, FLAG_XRAYS, FORCE, free_string(), get_attr_value(), GIRDLE, GLOVES, grace_bonus, HELMET, HORN, IS_COMBAT_SKILL, IS_GRACE_SKILL, IS_MANA_SKILL, llevDebug, LOG(), MAX, max_carry, Settings::max_level, MOVE_FLY_HIGH, MOVE_FLY_LOW, MOVE_WALK, NROFATTACKS, NUM_STATS, PLAYER, POTION, POTION_EFFECT, QUERY_FLAG, range_bow, range_misc, range_skill, RING, ROD, Settings::search_items, set_attr_value(), SET_FLAG, settings, SHIELD, SK_PRAYING, SKILL, SKILL_TOOL, sp_bonus, speed_bonus, Settings::spell_encumbrance, SYMPTOM, thaco_bonus, TRUE, update_ob_speed(), WAND, WEAPON, and WEAPON_SPEED.

Referenced by animate_weapon(), apply_special(), blind_living(), blindness_type_process(), cast_bless(), cast_curse(), cfapi_object_fix(), cfapi_object_set_property(), change_abil(), check_login(), command_abil(), command_brace(), command_dropall(), command_fix_me(), command_possess(), command_search_items(), do_skill(), do_symptoms(), do_turn(), dragon_eat_flesh(), drain_specific_stat(), drop_object(), eat_special_food(), fire_bow(), fix_weight(), god_intervention(), hit_with_one_attacktype(), improve_armour(), improve_weapon_stat(), insert_ob_in_ob(), key_change_class(), kill_player(), lighter_type_apply(), pay_for_amount(), pay_for_item(), pick_up_object(), player_changer_type_process(), player_lvl_adj(), poison_living(), poisoning_type_process(), potion_type_apply(), put_object_in_sack(), remove_force(), remove_ob(), remove_symptoms(), roll_stats(), save_life(), slow_living(), stop_jump(), swap_random_stats(), swap_stat(), and unapply_special().

Here is the call 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 flag_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_anim ( void  )

Clears all animation-related memory.

Definition at line 41 of file anim.c.

References animations, free_string(), and num_animations.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_archs ( void  )

Frees all memory allocated to archetypes.

After calling this, it's possible to call again init_archetypes() to reload data.

Definition at line 298 of file arch.c.

References clear_archetable(), first_archetype, free_arch(), llevDebug, and LOG().

Referenced by cleanup(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_god ( void  )

Frees all god information.

Definition at line 142 of file holy.c.

References first_god, free_string(), llevDebug, LOG(), glnk::name, and glnk::next.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_images ( void  )

Deallocates memory allocated by read_bmap_names() and read_smooth().

Definition at line 418 of file image.c.

References bmappair::name, and nroffiles.

Referenced by cleanup().

Here is the caller graph for this function:

void free_all_maps ( void  )

Frees all allocated maps.

Definition at line 1968 of file map.c.

References delete_map(), first_map, mapdef::in_memory, llevDebug, LOG(), MAP_IN_MEMORY, and MAP_SAVING.

Referenced by cleanup().

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, free_objects, llevDebug, LOG(), nrofallocobjects, nroffreeobjects, objects, 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_all_readable ( void  )

Definition at line 2084 of file readable.c.

References titlestruct::archname, titlestruct::authour, titleliststruct::first_book, first_mon_info, free_string(), llevDebug, LOG(), titlestruct::name, linked_char::name, titlestruct::next, titleliststruct::next, and linked_char::next.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_recipes ( void  )

Frees all memory allocated to recipes and recipes lists.

Definition at line 721 of file recipe.c.

References recipestruct::arch_name, recipestruct::cauldron, formulalist, free_string(), recipestruct::ingred, recipeliststruct::items, llevDebug, LOG(), linked_char::name, recipestruct::next, recipeliststruct::next, linked_char::next, recipestruct::skill, and recipestruct::title.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_all_treasures ( void  )

Free all treasure-related memory.

Definition at line 2131 of file treasure.c.

References first_artifactlist, first_treasurelist, free_artifactlist(), free_string(), free_treasurestruct(), treasureliststruct::items, treasureliststruct::name, and treasureliststruct::next.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_arch ( archetype *  at)

Frees archetype.

Parameters:
atarchetype to free. Pointer becomes invalid after the call.

Definition at line 273 of file arch.c.

References free_key_values(), and free_string().

Referenced by free_all_archs(), and free_object2().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_dialog_information ( object *  op)

Frees obj::dialog_information.

Parameters:
opwhat to clean for.

Definition at line 39 of file dialog.c.

References CLEAR_FLAG, FLAG_DIALOG_PARSED, struct_dialog_message::match, struct_dialog_reply::message, struct_dialog_message::message, struct_dialog_reply::next, struct_dialog_message::next, QUERY_FLAG, struct_dialog_message::replies, and struct_dialog_reply::reply.

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

Here is the caller graph for this function:

void free_experience ( void  )

Frees experience-related memory.

Definition at line 269 of file exp.c.

References FREE_AND_CLEAR, and levels.

Referenced by free_globals().

Here is the caller graph for this function:

void free_globals ( void  )

Cleans all memory allocated for global variables.

Will clear: * attack messages * emergency map settings * friendly list * experience * regions

Definition at line 307 of file init.c.

References attack_mess, Settings::emergency_mapname, first_friendly_object, first_region, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_experience(), regiondef::jailmap, regiondef::longname, MAXATTACKMESS, regiondef::msg, regiondef::name, regiondef::next, NROFATTACKMESS, regiondef::parent_name, and undead_name.

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.

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

Here is the caller graph for this function:

void free_loader ( void  )

Referenced by cleanup().

Here is the caller graph for this function:

void free_map ( mapstruct m)

Frees everything allocated by the given mapstructure.

Don't free tmpname - our caller is left to do that. Mapstructure itself is not freed.

Parameters:
mmap to free.

Definition at line 1707 of file map.c.

References mapdef::background_music, mapdef::buttons, EVENT_MAPUNLOAD, execute_global_event(), free_all_objects(), FREE_AND_CLEAR, free_objectlinkpt(), mapdef::in_memory, llevError, LOG(), MAP_SWAPPED, mapdef::maplore, mapdef::msg, mapdef::name, mapdef::shopitems, mapdef::shoprace, mapdef::spaces, mapdef::tile_map, and mapdef::tile_path.

Referenced by delete_map(), START_TEST(), swap_map(), and teardown().

Here is the call graph for this function:

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 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, insert_ob_in_map(), llevDebug, llevError, llevMonster, LOG(), MAP_IN_MEMORY, MOVE_ALL, nroffreeobjects, objects, QUERY_FLAG, remove_friendly_object(), remove_ob(), RUNE, SCRIPT_FIX_NOTHING, SET_FLAG, SIZEOFFREE, stringbuffer_finish(), stringbuffer_new(), TRAP, and update_ob_speed().

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 free_objectlink ( objectlink *  ol)

Recursively frees all objectlinks.

Parameters:
olobject link to free.

Definition at line 83 of file links.c.

References free_objectlink().

Referenced by add_button_link(), free_objectlink(), and free_objectlinkpt().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_objectlinkpt ( oblinkpt *  obp)

Recursively frees all linked list of objectlink pointers.

Parameters:
obppointer to free.

Definition at line 95 of file links.c.

References free_objectlink(), and free_objectlinkpt().

Referenced by free_map(), and free_objectlinkpt().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_player ( player pl)

Clears player structure, including pointed object (through free_object()).

Parameters:
plplayer to clear. Pointer is invalid after this call.

Definition at line 68 of file player.c.

References CFREE, clear_player(), socket_struct::faces_sent, first_player, FLAG_REMOVED, free_object(), llevError, LOG(), pl::next, pl::ob, QUERY_FLAG, remove_ob(), and pl::socket.

Referenced by final_free_player().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_socket_images ( void  )

Frees all faceset information.

Definition at line 584 of file image.c.

References MAX_FACE_SETS, and nrofpixmaps.

Referenced by free_all_newserver().

Here is the caller graph for this function:

void free_string ( sstring  str)

This will reduce the refcount, and if it has reached 0, str will be freed.

Parameters:
strstring to release, which *must *have been returned from a previous add_string().
Note:
the memory pointed to by str can be freed after this call, so don't use str anymore.

Definition at line 272 of file shstr.c.

References _shared_string::array, GATHER, _shared_string::next, _shared_string::previous, _shared_string::refcount, SS, TOPBIT, and _shared_string::u.

Referenced by add_abilities(), adjust_sign_msg(), alchemy_failure_effect(), animate_bomb(), animate_weapon(), attack_ob_simple(), become_follower(), cast_bless(), cast_change_ability(), cast_create_town_portal(), cast_curse(), cfapi_system_remove_string(), change_abil(), change_book(), change_treasure(), check_output_buffers(), cone_drop(), confuse_living(), copy_object(), do_symptoms(), do_throw(), enter_player_savebed(), find_archetype_by_object_name(), find_object_name(), fire_bow(), fix_container_multipart(), fix_multipart_object(), fix_object(), flush_output_element(), free_all_anim(), free_all_god(), free_all_readable(), free_all_recipes(), free_all_treasures(), free_arch(), free_artifact(), free_races(), give_artifact_abilities(), hit_with_arrow(), identify(), infect_object(), init_races(), key_change_class(), keyplace(), kill_player(), local_check_loaded_object(), make_formula_book(), move_monster(), new_text_name(), poison_living(), set_ob_key_value(), START_TEST(), summon_golem(), tailor_god_spell(), tailor_readable_ob(), and write_note().

void generate_artifact ( object *  op,
int  difficulty 
)

Decides randomly which artifact the object should be turned into.

Makes sure that the item can become that artifact (means magic, difficulty, and Allowed fields properly). Then calls give_artifact_abilities in order to actually create the artifact.

Definition at line 1906 of file treasure.c.

References ARTIFACT_TRIES, artifactstruct::chance, FABS, find_artifactlist(), give_artifact_abilities(), artifactstruct::item, artifactliststruct::items, legal_artifact_combination(), llevDebug, llevError, LOG(), artifactstruct::next, and artifactliststruct::total_chance.

Referenced by alchemy_failure_effect(), fix_generated_item(), generate_monster_arch(), generate_monster_inv(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

archetype* get_archetype_by_skill_name ( const char *  skill,
int  type 
)

Retrieves an archetype by skill name and type.

This is a lot like the other get_archetype_ functions, with different options.

Parameters:
skillskill to search for. Must not be NULL.
typeitem type to search for. -1 means that it doesn't matter.
Returns:
matching archetype, or NULL if none found.

Definition at line 120 of file arch.c.

References first_archetype.

Referenced by give_skill_by_name(), and START_TEST().

Here is the caller graph for this function:

archetype* get_archetype_by_type_subtype ( int  type,
int  subtype 
)

Retrieves an archetype by type and subtype.

Similiar to other get_archetype_ functions. This returns the first archetype that matches both the type and subtype. type and subtype can be -1 to say ignore, but in this case, the match it does may not be very useful. This function is most useful when subtypes are known to be unique for a particular type (eg, skills)

Parameters:
typeobject type to search for. -1 means any
subtypeobject subtype to search for. -1 means any
Returns:
matching archetype, or NULL if none found.

Definition at line 149 of file arch.c.

References first_archetype.

Referenced by CREUtils::artifactNode(), become_follower(), calculate_difficulty(), START_TEST(), and write_on_item().

Here is the caller graph for this function:

archetype* get_archetype_struct ( void  )

Allocates, initialises and returns the pointer to an archetype structure.

Returns:
new archetype structure, will never be NULL.
Note:
this function will call fatal() if it can't allocate memory.

Definition at line 323 of file arch.c.

References CALLOC, CLEAR_FLAG, clear_object(), fatal(), FLAG_FREED, FLAG_REMOVED, OUT_OF_MEMORY, and SET_FLAG.

Referenced by first_arch_pass(), local_check_loaded_object(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

sint8 get_attr_value ( const living stats,
int  attr 
)

Gets the value of a stat.

Parameters:
statsitem from which to get stat.
attrattribute to get.
Returns:
specified attribute, 0 if not found.
See also:
set_attr_value().

Definition at line 377 of file living.c.

References CHA, liv::Cha, CON, liv::Con, DEX, liv::Dex, INT, liv::Int, POW, liv::Pow, STR, liv::Str, WIS, and liv::Wis.

Referenced by add_abilities(), apply_changes_to_player(), calc_item_power(), cast_change_ability(), change_abil(), check_good_weapon(), check_stat_bounds(), describe_item(), eat_special_food(), fix_object(), god_intervention(), is_magical(), kill_player(), perceive_self(), potion_type_apply(), ring_desc(), set_ring_bonus(), swap_random_stats(), and swap_stat().

Here is the caller graph for this function:

int get_button_value ( const object *  button)

Returns the first value linked to this button.

Made as a separate function to increase efficiency

Parameters:
buttonobject to check. Must not be NULL.
Returns:
connection value, or 0 if not connected.

Definition at line 756 of file button.c.

client_spell* get_client_spell_state ( player pl,
object *  spell 
)

Gets the (client-side) spell state for specified spell.

Will be created to empty state if not found.

Note:
will fatal() in case of memory allocation failure.
Parameters:
plplayer we're handling.
spellspell for which to search data.
Returns:
state information for that spell.

Definition at line 147 of file player.c.

References fatal(), client_spell::next, OUT_OF_MEMORY, client_spell::spell, and pl::spell_state.

Referenced by append_spell(), and esrv_update_spells().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_dialog_message ( object *  op,
const char *  text,
struct_dialog_message **  message,
struct_dialog_reply **  reply 
)

Tries to find a message matching the said text.

Parameters:
opwho is being talked to.
textwhat is being said.
[out]messagewhat op should say. Won't be NULL if return is 1.
[out]replytext the one talking should say based on the text. Can be NULL.
Returns:
0 if no match, 1 if a message did match the text.
Todo:
smarter match, try to find exact before joker (*) one.

Definition at line 214 of file dialog.c.

References FLAG_DIALOG_PARSED, matches(), struct_dialog_reply::next, struct_dialog_message::next, parse_dialog_information(), and QUERY_FLAG.

Referenced by do_talk_npc().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* get_empty_map ( int  sizex,
int  sizey 
)

Creates and returns a map of the specific size.

Used in random map code and the editor.

Parameters:
sizex
sizeymap size.
Returns:
new map.
Note:
will never return NULL, as get_linked_map() never fails.

Definition at line 884 of file map.c.

References allocate_map(), get_linked_map(), mapdef::height, mapdef::in_memory, MAP_SWAPPED, and mapdef::width.

Referenced by cfapi_map_get_map(), make_map_floor(), setup(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_face_fallback ( int  faceset,
int  imageno 
)

This returns the set we will actually use when sending a face.

This is used because the image files may be sparse. This function is recursive. imageno is the face number we are trying to send

If face is not found in specified faceset, tries with 'fallback' faceset.

Parameters:
facesetfaceset to check
imagenoimage number

Definition at line 614 of file image.c.

References get_face_fallback(), llevError, and LOG().

Referenced by esrv_send_face(), get_face_fallback(), process_map(), and send_image_sums().

Here is the call graph for this function:

Here is the caller graph for this function:

Gets a formula list by ingredients count.

Parameters:
inumber of ingredients.
Returns:
pointer to the formula list, or NULL if it doesn't exist.

Definition at line 112 of file recipe.c.

References formulalist, and recipeliststruct::next.

Referenced by alchemy_failure_effect(), attempt_do_alchemy(), CREResourcesWindow::fillFormulae(), get_random_recipelist(), and make_formula_book().

Here is the caller graph for this function:

object* get_jail_exit ( object *  op)

Returns an object which is an exit through which the player represented by op should be sent in order to be imprisoned.

If there is no suitable place to which an exit can be constructed, then NULL will be returned. The caller is responsible for freeing the object created by this function.

Parameters:
opObject we want to jail. Must be a player.
Returns:
exit to jail, or NULL, in which case a message is LOG()ged .

Definition at line 272 of file region.c.

References add_string(), EXIT_PATH, EXIT_X, EXIT_Y, FLAG_DAMNED, get_object(), get_region_by_map(), regiondef::jailmap, regiondef::jailx, regiondef::jaily, llevDebug, llevError, LOG(), regiondef::name, regiondef::parent, PLAYER, and SET_FLAG.

Referenced by command_arrest().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_language ( object *  op)
void get_levelnumber ( int  i,
char *  buf,
size_t  size 
)

Formats a level.

Parameters:
ilevel to format.
[out]bufbuffer which will contain the level.
sizesize of the buffer.

Definition at line 444 of file item.c.

References levelnumbers, levelnumbers_10, numbers_10, and snprintf().

Referenced by examine(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

Allocates, initialises, and returns a pointer to a mapstruct.

Modified to no longer take a path option which was not being used anyways. MSW 2001-07-01

Returns:
new structure.
Note:
will never return NULL, but call fatal() if memory error.

Definition at line 816 of file map.c.

References fatal(), first_map, mapdef::in_memory, mapdef::last_reset_time, MAP_ENTER_X, MAP_ENTER_Y, MAP_HEIGHT, MAP_RESET_TIMEOUT, MAP_SWAPPED, MAP_TIMEOUT, MAP_WIDTH, mapdef::next, and OUT_OF_MEMORY.

Referenced by get_empty_map(), load_original_map(), and read_map_log().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_map_flags ( mapstruct oldmap,
mapstruct **  newmap,
sint16  x,
sint16  y,
sint16 nx,
sint16 ny 
)

This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.

. value (see map.h) it will also do map translation for tiled maps, returning new values into newmap, nx, and ny. Any and all of those values can be null, in which case if a new map is needed (returned by a P_NEW_MAP value, another call to get_map_from_coord is needed. The case of not passing values is if we're just checking for the existence of something on those spaces, but don't expect to insert/remove anything from those spaces.

Parameters:
oldmapmap for which we want information.
newmapif not NULL, will contain the actual map checked if not oldmap.
x
ycoordinates to check
nx
nyif not NULL, will contain the actual coordinates checked.
Returns:
flags for specified position, with maybe P_OUT_OF_MAP or P_NEW_MAP set.

Definition at line 330 of file map.c.

References MapSpace::flags, get_map_from_coord(), out_of_map(), P_NEW_MAP, P_OUT_OF_MAP, mapdef::spaces, and mapdef::width.

Referenced by alchemy(), animate_weapon(), armour_improver_type_apply(), attempt_jump(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_destruction(), cast_detection(), cast_earth_to_dust(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_spell(), cast_transfer(), cfapi_map_get_map_property(), cfapi_map_get_object_at(), check_bullet(), check_infection(), check_wall(), command_save(), common_process_projectile(), communicate(), counterspell(), create_bomb(), dimension_door(), dispel_rune(), do_harvest(), do_skill_ident(), do_throw(), draw_client_map(), execute_word_of_recall(), expand_lighted_sight(), expand_sight(), find_dir(), find_multi_free_spot_within_radius(), find_nearest_living_creature(), find_target_for_friendly_spell(), find_traps(), fire_arch_from_position(), fire_bolt(), fire_bow(), fire_bullet(), forklightning(), get_pet_enemy(), get_pointed_target(), hideability(), hit_map(), magic_mapping_mark(), magic_mapping_mark_recursive(), magic_wall(), mood_change(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_golem(), move_missile(), move_ob(), move_player_mover(), move_swarm_spell(), npc_call_help(), ob_blocked(), ok_to_put_more(), path_to_player(), pet_move(), pick_arrow_target(), probe(), process_players1(), remove_adjacent_doors(), remove_trap(), roll_ob(), singing(), skill_attack(), spell_failure(), spell_find_dir(), stand_in_light(), stand_near_hostile(), steal(), teleport(), try_fit(), use_oratory(), weapon_improver_type_apply(), and write_rune().

Here is the call graph for this function:

mapstruct* get_map_from_coord ( mapstruct m,
sint16 x,
sint16 y 
)

This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coordinates out of bounds and no tiled map), otherwise it returns the map as that the coordinates are really on, and updates x and y to be the localized coordinates.

Using this is more efficient of calling out_of_map and then figuring out what the real map is

Parameters:
mmap we want to look at.
x
ycoordinates, which will contain the real position that was checked.
Returns:
map that is at specified location. Should not be NULL.

Definition at line 2366 of file map.c.

References get_map_from_coord(), mapdef::in_memory, load_and_link_tiled_map(), MAP_HEIGHT, MAP_IN_MEMORY, MAP_WIDTH, mapdef::tile_map, and mapdef::tile_path.

Referenced by cfapi_map_get_map(), draw_client_map2(), follow_owner(), get_map_flags(), get_map_from_coord(), insert_ob_in_map(), look_at(), monster_use_bow(), move_ob(), move_player_attack(), pet_move(), remove_ob(), and summon_object().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* get_month_name ( const int  index)

give access to month names

Definition at line 120 of file time.c.

References month_name, and MONTHS_PER_YEAR.

Referenced by cfapi_get_month_name(), and START_TEST().

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.

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:

const char* get_name_of_region_for_map ( const mapstruct m)

Gets the name of a region for a map.

Since we won't assume all maps have a region set properly, we need an explicit check that it is, this is much nicer here than scattered throughout the map code.

Parameters:
mmap
Returns:
  • region's name if map has a region
  • if no region is set for the map, returns the first region with the 'fallback' property
  • if no fallback region, LOG()s an info message and returns "unknown".

Definition at line 103 of file region.c.

References regiondef::fallback, first_region, llevInfo, LOG(), regiondef::name, mapdef::name, regiondef::next, and mapdef::region.

Referenced by current_region_info(), get_region_by_map(), and get_who_escape_code_value().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Referenced by add_one_item(), command_diff(), dump_object(), and START_TEST().

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.

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

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  )
objectlink* get_objectlink ( void  )

Allocates a new objectlink structure, initialises it, and returns a pointer to it.

Note:
will call fatal() if memory allocation failure, thus never return NULL.
Returns:
new link object, cleared.

Definition at line 45 of file links.c.

References CALLOC, fatal(), and OUT_OF_MEMORY.

Referenced by add_button_link(), add_friendly_object(), add_to_racelist(), and get_racelist().

Here is the call graph for this function:

Here is the caller graph for this function:

oblinkpt* get_objectlinkpt ( void  )

Allocates a new oblinkpt structure, initialises it, and returns a pointer to it.

Note:
will call fatal() if memory allocation failure, thus never return NULL.
Returns:
new link pointer.

Definition at line 65 of file links.c.

References fatal(), and OUT_OF_MEMORY.

Referenced by add_button_link().

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 FLAG_FREED, FLAG_REMOVED, llevError, LOG(), 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:

const char* get_periodofday ( const int  index)

give access to weekday names

Definition at line 113 of file time.c.

References PERIODS_PER_DAY, and periodsofday.

Referenced by cfapi_get_periodofday_name().

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

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:

int get_power_from_ench ( int  ench)

Definition at line 240 of file item.c.

Referenced by calc_item_power(), and fix_generated_item().

Here is the caller graph for this function:

godlink* get_rand_god ( void  )

Returns a random god.

Returns:
a random god, or NULL if no god was found.

Definition at line 111 of file holy.c.

References first_god, glnk::id, llevError, LOG(), and glnk::next.

Referenced by god_info_msg().

Here is the call graph for this function:

Here is the caller graph for this function:

object* get_random_mon ( int  level)

Returns a random monster selected from linked list of all monsters in the current game.

Changed 971225 to be greater than equal to level passed. Also made choosing by level more random.

Parameters:
levelif non-zero, then only monsters greater than that level will be returned.
Returns:
random monster, or NULL if failure.

Definition at line 1316 of file readable.c.

References first_mon_info, llevError, LOG(), mon, and nrofmon.

Referenced by alchemy_failure_effect(), and mon_info_msg().

Here is the call graph for this function:

Here is the caller graph for this function:

Gets a random recipe from a list, based on chance.

Parameters:
rplrecipelist we want a recipe from. Can be NULL in which case a random one is selected.
Returns:
random recipe. Can be NULL if recipelist has a total_chance of 0.

Definition at line 697 of file recipe.c.

References recipestruct::chance, get_random_recipelist(), recipeliststruct::items, recipestruct::next, and recipeliststruct::total_chance.

Referenced by alchemy_failure_effect().

Here is the call graph for this function:

Here is the caller graph for this function:

void get_rangevector ( object *  op1,
const object *  op2,
rv_vector retval,
int  flags 
)

From map.c This is used by get_player to determine where the other creature is.

get_rangevector takes into account map tiling, so you just can not look the the map coordinates and get the right value. distance_x/y are distance away, which can be negative. direction is the crossfire direction scheme that the creature should head. part is the part of the monster that is closest.

get_rangevector looks at op1 and op2, and fills in the structure for op1 to get to op2. We already trust that the caller has verified that the two objects are at least on adjacent maps. If not, results are not likely to be what is desired. if the objects are not on maps, results are also likely to be unexpected

Parameters:
op1object which wants to go to op2's location.
op2target of op1.
retvalvector for op1 to go to op2.
flagsif 1, don't translate for closest body part of 'op1'

Definition at line 2504 of file map.c.

References adjacent_map(), rv_vector::direction, rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, find_dir_2(), isqrt(), and rv_vector::part.

Referenced by can_detect_enemy(), can_hit(), find_enemy(), flee_player(), get_pet_enemy(), monster_cast_spell(), monster_use_bow(), monster_use_scroll(), move_monster(), path_to_player(), player_can_view(), process_players1(), and spring_trap().

Here is the call graph for this function:

Here is the caller graph for this function:

void get_rangevector_from_mapcoord ( const mapstruct m,
int  x,
int  y,
const object *  op2,
rv_vector retval,
int  flags 
)

This is basically the same as get_rangevector() above, but instead of the first parameter being an object, it instead is the map and x,y coordinates - this is used for path to player - since the object is not infact moving but we are trying to traverse the path, we need this.

flags has no meaning for this function at this time - I kept it in to be more consistant with the above function and also in case they are needed for something in the future. Also, since no object is pasted, the best field of the rv_vector is set to NULL.

Parameters:
mmap to consider.
x
yorigin coordinates.
op2target object.
retvalvector to get to op2.
flagsunused.

Definition at line 2573 of file map.c.

References adjacent_map(), rv_vector::direction, rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, find_dir_2(), isqrt(), and rv_vector::part.

Referenced by path_to_player().

Here is the call graph for this function:

Here is the caller graph for this function:

const readable_message_type* get_readable_message_type ( object *  readable)

Get the readable type for an object (hopefully book).

Parameters:
readableobject for which we want the readable type.
Returns:
type of the book. Will never be NULL.

Definition at line 2181 of file readable.c.

References last_readable_subtype.

Referenced by apply_sign(), and book_type_apply().

Here is the caller graph for this function:

Gets a region from a map.

Parameters:
mmap we want the region of.
Returns:
region.
Todo:
This might need optimising at some point.

Definition at line 85 of file region.c.

References get_name_of_region_for_map(), and get_region_by_name().

Referenced by add_region_link(), cfapi_map_get_map_property(), command_whereabouts(), current_map_info(), enter_random_map(), enter_random_template_map(), get_jail_exit(), get_who_escape_code_value(), list_players(), and process_map().

Here is the call graph for this function:

Here is the caller graph for this function:

region* get_region_by_name ( const char *  region_name)

Gets a region by name.

Used by the map parsing code.

Parameters:
region_namename of region.
Returns:
  • matching region
  • if no match, returns the first region with the 'fallback' property set and LOG()s to debug.
  • if it can't find a matching name and a fallback region it LOG()s an info message and returns NULL.

Definition at line 57 of file region.c.

References regiondef::fallback, first_region, llevDebug, llevInfo, LOG(), regiondef::name, and regiondef::next.

Referenced by assign_region_parents(), current_region_info(), get_region_by_map(), and load_map_header().

Here is the call graph for this function:

Here is the caller graph for this function:

region* get_region_from_string ( const char *  name)

Tries to find a region that 'name' corresponds to.

It looks, in order, for:

  • an exact match to region name (case insensitive)
  • an exact match to longname (case insensitive)
  • a substring that matches to the longname (eg Kingdom)
  • a substring that matches to the region name (eg nav)
  • if it can find none of these it returns the first parentless region (there should be only one of these - the top level one) If we got a NULL, then just return the top level region
Parameters:
nameregion we're searching. Can be NULL.
Returns:
matching region.

Definition at line 132 of file region.c.

References first_region, regiondef::longname, regiondef::name, regiondef::next, regiondef::parent, and strcasecmp().

Referenced by command_who().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* get_region_longname ( const region r)

Gets the longname of a region.

The longname of a region is not a required field, any given region may want to not set it and use the parent's one instead.

Parameters:
rregion we're searching the longname.
Returns:
  • if a longname is set return it.
  • if there is a parent, call the function against that
  • if all fails, return a obviously wrong string if we can't get a longname, this should never happen. We also LOG() a debug message.

Definition at line 229 of file region.c.

References get_region_longname(), llevDebug, LOG(), regiondef::longname, regiondef::name, and regiondef::parent.

Referenced by command_whereabouts(), current_map_info(), current_region_info(), get_region_longname(), get_who_escape_code_value(), write_map_page(), write_region_index(), and write_region_page().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* get_region_msg ( const region r)

Gets a message for a region.

Parameters:
rregion. Can't be NULL.
Returns:
  • region's message if set
  • message of parent else
  • obviously wrong message if no parent, and we LOG() a debug message.

Definition at line 250 of file region.c.

References get_region_msg(), llevDebug, LOG(), regiondef::msg, regiondef::name, and regiondef::parent.

Referenced by current_region_info(), get_region_msg(), and write_region_page().

Here is the call graph for this function:

Here is the caller graph for this function:

Allocates and zeros a region struct, this isn't free()'d anywhere, so might be a memory leak, but it shouldn't matter too much since it isn't called that often....

Returns:
initialised region structure.
Note:
will never fail, as a memory allocation error calls fatal().
Todo:
free those pointers someday? :)

Definition at line 336 of file region.c.

References CALLOC, fatal(), and OUT_OF_MEMORY.

Referenced by main(), and parse_regions().

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

const char* get_season_name ( const int  index)

give access to season names

Definition at line 134 of file time.c.

References season_name, and SEASONS_PER_YEAR.

Referenced by cfapi_get_season_name(), and START_TEST().

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

void get_tod ( timeofday_t tod)

Computes the ingame time of the day.

Parameters:
[out]todwhere to store information. Must not be NULL.

Definition at line 268 of file time.c.

const typedata* get_typedata ( int  itemtype)
Parameters:
itemtypeitem type for which to return typedata.
Returns:
typedata that has a number equal to itemtype, if there isn't one, returns NULL

Definition at line 352 of file item.c.

References item_types_size.

Referenced by CREResourcesWindow::fillArtifacts(), parse_shop_string(), query_cost(), query_cost_string(), and CREFacePanel::setFace().

Here is the caller graph for this function:

const typedata* get_typedata_by_name ( const char *  name)
Parameters:
nameitem name for which to return typedata. Singular form is preferred.
Returns:
typedata that has a name equal to itemtype, if there isn't one, return the plural name that matches, if there still isn't one return NULL
Note:
will emit an Info if found by plural form.

Definition at line 372 of file item.c.

References item_types_size, llevInfo, and LOG().

Referenced by parse_shop_string().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* get_weekday ( const int  index)

give access to weekday names

Definition at line 127 of file time.c.

References DAYS_PER_WEEK, and weekdays.

Referenced by cfapi_get_weekday_name(), and START_TEST().

Here is the caller graph for this function:

void give_artifact_abilities ( object *  op,
object *  artifact 
)

Fixes the given object, giving it the abilities and titles it should have due to the second artifact-template.

Definition at line 1884 of file treasure.c.

References add_abilities(), add_string(), free_string(), MAX_BUF, and snprintf().

Referenced by cast_create_missile(), command_create(), generate_artifact(), and make_item_from_recipe().

Here is the call graph for this function:

Here is the caller graph for this function:

object* give_skill_by_name ( object *  op,
const char *  skill_name 
)

Given the skill name skill_name, we find the skill archetype/object, set appropriate values, and insert it into the object (op) that is passed.

We return the skill - this makes it easier for calling functions that want to do something with it immediately.

Parameters:
opobject to which to give the skill. Must not be NULL.
skill_nameskill to give. Must not be NULL.
Returns:
newly created skill, or NULL if failure (logger with error level).
Note:
this doesn't check whether the object already has the skill or not.

Definition at line 1689 of file living.c.

References arch_to_object(), CLEAR_FLAG, FLAG_CAN_USE_SKILL, get_archetype_by_skill_name(), insert_ob_in_ob(), llevError, LOG(), and SKILL.

Referenced by add_player_exp(), adjust_skill_tool(), become_follower(), cfapi_object_give_skill(), do_skill(), food_type_apply(), and learn_skill().

Here is the call graph for this function:

Here is the caller graph for this function:

int has_ability ( const object *  ob)

Checks whether object has innate abilities (spell/spellbook in inventory).

Returns:
1 if monster has any innate abilities, 0 else

Definition at line 151 of file exp.c.

References FALSE, SPELL, SPELLBOOK, and TRUE.

Referenced by new_exp().

Here is the caller graph for this function:

mapstruct* has_been_loaded ( const char *  name)

Checks whether map has been loaded.

Parameters:
namepath of the map to search. Can be NULL.
Returns:
the mapstruct which has a name matching the given argument. return NULL if no match is found.

Definition at line 87 of file map.c.

References first_map, mapdef::next, and mapdef::path.

Referenced by cfapi_map_has_been_loaded(), command_reset(), is_legal_2ways_exit(), and ready_map_name().

Here is the caller graph for this function:

int has_carried_lights ( const object *  op)

Checks if op has a light source.

Parameters:
opobject being checked.
Returns:
true if op carries one or more lights
Note:
This is a trivial function now days, but it used to be a bit longer. Probably better for callers to just check the op->glow_radius instead of calling this.

Definition at line 322 of file los.c.

Referenced by can_see_enemy(), and hideability().

Here is the caller graph for this function:

void i18n_init ( void  )

Initializes the i18n subsystem.

Definition at line 108 of file languages.c.

References convert_newline(), Settings::datadir, HUGE_BUF, i18n_strings, language_codes, llevDebug, llevError, LOG(), MAX_BUF, NUM_LANGUAGES, settings, snprintf(), and strerror_local().

Referenced by init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* i18n_translate ( int  language,
int  id 
)
void identify ( object *  op)

Identifies an item.

Supposed to fix face-values as well here, but later.

Parameters:
opitem to identify. Can be already identified without ill effects.

Definition at line 1447 of file item.c.

References add_refcount(), CLEAR_FLAG, esrv_update_item(), FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_KNOWN_BLESSED, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLAG_NO_SKILL_IDENT, free_string(), get_player_container(), PLAYER, POTION, present(), QUERY_FLAG, SET_FLAG, UPD_ALL, UPD_FACE, UPD_NAME, and update_object().

Referenced by auto_apply(), cast_identify(), cfapi_object_identify(), do_skill_ident2(), identify_altar_type_move_on(), potion_type_apply(), scroll_type_apply(), sell_item(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_anim ( void  )

Loads the lib/animations file.

Can be called multiple times without ill effects.

Definition at line 55 of file anim.c.

References add_string(), animations, animations_allocated, Settings::datadir, animations_struct::faces, animations_struct::facings, find_face(), llevDebug, llevError, LOG(), MAX_ANIMATIONS, MAX_BUF, animations_struct::name, animations_struct::num, animations_struct::num_animations, num_animations, settings, snprintf(), and strerror_local().

Referenced by cctk_init_std_archetypes(), and init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_archetype_pointers ( void  )

Initialize global archtype pointers:

Definition at line 66 of file treasure.c.

References amulet_arch, crown_arch, find_archetype(), ring_arch, staff_arch, and warn_archetypes.

Referenced by init_beforeplay().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_archetypes ( void  )

Initialises the internal linked list of archetypes (read from file).

Then the global empty_archetype pointer is initialised. Can be called multiple times, will just return.

Definition at line 195 of file arch.c.

References arch_init, empty_archetype, find_archetype(), first_archetype, and load_archetypes().

Referenced by cctk_init_std_archetypes(), init_beforeplay(), init_library(), main(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_artifacts ( void  )
void init_block ( void  )

initialises the array used by the LOS routines.

Since we are only doing the upper left quadrant, only these spaces could possibly get blocked, since these are the only ones further out that are still possibly in the sightline.

Definition at line 102 of file los.c.

References FABS, blstr::index, MAP_CLIENT_X, MAP_CLIENT_Y, set_block(), and SPACE_BLOCK.

Referenced by cctk_init_std_archetypes(), and init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_experience ( void  )

This loads the experience table from the exp_table file.

This tends to exit on any errors, since it populates the table as it goes along, so if there are errors, the table is likely in an inconsistent state.

Note:
will call exit() if file is invalid or not found.

Definition at line 170 of file exp.c.

References close_and_delete(), Settings::confdir, levels, llevDebug, llevError, LOG(), MAX_BUF, Settings::max_level, open_and_uncompress(), settings, snprintf(), and strncasecmp().

Referenced by init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_formulae ( void  )
void init_globals ( void  )

Initialises all global variables.

Might use environment-variables as default for some of them.

Setups logfile, and such variables.

Definition at line 263 of file init.c.

References add_string(), amulet_arch, animations, animations_allocated, exiting, first_archetype, first_artifactlist, first_friendly_object, first_map, first_map_ext_path, first_player, first_treasurelist, init_defaults(), logfile, Settings::logfilename, nrofallowedstr, nrofartifacts, nroftreasures, num_animations, ring_arch, staff_arch, statistics, trying_emergency_save, undead_name, and warn_archetypes.

Referenced by cctk_init_std_archetypes(), init_library(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_gods ( void  )

This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD)

Definition at line 63 of file holy.c.

References add_god_to_list(), first_archetype, GOD, llevDebug, and LOG().

Referenced by init_beforeplay(), main(), and setup().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_hash_table ( void  )

Initialises the hash-table used by the shared string library.

Definition at line 47 of file shstr.c.

References hash_table, and TABLESIZE.

Referenced by cctk_init_std_archetypes(), init_library(), and setup().

Here is the caller graph for this function:

void init_library ( void  )

It is vital that init_library() is called by any functions using this library.

If you want to lessen the size of the program using the library, you can replace the call to init_library() with init_globals() and init_function_pointers(). Good idea to also call init_vars and init_hash_table if you are doing any object loading.

Definition at line 201 of file init.c.

References i18n_init(), init_anim(), init_archetypes(), init_attackmess(), init_block(), init_clocks(), init_dynamic(), init_emergency_mappath(), init_environ(), init_experience(), init_globals(), init_hash_table(), init_objects(), init_vars(), read_bmap_names(), and read_smooth().

Referenced by init(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_ob_method_struct ( ob_methods methods,
ob_methods fallback 
)

Initializes a ob_methods struct.

Make sure this always matches ob_methods.h

Parameters:
methodsob_method structure to initialize
fallbackDefault fallback for the ob_method

Definition at line 49 of file ob_types.c.

References ob_methods::apply, ob_methods::describe, ob_methods::fallback, ob_methods::move_on, ob_methods::process, and ob_methods::trigger.

Referenced by init_ob_methods(), and init_ob_types().

Here is the caller graph for this function:

void init_ob_types ( ob_methods base_type)

Initializes the object system.

Parameters:
base_typebase type to use as a base for all types.
Todo:
when migration is complete, the parameter should go, and this function should be called from init_library() instead of init_ob_methods() in server/ob_methods.c.

Definition at line 66 of file ob_types.c.

References init_ob_method_struct(), and OBJECT_TYPE_MAX.

Referenced by init_ob_methods().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_objects ( void  )

Sets up and initialises the linked list of free and used objects.

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

Definition at line 347 of file init.c.

References active_objects, FLAG_FREED, FLAG_REMOVED, free_objects, objarray, objects, SET_FLAG, and STARTMAX.

Referenced by cctk_init_std_archetypes(), and init_library().

Here is the caller graph for this function:

void init_readable ( void  )

Initialize linked lists utilized by message functions in tailor_readable_ob()

This is the function called by the main routine to initialize all the readable information.

Definition at line 952 of file readable.c.

References init_book_archive(), init_mon_info(), init_msgfile(), llevDebug, and LOG().

Referenced by init_beforeplay(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_regions ( void  )

Initialises regions from the regions file.

Definition at line 301 of file region.c.

References assign_region_parents(), close_and_delete(), Settings::datadir, first_region, llevDebug, llevError, LOG(), Settings::mapdir, MAX_BUF, open_and_uncompress(), parse_regions(), Settings::regions, settings, and snprintf().

Referenced by init_beforeplay(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_vars ( void  )

Referenced by cctk_init_std_archetypes(), and init_library().

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 can_merge(), check_move_on(), CLEAR_FLAG, 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, insert_ob_in_map(), LAMP, llevError, LOG(), MAP_DARKNESS, merge_spell(), MOVE_FLY_HIGH, MOVE_FLY_LOW, out_of_map(), OUT_OF_REAL_MAP, PLAYER, QUERY_FLAG, remove_ob(), SET_MAP_OB, SET_MAP_TOP, SPELL_EFFECT, stringbuffer_finish(), stringbuffer_new(), update_all_los(), and update_object().

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

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 add_weight(), can_merge(), CLEAR_FLAG, CONTAINER, dump_object(), esrv_send_item(), fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_OBJ_ORIGINAL, FLAG_REMOVED, free_object(), get_player_container(), increase_ob_nr(), llevDebug, llevError, LOG(), MAP_DARKNESS, P_NEED_UPDATE, QUERY_FLAG, SET_FLAG, SET_MAP_FLAGS, SKILL, stringbuffer_finish(), stringbuffer_new(), update_all_los(), and update_position().

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 is_dragon_pl ( const object *  op)

Checks if player is a dragon.

Parameters:
opplayer to check. Can be NULL.
Returns:
TRUE if the adressed object 'ob' is a player of the dragon race.

Definition at line 125 of file player.c.

References PLAYER.

Referenced by check_login(), command_resistances(), command_title(), describe_item(), describe_monster(), dragon_eat_flesh(), find_best_player_hth_skill(), food_type_apply(), perceive_self(), and player_lvl_adj().

Here is the caller graph for this function:

int is_friendly ( const object *  op)

Checks if the given object is already in the friendly list or not Lauwenmark - 31/07/05.

Parameters:
opitem to check
Returns:
1 if on friendly list, 0 else

Definition at line 157 of file friend.c.

References first_friendly_object.

Referenced by add_friendly_object(), cfapi_object_get_property(), and cfapi_object_set_property().

Here is the caller graph for this function:

int is_magical ( const object *  op)

Checks whether object is magical.

A magical item is one that increases/decreases any abilities, provides a resistance, has a generic magical bonus, or is an artifact.

Parameters:
opitem to check.
Returns:
true if the item is magical.

Definition at line 1312 of file item.c.

References AMULET, ARMOUR, ATNR_PHYSICAL, BOOTS, FLAG_ALIVE, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_STEALTH, FLAG_XRAYS, get_attr_value(), GIRDLE, GLOVES, HELMET, NROFATTACKS, NUM_STATS, POTION, POWER_CRYSTAL, QUERY_FLAG, RING, ROD, SCROLL, SHIELD, SPELLBOOK, and WAND.

Referenced by cast_detection(), cfapi_object_get_property(), do_skill_detect_magic(), query_base_name(), and query_short_name().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_old_wraith_pl ( object *  op)

Checks if player is a wraith without the 'wraith feed' skill.

Parameters:
opplayer to check.
Returns:
true if the adressed object 'ob' is an old wraith player, false else.

Definition at line 192 of file player.c.

References is_wraith_pl(), and PLAYER.

Referenced by food_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_valid_faceset ( int  fsn)

Checks specified faceset is valid.

Parameters:
fsnfaceset number

Definition at line 575 of file image.c.

int is_wraith_pl ( object *  op)

Tests if a player is a wraith.

Parameters:
opplayer to check.
Returns:
true if the adressed object 'ob' is a wraith player, false else.

Definition at line 173 of file player.c.

References PLAYER.

Referenced by eat_special_food(), food_type_apply(), hit_with_one_attacktype(), and is_old_wraith_pl().

Here is the caller graph for this function:

int isqrt ( int  n)

Computes the square root.

Based on (n+1)^2 = n^2 + 2n + 1 given that 1^2 = 1, then 2^2 = 1 + (2 + 1) = 1 + 3 = 4 3^2 = 4 + (4 + 1) = 4 + 5 = 1 + 3 + 5 = 9 4^2 = 9 + (6 + 1) = 9 + 7 = 1 + 3 + 5 + 7 = 16 ... In other words, a square number can be express as the sum of the series n^2 = 1 + 3 + ... + (2n-1)

Parameters:
nnumber of which to compute the root.
Returns:
square root.

Definition at line 573 of file porting.c.

Referenced by expand_lighted_sight(), find_ingred_cost(), fix_flesh_item(), get_rangevector(), get_rangevector_from_mapcoord(), play_sound_map(), roguelike_place_room(), spell_failure(), stand_in_light(), and value_limit().

Here is the caller 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 FLAG_CURSED, FLAG_DAMNED, FLAG_INV_LOCKED, FLAG_KNOWN_CURSED, FLAG_UNPAID, HUGE_BUF, MAX_BUF, PLAYER, query_base_name(), QUERY_FLAG, query_name(), query_short_name(), strcasecmp(), and strncasecmp().

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:

int legal_artifact_combination ( object *  op,
artifact art 
)

Checks if op can be combined with art.

Definition at line 1849 of file treasure.c.

References artifactstruct::allowed, llevDebug, LOG(), linked_char::name, and linked_char::next.

Referenced by generate_artifact(), and locate_recipe_artifact().

Here is the call graph for this function:

Here is the caller graph for this function:

sint64 level_exp ( int  level,
double  expmul 
)

Returns how much experience is needed for a player to become the given level.

level should really never exceed max_level

Parameters:
levellevel player wants to reach
expmulpenality/bonus for experience.

Definition at line 1788 of file living.c.

References levels, Settings::max_level, and settings.

Referenced by calculate_difficulty(), command_statistics(), place_monsters(), player_lvl_adj(), and show_skills().

Here is the caller graph for this function:

int lex_load ( int *  depth,
object **  items,
int  maxdepth,
int  map_flags,
int  linemode 
)
int load_object ( FILE *  fp,
object *  op,
int  bufstate,
int  map_flags 
)

Referenced by check_login(), first_arch_pass(), init_artifacts(), load_objects(), load_unique_objects(), and second_arch_pass().

Here is the caller graph for this function:

mapstruct* load_original_map ( const char *  filename,
int  flags 
)

Opens the file "filename" and reads information about the map from the given file, and stores it in a newly allocated mapstruct.

A pointer to this structure is returned, or NULL on failure. flags correspond to those in map.h. Main ones used are MAP_PLAYER_UNIQUE, in which case we don't do any name changes, and

Parameters:
filenamemap path.
flagshow to interpret the path, and misc information (can be combined):
  • MAP_PLAYER_UNIQUE: this is a unique map, path isn't changed
  • MAP_OVERLAY: map is an overlay
  • MAP_BLOCK: we block on this load. This happens in all cases, no matter if this flag is set or not.
  • MAP_STYLE: style map - don't add active objects, don't add to server managed map list.
Returns:
loaded map, or NULL if failure.

Definition at line 1226 of file map.c.

References allocate_map(), calculate_difficulty(), close_and_delete(), mapdef::compressed, create_overlay_pathname(), create_pathname(), delete_map(), EVENT_MAPLOAD, execute_global_event(), get_linked_map(), mapdef::in_memory, llevDebug, llevError, load_map_header(), load_objects(), LOG(), MAP_BLOCK, MAP_DIFFICULTY, MAP_IN_MEMORY, MAP_LOADING, MAP_OVERLAY, MAP_PLAYER_UNIQUE, MAP_STYLE, MAX_BUF, open_and_uncompress(), mapdef::path, set_map_reset_time(), snprintf(), strerror_local(), and update_buttons().

Referenced by enter_fixed_template_map(), enter_unique_map(), load_overlay_map(), load_style_map(), load_temporary_map(), and ready_map_name().

Here is the call graph for this function:

Here is the caller graph for this function:

artifact* locate_recipe_artifact ( const recipe rp,
size_t  idx 
)

Finds an artifact for a recipe.

Parameters:
rprecipe
idxindex of ingredient in recipe.
Returns:
artifact, or NULL if not found.

Definition at line 637 of file recipe.c.

References recipestruct::arch_name, create_archetype(), find_artifactlist(), free_object(), artifactstruct::item, artifactliststruct::items, legal_artifact_combination(), artifactstruct::next, and recipestruct::title.

Referenced by check_recipe(), dump_alchemy(), dump_alchemy_costs(), and make_item_from_recipe().

Here is the call graph for this function:

Here is the caller graph for this function:

void LOG ( LogLevel  logLevel,
const char *  format,
  ... 
)

Logs a message to stderr, or to file.

Or discards the message if it is of no importance, and none have asked to hear messages of that logLevel.

See include/logger.h for possible logLevels. Messages with llevInfo and llevError are always printed, regardless of debug mode.

Parameters:
logLevellevel of the message
formatmessage to log. Works like printf() and such

Definition at line 63 of file logger.c.

References clean_tmp_files(), Settings::debug, emergency_save(), exiting, llevError, llevInfo, LOG(), Settings::log_timestamp, Settings::log_timestamp_format, logfile, Settings::logfilename, loglevel_names, MAX_ERRORS, nroferrors, reopen_logfile, settings, TRUE, trying_emergency_save, and vsnprintf.

Referenced by add_abilities(), add_book(), add_book_to_list(), add_button_link(), add_friendly_object(), add_god_to_list(), add_score(), add_to_buffer(), adj_attackroll(), alchemy_failure_effect(), allocate_map(), animate_object(), animate_weapon(), CREUtils::animationNode(), append_spell(), apply_builder_remove(), apply_cmd(), apply_container(), apply_map_builder(), apply_special(), arch_to_object(), arrow_type_process(), artifact_msg(), assign_region_parents(), attempt_do_alchemy(), attempt_recipe(), block_until_new_connection(), blocked_link(), calc_alch_danger(), calc_skill_exp(), can_detect_enemy(), can_pay(), cast_cone(), cast_consecrate(), cast_create_missile(), cast_create_town_portal(), cast_dust(), cast_light(), cast_spell(), cast_wonder(), cast_word_of_recall(), cfapi_log(), cfapi_object_delete(), cfapi_object_insert(), cfapi_object_remove(), change_attr_value(), change_book(), change_exp(), change_luck(), change_object(), check_altar_sacrifice(), check_faceset_fallback(), check_formulae(), check_login(), check_recipe(), check_special_prayers(), check_spells(), check_treasurelist(), check_trigger(), check_weapon_power(), checkbanned(), checkdm(), choose_cult_monster(), clean_friendly_list(), clean_tmp_files(), cleanup(), command_arrest(), command_banish(), command_create(), command_help(), command_loadplugin(), command_pickup(), command_reset(), command_unloadplugin(), command_use(), command_whereabouts(), common_ob_move_on(), common_pre_ob_move_on(), common_process_projectile(), communicate(), compile_info(), content_recipe_value(), convert_item(), copy_file(), create_one_treasure(), create_treasure(), dead_player(), deathstrike_living(), deep_swamp_type_process(), delete_map(), determine_holy_arch(), die_roll(), display_high_score(), display_who_entry(), do_forget_spell(), do_harvest(), do_learn_spell(), do_server(), do_skill(), do_skill_attack(), do_throw(), dragon_ability_gain(), drain_specific_stat(), draw_client_map(), draw_ext_info(), draw_magic_map(), dump_alchemy(), dump_alchemy_costs(), dump_all_archetypes(), dump_all_objects(), dump_friendly_objects(), dump_map(), emergency_save(), enter_exit(), enter_fixed_template_map(), enter_map(), enter_player_savebed(), enter_unique_map(), esrv_add_spells(), esrv_draw_look(), esrv_move_object(), esrv_remove_spell(), esrv_send_animation(), esrv_send_face(), esrv_update_item(), esrv_update_stats(), examine_cmd(), execute_event(), execute_newserver_command(), expand_lighted_sight(), explode_bullet(), find_animation(), find_archetype(), find_color(), find_doors_in_room_recursive(), find_mon_throw_ob(), find_nearest_living_creature(), find_recipe(), find_throw_ob(), find_title(), find_transmution_ob(), find_treasurelist(), fire_bow(), fire_misc_object(), fix_flesh_item(), fix_generated_item(), fix_multipart_object(), fix_object(), fix_weight(), flee_player(), flush_old_maps(), follow_owner(), follower_level_to_enchantments(), food_type_apply(), forbid_play(), free_all_archs(), free_all_god(), free_all_maps(), free_all_newserver(), free_all_object_data(), free_all_objects(), free_all_readable(), free_all_recipes(), free_map(), free_newsocket(), free_object2(), free_player(), free_races(), free_style_maps(), gate_type_process(), generate_artifact(), generate_monster_arch(), generate_monster_inv(), generate_treasure(), get_attack_mode(), get_face_fallback(), get_jail_exit(), get_name_of_region_for_map(), get_nearest_player(), get_object(), get_owner(), get_party_password(), get_player_archetype(), get_rand_god(), get_random_mon(), get_random_recipelist(), get_region_by_name(), get_region_longname(), get_region_msg(), get_split_ob(), get_titlelist(), get_typedata_by_name(), give_initial_items(), give_skill_by_name(), god_enchants_weapon(), god_info_msg(), god_intervention(), handle_client(), hit_map(), hit_player(), hit_with_one_attacktype(), i18n_init(), identify_altar_type_move_on(), improve_armour(), improve_weapon(), init_anim(), init_archetable(), init_artifacts(), init_attackmess(), init_book_archive(), init_clocks(), init_connection(), init_dynamic(), init_emergency_mappath(), init_experience(), init_formulae(), init_gods(), init_mon_info(), init_msgfile(), init_races(), init_readable(), init_regions(), init_server(), init_signals(), init_skills(), init_startup(), initPlugins(), inscribe_scroll_cmd(), insert_ob_in_map(), insert_ob_in_ob(), key_change_class(), key_roll_stat(), kill_object(), learn_skill(), leave(), legal_artifact_combination(), level_for_item(), link_player_skills(), load_archetypes(), load_map_header(), load_materials(), load_objects(), load_original_map(), load_overlay_map(), load_settings(), load_temporary_map(), load_treasure(), load_treasures(), load_unique_objects(), local_check_loaded_object(), lock_item_cmd(), LOG(), lookup_spell_by_name(), magic_from_difficulty(), magic_wall(), main(), make_formula_book(), make_item_from_recipe(), make_object_glow(), make_path_to_file(), make_throw_ob(), map2_add_ob(), mark_item_cmd(), merge_spell(), metaserver2_init(), metaserver2_writer(), metaserver_init(), metaserver_update(), mon_info_msg(), monster_cast_spell(), monster_check_apply(), monster_use_bow(), monster_use_range(), monster_use_skill(), move_cmd(), move_cone(), move_creator(), move_detector(), move_duplicator(), move_firewall(), move_golem(), move_monster(), move_ob(), move_player(), move_player_mover(), move_symptom(), move_teleporter(), msgfile_msg(), new_player_cmd(), numb_ob_inside(), open_and_uncompress_file(), operate_altar(), parse_dialog_information(), parse_regions(), parse_shop_string(), path_combine(), path_normalize(), pay_for_amount(), pay_for_item(), pay_from_container(), pet_move(), pick_up(), place_special_exit(), player_can_view(), player_changer_type_process(), plugins_init_plugin(), poison_living(), poison_type_apply(), poisoning_type_process(), polymorph_item(), potion_type_apply(), present(), present_arch(), process_events(), query_base_name(), query_cost(), query_money(), query_short_name(), random_roll(), random_roll64(), read_bmap_names(), read_client_images(), read_face_data(), read_map_log(), read_smooth(), ready_map_name(), rec_sigbus(), rec_sigint(), rec_sigpipe(), rec_sigquit(), rec_sigsegv(), rec_sigterm(), receive_player_password(), remove_all_pets(), remove_button_link(), remove_directory(), remove_friendly_object(), remove_ob(), remove_party(), reply_cmd(), resurrect_player(), save_life(), save_map(), save_objects(), save_player(), second_arch_pass(), sell_item(), send_exp_table(), send_image_sums(), send_news(), send_rules(), send_skill_info(), send_smooth(), send_spell_paths(), send_tick(), ServiceCtrlHandler(), set_block(), set_csport(), set_face_mode_cmd(), set_ob_key_value_s(), set_owner(), set_up_cmd(), shop_mat_type_move_on(), shop_specialisation_ratio(), should_arena_attack(), skill_ident(), slow_living(), SockList_ReadPacket(), SP_level_spellpoint_cost(), spellbook_type_apply(), spool(), ss_dump_table(), START_TEST(), summon_golem(), summon_object(), swap_below_max(), swap_map(), swap_stat(), tailor_god_spell(), tear_down_wall(), teleport(), tempnam_secure(), thrown_object_type_process(), transmute_materialname(), trigger_connected(), unapply_special(), update_button(), update_buttons(), update_ob_speed(), update_object(), update_position(), use_skill(), value_limit(), verify_button_links(), verify_player(), version_cmd(), write_book_archive(), write_map_log(), write_mark(), write_socket_buffer(), Write_To_Socket(), write_todclock(), and wrong_password().

Here is the call graph for this function:

void make_list_like ( char *  input)

Taking a string as an argument, mutate it into a string that looks like a list.

A 'list' for the purposes here is a string of items, seperated by commas, except for the last entry, which has an 'and' before it, and a full stop (period) after it.

This function will also strip all trailing non alphanumeric characters.

It does not insert an oxford comma.

Parameters:
inputstring to transform. Will be overwritten. Must be long enough to contain the modified string.
Todo:
use safe string functions.

Definition at line 485 of file utils.c.

References MAX_BUF.

Referenced by can_pay(), and describe_shop().

Here is the caller graph for this function:

void make_path_to_file ( const char *  filename)

Checks if any directories in the given path doesn't exist, and creates if necessary.

Parameters:
filenamefile path we'll want to access. Can be NULL.
Note:
will LOG() to debug and error.

Definition at line 764 of file porting.c.

References llevDebug, llevError, LOG(), MAX_BUF, mkdir, S_ISDIR, SAVE_DIR_MODE, and strerror_local().

Referenced by create_destination(), key_change_class(), process_map(), save_map(), save_player(), and write_map_page().

Here is the call graph for this function:

Here is the caller graph for this function:

void make_sure_not_seen ( const object *  op)

The object which is supposed to be visible through walls has just been removed from the map, so update the los of any players within its range.

Parameters:
opobject that disappears.
Todo:
what about tiled maps?

Definition at line 667 of file los.c.

References pl::do_los, first_player, socket_struct::mapx, socket_struct::mapy, pl::next, pl::ob, and pl::socket.

Referenced by process_object().

Here is the caller graph for this function:

void make_sure_seen ( const object *  op)

The object is supposed to be visible through walls, thus check if any players are nearby, and edit their LOS array.

Parameters:
opobject that should be visible.
Todo:
what about tiled maps?

Definition at line 644 of file los.c.

References pl::blocked_los, first_player, socket_struct::mapx, socket_struct::mapy, pl::next, pl::ob, and pl::socket.

Referenced by process_object().

Here is the caller graph for this function:

void map_remove_unique_files ( const mapstruct map)

Remove files containing the map's unique items.

Parameters:
map

Definition at line 2619 of file map.c.

References create_items_path(), HUGE_BUF, mapdef::path, snprintf(), mapdef::unique, and unlink.

Referenced by command_reset().

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 can_merge(), free_object(), increase_ob_nr(), and remove_ob().

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 FREE_AND_CLEAR, free_object(), GET_MAP_OB, llevError, LOG(), MAX, remove_ob(), Statistics::spell_hash_full, Statistics::spell_merges, and statistics.

Referenced by explosion(), and insert_ob_in_map().

Here is the call graph for this function:

Here is the caller graph for this function:

materialtype_t* name_to_material ( const char *  name)

Convert materialname to materialtype_t.

Todo:
why use a break?

Definition at line 262 of file utils.c.

References materialt, _materialtype::name, and _materialtype::next.

Referenced by animate_weapon(), did_make_save_item(), query_base_name(), query_name(), and transmute_materialname().

Here is the caller graph for this function:

int need_identify ( const object *  op)

This function really should not exist - by default, any item not identified should need it.

Parameters:
opitem to check.
Returns:
true if the item should be identified.
Todo:
either remove this function, or fix comment above :)

Definition at line 1401 of file item.c.

References AMULET, ARMOUR, ARROW, BOOK, BOOTS, BOW, BRACERS, CLOAK, CLOSE_CON, CONTAINER, DRINK, FLESH, FOOD, GEM, GIRDLE, GLOVES, HELMET, HORN, INORGANIC, POISON, POTION, POWER_CRYSTAL, RING, ROD, SCROLL, SHIELD, SKILL, SKILL_TOOL, SKILLSCROLL, SPELLBOOK, WAND, and WEAPON.

Referenced by cast_identify(), command_create(), describe_item(), do_skill_ident2(), examine(), give_initial_items(), identify_altar_type_move_on(), query_base_name(), query_cost(), and query_short_name().

Here is the caller graph for this function:

sint64 new_exp ( const object *  ob)

Alternative way to calculate experience based on the ability of a monster.

It's far from perfect, and doesn't consider everything which can be considered, thus it's only used in debugging. this is only used with one of the dumpflags, and not anyplace in the code.

Parameters:
obobject for which to return experience
Returns:
experience computed from object's properties.

Definition at line 104 of file exp.c.

References exp_att_mult, exp_prot_mult, FABS, FALSE, FLAG_CAST_SPELL, FLAG_HITBACK, FLAG_NO_MAGIC, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_INVISIBLE, FLAG_SPLITTING, FLAG_STAND_STILL, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_SCROLL, has_ability(), MAX, MIN, NROFATTACKS, and QUERY_FLAG.

Referenced by print_monsters().

Here is the call graph for this function:

Here is the caller graph for this function:

method_ret ob_apply ( object *  op,
object *  applier,
int  aflags 
)

Applies an object.

Parameters:
opThe object to apply
applierThe object that executes the apply action
aflagsSpecial (always apply/unapply) flags
Return values:
0A player or monster can't apply objects of that type
1has been applied, or there was an error applying the object
2objects of that type can't be applied if not in inventory

Definition at line 59 of file ob_methods.c.

References ob_methods::apply, ob_methods::fallback, METHOD_UNHANDLED, and type_methods.

Referenced by enter_exit(), manual_apply(), monster_use_scroll(), player_apply_below(), and thrown_item_effect().

Here is the caller graph for this function:

int ob_blocked ( const object *  ob,
mapstruct m,
sint16  x,
sint16  y 
)

Returns true if the given object can't fit in the given spot.

This is meant for multi space objects - for single space objecs, just calling get_map_blocked and checking that against movement type of object. This function goes through all the parts of the multipart object and makes sure they can be inserted.

While this doesn't call out of map, the get_map_flags does.

This function has been used to deprecate arch_out_of_map - this function also does that check, and since in most cases, a call to one would follow the other, doesn't make a lot of sense to have two seperate functions for this.

This returns nonzero if this arch can not go on the space provided, 0 otherwise. the return value will contain the P_.. value so the caller can know why this object can't go on the map. Note that callers should not expect P_NEW_MAP to be set in return codes - since the object is multispace - if we did return values, what do you return if half the object is one map, half on another.

Parameters:
obobject to test.
m
x
ymap and coordinates to check.
Returns:
0 if the object can fit on specified space, non-zero else.
Note:
This used to be arch_blocked, but with new movement code, we need to have actual object to check its move_type against the move_block values.

Definition at line 525 of file map.c.

References AB_NO_PASS, get_map_flags(), GET_MAP_MOVE_BLOCK, MOVE_ALL, OB_TYPE_MOVE_BLOCK, P_IS_ALIVE, P_OUT_OF_MAP, and TRANSPORT.

Referenced by compute_path(), enter_map(), find_first_free_spot(), find_free_spot(), find_multi_free_spot_around(), find_multi_free_spot_within_radius(), move_creator(), summon_golem(), summon_object(), and turn_one_transport().

Here is the call graph for this function:

Here is the caller graph for this function:

char* ob_describe ( const object *  op,
const object *  observer,
char *  buf,
size_t  size 
)

Returns the description of an object, as seen by the given observer.

Parameters:
opThe object to describe
observerThe object to which the description is made
bufBuffer that will contain the description
sizeSize of buf
Returns:
buf.

Definition at line 102 of file ob_methods.c.

References ob_methods::describe, ob_methods::fallback, and type_methods.

Referenced by book_type_apply(), cast_identify(), do_skill_ident2(), examine(), and identify_altar_type_move_on().

Here is the caller graph for this function:

method_ret ob_move_on ( object *  op,
object *  victim,
object *  originator 
)

Makes an object move on top of another one.

Parameters:
opThe object over which to move
victimThe object moving over op
originatorThe object that is the cause of the move
Return values:
METHOD_UNHANDLEDif the process method does not exist for that object

Definition at line 122 of file ob_methods.c.

References ob_methods::fallback, METHOD_UNHANDLED, ob_methods::move_on, and type_methods.

Referenced by check_move_on(), move_hole(), and remove_ob().

Here is the caller graph for this function:

method_ret ob_process ( object *  op)

Processes an object, giving it the opportunity to move or react.

Note: The return value of ob_process doesn't seem to be used anymore.

Parameters:
opThe object to process
Return values:
METHOD_UNHANDLEDif the process method does not exist for that objec,

Definition at line 79 of file ob_methods.c.

References ob_methods::fallback, METHOD_UNHANDLED, ob_methods::process, and type_methods.

Referenced by animate_bomb(), do_throw(), fire_arch_from_position(), fire_bolt(), fire_bow(), and process_object().

Here is the caller graph for this function:

method_ret ob_trigger ( object *  op,
object *  cause,
int  state 
)

An object is triggered by another one.

Parameters:
opThe object being triggered
causeThe object that is the cause of the trigger
statetrigger state, 0 for released, other for pushed
Return values:
METHOD_UNHANDLEDif the process method does not exist for that object
Todo:
check the exact state values/meaning

Definition at line 144 of file ob_methods.c.

References ob_methods::fallback, METHOD_UNHANDLED, ob_methods::trigger, and type_methods.

Referenced by trigger_connected().

Here is the caller graph for this function:

object* object_create_arch ( archetype *  at)

Create a full object using the given archetype.

This instanciate not only the archetype but also all linked archetypes in case of multisquare archetype.

Parameters:
atarchetype to instanciate. Must not be NULL.
Returns:
pointer to head of instance.
Note:
will never return NULL.

Definition at line 741 of file arch.c.

References arch_to_object().

Referenced by apply_map_builder(), cctk_create_game_object(), cfapi_object_create(), command_create(), command_use(), convert_item(), move_creator(), and START_TEST().

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(), insert_ob_in_ob(), 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.

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:

int on_same_map ( const object *  op1,
const object *  op2 
)

Checks whether 2 objects are on the same map or not.

Note we only look one map out to keep the processing simple and efficient. This could probably be a macro. MSW 2001-08-05

Parameters:
op1first object.
op2second object.
Returns:
TRUE if op1 and op2 are effectively on the same map (as related to map tiling).
Note:
This looks for a path from op1 to op2, so if the tiled maps are assymetric and op2 has a path to op1, this will still return false.

Definition at line 2609 of file map.c.

References adjacent_map().

Referenced by abort_attack(), adj_attackroll(), can_detect_enemy(), cfapi_object_on_same_map(), check_enemy(), find_enemy(), get_attack_mode(), get_pet_enemy(), move_ball_spell(), move_monster(), pet_move(), remove_all_pets(), and share_exp().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* open_and_uncompress ( const char *  name,
int  flag,
int *  compressed 
)

open_and_uncompress() first searches for the original filename.

If it exist, then it opens it and returns the file-pointer.

If not, it does two things depending on the flag. If the flag is set, it tries to create the original file by appending a compression suffix to name and uncompressing it. If the flag is not set, it creates a pipe that is used for reading the file (NOTE - you can not use fseek on pipes).

The compressed pointer is set to nonzero if the file is compressed (and thus, fp is actually a pipe.) It returns 0 if it is a normal file.

Parameters:
namethe base file name without compression extension
flagonly used for compressed files:
  • if set, uncompress and open the file
  • if unset, uncompress the file via pipe
[out]compressedset to zero if the file was uncompressed
Returns:
pointer to opened file, NULL on failure.
Note:
will set ::errno if an error occurs.

Definition at line 724 of file porting.c.

References NROF_COMPRESS_METHODS, and open_and_uncompress_file().

Referenced by add_score(), check_login(), display_high_score(), display_motd(), forbid_play(), init_artifacts(), init_attackmess(), init_book_archive(), init_experience(), init_formulae(), init_msgfile(), init_regions(), init_startup(), load_archetypes(), load_original_map(), load_overlay_map(), load_settings(), load_temporary_map(), load_treasures(), load_unique_objects(), metaserver2_init(), read_client_images(), send_news(), send_rules(), and verify_player().

Here is the call graph for this function:

Here is the caller graph for this function:

int operate_altar ( object *  altar,
object **  sacrifice 
)

Checks if sacrifice was accepted and removes sacrificed objects.

Might be better to call check_altar_sacrifice (above) than depend on the return value, since operate_altar will remove the sacrifice also.

If this function returns 1, '*sacrifice' is modified to point to the remaining sacrifice, or is set to NULL if the sacrifice was used up.

Parameters:
altaritem to which there is a sacrifice
sacrificeobject that may be sacrifed
Returns:
1 if sacrifice was accepted, else 0

Definition at line 470 of file button.c.

References check_altar_sacrifice(), decrease_ob_nr(), ext_info_map(), llevError, LOG(), MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_ALTAR, and NDI_BLACK.

Referenced by altar_type_move_on(), check_trigger(), and identify_altar_type_move_on().

Here is the call graph for this function:

Here is the caller graph for this function:

int out_of_map ( mapstruct m,
int  x,
int  y 
)

this returns TRUE if the coordinates (x,y) are out of map m.

This function also takes into account any tiling considerations, loading adjacant maps as needed. This is the function should always be used when it necessary to check for valid coordinates. This function will recursively call itself for the tiled maps.

Parameters:
mmap to consider.
x
ycoordinates.
Returns:
1 if out of map, 0 else

Definition at line 2300 of file map.c.

References mapdef::in_memory, load_and_link_tiled_map(), MAP_HEIGHT, MAP_IN_MEMORY, MAP_WIDTH, out_of_map(), mapdef::tile_map, and mapdef::tile_path.

Referenced by animate_bomb(), attack_message(), cfapi_map_out_of_map(), cfapi_object_teleport(), command_create(), enter_map(), esrv_draw_look(), explode_bullet(), get_map_flags(), insert_ob_in_map(), look_at(), move_player_attack(), move_teleporter(), out_of_map(), pick_lock(), present(), and present_arch().

Here is the call graph for this function:

Here is the caller graph for this function:

char* path_combine ( const char *  src,
const char *  dst,
char *  path,
size_t  size 
)

Combines 2 paths, which can be relative.

Parameters:
srcpath we're starting from.
dstpath we're doing to.
pathbuffer containing the combined path.
sizesize of path.
Returns:
path.
Note:
this doesn't handle the '..', check path_normalize().

Definition at line 63 of file path.c.

char* path_combine_and_normalize ( const char *  src,
const char *  dst,
char *  path,
size_t  size 
)

Combines the 2 paths.

Parameters:
srcpath we're starting from.
dstpath we're getting to.
pathbuffer that will contain combined paths.
sizelength of path.
Returns:
path

Definition at line 184 of file path.c.

void path_normalize ( char *  path)

Cleans specified path.

Removes .. and things like that.

Parameters:
pathpath to clear. It will be modified in place.
Note:
there shouldn't be any buffer overflow, as we just remove stuff.

Definition at line 97 of file path.c.

void player_lvl_adj ( object *  who,
object *  op 
)

For the new exp system.

we are concerned with whether the player gets more hp, sp and new levels. Note this this function should only be called for players. Monsters don't really gain levels

Will tell the player about changed levels.

Parameters:
whoplayer
opwhat we are checking to gain the level (eg, skill)
Note:
this function can call itself recursively to check for multiple levels.

Definition at line 1731 of file living.c.

References die_roll(), dragon_level_gain(), draw_ext_info(), draw_ext_info_format(), esrv_update_spells(), fix_object(), is_dragon_pl(), level_exp(), MAX_BUF, Settings::max_level, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_LEVEL_GAIN, MSG_TYPE_ATTRIBUTE_LEVEL_LOSS, NDI_RED, NDI_UNIQUE, PLAYER, player_lvl_adj(), PREFER_HIGH, settings, and snprintf().

Referenced by add_player_exp(), apply_death_exp_penalty(), command_addexp(), player_lvl_adj(), and subtract_player_exp().

Here is the call graph for this function:

Here is the caller graph for this function:

const object* pntr_to_god_obj ( godlink godlnk)

Returns a pointer to the object We need to be VERY careful about using this, as we are returning a pointer to the CLONE object.

-b.t.

Parameters:
godlnkgod to get object.

Definition at line 133 of file holy.c.

References glnk::arch.

Referenced by dump_gods(), find_god(), and god_info_msg().

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 GET_MAP_OB, 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:

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

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.

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.

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

Here is the caller graph for this function:

void print_los ( object *  op)

Debug-routine which dumps the array which specifies the visible area of a player.

Triggered by the DM command printlos.

Parameters:
opDM asking for information.
Todo:
change the command to view another player's LOS?

Definition at line 614 of file los.c.

References draw_ext_info(), MAP_CLIENT_X, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, NDI_UNIQUE, and snprintf().

Referenced by command_printlos().

Here is the call graph for this function:

Here is the caller graph for this function:

void print_monsters ( void  )

As dump_abilities(), but with an alternative way of output.

Definition at line 71 of file info.c.

References arch_to_object(), bitstostring(), first_archetype, FLAG_MONSTER, free_object(), new_exp(), NROFATTACKS, and QUERY_FLAG.

Referenced by init_beforeplay().

Here is the call graph for this function:

Here is the caller graph for this function:

void push_button ( object *  op)

Push the specified object.

This can affect other buttons/gates/handles altars/pedestals/holes in the whole map. Changed the routine to loop through _all_ linked objects. Better hurry with that linked list...

Parameters:
opobject to push.

Definition at line 165 of file button.c.

References get_button_links(), and trigger_connected().

Referenced by altar_type_move_on(), cf_handle_type_apply(), move_detector(), update_button(), and use_trigger().

Here is the call graph for this function:

Here is the caller graph for this function:

void query_base_name ( const object *  op,
int  plural,
char *  buf,
size_t  size 
)

Query a short name for the item.

This is a lot like query_name(), but we don't include the item count or item status. Used for inventory sorting and sending to client. If plural is set, we generate the plural name of this.

Parameters:
opitem we want the name of.
pluralwhether to get the singular or plural name
bufbuffer that will contain the object's name. Must not be NULL.
sizebuffer's length

Definition at line 732 of file item.c.

References AMULET, _materialtype::description, FLAG_BEEN_APPLIED, FLAG_IDENTIFIED, IS_ARMOR, is_magical(), IS_WEAPON, llevError, LOG(), M_SPECIAL, MAX_BUF, _materialtype::name, name_to_material(), need_identify(), QUERY_FLAG, RING, ring_desc(), ROD, safe_strcat(), SCROLL, SKILL, snprintf(), SPELLBOOK, and WAND.

Referenced by add_object_to_socklist(), add_shop_item(), cfapi_object_get_property(), change_spell(), command_rename_item(), esrv_update_item(), fire_misc_object(), item_matched_string(), matches_sacrifice(), rangetostring(), and use_alchemy().

Here is the call graph for this function:

Here is the caller graph for this function:

void query_name ( const object *  op,
char *  buf,
size_t  size 
)

Describes an item.

Parameters:
opitem to describe. Must not be NULL.
bufbuffer that will contain the description.
sizesize of buffer.

Definition at line 628 of file item.c.

References AMULET, ARMOUR, BOOTS, BOW, BRACERS, CLOAK, CONTAINER, _materialtype::description, FLAG_APPLIED, FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_INV_LOCKED, FLAG_KNOWN_BLESSED, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLAG_UNPAID, GIRDLE, GLOVES, HELMET, HORN, IS_ARMOR, IS_SHIELD, IS_WEAPON, name_to_material(), QUERY_FLAG, query_short_name(), RING, ROD, safe_strcat(), SHIELD, SKILL, WAND, and WEAPON.

Referenced by animate_weapon(), apply_builder_item(), apply_builder_remove(), apply_container(), apply_special(), attack_hth(), attempt_steal(), blind_living(), cast_smite_spell(), cast_spell(), cfapi_object_find_archetype_inside(), cfapi_object_forget_spell(), cfapi_object_get_property(), change_exp(), change_spell(), check_race_restrictions(), command_insert_into(), command_mark(), command_remove(), common_ob_describe(), converter_type_move_on(), do_skill(), do_skill_attack(), do_throw(), drop_object(), empty_container(), exit_type_apply(), find_key(), find_mon_throw_ob(), find_player(), find_throw_ob(), get_payment(), god_examines_item(), hit_with_one_attacktype(), inventory(), item_matched_string(), kill_object(), leave(), legacy_ob_describe(), look_at(), make_formula_book(), mark_item_cmd(), npc_say(), pick_up_object(), player_apply(), polymorph_melt(), put_object_in_sack(), recharge(), recursive_roll(), sack_can_hold(), save_life(), sell_item(), singing(), skillscroll_type_apply(), spellbook_type_apply(), transport_type_apply(), treasure_type_apply(), unapply_for_ob(), unapply_special(), use_oratory(), and write_scroll().

Here is the call graph for this function:

int query_refcount ( sstring  str)

This will return the refcount of the string str.

Parameters:
strstring which *must *have been returned from a previous add_string().
Returns:
refcount of the string.

Definition at line 216 of file shstr.c.

References SS, and TOPBIT.

Referenced by START_TEST().

Here is the caller graph for this function:

void query_short_name ( const object *  op,
char *  buf,
size_t  size 
)

query_short_name(object) is similar to query_name(), but doesn't contain any information about object status (worn/cursed/etc.)

Parameters:
opobject to describe.
bufbuffer which will contain the name. Must not be NULL.
sizebuffer length.

Definition at line 551 of file item.c.

References AMULET, FLAG_BEEN_APPLIED, FLAG_IDENTIFIED, is_magical(), llevError, LOG(), need_identify(), QUERY_FLAG, RING, ring_desc(), ROD, safe_strcat(), SCROLL, SKILL, snprintf(), SPELLBOOK, VERY_BIG_BUF, and WAND.

Referenced by cast_item_curse_or_curse(), cfapi_object_get_property(), command_lock_item(), dragon_ability_gain(), follower_remove_given_items(), god_gives_present(), item_matched_string(), player_attack_door(), query_name(), remove_force(), transmute_item_to_flower(), and write_note().

Here is the call graph for this function:

Here is the caller graph for this function:

void query_weight ( const object *  op,
char *  buf,
size_t  size 
)

Formats the item's weight.

Parameters:
opobject we want the weight of.
[out]bufbuffer to write to.
sizebuffer size.

Definition at line 424 of file item.c.

References snprintf().

Referenced by inventory().

Here is the call graph for this function:

Here is the caller graph for this function:

int random_roll ( int  min,
int  max,
const object *  op,
int  goodbad 
)

Roll a random number between min and max.

Uses op to determine luck, and if goodbad is non-zero, luck increases the roll, if zero, it decreases.

Generally, op should be the player/caster/hitter requesting the roll, not the recipient (ie, the poor slob getting hit). [garbled 20010916]

Definition at line 51 of file utils.c.

References llevError, LOG(), MAX, MIN, and PLAYER.

Referenced by alchemy_failure_effect(), apply_special(), attack_ob_simple(), attempt_do_alchemy(), attempt_steal(), become_follower(), cast_detection(), cast_heal(), cast_smite_spell(), cast_spell(), charge_mana_effect(), cure_disease(), deathstrike_living(), did_make_save(), do_harvest(), do_hidden_move(), do_symptoms(), flee_player(), gate_type_process(), god_examines_priest(), god_intervention(), hit_with_one_attacktype(), infect_object(), kill_player(), learn_skill(), mood_change(), potion_type_apply(), pray_at_altar(), push_ob(), recharge(), roll_ob(), scroll_failure(), singing(), spellbook_type_apply(), summon_object(), trap_disarm(), trap_see(), use_oratory(), and write_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

sint64 random_roll64 ( sint64  min,
sint64  max,
const object *  op,
int  goodbad 
)

This is a 64 bit version of random_roll() above.

This is needed for exp loss calculations for players changing religions.

Definition at line 86 of file utils.c.

References llevError, LOG(), MAX, MIN, and PLAYER.

Referenced by pray_at_altar().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* re_cmp ( const char *  str,
const char *  regexp 
)

re-cmp - get regular expression match.

Parameters:
strstring that will be matched against the regexp.
regexpregular expression.
Returns:
  • no match or error in regexp.
  • pointer to beginning of matching string

Definition at line 70 of file re-cmp.c.

References Boolean, False, re_cmp(), re_cmp_step(), re_get_token(), re_init(), re_init_done, re_match_token(), re_substr, re_token_depth, rep_null_or_more, rep_null_or_once, rep_once, rep_once_or_more, and True.

Referenced by cfapi_system_re_cmp(), matches(), and re_cmp().

Here is the call graph for this function:

Here is the caller graph for this function:

void read_bmap_names ( void  )

This reads the bmaps file to get all the bitmap names and stuff.

It only needs to be done once, because it is player independent (ie, what display the person is on will not make a difference.)

Note:
will call exit() if file doesn't exist, and abort() in case of memory error.

Definition at line 198 of file image.c.

References BLANK_FACE_NAME, bmaps_checksum, compar(), Settings::datadir, EMPTY_FACE_NAME, FACE_FLOOR, find_color(), find_face(), llevDebug, llevError, LOG(), new_face_struct::magicmap, MAX_BUF, new_face_struct::name, bmappair::name, nroffiles, nrofpixmaps, new_face_struct::number, bmappair::number, read_face_data(), ROTATE_RIGHT, settings, SMOOTH_FACE_NAME, new_face_struct::smoothface, snprintf(), strdup_local(), strerror_local(), and new_face_struct::visibility.

Referenced by cctk_init_std_archetypes(), and init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

void read_client_images ( void  )

Loads all the image types into memory.

This way, we can easily send them to the client. We should really do something better than abort on any errors - on the other hand, these are all fatal to the server (can't work around them), but the abort just seems a bit messy (exit would probably be better.)

Couple of notes: We assume that the faces are in a continous block. This works fine for now, but this could perhaps change in the future

Function largely rewritten May 2000 to be more general purpose. The server itself does not care what the image data is - to the server, it is just data it needs to allocate. As such, the code is written to do such.

Definition at line 471 of file image.c.

References check_faceset_fallback(), face_info::checksum, close_and_delete(), face_sets::comment, face_info::data, Settings::datadir, face_info::datalen, face_sets::extension, face_sets::faces, face_sets::fallback, face_sets::fullname, HUGE_BUF, llevDebug, llevError, LOG(), MAX_FACE_SETS, MAX_IMAGE_SIZE, nrofpixmaps, open_and_uncompress(), face_sets::prefix, ROTATE_RIGHT, settings, face_sets::size, snprintf(), and strdup_local().

Referenced by init_server(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int read_smooth ( void  )

Reads the smooth file to know how to smooth datas.

the smooth file if made of 2 elements lines. lines starting with # are comment the first element of line is face to smooth the next element is the 16x2 faces picture used for smoothing

Note:
will call exit() if file can't be opened.

Definition at line 348 of file image.c.

References Settings::datadir, find_face(), llevDebug, llevError, LOG(), MAX_BUF, settings, new_face_struct::smoothface, snprintf(), and strerror_local().

Referenced by cctk_init_std_archetypes(), and init_library().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* ready_map_name ( const char *  name,
int  flags 
)

Makes sure the given map is loaded and swapped in.

Parameters:
namepath name of the map.
flags
  • 0x1 (MAP_FLUSH): flush the map - always load from the map directory, and don't do unique items or the like.
  • 0x2 (MAP_PLAYER_UNIQUE) - this is a unique map for each player. dont do any more name translation on it.
Returns:
pointer to the given map, NULL on failure.

Definition at line 1809 of file map.c.

References clean_tmp_map(), create_pathname(), decay_objects(), delete_map(), fix_auto_apply(), gettimeofday(), has_been_loaded(), mapdef::in_memory, mapdef::last_reset_time, llevDebug, load_original_map(), load_overlay_map(), load_temporary_map(), load_unique_objects(), LOG(), MAP_FLUSH, MAP_IN_MEMORY, MAP_LOADING, MAP_OVERLAY, MAP_PLAYER_UNIQUE, MAX_BUF, mapdef::outdoor, set_darkness_map(), and mapdef::tmpname.

Referenced by cast_create_town_portal(), cfapi_map_get_map(), enter_exit(), enter_fixed_template_map(), enter_random_template_map(), enter_unique_map(), init_dynamic(), is_legal_2ways_exit(), load_and_link_tiled_map(), place_exits(), process_map(), and START_TEST().

Here is the call graph for this function:

Here is the caller graph for this function:

int region_is_child_of_region ( const region child,
const region r 
)

Checks if a region is a child of another.

Parameters:
childregion we want to test.
rpotential parent.
Returns:
  • 1 if child has r as parent somewhere.
  • -1 if passed a NULL region
  • 0 else

Definition at line 201 of file region.c.

References regiondef::name, regiondef::parent, and region_is_child_of_region().

Referenced by list_players(), and region_is_child_of_region().

Here is the call graph for this function:

Here is the caller graph for this function:

void register_apply ( int  ob_type,
apply_func  method 
)
void register_describe ( int  ob_type,
describe_func  method 
)

Registers the describe method for the given type.

Parameters:
ob_typeThe type of object to register this method to
methodThe method to link

Definition at line 97 of file ob_types.c.

References ob_methods::describe.

Referenced by init_type_power_crystal().

Here is the caller graph for this function:

void register_move_on ( int  ob_type,
move_on_func  method 
)
void register_process ( int  ob_type,
process_func  method 
)

Registers the process method for the given type.

Parameters:
ob_typeThe type of object to register this method to
methodThe method to link

Definition at line 88 of file ob_types.c.

References ob_methods::process.

Referenced by init_type_arrow(), init_type_blindness(), init_type_creator(), init_type_deep_swamp(), init_type_detector(), init_type_gate(), init_type_marker(), init_type_mood_floor(), init_type_peacemaker(), init_type_player_changer(), init_type_poisoning(), init_type_rune(), init_type_spell_effect(), init_type_teleporter(), init_type_thrown_object(), init_type_transport(), init_type_trap(), and init_type_trigger().

Here is the caller graph for this function:

void register_trigger ( int  ob_type,
trigger_func  method 
)

Registers the trigger method for the given type.

Parameters:
ob_typeThe type of object to register this method to
methodThe method to link

Definition at line 115 of file ob_types.c.

References ob_methods::trigger.

Referenced by init_type_creator(), init_type_duplicator(), init_type_marker(), init_type_mood_floor(), and init_type_teleporter().

Here is the caller graph for this function:

void remove_button_link ( object *  op)

Remove the object from the linked lists of buttons in the map.

This is only needed by editors.

Parameters:
opobject to remove. Must be on a map, and linked.

Definition at line 700 of file button.c.

References CLEAR_FLAG, FLAG_IS_LINKED, llevError, LOG(), and QUERY_FLAG.

Referenced by apply_builder_remove(), clean_object(), and delete_unique_items().

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_directory ( const char *  path)

This function removes everything in the directory, and the directory itself.

Errors are LOG() to error level.

Parameters:
pathdirectory to remove.
Note:
will fail if any file has a name starting by .

Definition at line 192 of file porting.c.

References closedir(), dirent::d_name, llevError, LOG(), MAX_BUF, opendir(), readdir(), remove_directory(), S_ISDIR, snprintf(), and unlink.

Referenced by delete_character(), and remove_directory().

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_friendly_object ( object *  op)

Removes the specified object from the linked list of friendly objects.

Parameters:
opobject to remove from list.

Definition at line 69 of file friend.c.

References CLEAR_FLAG, first_friendly_object, FLAG_FRIENDLY, llevError, and LOG().

Referenced by cfapi_object_set_property(), clear_object(), command_cast_spell(), command_kill_pets(), do_mood_floor(), enter_map(), free_object2(), get_nearest_player(), get_pet_enemy(), hit_player(), kill_object(), kill_player(), mood_change(), move_golem(), move_monster(), pet_move(), polymorph_living(), receive_play_again(), remove_all_pets(), terminate_all_pets(), and use_oratory().

Here is the call graph for this function:

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

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 CLEAR_FLAG, CONTAINER, pl::count, dump_object(), 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(), llevError, LOG(), MAP_SAVING, ob_move_on(), P_NEED_UPDATE, mapdef::path, PLAYER, QUERY_FLAG, remove_ob(), SET_FLAG, SET_MAP_FLAGS, SET_MAP_OB, SET_MAP_TOP, stringbuffer_finish(), stringbuffer_new(), sub_weight(), update_all_los(), update_object(), and update_position().

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 remove_statbonus ( object *  op)

Subtracts stat-bonuses given by the class which the player has chosen.

Parameters:
opobject which must be a player with contr not NULL.

Definition at line 840 of file living.c.

Referenced by key_change_class().

Here is the caller graph for this function:

void replace ( const char *  src,
const char *  key,
const char *  replacement,
char *  result,
size_t  resultsize 
)

Replace in string src all occurrences of key by replacement.

The resulting string is put into result; at most resultsize characters (including the terminating null character) will be written to result.

Definition at line 444 of file utils.c.

References snprintf().

Referenced by compilePython(), enter_fixed_template_map(), and enter_random_template_map().

Here is the call graph for this function:

Here is the caller 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 arch_to_object(), find_archetype(), free_object(), GET_MAP_OB, insert_ob_in_map(), and remove_ob().

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 replace_unprintable_chars ( char *  buf)

Replaces any unprintable character in the given buffer with a space.

Parameters:
bufthe buffer to modify

Definition at line 516 of file utils.c.

Referenced by command_party(), command_title(), and form_party().

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

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 reset_sleep ( void  )

Initialise all variables used in the timing routines.

Definition at line 141 of file time.c.

References GETTIMEOFDAY, last_time, PBUFLEN, process_max_utime, process_min_utime, process_tot_mtime, process_utime_save, psaveind, and pticks.

Referenced by block_until_new_connection(), command_speed(), init(), and setup().

Here is the caller graph for this function:

int rndm ( int  min,
int  max 
)
int save_map ( mapstruct m,
int  flag 
)

Saves a map to file.

If flag is SAVE_MODE_INPLACE, it is saved into the same file it was (originally) loaded from. Otherwise a temporary filename will be genarated, and the file will be stored there. The temporary filename will be stored in the mapstructure. If the map is unique, we also save to the filename in the map (this should have been updated when first loaded)

Parameters:
mmap to save.
flagOne of SAVE_MODE_xxx values.
Returns:
one of SAVE_ERROR_xxx values.

Definition at line 1453 of file map.c.

References mapdef::background_music, mapdef::compressed, create_items_path(), create_overlay_pathname(), create_pathname(), mapdef::darkness, mapdef::difficulty, mapdef::enter_x, mapdef::enter_y, mapdef::fixed_resettime, free_all_objects(), mapdef::height, mapdef::in_memory, mapdef::is_template, mapdef::last_reset_time, llevDebug, llevError, LOG(), make_path_to_file(), MAP_IN_MEMORY, MAP_SAVING, mapdef::maplore, MAX_BUF, mapdef::msg, regiondef::name, mapdef::name, mapdef::nosmooth, mapdef::outdoor, mapdef::path, pclose, popen, print_shop_string(), mapdef::region, mapdef::reset_timeout, SAVE_ERROR_CLOSE, SAVE_ERROR_NO_PATH, SAVE_ERROR_OK, SAVE_ERROR_RCREATION, SAVE_ERROR_RRENAME, SAVE_ERROR_UCREATION, SAVE_ERROR_URENAME, SAVE_FLAG_NO_REMOVE, SAVE_MODE, SAVE_MODE_NORMAL, SAVE_MODE_OVERLAY, save_objects(), settings, mapdef::shopgreed, mapdef::shopitems, mapdef::shopmax, mapdef::shopmin, mapdef::shoprace, snprintf(), strerror_local(), mapdef::swap_time, TEMP_EXT, tempnam_local(), mapdef::tile_path, Settings::tmpdir, mapdef::tmpname, uncomp, mapdef::unique, unlink, and mapdef::width.

Referenced by clean_tmp_files(), command_overlay_save(), main(), START_TEST(), and swap_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int save_object ( FILE *  fp,
object *  op,
int  flag 
)

Referenced by save_objects(), and save_player().

Here is the caller graph for this function:

long seconds ( void  )

Gets the seconds.

Returns:
seconds.

Definition at line 417 of file time.c.

References GETTIMEOFDAY.

Referenced by cftimer_create(), cftimer_process_timers(), flush_old_maps(), map_info(), read_map_log(), set_map_reset_time(), and swap_map().

Here is the caller graph for this function:

void set_abs_magic ( object *  op,
int  magic 
)

Sets magical bonus in an object, and recalculates the effect on the armour variable, and the effect on speed of armour.

This function doesn't work properly, should add use of archetypes to make it truly absolute.

Parameters:
opobject we're modifying.
magicmagic modifier.

Definition at line 844 of file treasure.c.

References ARMOUR, and ARMOUR_SPEED.

Referenced by add_abilities(), command_create(), and set_magic().

Here is the caller graph for this function:

void set_attr_value ( living stats,
int  attr,
sint8  value 
)

Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW).

Parameters:
statsitem to modify. Must not be NULL.
attrattribute to change.
valuenew value.
Todo:
check if attr is valid? Check whether value is valid or not.

Definition at line 296 of file living.c.

References CHA, liv::Cha, CON, liv::Con, DEX, liv::Dex, INT, liv::Int, POW, liv::Pow, STR, liv::Str, WIS, and liv::Wis.

Referenced by apply_changes_to_player(), cast_change_ability(), change_abil(), check_stat_bounds(), eat_special_food(), fix_object(), set_ring_bonus(), swap_random_stats(), and swap_stat().

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:

void set_dragon_name ( object *  pl,
const object *  abil,
const object *  skin 
)

Set the new dragon name after gaining levels or changing ability focus (later this can be extended to eventually change the player's face and animation)

Note that the title is written to 'own_title' in the player struct. This should be changed to 'ext_title' as soon as clients support this! Please, anyone, write support for 'ext_title'.

Parameters:
plplayer's object to change.
abildragon's innate abilities.
skindragon's skin.

Definition at line 1566 of file living.c.

References atnr_is_dragon_enabled(), attacks, NROFATTACKS, and snprintf().

Referenced by check_login(), and dragon_level_gain().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_map_reset_time ( mapstruct map)

Updates the map's timeout.

Parameters:
mapmap to update.

Definition at line 2239 of file map.c.

References MAP_DEFAULTRESET, MAP_MAXRESET, MAP_RESET_TIMEOUT, MAP_WHEN_RESET, and seconds().

Referenced by load_original_map(), and swap_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_materialname ( object *  op,
int  difficulty,
materialtype_t nmt 
)
void set_max_time ( long  t)

Sets the max speed.

Can be called by a DM through the speed command.

Parameters:
tnew speed.

Definition at line 256 of file time.c.

References max_time.

Referenced by command_speed().

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:

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(), llevError, and LOG().

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:

int set_variable ( object *  op,
char *  buf 
)

Referenced by command_create(), and command_patch().

Here is the caller graph for this function:

void share_exp ( object *  op,
sint64  exp,
const char *  skill,
int  flag 
)

Gives experience to a player/monster, sharing it with party if applicable.

This does bounds checking to make sure we don't overflow the max exp.

The exp passed is typically not modified much by this function - it is assumed the caller has modified the exp as needed.

This is merely a wrapper for change_exp().

Parameters:
opvictim to alter.
expexperience to gain (positive) or lose (negative).
skillskill to change. Can be NULL.
flag
  • if experience gain, what to do if player doesn't have the skill
  • if experience loss, whether to remove from all skills or only specified skill
Note:
flag only applies to op, not other players in same party.

Definition at line 2150 of file living.c.

References change_exp(), first_player, pl::next, pl::ob, on_same_map(), PLAYER, and SK_EXP_TOTAL.

Referenced by kill_object(), and mood_change().

Here is the call graph for this function:

Here is the caller graph for this function:

void sleep_delta ( void  )

sleep_delta checks how much time has elapsed since last tick.

If it is less than max_time, the remaining time is slept with select().

Definition at line 195 of file time.c.

References GETTIMEOFDAY, last_time, log_time(), max_time, and process_utime_long_count.

Referenced by server_main().

Here is the call graph for this function:

Here is the caller graph for this function:

void ss_dump_statistics ( char *  buf,
size_t  size 
)

A call to this function will cause the statistics to be dumped into specified buffer.

The routines will gather statistics if SS_STATISTICS is defined.

Parameters:
bufbuffer which will contain dumped information.
sizebuf's size.

Definition at line 315 of file shstr.c.

References snprintf().

Referenced by command_strings().

Here is the call graph for this function:

Here is the caller graph for this function:

char* ss_dump_table ( int  what,
char *  buf,
size_t  size 
)

Dump the contents of the share string tables.

Parameters:
whatcombination of flags:
  • SS_DUMP_TABLE: dump the contents of the hash table to stderr.
  • SS_DUMP_TOTALS: return a string which says how many entries etc. there are in the table.
bufbuffer that will contain total information if (what & SS_DUMP_TABLE). Left untouched else.
sizebuffer's size
Returns:
buf if (what & SS_DUMP_TOTALS) or NULL.

Definition at line 346 of file shstr.c.

References llevDebug, LOG(), _shared_string::next, _shared_string::refcount, snprintf(), SS_DUMP_TABLE, SS_DUMP_TOTALS, _shared_string::string, TABLESIZE, and TOPBIT.

Referenced by command_ssdumptable(), and command_strings().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* strcasestr_local ( const char *  s,
const char *  find 
)

Finds a substring in a string, in a case-insensitive manner.

Parameters:
sstring we're searching into.
findstring we're searching for.
Returns:
pointer to first occurrence of find in s, NULL if not found.

Definition at line 461 of file porting.c.

References strncasecmp(), and tolower.

Referenced by display_high_score(), write_mark(), and write_note().

Here is the call graph for this function:

Here is the caller graph for this function:

char* strdup_local ( const char *  str)

A replacement of strdup(), since it's not defined at some unix variants.

Parameters:
strstring to duplicate.
Returns:
copy, needs to be freed by caller. NULL on memory allocation error.

Definition at line 310 of file porting.c.

Referenced by add_shop_item(), build_stringlist(), cast_spell(), cfapi_system_strdup_local(), check_login(), draw_ext_info(), fire_bow(), form_party(), generate_random_map(), init_attackmess(), init_connection(), init_emergency_mappath(), load_dir(), load_map_header(), load_settings(), metaserver2_init(), parse_regions(), parse_shop_string(), push(), read_bmap_names(), read_client_images(), and read_map_log().

Here is the caller graph for this function:

char* strerror_local ( int  errnum,
char *  buf,
size_t  size 
)

This takes an err number and returns a string with a description of the error.

Parameters:
errnumerror we want the description of.
bufbuffer to contain the description.
sizebuf's length.
Returns:
buf.

Definition at line 525 of file porting.c.

References snprintf().

Referenced by add_score(), command_help(), compile_info(), dead_player(), display_high_score(), do_server(), i18n_init(), init_anim(), init_races(), init_server(), load_original_map(), load_temporary_map(), make_path_to_file(), read_bmap_names(), read_face_data(), read_smooth(), save_map(), SockList_ReadPacket(), write_socket_buffer(), and Write_To_Socket().

Here is the call graph for this function:

Here is the caller graph for this function:

void stringbuffer_append_printf ( StringBuffer sb,
const char *  format,
  ... 
)

Definition at line 106 of file stringbuffer.c.

void stringbuffer_append_string ( StringBuffer sb,
const char *  str 
)

Definition at line 97 of file stringbuffer.c.

Definition at line 133 of file stringbuffer.c.

Definition at line 78 of file stringbuffer.c.

Definition at line 87 of file stringbuffer.c.

Definition at line 64 of file stringbuffer.c.

void strip_endline ( char *  buf)

Removes endline from buffer (modified in place).

Definition at line 431 of file utils.c.

References EOL_SIZE.

Referenced by parse_shop_string(), and send_news().

Here is the caller graph for this function:

void strip_media_tag ( char *  message)

Strip out the media tags from a String.

Warning the input string will contain the result string

Definition at line 388 of file utils.c.

Referenced by draw_ext_info().

Here is the caller graph for this function:

const char* strrstr ( const char *  haystack,
const char *  needle 
)

Finds a string in a string.

Todo:
isn't there another function (porting.c?) for that?

Definition at line 414 of file utils.c.

int strtoint ( const char *  buf)

Convert buf into an integer equal to the coadded sum of the (lowercase) character.

ASCII values in buf (times prepended integers).

Parameters:
bufbuffer we want to convert. Can contain an initial number.
Returns:
sum of lowercase characters of the ingredient's name.

Definition at line 616 of file recipe.c.

References ingred_name(), numb_ingred(), and tolower.

Referenced by add_book_to_list(), calc_alch_danger(), content_recipe_value(), dump_alchemy(), find_title(), and init_formulae().

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

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 CONTAINER, and sum_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 tailor_readable_ob ( object *  book,
int  msg_type 
)

The main routine.

This chooses a random message to put in given readable object (type==BOOK) which will be referred hereafter as a 'book'. We use the book level to de- termine the value of the information we will insert. Higher values mean the book will (generally) have better/more info. See individual cases as to how this will be utilized. "Book" name/content length are based on the weight of the document. If the value of msg_type is negative, we will randomly choose the kind of message to generate. -b.t. thomas@astro.psu.edu

Parameters:
bookthe object we are creating into. Must be a book, can have a level.
msg_typeif it is a positive value, we use that to determine the message type - otherwise a random value is used.

Definition at line 2010 of file readable.c.

References add_string(), artifact_msg(), BOOK, BOOK_BUF, BOOKSIZE, change_book(), free_string(), god_info_msg(), make_formula_book(), mon_info_msg(), msgfile_msg(), MSGTYPE_ALCHEMY, MSGTYPE_ARTIFACT, MSGTYPE_GODS, MSGTYPE_LIB, MSGTYPE_MONSTER, MSGTYPE_SPELLPATH, and spellpath_msg().

Referenced by fix_generated_item().

Here is the call graph for this function:

Here is the caller graph for this function:

char* tempnam_local ( const char *  dir,
const char *  pfx 
)

A replacement for the tempnam() function since it's not defined at some unix variants.

Do not use this function for new code, use tempnam_secure() instead.

Parameters:
dirdirectory where to create the file. Can be NULL, in which case NULL is returned.
pfxprefix to create unique name. Can be NULL.
Returns:
path to temporary file, or NULL if failure. Must be freed by caller.

Definition at line 87 of file porting.c.

References curtmp, F_OK, getpid, MAXPATHLEN, and snprintf().

Referenced by save_map(), and tempnam_secure().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* tempnam_secure ( const char *  dir,
const char *  pfx,
char **  filename 
)

A replacement for the tempnam_local() function since that one is not very secure.

This one will open the file in an atomic way on platforms where it is possible.

Parameters:
dirDirectory where to create the file. Can be NULL, in which case NULL is returned.
pfxPrefix to create unique name. Can be NULL.
filenameThis should be a pointer to a char*, the function will overwrite the char* with the name of the resulting file. Must be freed by caller. Value is unchanged if the function returns NULL.
Returns:
A pointer to a FILE opened exclusively, or NULL if failure. It is up to the caller to properly close it.
Note:
The file will be opened read-write.
Todo:
Maybe adding some #ifdef for non-UNIX? I don't have any such system around to test with.

Definition at line 143 of file porting.c.

References llevError, LOG(), MAXTMPRETRY, S_IRUSR, S_IWUSR, and tempnam_local().

Referenced by save_player().

Here is the call graph for this function:

Here is the caller graph for this function:

void time_info ( object *  op)

Players wants to know the time.

Called through the 'time' command.

Parameters:
opplayer who requested time.

Definition at line 353 of file time.c.

References draw_ext_info(), draw_ext_info_format(), FLAG_WIZ, max_time, MIN, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, NDI_UNIQUE, PBUFLEN, print_tod(), process_max_utime, process_min_utime, process_tot_mtime, process_utime_long_count, process_utime_save, pticks, and QUERY_FLAG.

Referenced by command_time().

Here is the call graph for this function:

Here is the caller graph for this function:

void transmute_materialname ( object *  op,
const object *  change 
)

When doing transmutation of objects, we have to recheck the resistances, as some that did not apply previously, may apply now.

Only works on armors.

Definition at line 281 of file utils.c.

References CLOAK, GIRDLE, GLOVES, IS_ARMOR, IS_SHIELD, llevError, LOG(), _materialtype::mod, name_to_material(), and NROFATTACKS.

Referenced by cfapi_object_transmute(), and make_item_from_recipe().

Here is the call graph for this function:

Here is the caller graph for this function:

void trigger_connected ( objectlink *  ol,
object *  cause,
const int  state 
)

Trigger every object in an objectlink.

This was originally part of push_button but has been extracted to make it possible to trigger the connected object on a map from a plugin without requiring a source object. This method will take care of calling EVENT_TRIGGER of all elligible object in list (see state parameter)

Parameters:
olthe objectlink to trigger. This can be acquire from map
causethe object that cause this path to trigger, may be NULL
statewhich object to apply. 0=all object with FLAG_ACTIVATE_ON_PUSH other=all object with FLAG_ACTIVATE_ON_RELEASE

Definition at line 52 of file button.c.

References ALTAR, animate_turning(), BUTTON, CF_HANDLE, DIRECTOR, EVENT_TRIGGER, execute_event(), ext_info_map(), FIREWALL, FLAG_ACTIVATE_ON_PUSH, FLAG_ACTIVATE_ON_RELEASE, FLAG_ANIMATE, FLAG_FREED, GATE, HOLE, llevError, LOG(), move_firewall(), MSG_SUBTYPE_NONE, MSG_TYPE_SIGN, NDI_NAVY, NDI_UNIQUE, ob_trigger(), PEDESTAL, QUERY_FLAG, SCRIPT_FIX_ALL, SET_ANIMATION, SIGN, TIMED_GATE, update_ob_speed(), and update_object().

Referenced by cfapi_map_trigger_connected(), and push_button().

Here is the call graph for this function:

Here is the caller graph for this function:

int try_find_animation ( const char *  name)

Tries to find the animation id that matches name, don't LOG() an error if not found.

Parameters:
namethe animation's name.
Returns:
animation number, or 0 if no match found (animation 0 is initialized as the 'bug' face).
See also:
find_animation

Definition at line 161 of file anim.c.

References anim_compare(), animations, animations_struct::name, animations_struct::num, and num_animations.

Referenced by apply_anim_suffix(), apply_changes_to_player(), and find_animation().

Here is the call graph for this function:

Here is the caller graph for this function:

archetype* try_find_archetype ( const char *  name)

Finds, using the hashtable, which archetype matches the given name.

Will not LOG() if not found.

Returns:
pointer to the found archetype, otherwise NULL.
See also:
find_archetype()

Definition at line 671 of file arch.c.

References arch_cmp, arch_search, arch_table, ARCHTABLE, and hasharch().

Referenced by cfapi_map_present_arch_by_name(), cfapi_object_create(), cfapi_object_find_archetype_inside(), find_archetype(), pick_joined_wall(), retrofit_joined_wall(), send_race_info(), and CREArtifactPanel::setArtifact().

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 CLEAR_FLAG, 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_all_los ( const mapstruct map,
int  x,
int  y 
)

This function makes sure that update_los() will be called for all players on the given map within the next frame.

It is triggered by removal or inserting of objects which blocks the sight in the map. Modified by MSW 2001-07-12 to take a coordinate of the changed position, and to also take map tiling into account. This change means that just being on the same map is not sufficient - the space that changes must be withing your viewable area.

Parameters:
mapmap that changed.
x
ycoordinates of the change.
Todo:
check if this couldn't be simplified, especially tiling (isn't there a function somewhere that could help?)

Definition at line 544 of file los.c.

References pl::do_los, first_player, MAP_HEIGHT, MAP_WIDTH, socket_struct::mapx, socket_struct::mapy, pl::next, pl::ob, pl::socket, and mapdef::tile_map.

Referenced by cfapi_object_set_property(), do_turn(), gate_type_process(), insert_ob_in_map(), insert_ob_in_ob(), kill_object(), magic_wall(), remove_ob(), and tear_down_wall().

Here is the caller graph for this function:

void update_all_map_los ( mapstruct map)

update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are.

This generally should not be used, as a per specific map change doesn't make much sense when tiling is considered (lowering darkness would certainly be a strange effect if done on a tile map, as it makes the distinction between maps much more obvious to the players, which is should not be. Currently, this function is called from the change_map_light function

Parameters:
mapmap on which affected players are.

Definition at line 516 of file los.c.

References pl::do_los, first_player, pl::next, and pl::ob.

Referenced by change_map_light().

Here is the caller graph for this function:

void update_button ( object *  op)

Updates everything connected with the button op.

After changing the state of a button, this function must be called to make sure that all gates and other buttons connected to the button reacts to the (eventual) change of state.

Parameters:
opobject to update.

Definition at line 178 of file button.c.

References BUTTON, get_button_links(), llevDebug, LOG(), PEDESTAL, PLAYER, push_button(), SET_ANIMATION, SPECIAL_KEY, and update_object().

Referenced by button_type_move_on(), pedestal_type_move_on(), and update_buttons().

Here is the call graph for this function:

Here is the caller graph for this function:

void update_buttons ( mapstruct m)

Updates every button on the map (by calling update_button() for them).

Definition at line 241 of file button.c.

References BUTTON, mapdef::buttons, llevError, LOG(), PEDESTAL, and update_button().

Referenced by load_original_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void update_los ( object *  op)

Recalculates the array which specifies what is visible for the given player-object.

Parameters:
opplayer's object for which to compute.

Definition at line 467 of file los.c.

References blinded_sight(), check_wall(), clear_los(), expand_sight(), FLAG_BLIND, FLAG_REMOVED, FLAG_WIZ, FLAG_XRAYS, MAP_CLIENT_X, MAP_CLIENT_Y, and QUERY_FLAG.

Referenced by command_nowiz(), and draw_client_map().

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 active_objects, arch_init, FABS, FLAG_FREED, llevError, LOG(), MIN_ACTIVE_SPEED, and QUERY_FLAG.

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 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, llevDebug, llevError, LOG(), MAP_HEIGHT, MAP_SAVING, MAP_WIDTH, 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, UPD_FACE, update_object(), and update_position().

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_position ( mapstruct m,
int  x,
int  y 
)
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 FLAG_IS_TURNABLE, QUERY_FLAG, SET_ANIMATION, 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:

void use_trigger ( object *  op)

Toggles the state of specified button.

Parameters:
opobject to toggle.

Definition at line 268 of file button.c.

References push_button().

Referenced by check_inv(), do_talk_npc(), spring_trap(), and trigger_move().

Here is the call graph for this function:

Here is the caller graph for this function:

void verify_button_links ( const mapstruct map)

This does a minimal check of the button link consistency for object map.

All it really does it much sure the object id link that is set matches what the object has.

Will log to error level.

Parameters:
mapmap to check.

Definition at line 853 of file button.c.

References mapdef::buttons, llevError, and LOG().

Here is the call graph for this function:

void write_book_archive ( void  )

Write out the updated book archive to bookarch file.

Definition at line 2127 of file readable.c.

References titlestruct::archname, titlestruct::authour, titleliststruct::first_book, get_titlelist(), titlestruct::level, llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, titlestruct::msg_index, titlestruct::name, need_to_write_bookarchive, titlestruct::next, titleliststruct::next, SAVE_MODE, settings, titlestruct::size, and snprintf().

Referenced by cleanup(), and do_specials().

Here is the call graph for this function:

Here is the caller graph for this function:

void write_todclock ( void  )

Write out the current time to the file so time does not reset every time the server reboots.

Definition at line 424 of file init.c.

References llevError, Settings::localdir, LOG(), MAX_BUF, snprintf(), and todtick.

Referenced by clean_tmp_files(), init_clocks(), and tick_the_clock().

Here is the call graph for this function:

Here is the caller graph for this function:

void yyfree ( void *  ptr)
int yyget_debug ( void  )
FILE* yyget_in ( void  )
int yyget_leng ( void  )
int yyget_lineno ( void  )
FILE* yyget_out ( void  )
char* yyget_text ( void  )
int yylex_destroy ( void  )
void yypop_buffer_state ( void  )
void yyrestart ( FILE *  input_file)
void yyset_debug ( int  bdebug)
void yyset_in ( FILE *  in_str)
void yyset_lineno ( int  line_number)
void yyset_out ( FILE *  out_str)