diff options
author | Haruna <haru@dotalux.com> | 2014-12-16 22:44:08 +0100 |
---|---|---|
committer | Haruna <haru@dotalux.com> | 2014-12-16 22:44:08 +0100 |
commit | 57efadd40016af332be6c19f5f5e84b4104805bb (patch) | |
tree | e413519b4ef3df881a9bb245af824d1661765255 | |
parent | 445bb7d0595832b3fed3ad3218073c4f6b6bb207 (diff) | |
parent | dd6393551b6c93a9c6ebf9fcbe45c3eecf89dc81 (diff) | |
download | hercules-57efadd40016af332be6c19f5f5e84b4104805bb.tar.gz hercules-57efadd40016af332be6c19f5f5e84b4104805bb.tar.bz2 hercules-57efadd40016af332be6c19f5f5e84b4104805bb.tar.xz hercules-57efadd40016af332be6c19f5f5e84b4104805bb.zip |
Merge pull request #415 from 4144/pcfix
allow add script to pet egg.
-rw-r--r-- | src/map/itemdb.c | 9 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 27 |
6 files changed, 43 insertions, 1 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 508a0ccec..545ce9ba0 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2054,6 +2054,14 @@ struct item_combo * itemdb_id2combo( unsigned short id ) { return itemdb->combos[id]; } +/** + * check is item have usable type + **/ +bool itemdb_is_item_usable(struct item_data *item) +{ + return item->type == IT_HEALING || item->type == IT_USABLE || item->type == IT_CASH; +} + /*========================================== * Initialize / Finalize *------------------------------------------*/ @@ -2337,4 +2345,5 @@ void itemdb_defaults(void) { itemdb->final_sub = itemdb_final_sub; itemdb->clear = itemdb_clear; itemdb->id2combo = itemdb_id2combo; + itemdb->is_item_usable = itemdb_is_item_usable; } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 5504d72d9..23339790e 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -610,6 +610,7 @@ struct itemdb_interface { int (*final_sub) (DBKey key, DBData *data, va_list ap); void (*clear) (bool total); struct item_combo * (*id2combo) (unsigned short id); + bool (*is_item_usable) (struct item_data *item); }; struct itemdb_interface *itemdb; diff --git a/src/map/pc.c b/src/map/pc.c index 5c6cac6e9..6c3a32152 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4238,7 +4238,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) if( item == NULL ) return 0; //Not consumable item - if( item->type != IT_HEALING && item->type != IT_USABLE && item->type != IT_CASH ) + if (!itemdb->is_item_usable(item)) return 0; if( !item->script ) //if it has no script, you can't really consume it! return 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index a68afc9ed..7b9eadb91 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -2587,6 +2587,8 @@ struct { struct HPMHookPoint *HP_itemdb_clear_post; struct HPMHookPoint *HP_itemdb_id2combo_pre; struct HPMHookPoint *HP_itemdb_id2combo_post; + struct HPMHookPoint *HP_itemdb_is_item_usable_pre; + struct HPMHookPoint *HP_itemdb_is_item_usable_post; struct HPMHookPoint *HP_logs_pick_pc_pre; struct HPMHookPoint *HP_logs_pick_pc_post; struct HPMHookPoint *HP_logs_pick_mob_pre; @@ -7662,6 +7664,8 @@ struct { int HP_itemdb_clear_post; int HP_itemdb_id2combo_pre; int HP_itemdb_id2combo_post; + int HP_itemdb_is_item_usable_pre; + int HP_itemdb_is_item_usable_post; int HP_logs_pick_pc_pre; int HP_logs_pick_pc_post; int HP_logs_pick_mob_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index e615b9767..58af99107 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1312,6 +1312,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(itemdb->final_sub, HP_itemdb_final_sub) }, { HP_POP(itemdb->clear, HP_itemdb_clear) }, { HP_POP(itemdb->id2combo, HP_itemdb_id2combo) }, + { HP_POP(itemdb->is_item_usable, HP_itemdb_is_item_usable) }, /* logs */ { HP_POP(logs->pick_pc, HP_logs_pick_pc) }, { HP_POP(logs->pick_mob, HP_logs_pick_mob) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index cf4e0e871..62b1be620 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -34264,6 +34264,33 @@ struct item_combo* HP_itemdb_id2combo(unsigned short id) { } return retVal___; } +bool HP_itemdb_is_item_usable(struct item_data *item) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_itemdb_is_item_usable_pre ) { + bool (*preHookFunc) (struct item_data *item); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_is_item_usable_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_itemdb_is_item_usable_pre[hIndex].func; + retVal___ = preHookFunc(item); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.itemdb.is_item_usable(item); + } + if( HPMHooks.count.HP_itemdb_is_item_usable_post ) { + bool (*postHookFunc) (bool retVal___, struct item_data *item); + for(hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_is_item_usable_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_itemdb_is_item_usable_post[hIndex].func; + retVal___ = postHookFunc(retVal___, item); + } + } + return retVal___; +} /* logs */ void HP_logs_pick_pc(struct map_session_data *sd, e_log_pick_type type, int amount, struct item *itm, struct item_data *data) { int hIndex = 0; |