summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/mmo.h1
-rw-r--r--src/map/atcommand.c3
-rw-r--r--src/map/buyingstore.c5
-rw-r--r--src/map/clif.c12
-rw-r--r--src/map/guild.c4
-rw-r--r--src/map/homunculus.c2
-rw-r--r--src/map/itemdb.h4
-rw-r--r--src/map/pc.c32
-rw-r--r--src/map/pet.c43
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/skill.c85
11 files changed, 104 insertions, 89 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index feeb06524..ff7c1da28 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -208,6 +208,7 @@ enum item_types {
IT_MAX
};
+#define INDEX_NOT_FOUND (-1) ///< Used as invalid/failure value in various functions that return an index
// Questlog states
enum quest_state {
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 7e1b53a6f..b5e8fa797 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8214,8 +8214,7 @@ ACMD(delitem) {
total = amount;
// delete items
- while( amount && ( idx = pc->search_inventory(sd, nameid) ) != -1 )
- {
+ while (amount && (idx = pc->search_inventory(sd, nameid)) != INDEX_NOT_FOUND) {
int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 80264b30d..626d102a3 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -126,8 +126,9 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
break;
}
- if( !id->flag.buyingstore || !itemdb->cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 )
- {// restrictions: allowed, no character-bound items and at least one must be owned
+ if (!id->flag.buyingstore || !itemdb->cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd))
+ || (idx = pc->search_inventory(sd, nameid)) == INDEX_NOT_FOUND
+ ) { // restrictions: allowed, no character-bound items and at least one must be owned
break;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index e6953d7a2..d9acf0792 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -3486,10 +3486,10 @@ void clif_arrow_create_list(struct map_session_data *sd)
WFIFOW(fd,0) = 0x1ad;
for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
- if (skill->arrow_db[i].nameid > 0 &&
- (j = pc->search_inventory(sd, skill->arrow_db[i].nameid)) >= 0 &&
- !sd->status.inventory[j].equip && sd->status.inventory[j].identify)
- {
+ if (skill->arrow_db[i].nameid > 0
+ && (j = pc->search_inventory(sd, skill->arrow_db[i].nameid)) != INDEX_NOT_FOUND
+ && !sd->status.inventory[j].equip && sd->status.inventory[j].identify
+ ) {
if ((j = itemdb_viewid(skill->arrow_db[i].nameid)) > 0)
WFIFOW(fd,c*2+4) = j;
else
@@ -14615,7 +14615,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) {
int item_position = pc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED);
int hpsp = 100;
- if (item_position < 0) {
+ if (item_position == INDEX_NOT_FOUND) {
if (sd->sc.data[SC_LIGHT_OF_REGENE])
hpsp = 20 * sd->sc.data[SC_LIGHT_OF_REGENE]->val1;
else
@@ -14628,7 +14628,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) {
if (!status->revive(&sd->bl, hpsp, hpsp))
return;
- if ( item_position < 0)
+ if (item_position == INDEX_NOT_FOUND)
status_change_end(&sd->bl,SC_LIGHT_OF_REGENE,INVALID_TIMER);
else
pc->delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME);
diff --git a/src/map/guild.c b/src/map/guild.c
index af29dc64e..ac24edeab 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -347,8 +347,8 @@ int guild_create(struct map_session_data *sd, const char *name)
clif->guild_created(sd,1);
return 0;
}
- if( battle_config.guild_emperium_check && pc->search_inventory(sd,714) == -1 )
- {// item required
+ if (battle_config.guild_emperium_check && pc->search_inventory(sd, ITEMID_EMPERIUM) == INDEX_NOT_FOUND) {
+ // item required
clif->guild_created(sd,3);
return 0;
}
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 8c47226db..0f76fcf5f 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -578,7 +578,7 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
foodID = hd->homunculusDB->foodID;
i = pc->search_inventory(sd,foodID);
- if(i < 0) {
+ if (i == INDEX_NOT_FOUND) {
clif->hom_food(sd,foodID,0);
return false;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 2ad596ce1..198d7a542 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -58,6 +58,10 @@ enum item_itemid {
ITEMID_ORIDECON_STONE = 756,
ITEMID_ALCHOL = 970,
ITEMID_ORIDECON = 984,
+ ITEMID_ANVIL = 986,
+ ITEMID_ORIDECON_ANVIL = 987,
+ ITEMID_GOLDEN_ANVIL = 988,
+ ITEMID_EMPERIUM_ANVIL = 989,
ITEMID_BOODY_RED = 990,
ITEMID_CRYSTAL_BLUE = 991,
ITEMID_WIND_OF_VERDURE = 992,
diff --git a/src/map/pc.c b/src/map/pc.c
index 7c49730c9..a6619fad2 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3922,16 +3922,23 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type,
return 0;
}
-/*==========================================
- * Searching a specified itemid in inventory and return his stored index
- *------------------------------------------*/
-int pc_search_inventory(struct map_session_data *sd,int item_id)
-{
+/**
+ * Searches for the specified item ID in inventory and return its inventory index.
+ *
+ * If the item is found, the returned value is guaranteed to be a valid index
+ * (non-negative, smaller than MAX_INVENTORY).
+ *
+ * @param sd Character to search on.
+ * @param item_id The item ID to search.
+ * @return the inventory index of the first instance of the requested item.
+ * @retval INDEX_NOT_FOUND if the item wasn't found.
+ */
+int pc_search_inventory(struct map_session_data *sd, int item_id) {
int i;
- nullpo_retr(-1, sd);
+ nullpo_retr(INDEX_NOT_FOUND, sd);
ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == item_id && (sd->status.inventory[i].amount > 0 || item_id == 0) );
- return ( i < MAX_INVENTORY ) ? i : -1;
+ return ( i < MAX_INVENTORY ) ? i : INDEX_NOT_FOUND;
}
/*==========================================
@@ -3940,11 +3947,11 @@ int pc_search_inventory(struct map_session_data *sd,int item_id)
0 = success
1 = invalid itemid not found or negative amount
2 = overweight
- 3 = ?
+ 3 = ?
4 = no free place found
5 = max amount reached
- 6 = ?
- 7 = stack limitation
+ 6 = ?
+ 7 = stack limitation
*------------------------------------------*/
int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type)
{
@@ -4011,10 +4018,9 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
}
}
- if( i >= MAX_INVENTORY )
- {
+ if ( i >= MAX_INVENTORY ) {
i = pc->search_inventory(sd,0);
- if( i < 0 )
+ if (i == INDEX_NOT_FOUND)
return 4;
memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0]));
diff --git a/src/map/pet.c b/src/map/pet.c
index e083e58d1..9275a6de5 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -743,42 +743,39 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) {
return 0;
}
-int pet_food(struct map_session_data *sd, struct pet_data *pd)
-{
- int i,k;
+int pet_food(struct map_session_data *sd, struct pet_data *pd) {
+ int i, food_id;
- k=pd->petDB->FoodID;
- i=pc->search_inventory(sd,k);
- if(i < 0) {
- clif->pet_food(sd,k,0);
+ food_id = pd->petDB->FoodID;
+ i = pc->search_inventory(sd, food_id);
+ if(i == INDEX_NOT_FOUND) {
+ clif->pet_food(sd, food_id, 0);
return 1;
}
pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
- if( pd->pet.hungry > 90 )
+ if (pd->pet.hungry > 90) {
pet->set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
- else
- {
- if( battle_config.pet_friendly_rate != 100 )
- k = (pd->petDB->r_hungry * battle_config.pet_friendly_rate)/100;
+ } else {
+ int add_intimate = 0;
+ if (battle_config.pet_friendly_rate != 100)
+ add_intimate = (pd->petDB->r_hungry * battle_config.pet_friendly_rate)/100;
else
- k = pd->petDB->r_hungry;
- if( pd->pet.hungry > 75 )
- {
- k = k >> 1;
- if( k <= 0 )
- k = 1;
+ add_intimate = pd->petDB->r_hungry;
+ if (pd->pet.hungry > 75) {
+ add_intimate = add_intimate >> 1;
+ if (add_intimate <= 0)
+ add_intimate = 1;
}
- pet->set_intimate(pd, pd->pet.intimate + k);
+ pet->set_intimate(pd, pd->pet.intimate + add_intimate);
}
- if( pd->pet.intimate <= 0 )
- {
+ if (pd->pet.intimate <= 0) {
pd->pet.intimate = 0;
pet_stop_attack(pd);
pd->status.speed = pd->db->status.speed;
- }
- else if( pd->pet.intimate > 1000 )
+ } else if (pd->pet.intimate > 1000) {
pd->pet.intimate = 1000;
+ }
status_calc_pet(pd, SCO_NONE);
pd->pet.hungry += pd->petDB->fullness;
if( pd->pet.hungry > 100 )
diff --git a/src/map/script.c b/src/map/script.c
index 53161be5b..ecd12a3c1 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10343,7 +10343,7 @@ BUILDIN(homunculus_mutate) {
m_id = homun->class2type(homun_id);
if( m_class == HT_EVO && m_id == HT_S &&
- sd->hd->homunculus.level >= 99 && i >= 0 &&
+ sd->hd->homunculus.level >= 99 && i != INDEX_NOT_FOUND &&
!pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_SCRIPT) ) {
sd->hd->homunculus.vaporize = HOM_ST_REST; // Remove morph state.
homun->call(sd); // Respawn homunculus.
diff --git a/src/map/skill.c b/src/map/skill.c
index e71c0a045..b82c47a69 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2196,10 +2196,10 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
/* bugreport:7859 magical reflected zeroes blow count */
dmg.blewcount = 0;
//Spirit of Wizard blocks Kaite's reflection
- if( type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD )
- { //Consume one Fragment per hit of the casted skill? [Skotlex]
- type = tsd?pc->search_inventory(tsd, ITEMID_FRAGMENT_OF_CRYSTAL):0;
- if (type >= 0) {
+ if (type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD) {
+ //Consume one Fragment per hit of the casted skill? [Skotlex]
+ type = tsd ? pc->search_inventory(tsd, ITEMID_FRAGMENT_OF_CRYSTAL) : 0;
+ if (type != INDEX_NOT_FOUND) {
if ( tsd ) pc->delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
dmg.damage = dmg.damage2 = 0;
dmg.dmg_lv = ATK_MISS;
@@ -3038,22 +3038,20 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
return 1;
// Check item existences
- for( i = 0; i < ARRAYLENGTH(itemid); i++ )
- {
- index[i] = -1;
- if( itemid[i] < 1 ) continue; // No item
+ for (i = 0; i < ARRAYLENGTH(itemid); i++) {
+ index[i] = INDEX_NOT_FOUND;
+ if (itemid[i] < 1) continue; // No item
index[i] = pc->search_inventory(sd, itemid[i]);
- if( index[i] < 0 || sd->status.inventory[index[i]].amount < amount[i] )
- {
+ if (index[i] == INDEX_NOT_FOUND || sd->status.inventory[index[i]].amount < amount[i]) {
clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_ITEM, amount[i]|(itemid[i] << 16));
return 0;
}
}
// Consume items
- for( i = 0; i < ARRAYLENGTH(itemid); i++ )
- {
- if( index[i] >= 0 ) pc->delitem(sd, index[i], amount[i], 0, 1, LOG_TYPE_CONSUME);
+ for (i = 0; i < ARRAYLENGTH(itemid); i++) {
+ if (index[i] != INDEX_NOT_FOUND)
+ pc->delitem(sd, index[i], amount[i], 0, 1, LOG_TYPE_CONSUME);
}
if( type&2 )
@@ -6675,7 +6673,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
int x,bonus=100, potion = min(500+skill_lv,505);
x = skill_lv%11 - 1;
i = pc->search_inventory(sd,skill->db[skill_id].itemid[x]);
- if( i < 0 || skill->db[skill_id].itemid[x] <= 0 ) {
+ if (i == INDEX_NOT_FOUND || skill->db[skill_id].itemid[x] <= 0) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map->freeblock_unlock();
return 1;
@@ -6827,7 +6825,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
case AM_TWILIGHT3:
if (sd) {
int ebottle = pc->search_inventory(sd,ITEMID_EMPTY_BOTTLE);
- if( ebottle >= 0 )
+ if (ebottle != INDEX_NOT_FOUND)
ebottle = sd->status.inventory[ebottle].amount;
//check if you can produce all three, if not, then fail:
if (!skill->can_produce_mix(sd,ITEMID_ALCHOL,-1, 100) //100 Alcohol
@@ -10287,8 +10285,9 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if (sd) {
int i = skill_lv%11 - 1;
int j = pc->search_inventory(sd,skill->db[skill_id].itemid[i]);
- if( j < 0 || skill->db[skill_id].itemid[i] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->db[skill_id].amount[i] )
- {
+ if (j == INDEX_NOT_FOUND || skill->db[skill_id].itemid[i] <= 0
+ || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->db[skill_id].amount[i]
+ ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
}
@@ -13165,8 +13164,10 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
if( !require.itemid[0] ) // issue: 7935
break;
- if( skill->check_pc_partner(sd,skill_id,&skill_lv,1,0) <= 0 && ((idx = pc->search_inventory(sd,require.itemid[0])) < 0 || sd->status.inventory[idx].amount < require.amount[0]) )
- {
+ if (skill->check_pc_partner(sd,skill_id,&skill_lv,1,0) <= 0
+ && ((idx = pc->search_inventory(sd,require.itemid[0])) == INDEX_NOT_FOUND
+ || sd->status.inventory[idx].amount < require.amount[0])
+ ) {
//clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_ITEM,require.amount[0],require.itemid[0]);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -13716,7 +13717,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
if( !require.itemid[i] )
continue;
index[i] = pc->search_inventory(sd,require.itemid[i]);
- if( index[i] < 0 || sd->status.inventory[index[i]].amount < require.amount[i] ) {
+ if (index[i] == INDEX_NOT_FOUND || sd->status.inventory[index[i]].amount < require.amount[i]) {
useskill_fail_cause cause = USESKILL_FAIL_NEED_ITEM;
switch( skill_id ){
case NC_SILVERSNIPER:
@@ -13833,7 +13834,7 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin
break;
}
- if( (n = pc->search_inventory(sd,req.itemid[i])) >= 0 )
+ if ((n = pc->search_inventory(sd,req.itemid[i])) != INDEX_NOT_FOUND)
pc->delitem(sd,n,req.amount[i],0,1,LOG_TYPE_CONSUME);
}
}
@@ -14019,8 +14020,10 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
}
}
if( skill_id >= HT_SKIDTRAP && skill_id <= HT_TALKIEBOX && pc->checkskill(sd, RA_RESEARCHTRAP) > 0){
- int16 itIndex;
- if( (itIndex = pc->search_inventory(sd,req.itemid[i])) < 0 || ( itIndex >= 0 && sd->status.inventory[itIndex].amount < req.amount[i] ) ){
+ int16 item_index;
+ if ((item_index = pc->search_inventory(sd,req.itemid[i])) == INDEX_NOT_FOUND
+ || sd->status.inventory[item_index].amount < req.amount[i]
+ ) {
req.itemid[i] = ITEMID_TRAP_ALLOY;
req.amount[i] = 1;
}
@@ -14658,7 +14661,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
material = materials[ target_sd->inventory_data[idx]->wlv - 1 ]; // Lv1/2/3/4 weapons consume 1 Iron Ore/Iron/Steel/Rough Oridecon
else
material = materials[2]; // Armors consume 1 Steel
- if ( pc->search_inventory(sd,material) < 0 ) {
+ if (pc->search_inventory(sd,material) == INDEX_NOT_FOUND) {
clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0);
return;
}
@@ -14726,7 +14729,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
clif->upgrademessage(sd->fd, 2, item->nameid);
return;
}
- if( (i = pc->search_inventory(sd, material[ditem->wlv])) < 0 ){
+ if ((i = pc->search_inventory(sd, material[ditem->wlv])) == INDEX_NOT_FOUND) {
clif->upgrademessage(sd->fd, 3, material[ditem->wlv]);
return;
}
@@ -16413,11 +16416,10 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
int id,x,y;
if( (id=skill->produce_db[i].mat_id[j]) <= 0 )
continue;
- if(skill->produce_db[i].mat_amount[j] <= 0) {
- if(pc->search_inventory(sd,id) < 0)
+ if (skill->produce_db[i].mat_amount[j] <= 0) {
+ if (pc->search_inventory(sd,id) == INDEX_NOT_FOUND)
return 0;
- }
- else {
+ } else {
for(y=0,x=0;y<MAX_INVENTORY;y++)
if( sd->status.inventory[y].nameid == id )
x+=sd->status.inventory[y].amount;
@@ -16466,7 +16468,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
if( slot[i]<=0 )
continue;
j = pc->search_inventory(sd,slot[i]);
- if(j < 0)
+ if (j == INDEX_NOT_FOUND)
continue;
if( slot[i]==ITEMID_STAR_CRUMB ) {
pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
@@ -16517,7 +16519,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
int y=0;
j = pc->search_inventory(sd,id);
- if(j >= 0){
+ if (j != INDEX_NOT_FOUND) {
y = sd->status.inventory[j].amount;
if(y>x)y=x;
pc->delitem(sd,j,y,0,0,LOG_TYPE_PRODUCE);
@@ -16781,10 +16783,14 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
make_per += pc->checkskill(sd,skill_id)*500; // Smithing skills bonus: +5/+10/+15
make_per += pc->checkskill(sd,BS_WEAPONRESEARCH)*100 +((wlv >= 3)? pc->checkskill(sd,BS_ORIDEOCON)*100:0); // Weaponry Research bonus: +1/+2/+3/+4/+5/+6/+7/+8/+9/+10, Oridecon Research bonus (custom): +1/+2/+3/+4/+5
make_per -= (ele?2000:0) + sc*1500 + (wlv>1?wlv*1000:0); // Element Stone: -20%, Star Crumb: -15% each, Weapon level malus: -0/-20/-30
- if(pc->search_inventory(sd,989) > 0) make_per+= 1000; // Emperium Anvil: +10
- else if(pc->search_inventory(sd,988) > 0) make_per+= 500; // Golden Anvil: +5
- else if(pc->search_inventory(sd,987) > 0) make_per+= 300; // Oridecon Anvil: +3
- else if(pc->search_inventory(sd,986) > 0) make_per+= 0; // Anvil: +0?
+ if (pc->search_inventory(sd,ITEMID_EMPERIUM_ANVIL) != INDEX_NOT_FOUND)
+ make_per+= 1000; // +10
+ else if(pc->search_inventory(sd,ITEMID_GOLDEN_ANVIL) != INDEX_NOT_FOUND)
+ make_per+= 500; // +5
+ else if(pc->search_inventory(sd,ITEMID_ORIDECON_ANVIL) != INDEX_NOT_FOUND)
+ make_per+= 300; // +3
+ else if(pc->search_inventory(sd,ITEMID_ANVIL) != INDEX_NOT_FOUND)
+ make_per+= 0; // +0?
if(battle_config.wp_rate != 100)
make_per = make_per * battle_config.wp_rate / 100;
}
@@ -17045,7 +17051,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
break;
}
- if(index < 0 || (j = pc->search_inventory(sd,nameid)) < 0)
+ if(index < 0 || (j = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND)
return 1;
pc->delitem(sd,j,1,0,0,LOG_TYPE_PRODUCE);
@@ -17074,7 +17080,7 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) {
sc_type type;
int chance, i;
nullpo_ret(sd);
- if( nameid <= 0 || (i = pc->search_inventory(sd,nameid)) < 0 || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) ) {
+ if( nameid <= 0 || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) ) {
clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -17131,8 +17137,9 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
nullpo_ret(sd);
skill_id = sd->menuskill_val;
- if( nameid <= 0 || !itemdb_is_element(nameid) || (i = pc->search_inventory(sd,nameid)) < 0 || !skill_id || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) )
- {
+ if (nameid <= 0 || !itemdb_is_element(nameid) || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND
+ || !skill_id || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME)
+ ) {
clif->skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0);
return 0;
}