Angband
Functions | Variables
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-identify.h"
#include "obj-ignore.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.
void object_kind_name (char *buf, size_t max, const object_kind *kind, bool easy_know)
 Puts a very stripped-down version of an object's name into buf.
static const char * obj_desc_get_modstr (const object_kind *kind)
 A modifier string, put where '#' goes in the basename below.
static const char * obj_desc_get_basename (const object_type *o_ptr, 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.
static size_t obj_desc_name_prefix (char *buf, size_t max, size_t end, const object_type *o_ptr, bool known, const char *basename, const char *modstr, bool terse)
 Start to description, indicating number/uniqueness (a, the, no more, 7, etc)
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:
static size_t obj_desc_name (char *buf, size_t max, size_t end, const object_type *o_ptr, bool prefix, int mode, bool spoil, bool terse)
 Format object o_ptr's name into 'buf'.
static bool obj_desc_show_armor (const object_type *o_ptr)
 Is o_ptr armor?
static size_t obj_desc_chest (const object_type *o_ptr, char *buf, size_t max, size_t end)
 Special descriptions for types of chest traps.
static size_t obj_desc_combat (const object_type *o_ptr, char *buf, size_t max, size_t end, bool spoil)
 Describe combat properties of an item - damage dice, to-hit, to-dam, armor class, missile multipler.
static size_t obj_desc_light (const object_type *o_ptr, char *buf, size_t max, size_t end)
 Describe remaining light for refuellable lights.
static size_t obj_desc_mods (const object_type *o_ptr, char *buf, size_t max, size_t end, bool spoil)
 Describe numerical modifiers to stats and other player qualities which allow numerical bonuses - speed, stealth, etc.
static size_t obj_desc_charges (const object_type *o_ptr, char *buf, size_t max, size_t end, int mode)
 Describe charges or charging status for re-usable items with magic effects.
static size_t obj_desc_inscrip (const object_type *o_ptr, char *buf, size_t max, size_t end)
 Add player-defined inscriptions or game-defined descriptions.
static size_t obj_desc_aware (const object_type *o_ptr, char *buf, size_t max, size_t end)
 Add "unseen" to the end of unaware items in stores.
size_t object_desc (char *buf, size_t max, const object_type *o_ptr, int mode)
 Describes item o_ptr into buffer buf of size max.

Variables

const char * inscrip_text []

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 object_type o_ptr,
char *  buf,
size_t  max,
size_t  end 
)
static

Add "unseen" to the end of unaware items in stores.

References object_flavor_is_aware(), and strnfcat().

Referenced by object_desc().

static size_t obj_desc_charges ( const object_type o_ptr,
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::artifact, object::number, number_charging(), object_flavor_is_aware(), ODESC_STORE, PLURAL, object::pval, strnfcat(), object::timeout, tval_can_have_charges(), tval_is_light(), and tval_is_rod().

Referenced by object_desc().

static size_t obj_desc_chest ( const object_type o_ptr,
char *  buf,
size_t  max,
size_t  end 
)
static
static size_t obj_desc_combat ( const object_type o_ptr,
char *  buf,
size_t  max,
size_t  end,
bool  spoil 
)
static
static const char* obj_desc_get_basename ( const object_type o_ptr,
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, FALSE, object_kind::flavor, object::id_flags, id_has, object::kind, object_kind::name, ODESC_STORE, OPT, and object::tval.

Referenced by obj_desc_name().

static const char* obj_desc_get_modstr ( const 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 object_type o_ptr,
char *  buf,
size_t  max,
size_t  end 
)
static
static size_t obj_desc_light ( const object_type o_ptr,
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 object_type o_ptr,
char *  buf,
size_t  max,
size_t  end,
bool  spoil 
)
static

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

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

Referenced by object_desc().

static size_t obj_desc_name ( char *  buf,
size_t  max,
size_t  end,
const object_type o_ptr,
bool  prefix,
int  mode,
bool  spoil,
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 obj_desc_name_format(), prev, and strnfcat().

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

static size_t obj_desc_name_prefix ( char *  buf,
size_t  max,
size_t  end,
const object_type o_ptr,
bool  known,
const char *  basename,
const char *  modstr,
bool  terse 
)
static

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

References object::artifact, FALSE, is_a_vowel(), object::number, object_name_is_visible(), strnfcat(), and TRUE.

Referenced by obj_desc_name().

static bool obj_desc_show_armor ( const object_type o_ptr)
static

Is o_ptr armor?

References object::ac, FALSE, TRUE, and tval_is_armor().

Referenced by obj_desc_combat().

void object_base_name ( char *  buf,
size_t  max,
int  tval,
bool  plural 
)

Puts the object base kind's name into buf.

References kb_info, object_base::name, obj_desc_name_format(), and object::tval.

Referenced by wiz_create_item_action(), and wiz_create_item_display().

size_t object_desc ( char *  buf,
size_t  max,
const object_type o_ptr,
int  mode 
)

Describes item o_ptr 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, ego_item::everseen, ignore_item_ok(), object::kind, MARK_AWARE, object::marked, 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_is_known(), ODESC_COMBAT, ODESC_EXTRA, ODESC_PREFIX, ODESC_SPOIL, ODESC_STORE, ODESC_TERSE, prefix(), object::pval, strnfmt(), TRUE, 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(), do_ident_item(), drop_near(), effect_handler_CURSE_ARMOR(), effect_handler_CURSE_WEAPON(), effect_handler_DISENCHANT(), enchant_spell(), equip_notice_after_time(), equip_notice_element(), equip_notice_flag(), floor_object_for_use(), gear_object_for_use(), get_art_name(), get_artifact_display_name(), history_add_artifact(), inven_carry(), inven_damage(), inven_drop(), inven_takeoff(), kind_info(), melee_effect_handler_EAT_FOOD(), melee_effect_handler_EAT_ITEM(), minus_ac(), object_list_format_name(), object_notice_attack_plusses(), object_notice_brands(), object_notice_defence_plusses(), object_notice_slays(), pack_overflow(), process_monster_grab_objects(), project_o(), ranged_helper(), recharged_notice(), see_floor_items(), sense_inventory(), show_obj_list(), 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(), verify_object(), wield_item(), wiz_display_item(), and write_character_dump().

void object_kind_name ( char *  buf,
size_t  max,
const 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, FALSE, object_kind::flavor, my_strcpy(), object_kind::name, obj_desc_name_format(), and flavor::text.

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

Variable Documentation

const char* inscrip_text[]
Initial value:
{
NULL,
"strange",
"average",
"magical",
"splendid",
"excellent",
"special",
"unknown"
}

Referenced by obj_desc_inscrip(), and sense_inventory().