diff options
author | Haru <haru@dotalux.com> | 2018-03-11 17:20:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-11 17:20:18 +0100 |
commit | 20234c126675aeb292ba1abefc0a5b27ccae1854 (patch) | |
tree | 623d012bea3b8c1def5645d97f6b89e67aa640d9 /src/map/clif.c | |
parent | cd56f7302cfe7c64e5a2e15ed2f0bed745d03b9e (diff) | |
parent | 2691fcbedb580f5a8994a345b4476e95af2fc442 (diff) | |
download | hercules-20234c126675aeb292ba1abefc0a5b27ccae1854.tar.gz hercules-20234c126675aeb292ba1abefc0a5b27ccae1854.tar.bz2 hercules-20234c126675aeb292ba1abefc0a5b27ccae1854.tar.xz hercules-20234c126675aeb292ba1abefc0a5b27ccae1854.zip |
Merge pull request #1541 from Normynator/master
Changed Kafrapoints calculation.
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 4f98d2c9c..cf5edd0e0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18121,31 +18121,37 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { short tab = RFIFOW(fd, 18 + ( i * 10 )); enum CASH_SHOP_BUY_RESULT result = CSBR_UNKNOWN; - if( tab < 0 || tab >= CASHSHOP_TAB_MAX ) + if(tab < 0 || tab >= CASHSHOP_TAB_MAX) continue; - for( j = 0; j < clif->cs.item_count[tab]; j++ ) { + for(j = 0; j < clif->cs.item_count[tab]; j++) { if( clif->cs.data[tab][j]->id == id ) break; } - if( j < clif->cs.item_count[tab] ) { + if(j < clif->cs.item_count[tab]) { struct item_data *data; - if( sd->kafraPoints < kafra_pay ) { + if(sd->kafraPoints < kafra_pay) { result = CSBR_SHORTTAGE_CASH; - } else if( (sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty) ) { + } else if((sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty)) { result = CSBR_SHORTTAGE_CASH; - } else if ( !( data = itemdb->exists(clif->cs.data[tab][j]->id) ) ) { + } else if (!(data = itemdb->exists(clif->cs.data[tab][j]->id))) { result = CSBR_UNKONWN_ITEM; } else { struct item item_tmp; int k, get_count; - + int ret = 0; + get_count = qty; if (!itemdb->isstackable2(data)) get_count = 1; - - pc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] + + ret = pc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] //changed Kafrapoints calculation. [Normynator] + if (ret < 0) { + ShowError("clif_parse_CashShopBuy: The return from pc->paycash was negative which is not allowed.\n"); + break; //This should never happen. + } + kafra_pay = ret; for (k = 0; k < qty; k += get_count) { if (!pet->create_egg(sd, data->nameid)) { memset(&item_tmp, 0, sizeof(item_tmp)); |