فهرست منبع

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
Jeybla 7 سال پیش
والد
کامیت
557cccac9c
4فایلهای تغییر یافته به همراه20 افزوده شده و 6 حذف شده
  1. 5 0
      conf/battle/items.conf
  2. 1 0
      src/map/battle.c
  3. 1 0
      src/map/battle.h
  4. 13 6
      src/map/pc.c

+ 5 - 0
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

+ 1 - 0
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"
 };

+ 1 - 0
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;

+ 13 - 6
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;