Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/map/clif.c b/src/map/clif.c
- index 15d6aeb..f74b728 100644
- --- a/src/map/clif.c
- +++ b/src/map/clif.c
- @@ -14742,7 +14742,7 @@ void clif_parse_Auction_buysell(int fd, struct map_session_data* sd)
- /// 0287 <packet len>.W <cash point>.L <kafra point>.L { <sell price>.L <discount price>.L <item type>.B <name id>.W }* (PACKETVER >= 20070711)
- void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
- {
- - int fd,i;
- + int fd,i,val = 0;
- #if PACKETVER < 20070711
- const int offset = 8;
- #else
- @@ -14757,7 +14757,22 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
- WFIFOHEAD(fd,offset+nd->u.shop.count*11);
- WFIFOW(fd,0) = 0x287;
- WFIFOW(fd,2) = offset+nd->u.shop.count*11;
- - WFIFOL(fd,4) = sd->cashPoints; // Cash Points
- + if( nd->subtype == ISHOP ) //[Dastgir Pojee]
- + {
- + if( (i = pc_search_inventory(sd,nd->ishop)) >= 0 )
- + {
- + char output[128];
- + val = sd->status.inventory[i].amount;
- + sprintf(output,"This is a Item Shop. You need %s (%d) to Buy items.", itemdb_search(nd->ishop)->jname, nd->ishop);
- + clif->colormes(fd,COLOR_RED,output);
- + }
- + }
- + else
- + {
- + val = sd->cashPoints;
- + }
- + WFIFOL(fd,4) = val; // Cash Points
- +
- #if PACKETVER >= 20070711
- WFIFOL(fd,8) = sd->kafraPoints; // Kafra Points
- #endif
- @@ -14786,12 +14801,23 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
- /// 6 = You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY)
- /// 7 = You can purchase up to 10 items.
- /// 8 = Some items could not be purchased.
- -void clif_cashshop_ack(struct map_session_data* sd, int error) {
- +void clif_cashshop_ack(struct map_session_data* sd,struct npc_data *nd, int error) {
- int fd = sd->fd;
- + int i;
- + int val = 0; // Cash Points client slot
- +
- + if ( nd && nd->subtype == ISHOP) //[Dastgir Pojee]
- + {
- + if( (i = pc_search_inventory(sd,nd->ishop)) >= 0 )
- + val = sd->status.inventory[i].amount;
- + }
- + else{
- + val = sd->cashPoints;
- + }
- WFIFOHEAD(fd, packet_len(0x289));
- WFIFOW(fd,0) = 0x289;
- - WFIFOL(fd,2) = sd->cashPoints;
- + WFIFOL(fd,2) = val;
- #if PACKETVER < 20070711
- WFIFOW(fd,6) = TOW(error);
- #else
- @@ -14809,8 +14835,12 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) {
- void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
- {
- int fail = 0;
- + struct npc_data *nd;
- nullpo_retv(sd);
- + if( (nd = (struct npc_data *)map_id2bl(sd->npc_shopid)) == NULL )
- + return;
- +
- if( sd->state.trading || !sd->npc_shopid )
- fail = 1;
- else {
- @@ -14835,7 +14865,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
- #endif
- }
- - clif->cashshop_ack(sd,fail);
- + clif->cashshop_ack(sd,nd,fail);
- }
- diff --git a/src/map/clif.h b/src/map/clif.h
- index 2aec335..3aede0d 100644
- --- a/src/map/clif.h
- +++ b/src/map/clif.h
- @@ -516,7 +516,7 @@ struct clif_interface {
- void (*cashshop_show) (struct map_session_data *sd, struct npc_data *nd);
- void (*npc_buy_result) (struct map_session_data* sd, unsigned char result);
- void (*npc_sell_result) (struct map_session_data* sd, unsigned char result);
- - void (*cashshop_ack) (struct map_session_data* sd, int error);
- + void (*cashshop_ack) (struct map_session_data* sd,struct npc_data *nd, int error);
- /* npc-script-related */
- void (*scriptmes) (struct map_session_data *sd, int npcid, const char *mes);
- void (*scriptnext) (struct map_session_data *sd,int npcid);
- diff --git a/src/map/map.h b/src/map/map.h
- index a7bcb08..7a7e6b8 100644
- --- a/src/map/map.h
- +++ b/src/map/map.h
- @@ -253,7 +253,7 @@ enum bl_type {
- //For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
- #define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM)
- -enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB };
- +enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, TOMB, ISHOP };
- enum {
- RC_FORMLESS=0,
- diff --git a/src/map/npc.c b/src/map/npc.c
- index 77ee8d4..39dc377 100644
- --- a/src/map/npc.c
- +++ b/src/map/npc.c
- @@ -1213,6 +1213,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
- case SHOP:
- clif->npcbuysell(sd,nd->bl.id);
- break;
- + case ISHOP:
- case CASHSHOP:
- clif->cashshop_show(sd,nd);
- break;
- @@ -1317,7 +1318,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
- int i, j, nameid, amount, new_, w, vt;
- struct npc_data *nd = (struct npc_data *)map_id2bl(sd->npc_shopid);
- - if( !nd || nd->subtype != CASHSHOP )
- + if( !nd || (nd->subtype != CASHSHOP && nd->subtype != ISHOP) )
- return 1;
- if( sd->state.trading )
- @@ -1366,9 +1367,26 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
- if( points > vt ) points = vt;
- // Payment Process ----------------------------------------------------
- - if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
- - return 6;
- - pc_paycash(sd,vt,points);
- + if (nd->subtype = ISHOP){ //[Dastgir Pojee]
- + if( points > 0 )
- + {
- + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy with points from a IShop.\n", sd->status.name, sd->status.account_id, sd->status.char_id);
- + return 6;
- + }
- + if (nd->ishop > 0)
- + {
- + i = pc_search_inventory(sd,nd->ishop);
- + if( i < 0 || sd->status.inventory[i].amount < vt )
- + return 6;
- + pc_delitem(sd,i,vt,0,0,LOG_TYPE_NPC);
- + }
- + }
- + else{
- + if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
- + return 6;
- + pc_paycash(sd,vt,points);
- + }
- +
- // Delivery Process ----------------------------------------------------
- for( i = 0; i < count; i++ )
- @@ -1432,7 +1450,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
- if( points < 0 )
- return 6;
- - if( !nd || nd->subtype != CASHSHOP )
- + if( !nd || ( nd->subtype != CASHSHOP && nd->subtype != ISHOP ))
- return 1;
- if( sd->state.trading )
- @@ -1480,10 +1498,28 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
- if( points > price )
- points = price;
- - if( (sd->kafraPoints < points) || (sd->cashPoints < price - points) )
- - return 6;
- + //Payment
- + if (nd->subtype == ISHOP){
- + if( points > 0 )
- + {
- + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy with points from a IShop.\n", sd->status.name, sd->status.account_id, sd->status.char_id);
- + return 6;
- + }
- + if (nd->ishop>0)
- + {
- + i = pc_search_inventory(sd,nd->ishop);
- + if( i < 0 || sd->status.inventory[i].amount < price )
- + return 6;
- + pc_delitem(sd,i,price,0,0,LOG_TYPE_NPC);
- + }
- + }
- + else{
- + if( (sd->kafraPoints < points) || (sd->cashPoints < price - points) )
- + return 6;
- +
- + pc_paycash(sd, price, points);
- + }
- - pc_paycash(sd, price, points);
- if( !pet_create_egg(sd, nameid) )
- {
- @@ -1842,7 +1878,7 @@ int npc_unload(struct npc_data* nd, bool single) {
- }
- }
- - if( (nd->subtype == SHOP || nd->subtype == CASHSHOP) && nd->src_id == 0) //src check for duplicate shops [Orcao]
- + if( (nd->subtype == SHOP || nd->subtype == CASHSHOP || nd->subtype == ISHOP) && nd->src_id == 0) //src check for duplicate shops [Orcao]
- aFree(nd->u.shop.shop_item);
- else if( nd->subtype == SCRIPT ) {
- struct s_mapiterator* iter;
- @@ -2186,30 +2222,56 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
- struct npc_data *nd;
- enum npc_subtype type;
- + //Item Shop
- + int ishop = 0;
- +
- + if( !strcasecmp(w2,"cashshop") )
- + type = CASHSHOP;
- + else if( !strcasecmp(w2,"ishop") )
- + type = ISHOP;
- + else
- + type = SHOP;
- +
- +
- if( strcmp(w1,"-") == 0 ) {// 'floating' shop?
- x = y = dir = 0;
- m = -1;
- } else {// w1=<map name>,<x>,<y>,<facing>
- char mapname[32];
- - if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4
- - || strchr(w4, ',') == NULL )
- - {
- - ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
- - return strchr(start,'\n');// skip and continue
- + switch (type){
- + case ISHOP:
- + if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &dir,&ishop) != 5
- + || strchr(w4, ',') == NULL )
- + {
- + ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
- + return strchr(start,'\n');// skip and continue
- + }
- + break;
- + case SHOP:
- + case CASHSHOP:
- + if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4
- + || strchr(w4, ',') == NULL )
- + {
- + ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
- + return strchr(start,'\n');// skip and continue
- + }
- +
- + break;
- }
- +
- m = map_mapname2mapid(mapname);
- }
- + if( type == ISHOP && ishop >= 0 && itemdb_exists(ishop) == NULL )
- + {
- + ShowError("npc_parse_shop: Invalid IShop item in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
- + return strchr(start,'\n');
- + }
- if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
- ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer));
- return strchr(start,'\n');;//try next
- }
- -
- - if( !strcasecmp(w2,"cashshop") )
- - type = CASHSHOP;
- - else
- - type = SHOP;
- p = strchr(w4,',');
- for( i = 0; i < ARRAYLENGTH(items) && p; ++i )
- @@ -2275,6 +2337,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
- ++npc_shop;
- nd->bl.type = BL_NPC;
- nd->subtype = type;
- + nd->ishop = ishop;
- if( m >= 0 )
- {// normal shop npc
- map_addnpc(m,nd);
- @@ -2576,7 +2639,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
- type = dnd->subtype;
- // get placement
- - if( (type==SHOP || type==CASHSHOP || type==SCRIPT) && strcmp(w1, "-") == 0 )
- + if( (type==SHOP || type==CASHSHOP || type==ISHOP || type==SCRIPT) && strcmp(w1, "-") == 0 )
- {// floating shop/chashshop/script
- x = y = dir = 0;
- m = -1;
- @@ -2629,6 +2692,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
- nd->u.scr.label_list_num = dnd->u.scr.label_list_num;
- break;
- + case ISHOP:
- case SHOP:
- case CASHSHOP:
- ++npc_shop;
- @@ -3697,7 +3761,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
- {
- p = npc_parse_warp(w1,w2,w3,w4, p, buffer, filepath);
- }
- - else if( (!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop")) && count > 3 )
- + else if( (!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop") || !strcasecmp(w2,"ishop")) && count > 3 )
- {
- p = npc_parse_shop(w1,w2,w3,w4, p, buffer, filepath);
- }
- diff --git a/src/map/npc.h b/src/map/npc.h
- index 8800b4e..069a195 100644
- --- a/src/map/npc.h
- +++ b/src/map/npc.h
- @@ -37,6 +37,7 @@ struct npc_data {
- int touching_id;
- unsigned int next_walktime;
- + int ishop; //ItemShop
- unsigned size : 2;
- struct status_data status;
- diff --git a/src/map/script.c b/src/map/script.c
- index 76092f4..ca2486d 100644
- --- a/src/map/script.c
- +++ b/src/map/script.c
- @@ -14310,7 +14310,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
- if( script_hasdata(st,3) )
- flag = script_getnum(st,3);
- nd = npc_name2id(shopname);
- - if( !nd || nd->bl.type != BL_NPC || (nd->subtype != SHOP && nd->subtype != CASHSHOP) )
- + if( !nd || nd->bl.type != BL_NPC || (nd->subtype != SHOP && nd->subtype != CASHSHOP && nd->subtype != ISHOP) )
- {
- ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname);
- script_pushint(st,0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement