summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorNormynator <Norman.Ziebal@web.de>2017-01-04 16:23:09 +0100
committerNorman Ziebal <s8nozieb@stud.uni-saarland.de>2018-02-19 22:57:29 +0100
commit2691fcbedb580f5a8994a345b4476e95af2fc442 (patch)
tree9d68f8290b89f37d5377198b02b44568f112aeeb /src/map/clif.c
parent38914c4b3362a055468e3d3d8c26204c4a2d50d2 (diff)
downloadhercules-2691fcbedb580f5a8994a345b4476e95af2fc442.tar.gz
hercules-2691fcbedb580f5a8994a345b4476e95af2fc442.tar.bz2
hercules-2691fcbedb580f5a8994a345b4476e95af2fc442.tar.xz
hercules-2691fcbedb580f5a8994a345b4476e95af2fc442.zip
Changed Kafrapoints calculation.
Kafrapoints should now be used correctly. Issue #1540 Changed opening braces according to coding styl. Changed some lines according to coding styl. new-line-before-return ? more styling code changes changes in coding style coding style changes Fixed message output on acted cash. Removed unsupported and not needed var ret. Update pc.c Update atcommand.c Coding style added function description added return validation used wrong method in validation Fixed typo in clif.c Moved temp var to block start
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 7c314b075..64e44dfff 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -18010,31 +18010,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));