summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-12-27 21:42:14 +0300
committerAndrei Karas <akaras@inbox.ru>2019-01-14 20:18:10 +0300
commitfa1cb492536f2853c59a995dc54aa51ead420546 (patch)
treeb0b3751721d688a4795ca7a8a7b5909dca09191a /src/map/clif.c
parent93b9a86bed2eb3a54b49557f663e06804985654f (diff)
downloadhercules-fa1cb492536f2853c59a995dc54aa51ead420546.tar.gz
hercules-fa1cb492536f2853c59a995dc54aa51ead420546.tar.bz2
hercules-fa1cb492536f2853c59a995dc54aa51ead420546.tar.xz
hercules-fa1cb492536f2853c59a995dc54aa51ead420546.zip
Add barter type shop and add packet ZC_NPC_BARTER_OPEN
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index c25f5a9af..a0081ba6f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -22215,6 +22215,41 @@ static bool clif_enchant_equipment(struct map_session_data *sd, enum equip_pos p
#endif
}
+static void clif_npc_barter_open(struct map_session_data *sd, struct npc_data *nd)
+{
+#if PACKETVER_ZERO_NUM >= 20181226
+ nullpo_retv(sd);
+ nullpo_retv(nd);
+ struct npc_item_list *shop = nd->u.scr.shop->item;
+ const int shop_size = nd->u.scr.shop->items;
+
+ int c = 0;
+ int maxCount = (sizeof(packet_buf) - sizeof(struct PACKET_ZC_NPC_BARTER_OPEN)) / sizeof(struct PACKET_ZC_NPC_BARTER_OPEN_sub);
+ struct PACKET_ZC_NPC_BARTER_OPEN *packet = (struct PACKET_ZC_NPC_BARTER_OPEN*)&packet_buf[0];
+ packet->packetType = HEADER_ZC_NPC_BARTER_OPEN;
+
+ for (int i = 0; i < shop_size && c < maxCount; i++) {
+ if (shop[i].nameid) {
+ struct item_data *id = itemdb->exists(shop[i].nameid);
+ if (id == NULL)
+ continue;
+
+ packet->list[c].nameid = shop[i].nameid;
+ packet->list[c].type = itemtype(id->type);
+ packet->list[c].amount = shop[i].qty;
+ packet->list[c].currencyNameid = shop[i].value;
+ packet->list[c].currencyAmount = shop[i].value2;
+ packet->list[c].weight = id->weight * 10;
+ packet->list[c].index = i;
+ c++;
+ }
+ }
+
+ packet->packetLength = sizeof(struct PACKET_ZC_NPC_BARTER_OPEN) + sizeof(struct PACKET_ZC_NPC_BARTER_OPEN_sub) * c;
+ clif->send(packet, packet->packetLength, &sd->bl, SELF);
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -23400,4 +23435,7 @@ void clif_defaults(void)
clif->pMemorialDungeonCommand = clif_parse_memorial_dungeon_command;
clif->pReqRemainTime = clif_parse_reqRemainTime;
+
+ clif->npc_barter_open = clif_npc_barter_open;
+
}