summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-02 22:33:32 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-02 22:33:32 +0000
commitb4bcbd1a2dca417a61f70eb9d1524fa92b2e0aa9 (patch)
tree64e357255f2460a8c93fb46e315e606416f84583 /src/map/itemdb.c
parente6b8222bdb14b6e1e8b3cd12733ae1bce97a23fb (diff)
downloadhercules-b4bcbd1a2dca417a61f70eb9d1524fa92b2e0aa9.tar.gz
hercules-b4bcbd1a2dca417a61f70eb9d1524fa92b2e0aa9.tar.bz2
hercules-b4bcbd1a2dca417a61f70eb9d1524fa92b2e0aa9.tar.xz
hercules-b4bcbd1a2dca417a61f70eb9d1524fa92b2e0aa9.zip
* Various code tweaks and updates related to item types.
- Replaced item type literals with their appropriate constants. - Added itemdb_typename to replace the ugly "BUG!" filled array in @iteminfo (since r1741, follow up to r14550). - Made the item database parser verify item type for validity. - Added item type constants to const.txt for use in scripts (getiteminfo). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14551 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 8eb173a85..10341ff0f 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -180,6 +180,27 @@ struct item_data* itemdb_exists(int nameid)
return item;
}
+/// Returns human readable name for given item type.
+/// @param type Type id to retrieve name for ( IT_* ).
+const char* itemdb_typename(int type)
+{
+ switch(type)
+ {
+ case IT_HEALING: return "Potion/Food";
+ case IT_USABLE: return "Usable";
+ case IT_ETC: return "Etc.";
+ case IT_WEAPON: return "Weapon";
+ case IT_ARMOR: return "Armor";
+ case IT_CARD: return "Card";
+ case IT_PETEGG: return "Pet Egg";
+ case IT_PETARMOR: return "Pet Accessory";
+ case IT_AMMO: return "Arrow/Ammunition";
+ case IT_DELAYCONSUME: return "Delay-Consume Usable";
+ case IT_CASH: return "Cash Usable";
+ }
+ return "Unknown Type";
+}
+
/*==========================================
* Converts the jobid from the format in itemdb
* to the format used by the map server. [Skotlex]
@@ -748,6 +769,13 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
safestrncpy(id->jname, str[2], sizeof(id->jname));
id->type = atoi(str[3]);
+
+ if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_DELAYCONSUME && id->type < IT_CASH ) || id->type >= IT_MAX )
+ {// catch invalid item types
+ ShowWarning("itemdb_parse_dbrow: Invalid item type %d for item %d. IT_ETC will be used.\n", id->type, nameid);
+ id->type = IT_ETC;
+ }
+
if (id->type == IT_DELAYCONSUME)
{ //Items that are consumed only after target confirmation
id->type = IT_USABLE;