diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 14 | ||||
-rw-r--r-- | src/map/itemdb.c | 28 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/skill.c | 4 |
5 files changed, 37 insertions, 12 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6cf5d1c4e..117d6dc0a 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1663,15 +1663,15 @@ ACMD_FUNC(item2) if (item_id > 500) { loop = 1; get_count = number; - if (item_data->type == 4 || item_data->type == 5 || - item_data->type == 7 || item_data->type == 8) { + if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR || + item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) { loop = number; get_count = 1; - if (item_data->type == 7) { + if (item_data->type == IT_PETEGG) { identify = 1; refine = 0; } - if (item_data->type == 8) + if (item_data->type == IT_PETARMOR) refine = 0; if (refine > 10) refine = 10; @@ -7390,10 +7390,6 @@ ACMD_FUNC(homshuffle) *------------------------------------------*/ ACMD_FUNC(iteminfo) { - char *itype[IT_MAX] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow", - "BUG!", // No need, type 11 items are converted to type 2 upon loading [Skotlex] - "BUG!", "BUG!", "BUG!", "BUG!", "BUG!", "BUG!", "Cash Usable"}; - struct item_data *item_data, *item_array[MAX_SEARCH]; int i, count = 1; @@ -7418,7 +7414,7 @@ ACMD_FUNC(iteminfo) item_data = item_array[i]; sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s", item_data->name,item_data->jname,item_data->slot,item_data->nameid, - item_data->type < IT_MAX ? itype[item_data->type] : "BUG!", + itemdb_typename(item_data->type), (item_data->script==NULL)? "None" : "With script" ); clif_displaymessage(fd, atcmd_output); 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; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 5b07b5c1b..00dbf73e3 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -108,6 +108,7 @@ struct item_data* itemdb_exists(int nameid); #define itemdb_available(n) (itemdb_exists(n) && itemdb_search(n)->flag.available) #define itemdb_viewid(n) (itemdb_search(n)->view_id) #define itemdb_autoequip(n) (itemdb_search(n)->flag.autoequip) +const char* itemdb_typename(int type); int itemdb_group_bonus(struct map_session_data* sd, int itemid); int itemdb_searchrandomid(int flags); diff --git a/src/map/pc.c b/src/map/pc.c index 9d8ad29b0..785036d0f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -605,7 +605,7 @@ int pc_setequipindex(struct map_session_data *sd) if( sd->status.inventory[i].equip & EQP_HAND_L ) { - if( sd->inventory_data[i] && sd->inventory_data[i]->type == 4 ) + if( sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON ) sd->weapontype2 = sd->inventory_data[i]->look; else sd->weapontype2 = 0; diff --git a/src/map/skill.c b/src/map/skill.c index a6b008d5d..e77703e1f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -9306,7 +9306,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) return; } - if (itemdb_type(item->nameid)==4) + if (itemdb_type(item->nameid)==IT_WEAPON) material = materials [itemdb_wlv(item->nameid)-1]; // Lv1/2/3/4 weapons consume 1 Iron Ore/Iron/Steel/Rough Oridecon else material = materials [2]; // Armors consume 1 Steel @@ -9357,7 +9357,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) struct item_data *ditem = sd->inventory_data[idx]; item = &sd->status.inventory[idx]; - if(item->nameid > 0 && ditem->type == 4) + if(item->nameid > 0 && ditem->type == IT_WEAPON) { if( item->refine >= sd->menuskill_val || item->refine >= MAX_REFINE // if it's no longer refineable |