Angband
Functions
obj-desc.c File Reference

Create object name descriptions. More...

#include "angband.h"
#include "obj-chest.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-knowledge.h"
#include "obj-tval.h"
#include "obj-util.h"

Functions

void object_base_name (char *buf, size_t max, int tval, bool plural)
 Puts the object base kind's name into buf. More...
 
void object_kind_name (char *buf, size_t max, const struct object_kind *kind, bool easy_know)
 Puts a very stripped-down version of an object's name into buf. More...
 
static const char * obj_desc_get_modstr (const struct object_kind *kind)
 A modifier string, put where '#' goes in the basename below. More...
 
static const char * obj_desc_get_basename (const struct object *obj, bool aware, bool terse, int mode)
 An object's basic name - a generic name for flavored objects (with the actual name added later depending on awareness, the name from object.txt for almost everything else, and a bit extra for books. More...
 
static size_t obj_desc_name_prefix (char *buf, size_t max, size_t end, const struct object *obj, const char *basename, const char *modstr, bool terse)
 Start to description, indicating number/uniqueness (a, the, no more, 7, etc) More...
 
size_t obj_desc_name_format (char *buf, size_t max, size_t end, const char *fmt, const char *modstr, bool pluralise)
 Formats 'fmt' into 'buf', with the following formatting characters: More...
 
static size_t obj_desc_name (char *buf, size_t max, size_t end, const struct object *obj, bool prefix, int mode, bool terse)
 Format object obj's name into 'buf'. More...
 
static bool obj_desc_show_armor (const struct object *obj)
 Is obj armor? More...
 
static size_t obj_desc_chest (const struct object *obj, char *buf, size_t max, size_t end)
 Special descriptions for types of chest traps. More...
 
static size_t obj_desc_combat (const struct object *obj, char *buf, size_t max, size_t end, int mode)
 Describe combat properties of an item - damage dice, to-hit, to-dam, armor class, missile multipler. More...
 
static size_t obj_desc_light (const struct object *obj, char *buf, size_t max, size_t end)
 Describe remaining light for refuellable lights. More...
 
static size_t obj_desc_mods (const struct object *obj, char *buf, size_t max, size_t end)
 Describe numerical modifiers to stats and other player qualities which allow numerical bonuses - speed, stealth, etc. More...
 
static size_t obj_desc_charges (const struct object *obj, char *buf, size_t max, size_t end, int mode)
 Describe charges or charging status for re-usable items with magic effects. More...
 
static size_t obj_desc_inscrip (const struct object *obj, char *buf, size_t max, size_t end)
 Add player-defined inscriptions or game-defined descriptions. More...
 
static size_t obj_desc_aware (const struct object *obj, char *buf, size_t max, size_t end)
 Add "unseen" to the end of unaware items in stores, and "??" to not fully known unflavored items. More...
 
size_t object_desc (char *buf, size_t max, const struct object *obj, int mode)
 Describes item obj into buffer buf of size max. More...
 

Detailed Description

Create object name descriptions.

Copyright (c) 1997 - 2007 Angband contributors

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Function Documentation

static size_t obj_desc_aware ( const struct object obj,
char *  buf,
size_t  max,
size_t  end 
)
static

Add "unseen" to the end of unaware items in stores, and "??" to not fully known unflavored items.

References object_flavor_is_aware(), object_runes_known(), and strnfcat().

Referenced by object_desc().

static size_t obj_desc_charges ( const struct object obj,
char *  buf,
size_t  max,
size_t  end,
int  mode 
)
static

Describe charges or charging status for re-usable items with magic effects.

References object::activation, object::effect, object::number, number_charging(), object_flavor_is_aware(), ODESC_STORE, PLURAL, object::pval, strnfcat(), object::timeout, tval_can_have_charges(), and tval_is_rod().

Referenced by object_desc().

static size_t obj_desc_chest ( const struct object obj,
char *  buf,
size_t  max,
size_t  end 
)
static
static size_t obj_desc_combat ( const struct object obj,
char *  buf,
size_t  max,
size_t  end,
int  mode 
)
static
static const char* obj_desc_get_basename ( const struct object obj,
bool  aware,
bool  terse,
int  mode 
)
static

An object's basic name - a generic name for flavored objects (with the actual name added later depending on awareness, the name from object.txt for almost everything else, and a bit extra for books.

References object::artifact, object_kind::flavor, object::kind, object_kind::name, object_is_known_artifact(), ODESC_STORE, OPT, and object::tval.

Referenced by obj_desc_name().

static const char* obj_desc_get_modstr ( const struct object_kind kind)
static

A modifier string, put where '#' goes in the basename below.

The weird games played with book names are to allow the non-essential part of the name to be abbreviated when there is not much room to display.

References object_kind::flavor, object_kind::name, flavor::text, tval_can_have_flavor_k(), and tval_is_book_k().

Referenced by obj_desc_name().

static size_t obj_desc_inscrip ( const struct object obj,
char *  buf,
size_t  max,
size_t  end 
)
static
static size_t obj_desc_light ( const struct object obj,
char *  buf,
size_t  max,
size_t  end 
)
static

Describe remaining light for refuellable lights.

References object::flags, of_has, strnfcat(), object::timeout, and tval_is_light().

Referenced by object_desc().

