diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-15 12:37:03 +0000 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-15 12:37:03 +0000 |
commit | b152e7e73348473517a58f3ad005fbc3d89fc541 (patch) | |
tree | 7ac8b227fb6ab4e89902769906382ae5330259d7 /src/map | |
parent | 6841ab57286c04fce48224c91142d48503ab4cc1 (diff) | |
download | tmwa-b152e7e73348473517a58f3ad005fbc3d89fc541.tar.gz tmwa-b152e7e73348473517a58f3ad005fbc3d89fc541.tar.bz2 tmwa-b152e7e73348473517a58f3ad005fbc3d89fc541.tar.xz tmwa-b152e7e73348473517a58f3ad005fbc3d89fc541.zip |
Allow shop parsing to continue after bad item name
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/npc.c | 25 | ||||
-rw-r--r-- | src/map/trade.c | 12 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 932bb6b..2cdcf00 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1236,19 +1236,22 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4) if (sscanf(p, "%d:%d", &nameid, &value) == 2) { } else if (sscanf(p, "%s :%d", name, &value) == 2) { id = itemdb_searchname(name); - if (id == NULL) break; - nameid = id->nameid; + if (id == NULL) nameid = -1; + else nameid = id->nameid; } else break; - nd->u.shop_item[pos].nameid = nameid; - if (value < 0) { - int temp = abs(value); - if (id == NULL) id = itemdb_search(nameid); - value = id->value_buy; - if (temp % 2) value = value / ((temp + 1) / 2); - else value = value * (temp / 2); + + if (nameid > 0) { + nd->u.shop_item[pos].nameid = nameid; + if (value < 0) { + int temp = abs(value); + if (id == NULL) id = itemdb_search(nameid); + value = id->value_buy; + if (temp % 2) value = value / ((temp + 1) / 2); + else value = value * (temp / 2); + } + nd->u.shop_item[pos].value = value; + pos++; } - nd->u.shop_item[pos].value = value; - pos++; p=strchr(p,','); } if (pos == 0) { diff --git a/src/map/trade.c b/src/map/trade.c index 5192a08..5f924e0 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -252,11 +252,15 @@ void trade_tradecommit(struct map_session_data *sd) if( (sd->deal_locked >=1) && (target_sd->deal_locked >=1) ){ // both have pressed 'ok' if(sd->deal_locked < 2) {sd->deal_locked=2;} // set locked to 2 if(target_sd->deal_locked==2) { // the other one pressed 'trade' too - if(sd->deal_zeny) { - if (sd->deal_zeny > sd->status.zeny) trade_tradecancel(sd); + if(sd->deal_zeny > sd->status.zeny) { + sd->deal_zeny = 0; + trade_tradecancel(sd); + return; } - if(target_sd->deal_zeny) { - if (target_sd->deal_zeny > target_sd->status.zeny) trade_tradecancel(sd); + if(target_sd->deal_zeny > target_sd->status.zeny) { + target_sd->deal_zeny = 0; + trade_tradecancel(sd); + return; } for(trade_i=0; trade_i<10;trade_i++) { if(sd->deal_item_amount[trade_i] != 0) { |