1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_shop_c = |
|
|
4 | * "$Id: shop.C,v 1.14 2006/09/12 19:20:08 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #include <spells.h> |
25 | #include <spells.h> |
32 | #include <skills.h> |
26 | #include <skills.h> |
… | |
… | |
334 | |
328 | |
335 | do |
329 | do |
336 | { |
330 | { |
337 | if (coins[*cointype] == NULL) |
331 | if (coins[*cointype] == NULL) |
338 | return NULL; |
332 | return NULL; |
339 | coin = find_archetype (coins[*cointype]); |
333 | coin = archetype::find (coins[*cointype]); |
340 | if (coin == NULL) |
334 | if (coin == NULL) |
341 | return NULL; |
335 | return NULL; |
342 | *cointype += 1; |
336 | *cointype += 1; |
343 | } |
337 | } |
344 | while (coin->clone.value > c); |
338 | while (coin->clone.value > c); |
… | |
… | |
625 | /* Fill in any gaps in the coin_objs array - needed to make change. */ |
619 | /* Fill in any gaps in the coin_objs array - needed to make change. */ |
626 | /* Note that the coin_objs array goes from least value to greatest value */ |
620 | /* Note that the coin_objs array goes from least value to greatest value */ |
627 | for (i = 0; i < NUM_COINS; i++) |
621 | for (i = 0; i < NUM_COINS; i++) |
628 | if (!coin_objs[i]) |
622 | if (!coin_objs[i]) |
629 | { |
623 | { |
630 | at = find_archetype (coins[NUM_COINS - 1 - i]); |
624 | at = archetype::find (coins[NUM_COINS - 1 - i]); |
631 | |
625 | |
632 | if (at == NULL) |
626 | if (at == NULL) |
633 | LOG (llevError, "Could not find %s archetype\n", coins[NUM_COINS - 1 - i]); |
627 | LOG (llevError, "Could not find %s archetype\n", coins[NUM_COINS - 1 - i]); |
634 | |
628 | |
635 | coin_objs[i] = arch_to_object (at); |
629 | coin_objs[i] = arch_to_object (at); |
… | |
… | |
753 | return 0; |
747 | return 0; |
754 | } |
748 | } |
755 | else |
749 | else |
756 | { |
750 | { |
757 | object *tmp; |
751 | object *tmp; |
758 | tag_t c = op->count; |
|
|
759 | |
752 | |
760 | CLEAR_FLAG (op, FLAG_UNPAID); |
753 | CLEAR_FLAG (op, FLAG_UNPAID); |
761 | CLEAR_FLAG (op, FLAG_PLAYER_SOLD); |
754 | CLEAR_FLAG (op, FLAG_PLAYER_SOLD); |
762 | new_draw_info_format (NDI_UNIQUE, 0, op, "You paid %s for %s.", buf, query_name (op)); |
755 | new_draw_info_format (NDI_UNIQUE, 0, op, "You paid %s for %s.", buf, query_name (op)); |
763 | tmp = merge_ob (op, NULL); |
756 | tmp = merge_ob (op, NULL); |
764 | |
757 | |
765 | if (pl->type == PLAYER) |
758 | if (pl->type == PLAYER) |
766 | { |
759 | { |
767 | if (tmp) |
760 | if (tmp) |
768 | { /* it was merged */ |
761 | { /* it was merged */ |
769 | esrv_del_item (pl->contr, c); |
762 | esrv_del_item (pl->contr, op->count); |
770 | op = tmp; |
763 | op = tmp; |
771 | } |
764 | } |
772 | |
765 | |
773 | esrv_send_item (pl, op); |
766 | esrv_send_item (pl, op); |
774 | } |
767 | } |
… | |
… | |
800 | archetype *at = 0; |
793 | archetype *at = 0; |
801 | object *pouch = 0, *tmp = 0; |
794 | object *pouch = 0, *tmp = 0; |
802 | |
795 | |
803 | for (count = 0; coins[count] != NULL; count++) |
796 | for (count = 0; coins[count] != NULL; count++) |
804 | { |
797 | { |
805 | at = find_archetype (coins[count]); |
798 | at = archetype::find (coins[count]); |
806 | |
799 | |
807 | if (at == NULL) |
800 | if (at == NULL) |
808 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
801 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
809 | else if ((amount / at->clone.value) > 0) |
802 | else if ((amount / at->clone.value) > 0) |
810 | { |
803 | { |
… | |
… | |
857 | |
850 | |
858 | /* elmex: this is for the bank plugin :( */ |
851 | /* elmex: this is for the bank plugin :( */ |
859 | sint64 |
852 | sint64 |
860 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
853 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
861 | { |
854 | { |
862 | archetype *at = find_archetype (arch); |
855 | archetype *at = archetype::find (arch); |
863 | object *tmp = NULL; |
856 | object *tmp = NULL; |
864 | |
857 | |
865 | if (at == NULL) |
858 | if (at == NULL) |
866 | return 0; |
859 | return 0; |
867 | |
860 | |