summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-10 08:32:32 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-10 08:34:59 -0700
commit8844f9d7204f9ae5114f36a60c89386ae938718f (patch)
treeeb9d975696f9cceae4575833cbb2bc5f6f95c52d /crawl-ref/source/initfile.cc
parentdc23beb9a4f92a5af90896e1876596e2a5d5b274 (diff)
downloadcrawl-ref-8844f9d7204f9ae5114f36a60c89386ae938718f.tar.gz
crawl-ref-8844f9d7204f9ae5114f36a60c89386ae938718f.zip
Partially refactor _weapon_to_str
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc34
1 files changed, 5 insertions, 29 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index ac93bfbe62..925050f7ef 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -34,6 +34,7 @@
#include "tileweb.h"
#endif
#include "invent.h"
+#include "itemprop.h"
#include "libutil.h"
#include "macro.h"
#include "mapdef.h"
@@ -245,40 +246,15 @@ weapon_type str_to_weapon(const string &str)
return WPN_UNKNOWN;
}
-static string _weapon_to_str(int wpn_type)
+static string _weapon_to_str(weapon_type wpn_type)
{
+ if (wpn_type >= 0 && wpn_type < NUM_WEAPONS)
+ return weapon_base_name(wpn_type);
+
switch (wpn_type)
{
- case WPN_SHORT_SWORD:
- return "short sword";
- case WPN_CUTLASS:
- return "cutlass";
- case WPN_FALCHION:
- return "falchion";
- case WPN_LONG_SWORD:
- return "long sword";
- case WPN_QUARTERSTAFF:
- return "quarterstaff";
- case WPN_MACE:
- return "mace";
- case WPN_FLAIL:
- return "flail";
- case WPN_SPEAR:
- return "spear";
- case WPN_TRIDENT:
- return "trident";
- case WPN_HAND_AXE:
- return "hand axe";
- case WPN_WAR_AXE:
- return "war axe";
case WPN_UNARMED:
return "claws";
- case WPN_HUNTING_SLING:
- return "hunting sling";
- case WPN_SHORTBOW:
- return "shortbow";
- case WPN_CROSSBOW:
- return "crossbow";
case WPN_THROWN:
return "thrown";
case WPN_VIABLE: