ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/shop.C
(Generate patch)

Comparing deliantra/server/server/shop.C (file contents):
Revision 1.8 by root, Sun Sep 3 00:18:42 2006 UTC vs.
Revision 1.9 by pippijn, Thu Sep 7 10:01:58 2006 UTC

1/* 1/*
2 * static char *rcsid_shop_c = 2 * static char *rcsid_shop_c =
3 * "$Id: shop.C,v 1.8 2006/09/03 00:18:42 root Exp $"; 3 * "$Id: shop.C,v 1.9 2006/09/07 10:01:58 pippijn Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
309 */ 309 */
310 310
311static archetype *find_next_coin(uint64 c, int *cointype) { 311static archetype *find_next_coin(uint64 c, int *cointype) {
312 archetype *coin; 312 archetype *coin;
313 313
314 do { 314 do
315 {
315 if (coins[*cointype]==NULL) return NULL; 316 if (coins[*cointype] == NULL) return NULL;
316 coin = find_archetype(coins[*cointype]); 317 coin = find_archetype(coins[*cointype]);
317 if (coin == NULL) 318 if (coin == NULL) return NULL;
318 return NULL;
319 *cointype += 1; 319 *cointype += 1;
320 } while (coin->clone.value > c); 320 } while ((uint64) coin->clone.value > c);
321 321
322 return coin; 322 return coin;
323} 323}
324 324
325/* This returns a string of how much something is worth based on 325/* This returns a string of how much something is worth based on
529 * to_pay is the required amount. 529 * to_pay is the required amount.
530 * returns the amount still missing after using "pouch". 530 * returns the amount still missing after using "pouch".
531 */ 531 */
532static uint64 pay_from_container(object *pl, object *pouch, uint64 to_pay) { 532static uint64 pay_from_container(object *pl, object *pouch, uint64 to_pay) {
533 int count, i; 533 int count, i;
534 sint64 remain; 534 uint64 remain;
535 object *tmp, *coin_objs[NUM_COINS], *next; 535 object *tmp, *coin_objs[NUM_COINS], *next;
536 archetype *at; 536 archetype *at;
537 537
538 if (pouch->type != PLAYER && pouch->type != CONTAINER) return to_pay; 538 if (pouch->type != PLAYER && pouch->type != CONTAINER) return to_pay;
539 539
585 for (i=0; i<NUM_COINS; i++) { 585 for (i=0; i<NUM_COINS; i++) {
586 int num_coins; 586 int num_coins;
587 587
588 if (coin_objs[i]->nrof*coin_objs[i]->value> remain) { 588 if (coin_objs[i]->nrof*coin_objs[i]->value> remain) {
589 num_coins = remain / coin_objs[i]->value; 589 num_coins = remain / coin_objs[i]->value;
590 if ((uint64)num_coins*(uint64)coin_objs[i]->value < remain) num_coins++; 590 if ( (uint64) num_coins * (uint64) coin_objs[i]->value < remain ) num_coins++;
591 } else { 591 } else {
592 num_coins = coin_objs[i]->nrof; 592 num_coins = coin_objs[i]->nrof;
593 } 593 }
594 remain -= (sint64) num_coins * (sint64)coin_objs[i]->value; 594 remain -= (sint64) num_coins * (sint64)coin_objs[i]->value;
595 coin_objs[i]->nrof -= num_coins; 595 coin_objs[i]->nrof -= num_coins;
654 else if (item->below) item = item->below; 654 else if (item->below) item = item->below;
655 else if (item->env && item->env != pl && item->env->below) item = item->env->below; 655 else if (item->env && item->env != pl && item->env->below) item = item->env->below;
656 else item = NULL; 656 else item = NULL;
657 } 657 }
658 if (unpaid_price > player_wealth) { 658 if (unpaid_price > player_wealth) {
659 char buf[MAX_BUF], coinbuf[MAX_BUF]; 659 char buf[MAX_BUF];
660 int denominations = 0;
661 int has_coins = NUM_COINS;
662 char cost[MAX_BUF]; 660 char cost[MAX_BUF];
663 char missing[MAX_BUF]; 661 char missing[MAX_BUF];
664 662
665 sprintf(cost, "%s", cost_string_from_value (unpaid_price, 0)); 663 sprintf(cost, "%s", cost_string_from_value (unpaid_price, 0));
666 sprintf(missing, "%s", cost_string_from_value (unpaid_price - player_wealth, 0)); 664 sprintf(missing, "%s", cost_string_from_value (unpaid_price - player_wealth, 0));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines