diff --git a/src/map/npc.c b/src/map/npc.c index 6be28b75745..ace65c2230a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1679,6 +1679,8 @@ uint8 npc_buylist(struct map_session_data* sd, uint16 n, struct s_npc_buy_list * count = pc_readaccountreg(sd, nd->u.shop.pointshop_str); break; case '@': + count = pc_readreg(sd, add_str(nd->u.shop.pointshop_str)); + break; default: count = pc_readglobalreg(sd, nd->u.shop.pointshop_str); break; @@ -2539,19 +2541,13 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const nd->u.shop.count = 0; while ( p ) { unsigned short nameid2, qty = 0; - int value, i = 0; + int value; struct item_data* id; bool skip = false; if( p == NULL ) break; switch(type) { - case NPCTYPE_SHOP: - if (sscanf(p, ",%hu:%d", &nameid2, &value) != 2) { - ShowError("npc_parse_shop: (SHOP) Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4); - skip = true; - } - break; case NPCTYPE_MARKETSHOP: #if PACKETVER >= 20131223 if (sscanf(p, ",%hu:%d:%hu", &nameid2, &value, &qty) != 3) { @@ -2560,6 +2556,12 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const } #endif break; + default: + if (sscanf(p, ",%hu:%d", &nameid2, &value) != 2) { + ShowError("npc_parse_shop: Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer, start - buffer), w1, w2, w3, w4); + skip = true; + } + break; } if (skip) @@ -2593,6 +2595,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const #if PACKETVER >= 20131223 if (nd->u.shop.count && type == NPCTYPE_MARKETSHOP) { + uint16 i; // Duplicate entry? Replace the value ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid); if (i != nd->u.shop.count) { diff --git a/src/map/script.c b/src/map/script.c index e5fa02c5253..590f1cfe2db 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16500,7 +16500,7 @@ BUILDIN_FUNC(setunitdata) TBL_PET* pd = NULL; TBL_ELEM* ed = NULL; TBL_NPC* nd = NULL; - int type, value; + int type, value = 0; bl = map_id2bl(script_getnum(st, 2)); @@ -19878,7 +19878,9 @@ BUILDIN_FUNC(npcshopupdate) { struct npc_data* nd = npc_name2id(npcname); uint16 nameid = script_getnum(st, 3); int price = script_getnum(st, 4); - uint16 stock = 0; +#if PACKETVER >= 20131223 + uint16 stock = script_hasdata(st,5) ? script_getnum(st,5) : 0; +#endif int i; if( !nd || ( nd->subtype != NPCTYPE_SHOP && nd->subtype != NPCTYPE_CASHSHOP && nd->subtype != NPCTYPE_ITEMSHOP && nd->subtype != NPCTYPE_POINTSHOP && nd->subtype != NPCTYPE_MARKETSHOP ) ) { // Not found. @@ -19892,14 +19894,6 @@ BUILDIN_FUNC(npcshopupdate) { return SCRIPT_CMD_FAILURE; } - if (nd->subtype == NPCTYPE_MARKETSHOP) { - FETCH(5, stock); - } - else if ((price = cap_value(price, 0, INT_MAX)) == 0) { // Nothing to do here... - script_pushint(st,1); - return SCRIPT_CMD_SUCCESS; - } - for (i = 0; i < nd->u.shop.count; i++) { if (nd->u.shop.shop_item[i].nameid == nameid) {