From 557cccac9c987ba28c3d6fd906dc9633e1e60eb7 Mon Sep 17 00:00:00 2001 From: Jeybla Date: Tue, 12 Sep 2017 21:53:55 +0200 Subject: [PATCH] Adds allow_bound_sell configuration. (#2401) - It is possible to sell bound items, when allow_bound_sell is enabled. - Fixes #2398. - Changes made by @aleos89 - Thanks to @Everade --- conf/battle/items.conf | 5 +++++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/pc.c | 19 +++++++++++++------ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/conf/battle/items.conf b/conf/battle/items.conf index 735faf1853..f7efd93d10 100644 --- a/conf/battle/items.conf +++ b/conf/battle/items.conf @@ -105,3 +105,8 @@ item_flooritem_check: yes // 3 - Party // 4 - Character default_bind_on_equip: 4 + +// Allow selling of bound items as Itemshop currency? +// no = Bound items are unable to be sold at Itemshops +// yes = Bound items are able to be sold at Itemshops +allow_bound_sell: no diff --git a/src/map/battle.c b/src/map/battle.c index 01c58c8179..e2d616bd9d 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -8429,6 +8429,7 @@ static const struct _battle_data { { "guild_leaderchange_woe", &battle_config.guild_leaderchange_woe, 0, 0, 1, }, { "guild_alliance_onlygm", &battle_config.guild_alliance_onlygm, 0, 0, 1, }, { "feature.achievement", &battle_config.feature_achievement, 1, 0, 1, }, + { "allow_bound_sell", &battle_config.allow_bound_sell, 1, 0, 1, }, #include "../custom/battle_config_init.inc" }; diff --git a/src/map/battle.h b/src/map/battle.h index b5de40b583..37c86dfbb6 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -631,6 +631,7 @@ extern struct Battle_Config int guild_leaderchange_woe; int guild_alliance_onlygm; int feature_achievement; + int allow_bound_sell; #include "../custom/battle_config_struct.inc" } battle_config; diff --git a/src/map/pc.c b/src/map/pc.c index f3787b1dab..4682102bb3 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -581,15 +581,19 @@ void pc_inventory_rental_add(struct map_session_data *sd, unsigned int seconds) } /** -* Check if the player can sell the current item -* @param sd map_session_data of the player -* @param item struct of the checking item. -* @return bool 'true' is sellable, 'false' otherwise -*/ -bool pc_can_sell_item(struct map_session_data * sd, struct item * item) { + * Check if the player can sell the current item + * @param sd: map_session_data of the player + * @param item: struct of the checking item + * @return bool 'true' is sellable, 'false' otherwise + */ +bool pc_can_sell_item(struct map_session_data *sd, struct item *item) { + struct npc_data *nd; + if (sd == NULL || item == NULL) return false; + nd = map_id2nd(sd->npc_shopid); + if (!itemdb_cansell(item, pc_get_group_level(sd))) return false; @@ -599,6 +603,9 @@ bool pc_can_sell_item(struct map_session_data * sd, struct item * item) { if (item->expire_time) return false; // Cannot Sell Rental Items + if (nd && nd->subtype == NPCTYPE_ITEMSHOP && item->bound && battle_config.allow_bound_sell) + return true; // NPCTYPE_ITEMSHOP and bound item config is sellable + if (item->bound && !pc_can_give_bounded_items(sd)) return false; // Don't allow sale of bound items return true;