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.10 by root, Sun Sep 10 15:59:57 2006 UTC vs.
Revision 1.11 by root, Mon Sep 11 20:26:41 2006 UTC

1 1
2/* 2/*
3 * static char *rcsid_shop_c = 3 * static char *rcsid_shop_c =
4 * "$Id: shop.C,v 1.10 2006/09/10 15:59:57 root Exp $"; 4 * "$Id: shop.C,v 1.11 2006/09/11 20:26:41 root Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
675 { 675 {
676 object *tmp = insert_ob_in_ob (coin_objs[i], pouch); 676 object *tmp = insert_ob_in_ob (coin_objs[i], pouch);
677 677
678 esrv_send_item (pl, tmp); 678 esrv_send_item (pl, tmp);
679 esrv_send_item (pl, pouch); 679 esrv_send_item (pl, pouch);
680
680 if (pl != pouch) 681 if (pl != pouch)
681 esrv_update_item (UPD_WEIGHT, pl, pouch); 682 esrv_update_item (UPD_WEIGHT, pl, pouch);
683
682 if (pl->type != PLAYER) 684 if (pl->type != PLAYER)
683 {
684 esrv_send_item (pl, pl); 685 esrv_send_item (pl, pl);
685 }
686 } 686 }
687 else 687 else
688 {
689 free_object (coin_objs[i]); 688 free_object (coin_objs[i]);
690 }
691 } 689 }
690
692 return (remain); 691 return (remain);
693} 692}
694 693
695/* Checks all unpaid items in op's inventory, adds up all the money they 694/* Checks all unpaid items in op's inventory, adds up all the money they
696 * have, and checks that they can actually afford what they want to buy. 695 * have, and checks that they can actually afford what they want to buy.
710 if (!pl || pl->type != PLAYER) 709 if (!pl || pl->type != PLAYER)
711 { 710 {
712 LOG (llevError, "can_pay(): called against something that isn't a player\n"); 711 LOG (llevError, "can_pay(): called against something that isn't a player\n");
713 return 0; 712 return 0;
714 } 713 }
714
715 for (i = 0; i < NUM_COINS; i++) 715 for (i = 0; i < NUM_COINS; i++)
716 coincount[i] = 0; 716 coincount[i] = 0;
717
717 for (item = pl->inv; item;) 718 for (item = pl->inv; item;)
718 { 719 {
719 if QUERY_FLAG
720 (item, FLAG_UNPAID) 720 if (QUERY_FLAG (item, FLAG_UNPAID))
721 { 721 {
722 unpaid_count++; 722 unpaid_count++;
723 unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); 723 unpaid_price += query_cost (item, pl, F_BUY | F_SHOP);
724 } 724 }
725
725 /* merely converting the player's monetary wealth won't do, if we did that, 726 /* merely converting the player's monetary wealth won't do, if we did that,
726 * we could print the wrong numbers for the coins, so we count the money instead 727 * we could print the wrong numbers for the coins, so we count the money instead
727 */ 728 */
728 for (i = 0; i < NUM_COINS; i++) 729 for (i = 0; i < NUM_COINS; i++)
729 if (!strcmp (coins[i], item->arch->name)) 730 if (!strcmp (coins[i], item->arch->name))
730 coincount[i] += item->nrof; 731 coincount[i] += item->nrof;
732
731 if (item->inv) 733 if (item->inv)
732 item = item->inv; 734 item = item->inv;
733 else if (item->below) 735 else if (item->below)
734 item = item->below; 736 item = item->below;
735 else if (item->env && item->env != pl && item->env->below) 737 else if (item->env && item->env != pl && item->env->below)
736 item = item->env->below; 738 item = item->env->below;
737 else 739 else
738 item = NULL; 740 item = NULL;
739 } 741 }
742
740 if (unpaid_price > player_wealth) 743 if (unpaid_price > player_wealth)
741 { 744 {
742 char buf[MAX_BUF]; 745 char buf[MAX_BUF];
743 char cost[MAX_BUF]; 746 char cost[MAX_BUF];
744 char missing[MAX_BUF]; 747 char missing[MAX_BUF];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines