summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-08-09 06:47:15 +0300
committerAndrei Karas <akaras@inbox.ru>2019-08-21 22:36:41 +0300
commitbf4abf934cb74f0e55a10cc9943d469072c2a8c9 (patch)
treeb9f8ac2ff52c7ee05b2d3b9060c4ee07e7d9b38c /src/map/npc.c
parentaf9ee21c486c3099f4811e63f8c6d91d509a1034 (diff)
downloadhercules-bf4abf934cb74f0e55a10cc9943d469072c2a8c9.tar.gz
hercules-bf4abf934cb74f0e55a10cc9943d469072c2a8c9.tar.bz2
hercules-bf4abf934cb74f0e55a10cc9943d469072c2a8c9.tar.xz
hercules-bf4abf934cb74f0e55a10cc9943d469072c2a8c9.zip
Add new version for packet ZC_NPC_MARKET_PURCHASE_RESULT
Also add enum for result field in packet ZC_NPC_MARKET_PURCHASE_RESULT
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index fea82c873..c3dff5870 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2115,7 +2115,7 @@ static int npc_buylist(struct map_session_data *sd, struct itemlist *item_list)
/**
* Processes incoming npc market purchase list
**/
-static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item_list)
+static enum market_buy_result npc_market_buylist(struct map_session_data *sd, struct itemlist *item_list)
{
struct npc_data* nd;
struct npc_item_list *shop = NULL;
@@ -2129,7 +2129,7 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item
nd = npc->checknear(sd,map->id2bl(sd->npc_shopid));
if (nd == NULL || nd->subtype != SCRIPT || VECTOR_LENGTH(*item_list) == 0 || !nd->u.scr.shop || nd->u.scr.shop->type != NST_MARKET)
- return 1;
+ return MARKET_BUY_RESULT_ERROR;
shop = nd->u.scr.shop->item;
shop_size = nd->u.scr.shop->items;
@@ -2149,18 +2149,18 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item
entry->id == itemdb_viewid(shop[j].nameid) //item_avail replacement
);
if (j == shop_size) /* TODO find official response for this */
- return 1; // no such item in shop
+ return MARKET_BUY_RESULT_ERROR; // no such item in shop
entry->id = shop[j].nameid; //item_avail replacement
if (entry->amount > (int)shop[j].qty)
- return 1;
+ return MARKET_BUY_RESULT_AMOUNT_TOO_BIG;
value = shop[j].value;
npc_market_qty[i] = j;
if (!itemdb->exists(entry->id)) /* TODO find official response for this */
- return 1; // item no longer in itemdb
+ return MARKET_BUY_RESULT_ERROR; // item no longer in itemdb
if (!itemdb->isstackable(entry->id) && entry->amount > 1) {
//Exploit? You can't buy more than 1 of equipment types o.O
@@ -2184,13 +2184,13 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item
}
if (z > sd->status.zeny) /* TODO find official response for this */
- return 1; // Not enough Zeny
+ return MARKET_BUY_RESULT_NO_ZENY; // Not enough Zeny
if( w + sd->weight > sd->max_weight ) /* TODO find official response for this */
- return 1; // Too heavy
+ return MARKET_BUY_RESULT_OVER_WEIGHT; // Too heavy
if( pc->inventoryblank(sd) < new_ ) /* TODO find official response for this */
- return 1; // Not enough space to store items
+ return MARKET_BUY_RESULT_OUT_OF_SPACE; // Not enough space to store items
pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL);
@@ -2200,7 +2200,7 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item
j = npc_market_qty[i];
if (entry->amount > (int)shop[j].qty) /* wohoo someone tampered with the packet. */
- return 1;
+ return MARKET_BUY_RESULT_AMOUNT_TOO_BIG;
shop[j].qty -= entry->amount;
@@ -2218,7 +2218,7 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item
}
}
- return 0;
+ return MARKET_BUY_RESULT_SUCCESS;
}
/**