Skip to content

Commit a5f8d06

Browse files
committed
equip_slot_by_name(): Remove duplicated list and catch "Body Armour"
Allows Lua API's `item.equip_type` to work with `l_item_equipped_at()` and `l_slot_is_available()`. Previously didn't work for body armour. `s_equip_slot_names` was only created to support this function afaict, and just shadows `enum equipment_slot`. It's not used anywhere else and afaict was just tech debt. Tested locally and everything works as before, just with the body armour improvement.
1 parent 9201133 commit a5f8d06

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

crawl-ref/settings/crawl-rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 2dd35f34996ff21cdb522f328c9a9f4bfadd0ec2

crawl-ref/source/output.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,17 +1999,15 @@ int update_monster_pane()
19991999
}
20002000
#endif
20012001

2002-
static const char *s_equip_slot_names[] =
2003-
{
2004-
"Weapon", "Offhand", "Armour", "Helmet", "Gloves", "Boots",
2005-
"Barding", "Cloak", "Ring", "Amulet", "Gizmo"
2006-
};
2007-
20082002
int equip_slot_by_name(const char *s)
20092003
{
20102004
for (int i = SLOT_FIRST_STANDARD; i <= SLOT_LAST_STANDARD; ++i)
2011-
if (!strcasecmp(s_equip_slot_names[i - SLOT_FIRST_STANDARD], s))
2005+
{
2006+
equipment_slot slot = static_cast<equipment_slot>(i);
2007+
if (!strcasecmp(s, equip_slot_name(slot, true)) ||
2008+
!strcasecmp(s, equip_slot_name(slot, false)))
20122009
return i;
2010+
}
20132011

20142012
return -1;
20152013
}

0 commit comments

Comments
 (0)