From 0a577362dfe772e6e13eebce39489327b282c98d Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 13 Apr 2007 07:40:38 +0000 Subject: Cleaned up some of the randart code. Fixed a free-without-malloc security issue (of art_n.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1291 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/itemprop.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crawl-ref/source/itemprop.cc') diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index f4c3986a69..7980a564f4 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -2085,3 +2085,24 @@ bool is_shield_incompatible(const item_def &weapon, const item_def *shield) && !item_is_rod(weapon) && !is_range_weapon(weapon); } + +const char* item_base_name(const item_def &item) +{ + return item_base_name(static_cast(item.base_type), + item.sub_type); +} + +const char* item_base_name(object_class_type basetype, unsigned char subtype) +{ + switch (basetype) + { + case OBJ_WEAPONS: + return Weapon_prop[Weapon_index[subtype]].name; + case OBJ_ARMOUR: + return Armour_prop[Armour_index[subtype]].name; + case OBJ_MISSILES: + return Missile_prop[Missile_index[subtype]].name; + default: + return ""; + } +} -- cgit v1.2.3-54-g00ecf