static size_t obj_desc_mods ( const struct object obj,
char *  buf,
size_t  max,
size_t  end 
)
static

Describe numerical modifiers to stats and other player qualities which allow numerical bonuses - speed, stealth, etc.

References i, object::modifiers, OBJ_MOD_MAX, and strnfcat().

Referenced by object_desc().

static size_t obj_desc_name ( char *  buf,
size_t  max,
size_t  end,
const struct object obj,
bool  prefix,
int  mode,
bool  terse 
)
static
size_t obj_desc_name_format ( char *  buf,
size_t  max,
size_t  end,
const char *  fmt,
const char *  modstr,
bool  pluralise 
)

Formats 'fmt' into 'buf', with the following formatting characters:

'~' at the end of a word (e.g. "fridge~") will pluralise

'|x|y|' will be output as 'x' if singular or 'y' if plural (e.g. "kni|fe|ves|")

'#' will be replaced with 'modstr' (which may contain the pluralising formats given above).

References NULL, obj_desc_name_format(), prev, and strnfcat().

Referenced by lookup_sval(), obj_desc_name(), obj_desc_name_format(), object_base_name(), object_kind_name(), wr_ignore(), and wr_item().

static size_t obj_desc_name_prefix ( char *  buf,
size_t  max,
size_t  end,
const struct object obj,
const char *  basename,
const char *  modstr,
bool  terse 
)
static

Start to description, indicating number/uniqueness (a, the, no more, 7, etc)

References is_a_vowel(), object::number, object_is_known_artifact(), and strnfcat().

Referenced by obj_desc_name().

static bool obj_desc_show_armor ( const struct object obj)
static

Is obj armor?

References object::ac, player::obj_k, and tval_is_armor().

Referenced by obj_desc_combat().

void object_base_name ( char *  buf,
size_t  max,
int  tval,
bool  plural 
)
size_t object_desc ( char *  buf,
size_t  max,
const struct object obj,
int  mode 
)

Describes item obj into buffer buf of size max.

ODESC_PREFIX prepends a 'the', 'a' or number ODESC_BASE results in a base description. ODESC_COMBAT will add to-hit, to-dam and AC info. ODESC_EXTRA will add pval/charge/inscription/ignore info. ODESC_PLURAL will pluralise regardless of the number in the stack. ODESC_STORE turns off ignore markers, for in-store display. ODESC_SPOIL treats the object as fully identified.

Setting 'prefix' to true prepends a 'the', 'a' or the number in the stack, respectively.

Returns
The number of bytes used of the buffer.

Construct the name

References object::ego, object_kind::everseen, ego_item::everseen, ignore_item_ok(), object::kind, object::known, object_kind::name, obj_desc_aware(), obj_desc_charges(), obj_desc_chest(), obj_desc_combat(), obj_desc_inscrip(), obj_desc_light(), obj_desc_mods(), obj_desc_name(), object_flavor_is_aware(), ODESC_COMBAT, ODESC_EXTRA, ODESC_PREFIX, ODESC_SPOIL, ODESC_STORE, ODESC_TERSE, prefix(), object::pval, strnfmt(), tval_is_chest(), tval_is_light(), and tval_is_money().

Referenced by activation_message(), apply_autoinscription(), artifact_power(), become_aware(), brand_object(), context_menu_cave(), context_menu_object(), context_menu_store_item(), death_examine(), death_info(), desc_art_fake(), desc_obj_fake(), display_object_recall(), display_object_recall_interactive(), do_cmd_buy(), do_cmd_inscribe(), do_cmd_sell(), do_cmd_stash(), do_cmd_wield(), drop_near(), effect_handler_CURSE_ARMOR(), effect_handler_CURSE_WEAPON(), effect_handler_DAMAGE(), effect_handler_DISENCHANT(), enchant_spell(), equip_learn_after_time(), equip_learn_element(), equip_learn_flag(), floor_carry_fail(), floor_object_for_use(), gear_object_for_use(), get_art_name(), get_artifact_display_name(), get_artifact_name(), inven_carry(), inven_damage(), inven_drop(), inven_takeoff(), inven_wield(), kind_info(), melee_effect_handler_EAT_FOOD(), melee_effect_handler_EAT_ITEM(), minus_ac(), object_curses_find_element(), object_curses_find_flags(), object_learn_on_wield(), object_list_format_name(), pack_overflow(), player_know_object(), process_monster_grab_objects(), project_o(), project_p(), ranged_helper(), recharged_notice(), see_floor_items(), set_obj_names(), spoil_artifact(), store_display_entry(), store_examine(), store_purchase(), store_sell(), target_recall_loop_object(), target_set_interactive_aux(), textui_cmd_ignore_menu(), textui_obj_examine(), uncurse_object(), verify_object(), wiz_display_item(), and write_character_dump().

void object_kind_name ( char *  buf,
size_t  max,
const struct object_kind kind,
bool  easy_know 
)

Puts a very stripped-down version of an object's name into buf.

If easy_know is true, then the IDed names are used, otherwise flavours, scroll names, etc will be used.

Just truncates if the buffer isn't big enough.

References object_kind::aware, object_kind::flavor, my_strcpy(), object_kind::name, NULL, obj_desc_name_format(), and flavor::text.

Referenced by activation_message(), cmp_ignore(), display_object(), ignore_sval_menu_display(), and wiz_create_item_subdisplay().