49 extern int check_altar_sacrifice(
const object *altar,
const object *sacrifice,
int remove_others,
int *toremove);
56 extern void check_inv(
object *op,
object *trig);
61 extern int64_t
new_exp(
const object *ob);
83 extern const object *
find_god(
const char *name);
127 extern object *
identify(
object *op);
135 extern uint64_t
price_base(
const object *obj);
137 extern const char *
i18n(
const object *who,
const char *code);
163 extern void set_dragon_name(
object *pl,
const object *abil,
const object *skin);
171 extern void change_exp(
object *op, int64_t exp,
const char *skill_name,
int flag);
174 extern void share_exp(
object *op, int64_t exp,
const char *skill,
int flag);
204 extern
int check_path(const
char *name,
int prepend_dir);
228 extern
int on_same_map(const
object *op1, const
object *op2);
235 extern
char *
ob_describe(const
object *op, const
object *observer,
int use_media_tags,
char *buf,
size_t size);
236 extern
method_ret ob_examine(const
object *op, const
object *observer,
int use_media_tags,
char *buf,
size_t size);
267 extern
void object_copy(const
object *src_ob,
object *dest_ob);
287 extern
object *
object_split(
object *orig_ob, uint32_t nr,
char *err,
size_t size);
308 extern
int dirdiff(
int dir1,
int dir2);
331 extern
int object_set_value(
object *op, const
char *key, const
char *value,
int add_key);
338 extern
int save_object(FILE *fp,
object *op,
int flag);
343 extern
char *
path_combine(const
char *src, const
char *dst,
char *path,
size_t size);
347 extern FILE *
tempnam_secure(const
char *dir, const
char *pfx,
char **filename);
349 extern
int ihypot(
int a,
int b);
350 extern
int isqrt(
int n);
367 extern const
char *
re_cmp(const
char *str, const
char *regexp);
369 extern
int nstrtok(const
char *buf1, const
char *buf2);
370 extern
char *
strtoktolin(const
char *buf1, const
char *buf2,
char *retbuf,
size_t size);
382 extern
void init_msgfile(FILE *file, const
char *filename);
390 extern
int strtoint(const
char *buf);
426 extern
long usec_elapsed(struct timespec first, struct timespec second);
435 extern
long timespec_diff(struct timespec *end, struct timespec *start);
445 extern
void fix_generated_item(
object *op,
object *creator,
int difficulty,
int max_magic,
int flags);
452 extern
int random_roll(
int min,
int max, const
object *op,
int goodbad);
453 extern int64_t
random_roll64(int64_t min, int64_t max, const
object *op,
int goodbad);
454 extern
int die_roll(
int num,
int size, const
object *op,
int goodbad);
455 extern
int rndm(
int min,
int max);
461 extern
void replace(const
char *src, const
char *key, const
char *replacement,
char *result,
size_t resultsize);
467 extern
size_t split_string(
char *str,
char *array[],
size_t array_size,
char sep);
484 extern
void yyfree(
void *ptr);
485 extern
int load_object(FILE *fp,
object *op,
int bufstate,
int map_flags,
bool artifact_init);
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Returns the description (short item name) of an object, as seen by the given observer.
void init_objects(void)
Sets up and initialises the linked list of free and used objects.
void object_set_owner(object *op, object *owner)
Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects...
void object_reset(object *op)
Totally resets the specified object, without freeing associated memory.
int object_count_free(void)
Objects statistics.
method_ret(* apply_func)(object *, object *, int)
Typedefs for ob_methods.
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 ...
void dump_map(const mapstruct *m)
Prints out debug-information about a map.
void free_all_recipes(void)
Frees all memory allocated to recipes and recipes lists.
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
object * object_find_by_tag_global(tag_t i)
Returns the object which has the count-variable equal to the argument.
archetype * find_archetype_by_object_name(const char *name)
This function retrieves an archetype given the name that appears during the game (for example...
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Combines the 2 paths.
int is_type_valid(uint8_t type)
oblinkpt * get_objectlinkpt(void)
Allocates a new oblinkpt structure, initialises it, and returns a pointer to it.
int check_altar_sacrifice(const object *altar, const object *sacrifice, int remove_others, int *toremove)
Checks whether the altar has enough to sacrifice.
method_ret ob_examine(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Get examine text for OP as seen by OBSERVER.
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
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...
Implements a buffer reader.
int object_matches_string(object *pl, object *op, const char *name)
This is a subset of the parse_id command.
This is used by get_rangevector to determine where the other creature is.
int object_find_multi_free_spot_around(const object *ob, const object *gen, int16_t *hx, int16_t *hy)
Sets hx and hy to the coords to insert a possibly multi-tile ob at, around gen.
This represents one animation.
void dump_faces(void)
Dump all faces to stderr, for debugging purposes.
void free_map(mapstruct *m)
Frees everything allocated by the given mapstructure.
void void init_block(void)
initialises the array used by the LOS routines.
void object_merge_spell(object *op, int16_t x, int16_t y)
This sees if there are any objects on the space that can merge with op.
void tick_game_time(void)
void object_copy_owner(object *op, object *clone)
Set the owner to clone's current owner and set the skill and experience objects to clone's objects (t...
void free_arch(archetype *at)
Frees archetype.
void add_abilities(object *op, const object *change)
Apply artifact properties to an object.
sstring stringbuffer_finish_shared(StringBuffer *sb)
const char * get_month_name(const int index)
give access to month names
const object * get_rand_god(void)
Returns a random god.
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Searches for any objects with a matching archetype at the given map and coordinates.
void replace_unprintable_chars(char *buf)
Replaces any unprintable character in the given buffer with a space.
StringBuffer * describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf)
Generates the visible naming for resistances.
object * object_find_by_type_and_skill(const object *who, int type, const char *skill)
Find object in inventory by type and skill.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
This struct stores function pointers for actions that can be done to objects.
int adjust_dir(int dir, int destination_dir)
Adjusts a given direction by +/-1 towards a destination direction.
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
int load_object(FILE *fp, object *op, int bufstate, int map_flags, bool artifact_init)
int is_old_wraith_pl(object *op)
Checks if player is a wraith without the 'wraith feed' skill.
objectlink * get_objectlink(void)
Allocates a new objectlink structure, initialises it, and returns a pointer to it.
void dump_abilities(void)
Dump to standard out the abilities of all monsters.
void decay_objects(mapstruct *m)
Decay and destroy persihable items in a map.
void print_los(object *op)
Debug-routine which dumps the array which specifies the visible area of a player. ...
int get_dex_bonus(int stat)
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
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 dump_experience(void)
Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format o...
void * language_t
Strings that should be manipulated through add_string() and free_string().
int load_face_file(FILE *file, const char *full_path)
void dump_all_archetypes(void)
Dumps all archetypes to debug-level output.
artifact * get_empty_artifact(void)
Allocate and return the pointer to an empty artifact structure.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
int describe_god(const object *god, int what, StringBuffer *buf, size_t maxlen)
Describe a god.
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
void object_insert_to_free_spot_or_free(object *op, mapstruct *map, int x, int y, int start, int stop, object *originator)
Inserts an object into its map.
int exp_level(int64_t exp)
Returns the level for a given exp.
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
void object_replace_insert_in_map(const char *arch_string, object *op)
This function inserts an object of a specified archetype in the map, but if it finds objects of its o...
void clean_friendly_list(void)
It traverses the friendly list removing objects that should not be here (ie, do not have friendly fla...
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.
object * create_singularity(const char *name)
Creates a dummy object.
void object_copy_no_speed(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
int ihypot(int a, int b)
Rough estimate of hypot(a, b).
void object_dump(const object *op, StringBuffer *sb)
Dumps an object.
New face structure - this enforces the notion that data is face by face only - you can not change the...
void object_dump_all(void)
Dumps all objects to console.
const Face * recipe_get_face(const recipe *rp)
Return the best face associated with a recipe.
unsigned int tick_length(float seconds)
Calculate the number of ticks that correspond to real time.
void change_luck(object *op, int value)
Alter the object's luck.
int get_power_from_ench(int ench)
void map_remove_unique_files(const mapstruct *map)
Remove files containing the map's unique items.
uint16_t artifact_get_face(const artifact *art)
Get a suitable face number for representing an artifact.
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 stringbuffer_append_stringbuffer(StringBuffer *sb, const StringBuffer *sb2)
archetype * find_archetype(const char *name)
void delete_map(mapstruct *m)
Frees the map, including the mapstruct.
void yypop_buffer_state(void)
int calc_item_enhancement(const object *op)
method_ret(* trigger_func)(object *, object *, int)
int get_thaco_bonus(int stat)
Each object (this also means archetypes!) could have a few of these "dangling" from it; this could al...
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
void init_msgfile(FILE *file, const char *filename)
int load_object_from_reader(BufferReader *reader, object *op, int map_flags, bool arch_init, bool artifact_init)
void init_archetype_pointers(void)
Initialize global archtype pointers:
void player_set_own_title(struct player *pl, const char *title)
Sets the custom title.
void yyset_out(FILE *out_str)
object * generate_treasure(treasurelist *t, int difficulty)
Generate a treasure from a list generating a single item.
void update_button(object *op)
Updates everything connected with the button op.
void use_trigger(object *op)
Toggles the state of specified button.
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.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
int is_identifiable_type(const object *op)
Return true if this item's type is one that cares about whether or not it's been identified – e...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
int operate_altar(object *altar, object **sacrifice)
Checks if sacrifice was accepted and removes sacrificed objects.
treasure * treasure_insert(treasurelist *list, int position)
Insert a new treasure in the treasure list, at a specific position in the children list...
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...
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
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...
void dump_gods(void)
Prints all gods to stderr.
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
Represents the ingame time.
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings...
int die_roll(int num, int size, const object *op, int goodbad)
Roll a number of dice (2d3, 4d6).
int find_smooth(const Face *face, const Face **smoothed)
Find the smooth face for a given face.
region * get_region_by_name(const char *region_name)
Gets a region by name.
region * get_region_from_string(const char *name)
Tries to find a region that 'name' corresponds to.
This stores, for a spell a player knows, the last sp/gr/dam information sent to client.
void clear_los(player *pl)
Clears/initialises the los-array associated to the player controlling the object. ...
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Find object in inventory by type and archetype name.
void dump_alchemy_costs(void)
Dumps to output all costs of recipes.
uint8_t find_color(const char *name)
Finds a color by name.
void dump_friendly_objects(void)
Dumps all friendly objects.
void object_update_turn_face(object *op)
If an object with the IS_TURNABLE() flag needs to be turned due to the closest player being on the ot...
const Face * try_find_face(const char *name, const Face *error)
const typedata * get_typedata(int itemtype)
int object_find_multi_free_spot_within_radius(const object *ob, const object *gen, int *hx, int *hy)
Sets hx and hy to the coords to insert a possibly multi-tile ob at, within radius of generator...
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
archetype * get_next_archetype(archetype *current)
region * get_region_struct(void)
Allocates and zeros a region struct, this isn't free()'d anywhere, so might be a memory leak...
int get_fear_bonus(int stat)
void init_experience(void)
This loads the experience table from the exp_table file.
Link an object type with skill needed to identify, and general name.
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
void generate_artifact(object *op, int difficulty)
Decides randomly which artifact the object should be turned into.
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coo...
void player_get_title(const struct player *pl, char *buf, size_t bufsize)
method_ret(* process_func)(object *)
void free_objectlinkpt(oblinkpt *obp)
Recursively frees all linked list of objectlink pointers.
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying...
int object_matches_pickup_mode(const object *item, int mode)
Checks if an item matches a specific pickup mode.
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.
void write_todclock(void)
Write out the current time to the file so time does not reset every time the server reboots...
#define PRINTF_ARGS(x, y)
Used for printf-like functions, mostly LOG and draw_ext_info_format.
mapstruct * mapfile_load(const char *map, int flags)
Opens the file "filename" and reads information about the map from the given file, and stores it in a newly allocated mapstruct.
int get_cha_bonus(int stat)
void load_treasures(void)
int64_t check_exp_loss(const object *op, int64_t exp)
This function checks to make sure that object 'op' can lose 'exp' experience.
int find_dir_2(int x, int y)
Computes a direction which you should travel to move of x and y.
Used to link together several object links.
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
int is_identified(const object *op)
Return true if the item is identified, either because it is of a type that doesn't ever need identifi...
object * object_find_by_type_and_slaying(const object *who, int type, const char *slaying)
Find object in inventory by type and slaying.
void yyset_in(FILE *in_str)
int get_cleric_chance(int stat)
void path_normalize(char *path)
Cleans specified path.
One reply a NPC can expect.
char * strtoktolin(const char *buf1, const char *buf2, char *retbuf, size_t size)
Takes a string in buf1 and separates it into a list of strings delimited by buf2. ...
void object_remove_from_active_list(object *op)
This function removes object 'op' from the list of active objects.
void fatal(enum fatal_error err) __attribute__((noreturn))
fatal() is meant to be called whenever a fatal signal is intercepted.
int check_trigger(object *op, object *cause)
char method_ret
Define some standard return values for callbacks which don't need to return any other results...
void init_readable(void)
Initialize linked lists utilized by message functions in tailor_readable_ob()
object * get_next_friend(object *current)
Get the next object on the friendly list.
void object_fix_multipart(object *tmp)
Ensures specified object has its more parts correctly inserted in map.
object * map_find_by_type(mapstruct *m, int x, int y, uint8_t type)
Searches for any objects with a matching type variable at the given map and coordinates.
void push_button(object *op)
Push the specified object.
int set_variable(object *op, const char *buf)
bool check_formulae(void)
Check if formula don't have the same index.
int object_can_merge(object *ob1, object *ob2)
Examines the 2 objects given to it, and returns true if they can be merged together, including inventory.
int absdir(int d)
Computes an absolute direction.
object * map_find_by_flag(mapstruct *map, int x, int y, int flag)
Finds an object in a map tile by flag number.
StringBuffer * describe_spellpath_attenuation(const char *attenuation, int value, StringBuffer *buf)
Describe the specified path attenuation.
objectlink * get_friends_of(const object *owner)
Get a list of friendly objects for the specified owner.
void(* describe_func)(const object *, const object *, int use_media_tags, char *buf, size_t size)
sstring get_message_body(const GeneralMessage *message)
Get a message's body.
void artifact_compute_chance_for_item(const object *op, const artifact *art, int *numerator, int *denominator)
Compute the chance for a specified item to become the specified artifact.
void link_player_skills(object *op)
This function goes through the player inventory and sets up the last_skills[] array in the player obj...
void query_name(const object *op, char *buf, size_t size)
Describes an item.
void object_clear_owner(object *op)
Clears the owner of specified object.
void object_unset_flag_inv(object *op, int flag)
Desactivate recursively a flag on an object inventory.
void object_add_weight(object *op, signed long weight)
object_add_weight(object, weight) adds the specified weight to an object, and also updates how much t...
void i18n_free(void)
Clears all i18n-related data.
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players...
size_t get_faces_count(void)
object * arch_present_in_ob(const archetype *at, const object *op)
Searches for any objects with a matching archetype in the inventory of the given object.
void free_dialog_information(object *op)
Frees obj::dialog_information.
long timespec_diff(struct timespec *end, struct timespec *start)
Return the difference between two timespec's in microseconds.
archetype * get_archetype_struct(void)
Allocates, initialises and returns the pointer to an archetype structure.
const char * get_periodofday(const int index)
give access to weekday names
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
void create_template_pathname(const char *name, char *buf, size_t size)
same as create_pathname(), but for the template maps.
const char * get_weekday(const int index)
give access to weekday names
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
void register_examine(int ob_type, examine_func method)
Registers the examine method for the given type.
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
object * object_present_in_ob(uint8_t type, const object *op)
Searches for any objects with a matching type variable in the inventory of the given object...
void stringbuffer_append_multiline_block(StringBuffer *sb, const char *start, const char *content, const char *end)
sstring i18n_get_language_code(language_t language)
Return the code of a specified language.
const char * destination_dir
Root destination dir.
int 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 object_clear(object *op)
Frees everything allocated by an object, and also clears all variables and flags to default settings...
object * object_find_by_type_and_race(const object *who, int type, const char *race)
Find object in inventory by type and race.
void free_experience(void)
Frees experience-related memory.
int save_map(mapstruct *m, int flag)
Saves a map to file.
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 object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Information on one title.
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
object_find_first_free_spot(archetype, mapstruct, x, y) works like object_find_free_spot(), but it will search max number of squares.
StringBuffer * describe_monster(const object *op, int use_media_tags, StringBuffer *buf)
Describes a monster.
void remove_statbonus(object *op)
Subtracts stat-bonuses given by the class which the player has chosen.
void init_regions(BufferReader *reader, const char *filename)
Reads/parses the region file, and copies into a linked list of region structs.
void object_copy(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
void object_update_speed(object *op)
Updates the speed of an object.
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
bool object_value_set_shared(const object *op, sstring key)
Determine if an extra value is set to a non empty or 0 value.
client_spell * get_client_spell_state(player *pl, object *spell)
Gets the (client-side) spell state for specified spell.
uint32_t get_weight_limit(int stat)
const char * get_region_msg(const region *r)
Gets a message for a region.
object * object_find_by_tag(const object *who, tag_t tag)
Find object in inventory.
void clean_object(object *op)
Remove and free all objects in the inventory of the given object.
const Face * get_message_face(const GeneralMessage *message)
Get a message's face.
void clear_friendly_list(void)
Totally clear the friendly list.
materialtype_t * name_to_material(const char *name)
Convert materialname to materialtype_t.
void update_los(object *op)
Recalculates the array which specifies what is visible for the given player-object.
void tailor_readable_ob(object *book, int msg_type)
The main routine.
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 p...
List of recipes with a certain number of ingredients.
void free_globals(void)
Cleans all memory allocated for global variables.
int object_distance(const object *ob1, const object *ob2)
Return the square of the distance between the two given objects.
void update_buttons(mapstruct *m)
Updates every button on the map (by calling update_button() for them).
treasure * get_empty_treasure()
Allocate and return the pointer to an empty treasure structure.
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
void drain_stat(object *op)
Drains a random stat from op.
void yyrestart(FILE *input_file)
archetype * find_treasure_by_name(const treasure *t, const char *name, int depth)
Find a treasure with a matching name.
mapstruct * get_empty_map(int sizex, int sizey)
Creates and returns a map of the specific size.
void treasure_remove_item(treasurelist *list, int position)
Remove the treasure at the specified position from the list.
int64_t new_exp(const object *ob)
Alternative way to calculate experience based on the ability of a monster.
artifactlist * find_artifactlist(int type)
Finds the artifact list for a certain item type.
const readable_message_type * get_readable_message_type(object *readable)
Get the readable type for an object (hopefully book).
void formula_knowledge_code(const recipe *r, char *buf, size_t len)
Store the textual knowledge marker code for recipe R in BUF.
const char * get_region_longname(const region *r)
Gets the longname of a region.
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Find object in inventory by type and name.
void dump_animations(void)
Dump all animations to stderr, for debugging purposes.
int object_count_active(void)
Objects statistics.
Used to link together several objects.
void register_trigger(int ob_type, trigger_func method)
Registers the trigger method for the given type.
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling. ...
int blocked_link(object *ob, mapstruct *m, int16_t sx, int16_t sy)
Returns true if the given coordinate is blocked except by the object passed is not blocking...
int get_learn_spell(int stat)
int has_ability(const object *ob)
Checks whether object has innate abilities (spell/spellbook in inventory).
int is_friendly(const object *op)
Checks if the given object is already in the friendly list or not.
void init_library(void)
It is vital that init_library() is called by any functions using this library.
StringBuffer * stringbuffer_new(void)
float get_speed_bonus(int stat)
Struct to store the message_type and message_subtype for signs and books used by the player...
int check_path(const char *name, int prepend_dir)
This function checks if a file with the given path exists.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
void load_image_info(FILE *file, const char *filename)
This represents all archetypes for one particular object type.
object * object_find_by_type_without_flags(const object *who, int type, int *flags, int num_flags)
Find an object in inventory that does not have any of the provided flags set.
void free_all_god(void)
Frees all god information.
char * create_pathname(const char *name, char *buf, size_t size)
Get the full path to a map file.
void animate_turning(object *op)
Animates one step of object.
int has_carried_lights(const object *op)
Checks if op has a light source.
void make_path_to_file(const char *filename)
Checks if any directories in the given path doesn't exist, and creates if necessary.
void dump_artifacts(void)
For debugging purposes.
void player_set_dragon_title(struct player *pl, int level, const char *attack, int skin_resist)
Updates the title of a dragon player to reflect the current level, attack type, and resistances...
void add_friendly_object(object *op)
Add a new friendly object to the list of friendly objects.
char * size
Human-readable set size.
char * stringbuffer_finish(StringBuffer *sb)
int get_rangevector_from_mapcoord(const mapstruct *m, int x, int y, const object *op2, rv_vector *retval)
This is basically the same as get_rangevector() above, but instead of the first parameter being an ob...
object * object_insert_in_map(object *op, mapstruct *m, object *originator, int flag)
This function inserts the object in the two-way linked list which represents what is on a map...
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...
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
void object_update(object *op, int action)
object_update() updates the array which represents the map.
uint32_t tag_t
Object tag, unique during the whole game.
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
Computes the size of a multitile object.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
void stringbuffer_append_string(StringBuffer *sb, const char *str)
static ob_methods base_type
void free_all_artifacts(void)
Free all artifact-related information.
void set_map_reset_time(mapstruct *map)
Updates the map's timeout.
int nstrtok(const char *buf1, const char *buf2)
Simple routine to return the number of list items in buf1 as separated by the value of buf2...
int allowed_class(const object *op)
Returns true if the given player is a legal class.
method_ret ob_process(object *op)
Processes an object, giving it the opportunity to move or react.
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
void yyset_lineno(int line_number)
object * object_find_by_type2(const object *who, int type1, int type2)
Find object in inventory.
void yyset_debug(int bdebug)
void init_ob_method_struct(ob_methods *methods, ob_methods *fallback)
Initializes a ob_methods struct.
int get_face_fallback(int faceset, uint16_t imageno)
This returns the set we will actually use when sending a face.
language_t i18n_get_language_by_code(const char *code)
Find the identifier of a language from its code.
void set_attr_value(living *stats, int attr, int8_t value)
Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW)...
int calculate_difficulty(mapstruct *m)
This routine is supposed to find out the difficulty of the map.
int dirdiff(int dir1, int dir2)
Computes a direction difference.
void i18n_list_languages(object *who)
List all languages for who.
int get_button_value(const object *button)
Returns the first value linked to this button.
LogLevel
Log levels for the LOG() function.
const char * time_format_time(const timeofday_t *tod, char *buf, size_t bufsize)
Formats a timestamp in Crossfire time.
int save_object(FILE *fp, object *op, int flag)
Dumps all variables in an object to a file.
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. ...
int calc_item_power(const object *op)
This takes an object 'op' and figures out what its item_power rating should be.
object * get_random_mon(int level)
Returns a random monster selected from linked list of all monsters in the current game...
int player_has_own_title(const struct player *pl)
Returns whether the player has a custom title.
const char * recipe_get_difficulty_string(int difficulty)
A method to produce a difficulty adjective to describe alchemy projects.
method_ret(* examine_func)(const object *, const object *, int use_media_tags, char *buf, size_t size)
key_value * object_get_key_value(const object *ob, const char *key)
Search for a field by key.
void make_list_like(char *input)
Taking a string as an argument, mutate it into a string that looks like a list.
void trigger_connected(objectlink *ol, object *cause, const int state)
Trigger every object in an objectlink.
int get_randomized_dir(int dir)
Returns a random direction (1..8) similar to a given direction.
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
int book_overflow(const char *buf1, const char *buf2, size_t booksize)
Checks if buf1 and buf2 can be combined.
void free_player(player *pl)
Frees player structure, including pointed object (through object_free_drop_inventory()).
void init_stats()
This loads statistic bonus/penalties from the stat_bonus file.
int strtoint(const char *buf)
Convert buf into an integer equal to the coadded sum of the (lowercase) character.
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 object_sub_weight(object *op, signed long weight)
Recursively (outwards) subtracts a number from the weight of an object (and what is carried by it's e...
Various statistics of objects.
object * check_inv_recursive(object *op, const object *trig)
Checks object and its inventory for specific item.
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
static const flag_definition flags[]
Flag mapping.
const char * get_season_name(const int index)
give access to season names
void object_free_all_data(void)
Destroys all allocated objects.
treasurelist represents one logical group of items to be generated together.
void object_copy_with_inv(const object *src_ob, object *dest_ob, bool update_speed)
Copy an object with an inventory, duplicate the inv too.
const artifact * find_artifact(const object *op, const char *name)
Searches and returns a specific artifact compatible with an object, NULL if not found.
int is_magical(const object *op)
Checks whether object is magical.
object * object_find_by_type(const object *who, int type)
Find object in inventory.
recipe * find_recipe_for_tool(const char *tool, recipe *from)
Find a recipe for a specified tool.
int get_random_dir(void)
Returns a random direction (1..8).
const Face * get_face_by_id(uint16_t id)
Get a face from its unique identifier.
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
Animations * try_find_animation(const char *name)
uint64_t price_base(const object *obj)
Determine the base (intrinsic) value of an item.
const char * player_get_own_title(const struct player *pl)
Returns the player's own title.
method_ret ob_apply(object *op, object *applier, int aflags)
Apply an object by running an event hook or an object method.
size_t stringbuffer_length(StringBuffer *sb)
object * object_get_player_container(object *op)
Finds the player carrying an object.
void create_overlay_pathname(const char *name, char *buf, size_t size)
Same as create_pathname(), but for the overlay maps.
void free_charlinks(linked_char *lc)
Frees a link structure and its next items.
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...
const char * re_cmp(const char *str, const char *regexp)
re-cmp - get regular expression match.
recipelist * get_formulalist(int i)
Gets a formula list by ingredients count.
archetype * try_find_archetype(const char *name)
int get_dam_bonus(int stat)
language_t i18n_find_language_by_code(const char *code)
Attempt to find the identifier of a language from its code.
const artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
Finds an artifact for a recipe.
void free_objectlink(objectlink *ol)
Recursively frees all objectlinks.
int64_t check_exp_adjust(const object *op, int64_t exp)
Returns the maximum experience the object can gain or lose.
void change_attr_value(living *stats, int attr, int8_t value)
Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat...
void set_tick_duration(long t)
Sets the tick duration.
static event_registration m
archetype * get_archetype_by_skill_name(const char *skill, int type)
Retrieves an archetype by skill name and type.
int is_dragon_pl(const object *op)
Checks if player is a dragon.
int load_png_file(FILE *file, const char *full_path)
void register_describe(int ob_type, describe_func method)
Registers the describe method for the given type.
int region_is_child_of_region(const region *child, const region *r)
Checks if a region is a child of another.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
mapstruct * get_linked_map(void)
Allocates, initialises, and returns a pointer to a mapstruct, linked through first_map.
Animations * find_animation(const char *name)
void init_ob_types(ob_methods *base_type)
Initializes the object system.
void drain_specific_stat(object *op, int deplete_stats)
Drain a specified stat from op.
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.
struct face_sets * fallback
Faceset to use when an image is not found in this faceset.
method_ret ob_trigger(object *op, object *cause, int state)
An object is triggered by another one.
int get_turn_bonus(int stat)
void treasure_free(treasure *t)
Frees a treasure, including its yes, no and next items.
long usec_elapsed(struct timespec first, struct timespec second)
Return the number of microseconds between two timespec structures.
object * object_create_clone(object *asrc)
Create clone from object to another.
void free_all_maps(void)
Frees all allocated maps.
One message a NPC can react to.
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
int change_map_light(mapstruct *m, int change)
Used to change map light level (darkness) up or down.
float ticks_to_seconds(int ticks)
void player_lvl_adj(object *who, object *op)
For the new exp system.
const char * map_get_path(const object *item)
Return the map path on which the specified item is.
const char * get_colorname(uint8_t index)
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
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 ...
void object_handle_death_animation(object *op)
const Face * find_face(const char *name)
void add_statbonus(object *op)
Adds stat-bonuses given by the class which the player has chosen.
void init_formulae(BufferReader *reader, const char *filename)
Builds up the lists of formula from the file in the libdir.
void first_arch_pass(FILE *fp, const char *filename)
recipe * get_random_recipe(recipelist *rpl)
Gets a random recipe from a list, based on chance.
void get_search_arr(int *search_arr)
New function to make monster searching more efficient, and effective! This basically returns a random...
void get_levelnumber(int i, char *buf, size_t size)
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...
const char * get_name_of_region_for_map(const mapstruct *m)
Gets the name of a region for a map.
void object_free_key_values(object *op)
Zero the key_values on op, decrementing the shared-string refcounts and freeing the links...
treasure is one element in a linked list, which together consist of a complete treasure-list.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
void save_object_in_sb(StringBuffer *sb, object *op, const int flag)
Store a string representation of op in sb.
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
void check_stat_bounds(living *stats, int8_t min_stat, int8_t max_stat)
Ensures that all stats (str/dex/con/wis/cha/int) are within the passed in range of min_stat and max_s...
int object_count_used(void)
Object statistics.
void calc_perm_exp(object *op)
Ensure that the permanent experience requirements in an exp object are met.
void object_free_inventory(object *ob)
Frees the inventory of an object, without any callback.
int is_valid_faceset(int fsn)
Checks specified faceset is valid.
void apply_anim_suffix(object *who, const char *suffix)
Applies a compound animation to an object.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
char * path_combine(const char *src, const char *dst, char *path, size_t size)
Combines 2 paths, which can be relative.
long seconds(void)
Return wall clock time in seconds.
void dump_monster_treasure(const char *name)
For debugging purposes.
bool check_recipes()
Ensure that all recipes have a valid artifact, and that archetypes are correct.
artifactlist * get_empty_artifactlist(void)
Allocate and return the pointer to an empty artifactlist structure.
int isqrt(int n)
Compute the square root.
int rndm(int min, int max)
Returns a number between min and max.
object * object_find_by_name_global(const char *str)
Finds an object by name.
object * object_find_by_flag(const object *who, int flag)
Find object in inventory by flag.
object * identify(object *op)
Identifies an item.
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...
const char * get_god_for_race(const char *race)
Returns a string that is the name of the god that should be natively worshipped by a creature of who ...
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.
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...
const typedata * get_typedata_by_name(const char *name)
void print_monsters(void)
As dump_abilities(), but with an alternative way of output.
sstring get_message_title(const GeneralMessage *message)
Get a message's title.
void LOG(LogLevel logLevel, const char *format,...) PRINTF_ARGS(2
void make_sure_seen(const object *op)
The object is supposed to be visible through walls, thus check if any players are nearby...
One general message, from the lib/messages file.
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.
const GeneralMessage * get_message_from_identifier(const char *identifier)
Find the message from its identifier.
void set_materialname(object *op)
Set the material name and type for an item, if not set.
void object_set_flag_inv(object *op, int flag)
Activate recursively a flag on an object's inventory.
method_ret(* move_on_func)(object *, object *, object *)
void i18n_init(void)
Initializes the i18n subsystem.
void dump_arch(archetype *at, StringBuffer *sb)
Dumps an archetype to buffer.
int is_wraith_pl(object *op)
Tests if a player is a wraith.
A buffer that will be expanded as content is added to it.
int64_t random_roll64(int64_t min, int64_t max, const object *op, int goodbad)
This is a 64 bit version of random_roll() above.
void get_tod(timeofday_t *tod)
Computes the ingame time of the day.
void free_all_readable(void)
Free all readable-related information.
void write_book_archive(void)
Write out the updated book archive to bookarch file.
void apply_death_exp_penalty(object *op)
Applies a death penalty experience, the size of this is defined by the settings death_penalty_percent...
void add_button_link(object *button, mapstruct *map, int connected)
Links specified object in the map.
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
long get_sleep_remaining(void)
void stringbuffer_delete(StringBuffer *sb)
void clear_player(player *pl)
Clears data in player structure.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
const object * find_god(const char *name)
Returns a god's object from its name.
void share_exp(object *op, int64_t exp, const char *skill, int flag)
Gives experience to a player/monster, sharing it with party if applicable.
This is one artifact, ie one special item.
void strip_endline(char *buf)
Removes endline from buffer (modified in place).
void time_info(object *op)
Players wants to know the time.
object * object_decrease_nrof(object *op, uint32_t i)
Decreases a specified number from the amount of an object.
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
void query_weight(const object *op, char *buf, size_t size)
Formats the item's weight.
fatal_error
Fatal variables; used as arguments to fatal().
void object_set_cheat(object *op)
object_set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recur...
void init_globals(void)
Initialises all global variables.
void animation_load_block(FILE *file, const char *full_path, const char *animation_name)
void init_attackmess(BufferReader *reader, const char *filename)
Initializes the attack messages.
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
Returns true if the given object can't fit in the given spot.
object * object_get_env_recursive(object *op)
Utility function.
method_ret ob_move_on(object *op, object *victim, object *originator)
Makes an object move on top of another one.
void clean_tmp_map(mapstruct *m)
Removse the temporary file used by the map.
void reset_sleep(void)
Initialise all variables used in the timing routines.
void give_artifact_abilities(object *op, const object *artifact)
Fixes the given object, giving it the abilities and titles it should have due to the second artifact-...
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.
StringBuffer * describe_attacktype(const char *attack, int value, StringBuffer *buf)
Describe the specified attack type.
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Returns a pointer to a static string which contains all variables which are different in the two give...
int object_check_move_on(object *op, object *originator)
Checks if any objects has a move_type that matches objects that effect this object on this space...
int legal_artifact_combination(const object *op, const artifact *art)
Checks if op can be combined with art.
object * object_find_by_name(const object *who, const char *name)
Finds an object in inventory name.
void dump_alchemy(void)
Dumps alchemy recipes to output.
object * object_find_by_flag_applied(const object *who, int flag)
Find applied object in inventory by flag.
void dump_all_maps(void)
Prints out debug-information about all maps.
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
const char * i18n(const object *who, const char *code)
Translate a message in the appropriate language.