summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/pc.c8
-rw-r--r--src/map/script.c17
-rw-r--r--src/map/script.h1
3 files changed, 22 insertions, 4 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index d6b377b9b..ec74e2da8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -9815,10 +9815,10 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
if ( battle_config.unequip_restricted_equipment & 1 ) {
ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid);
if ( i == map->list[sd->bl.m].zone->disabled_items_count )
- script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id);
}
else
- script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id);
}
if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
@@ -9834,10 +9834,10 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
int j;
ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]);
if ( j == map->list[sd->bl.m].zone->disabled_items_count )
- script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id);
}
else
- script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
+ script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id);
}
}
diff --git a/src/map/script.c b/src/map/script.c
index 190a942fb..1cad581b3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -19866,6 +19866,22 @@ void script_run_item_equip_script(struct map_session_data *sd, struct item_data
script->current_item_id = 0;
}
+void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2)));
+
+/**
+ * Run item unequip script for item.
+ *
+ * @param sd player session data. Must be correct and checked before.
+ * @param data unequipped item data. Must be correct and checked before.
+ * @param oid npc id. Can be also 0 or fake npc id.
+ */
+void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid)
+{
+ script->current_item_id = data->nameid;
+ script->run(data->unequip_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 }
@@ -20813,4 +20829,5 @@ void script_defaults(void) {
script->run_use_script = script_run_use_script;
script->run_item_equip_script = script_run_item_equip_script;
+ script->run_item_unequip_script = script_run_item_unequip_script;
}
diff --git a/src/map/script.h b/src/map/script.h
index d8b008d78..20aa7b3c2 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -768,6 +768,7 @@ struct script_interface {
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);
+ void (*run_item_unequip_script) (struct map_session_data *sd, struct item_data *data, int oid);
};
struct script_interface *script;