diff options
author | Haru <haru@dotalux.com> | 2014-08-20 04:55:22 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-08-20 04:58:02 +0200 |
commit | 769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6 (patch) | |
tree | 99907d827264e501774e58ab4630e41fa7103c02 /src/map/pet.c | |
parent | b294026e6614a652c23bb0cea8a0d4dc69d8b125 (diff) | |
download | hercules-769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6.tar.gz hercules-769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6.tar.bz2 hercules-769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6.tar.xz hercules-769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6.zip |
Follow-up to b294026e6614a652c23bb0cea8a0d4dc69d8b125
- Added documentation for the pc->search_item function and formalized
its return values. If the searched item is not found, now it returns
the newly introduced constant INDEX_NOT_FOUND.
- Updated pc->search_item checks to make use of INDEX_NOT_FOUND.
- Fixed an issue with anvils not detected by the weapon forginc code,
if they were in the first position of the inventory.
- Added ITEMID constants for the four anvil types.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pet.c')
-rw-r--r-- | src/map/pet.c | 43 |
1 files changed, 20 insertions, 23 deletions
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 ) |