version 1.54 | | version 1.55 |
---|
| | |
/* | | /* |
* static char *rcsid_shop_c = | | * static char *rcsid_shop_c = |
* "$Id: shop.c,v 1.54 2006/05/05 09:47:40 ryo_saeba Exp $"; | | * "$Id: shop.c,v 1.55 2006/07/25 19:14:24 tchize Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
/* This hunk should remove all the money objects from the player/container */ | | /* This hunk should remove all the money objects from the player/container */ |
for (tmp=pouch->inv; tmp; tmp=next) { | | for (tmp=pouch->inv; tmp; tmp=next) { |
next = tmp->below; | | next = tmp->below; |
| | |
if (tmp->type == MONEY) { | | if (tmp->type == MONEY) { |
for (i=0; i<NUM_COINS; i++) { | | for (i=0; i<NUM_COINS; i++) { |
if (!strcmp(coins[NUM_COINS-1-i], tmp->arch->name) && | | if (!strcmp(coins[NUM_COINS-1-i], tmp->arch->name) && |
(tmp->value == tmp->arch->clone.value) ) { | | (tmp->value == tmp->arch->clone.value) ) { |
| | |
/* This should not happen, but if it does, just * | | /* This should not happen, but if it does, just * |
* merge the two. */ | | * merge the two. |
| | */ |
if (coin_objs[i]!=NULL) { | | if (coin_objs[i]!=NULL) { |
LOG(llevError,"%s has two money entries of (%s)\n", | | LOG(llevError,"%s has two money entries of (%s)\n", |
pouch->name, coins[NUM_COINS-1-i]); | | pouch->name, coins[NUM_COINS-1-i]); |
| | |
coin_objs[i]->nrof += tmp->nrof; | | coin_objs[i]->nrof += tmp->nrof; |
esrv_del_item(pl->contr, tmp->count); | | esrv_del_item(pl->contr, tmp->count); |
free_object(tmp); | | free_object(tmp); |
} | | } else { |
else { | | |
remove_ob(tmp); | | remove_ob(tmp); |
if(pouch->type==PLAYER) esrv_del_item(pl->contr, tmp->count); | | if(pouch->type==PLAYER) esrv_del_item(pl->contr, tmp->count); |
coin_objs[i] = tmp; | | coin_objs[i] = tmp; |
| | |
| | |
for (i=0; i<NUM_COINS; i++) { | | for (i=0; i<NUM_COINS; i++) { |
int num_coins; | | int num_coins; |
| | |
if (coin_objs[i]->nrof*coin_objs[i]->value> remain) { | | if (coin_objs[i]->nrof*coin_objs[i]->value> remain) { |
num_coins = remain / coin_objs[i]->value; | | num_coins = remain / coin_objs[i]->value; |
if ((uint64)num_coins*(uint64)coin_objs[i]->value < remain) num_coins++; | | if ((uint64)num_coins*(uint64)coin_objs[i]->value < remain) num_coins++; |
| | |
| | |
esrv_send_item(pl, tmp); | | esrv_send_item(pl, tmp); |
esrv_send_item (pl, pouch); | | esrv_send_item (pl, pouch); |
if (pl != pouch) esrv_update_item (UPD_WEIGHT, pl, pouch); | | if (pl != pouch) |
| | esrv_update_item (UPD_WEIGHT, pl, pouch); |
if (pl->type != PLAYER) { | | if (pl->type != PLAYER) { |
esrv_send_item (pl, pl); | | esrv_send_item (pl, pl); |
} | | } |
| | |
return(remain); | | return(remain); |
} | | } |
| | |
| | |
/* Checks all unpaid items in op's inventory, adds up all the money they | | /* Checks all unpaid items in op's inventory, adds up all the money they |
* have, and checks that they can actually afford what they want to buy. | | * have, and checks that they can actually afford what they want to buy. |
* Returns 1 if they can, and 0 if they can't. also prints an appropriate message | | * Returns 1 if they can, and 0 if they can't. also prints an appropriate message |
| | |
LOG(llevError, "can_pay(): called against something that isn't a player\n"); | | LOG(llevError, "can_pay(): called against something that isn't a player\n"); |
return 0; | | return 0; |
} | | } |
for (i=0; i< NUM_COINS; i++) coincount[i] = 0; | | for (i=0; i< NUM_COINS; i++) |
| | coincount[i] = 0; |
for (item = pl->inv;item;) { | | for (item = pl->inv;item;) { |
if QUERY_FLAG(item, FLAG_UNPAID) { | | if QUERY_FLAG(item, FLAG_UNPAID) { |
unpaid_count++; | | unpaid_count++; |
| | |
for (i=0; i< NUM_COINS; i++) | | for (i=0; i< NUM_COINS; i++) |
if (!strcmp(coins[i], item->arch->name)) | | if (!strcmp(coins[i], item->arch->name)) |
coincount[i] += item->nrof; | | coincount[i] += item->nrof; |
if (item->inv) item = item->inv; | | if (item->inv) |
else if (item->below) item = item->below; | | item = item->inv; |
else if (item->env && item->env != pl && item->env->below) item = item->env->below; | | else if (item->below) |
| | item = item->below; |
| | else if (item->env && item->env != pl && item->env->below) |
| | item = item->env->below; |
else item = NULL; | | else item = NULL; |
} | | } |
if (unpaid_price > player_wealth) { | | if (unpaid_price > player_wealth) { |