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.5 by pippijn, Wed May 24 02:06:52 2006 UTC vs.
Revision 1.6 by pippijn, Wed May 24 03:30:23 2006 UTC

1/* 1/*
2 * static char *rcsid_shop_c = 2 * static char *rcsid_shop_c =
3 * "$Id: shop.c,v 1.5 2006/05/24 02:06:52 pippijn Exp $"; 3 * "$Id: shop.c,v 1.6 2006/05/24 03:30:23 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
362 362
363 next_coin = find_next_coin(cost, &cointype); 363 next_coin = find_next_coin(cost, &cointype);
364 if (next_coin == NULL) 364 if (next_coin == NULL)
365 return buf; 365 return buf;
366 366
367 do {
368 endbuf = buf + strlen(buf); 367 endbuf = buf + strlen(buf);
369 368
370 coin = next_coin; 369 coin = next_coin;
371 num = cost / coin->clone.value; 370 num = cost / coin->clone.value;
372 cost -= (uint64)num * (uint64)coin->clone.value; 371 cost -= (uint64)num * (uint64)coin->clone.value;
373 372
374 if (cost == 0)
375 next_coin = NULL;
376 else
377 next_coin = find_next_coin(cost, &cointype);
378
379 if (next_coin) {
380 /* There will be at least one more string to add to the list,
381 * use a comma.
382 */
383 strcat(endbuf, ", "); endbuf += 2;
384 } else {
385 strcat(endbuf, " and "); endbuf += 5; 373 strcat(endbuf, " and "); endbuf += 5;
386 }
387 if (num == 1) 374 if (num == 1)
388 sprintf(endbuf, "1 %s", coin->clone.name); 375 sprintf(endbuf, "1 %s", coin->clone.name);
389 else 376 else
390 sprintf(endbuf, "%d %s", num, coin->clone.name_pl); 377 sprintf(endbuf, "%d %s", num, coin->clone.name_pl);
391 } while (next_coin); 378
392
393 return buf; 379 return buf;
394} 380}
395 381
396const char *query_cost_string(const object *tmp,object *who,int flag) { 382const char *query_cost_string(const object *tmp,object *who,int flag) {
397 uint64 real_value = query_cost(tmp,who,flag); 383 uint64 real_value = query_cost(tmp,who,flag);
669 } 655 }
670 if (unpaid_price > player_wealth) { 656 if (unpaid_price > player_wealth) {
671 char buf[MAX_BUF], coinbuf[MAX_BUF]; 657 char buf[MAX_BUF], coinbuf[MAX_BUF];
672 int denominations = 0; 658 int denominations = 0;
673 int has_coins = NUM_COINS; 659 int has_coins = NUM_COINS;
674 sprintf(buf, "You have %d unpaid items that would cost you %s, but you", 660 char cost[MAX_BUF];
661 char missing[MAX_BUF];
662
675 unpaid_count, cost_string_from_value(unpaid_price)); 663 sprintf(cost, "%s", cost_string_from_value(unpaid_price));
676 for (i=0; i< NUM_COINS; i++) { 664 sprintf(missing, "%s", cost_string_from_value(unpaid_price - player_wealth));
677 if (coincount[i] == 0) { 665
678 has_coins--; 666 sprintf(buf, "You have %d unpaid items that would cost you %s. You need another %s to be able to afford that.",
679 } 667 unpaid_count, cost, missing);
680 }
681 if (has_coins == 0) {
682 strcat (buf, " have nothing to spend.");
683 new_draw_info(NDI_UNIQUE, 0, pl, buf);
684 return 0;
685 } else {
686 strcat (buf, " only have");
687 }
688 for (i=0; i< NUM_COINS; i++) {
689 if (coincount[i] > 0 && coins[i]) {
690 denominations++;
691 if (coincount[i+1] == 0 || !coins[i+1]) {
692 sprintf(coinbuf, " %d %s.", coincount[i], find_archetype(coins[i])->clone.name_pl);
693 } else {
694 sprintf(coinbuf, " %d %s,", coincount[i], find_archetype(coins[i])->clone.name_pl);
695 }
696 strcat (buf, coinbuf);
697 }
698 }
699 if (denominations > 1) make_list_like(buf);
700 new_draw_info(NDI_UNIQUE, 0, pl, buf); 668 new_draw_info(NDI_UNIQUE, 0, pl, buf);
701 return 0; 669 return 0;
702 } 670 }
703 else return 1; 671 else return 1;
704} 672}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines