diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-07 21:57:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-10 23:06:08 +0300 |
commit | 2f488d98cacccc17d1702230488e15f7f9bc25e7 (patch) | |
tree | 0acf0239078b8bf1ce35dc4929ce8435f37be546 | |
parent | c0367b69fd226be21643cd4b620fff2aadb0e742 (diff) | |
download | hercules-2f488d98cacccc17d1702230488e15f7f9bc25e7.tar.gz hercules-2f488d98cacccc17d1702230488e15f7f9bc25e7.tar.bz2 hercules-2f488d98cacccc17d1702230488e15f7f9bc25e7.tar.xz hercules-2f488d98cacccc17d1702230488e15f7f9bc25e7.zip |
Move equip item script function call into function script_run_item_equip_script.
-rw-r--r-- | src/map/pc.c | 7 | ||||
-rw-r--r-- | src/map/script.c | 17 | ||||
-rw-r--r-- | src/map/script.h | 2 | ||||
-rw-r--r-- | src/map/status.c | 4 |
4 files changed, 25 insertions, 5 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 1589ae910..d6b377b9b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9637,7 +9637,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) //OnEquip script [Skotlex] if (id->equip_script) - script->run(id->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_equip_script(sd, id, npc->fake_nd->bl.id); + if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards else { @@ -9646,8 +9647,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if (!sd->status.inventory[n].card[i]) continue; if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->equip_script ) - script->run(data->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); + if (data->equip_script) + script->run_item_equip_script(sd, data, npc->fake_nd->bl.id); } } } diff --git a/src/map/script.c b/src/map/script.c index 1290d96e1..190a942fb 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -19850,6 +19850,22 @@ void script_run_use_script(struct map_session_data *sd, struct item_data *data, script->current_item_id = 0; } +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); + +/** + * Run item equip script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param data equipped item data. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->equip_script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + #define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args, false } #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false } #define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true } @@ -20796,4 +20812,5 @@ void script_defaults(void) { script->parser_clean_leftovers = script_parser_clean_leftovers; script->run_use_script = script_run_use_script; + script->run_item_equip_script = script_run_item_equip_script; } diff --git a/src/map/script.h b/src/map/script.h index bdd6e20ac..d8b008d78 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -19,6 +19,7 @@ * Declarations **/ struct eri; +struct item_data; /** * Defines @@ -766,6 +767,7 @@ struct script_interface { const char *(*get_translation_file_name) (const char *file); void (*parser_clean_leftovers) (void); void (*run_use_script) (struct map_session_data *sd, struct item_data *data, int oid); + void (*run_item_equip_script) (struct map_session_data *sd, struct item_data *data, int oid); }; struct script_interface *script; diff --git a/src/map/status.c b/src/map/status.c index d19ce0511..e70fb1eb1 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2267,7 +2267,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if (opt&SCO_FIRST && sd->inventory_data[index]->equip_script) { //Execute equip-script on login - script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); + script->run_item_equip_script(sd, sd->inventory_data[index], 0); if (!calculating) return 1; } @@ -2428,7 +2428,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { continue; if(opt&SCO_FIRST && data->equip_script) {//Execute equip-script on login - script->run(data->equip_script,0,sd->bl.id,0); + script->run_item_equip_script(sd, data, 0); if (!calculating) return 1; } |