1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The author can be reached via e-mail to <crossfire@schmorp.de> |
|
|
23 | * |
|
|
24 | */ |
22 | |
25 | |
|
|
26 | /* |
23 | Object (handling) commands |
27 | * Object (handling) commands |
24 | */ |
28 | */ |
25 | |
29 | |
26 | #include <global.h> |
30 | #include <global.h> |
27 | #include <loader.h> |
31 | #include <loader.h> |
28 | #include <skills.h> |
32 | #include <skills.h> |
29 | #ifndef __CEXTRACT__ |
|
|
30 | # include <sproto.h> |
33 | #include <sproto.h> |
31 | #endif |
|
|
32 | #include <living.h> |
34 | #include <living.h> |
33 | #include <math.h> |
35 | #include <math.h> |
34 | |
36 | |
35 | /* |
37 | /* |
36 | * Object id parsing functions |
38 | * Object id parsing functions |
… | |
… | |
510 | if (tmp->invisible) |
512 | if (tmp->invisible) |
511 | { |
513 | { |
512 | tmp = next; |
514 | tmp = next; |
513 | continue; |
515 | continue; |
514 | } |
516 | } |
|
|
517 | |
515 | /* This following two if and else if could be merged into line |
518 | /* This following two if and else if could be merged into line |
516 | * but that probably will make it more difficult to read, and |
519 | * but that probably will make it more difficult to read, and |
517 | * not make it any more efficient |
520 | * not make it any more efficient |
518 | */ |
521 | */ |
519 | if (params && item_matched_string (op, tmp, params)) |
522 | if (params && item_matched_string (op, tmp, params)) |
520 | { |
|
|
521 | pick_up (op, tmp); |
523 | pick_up (op, tmp); |
522 | } |
|
|
523 | else if (can_pick (op, tmp) && !params) |
524 | else if (can_pick (op, tmp) && !params) |
524 | { |
525 | { |
525 | pick_up (op, tmp); |
526 | pick_up (op, tmp); |
526 | break; |
527 | break; |
527 | } |
528 | } |
|
|
529 | |
528 | tmp = next; |
530 | tmp = next; |
529 | /* Might as well just skip over the player immediately - |
|
|
530 | * we know it can't be picked up |
|
|
531 | */ |
|
|
532 | if (tmp == op) |
|
|
533 | tmp = tmp->below; |
|
|
534 | } |
531 | } |
|
|
532 | |
535 | if (!params && !tmp) |
533 | if (!params && !tmp) |
536 | { |
534 | { |
537 | for (tmp = op->below; tmp != NULL; tmp = tmp->next) |
535 | for (tmp = op->below; tmp; tmp = tmp->below) |
538 | if (!tmp->invisible) |
536 | if (!tmp->invisible) |
539 | { |
537 | { |
540 | char buf[MAX_BUF]; |
538 | char buf[MAX_BUF]; |
541 | |
539 | |
542 | sprintf (buf, "You can't pick up a %s.", &tmp->name); |
540 | sprintf (buf, "You can't pick up a %s.", &tmp->name); |
543 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
541 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
544 | break; |
542 | break; |
545 | } |
543 | } |
|
|
544 | |
546 | if (!tmp) |
545 | if (!tmp) |
547 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up."); |
546 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up."); |
548 | } |
547 | } |
|
|
548 | |
549 | return 0; |
549 | return 0; |
550 | } |
550 | } |
551 | |
551 | |
552 | |
552 | |
553 | /* |
553 | /* |
… | |
… | |
710 | |
710 | |
711 | tmp->destroy (); |
711 | tmp->destroy (); |
712 | op->update_stats (); |
712 | op->update_stats (); |
713 | return; |
713 | return; |
714 | } |
714 | } |
715 | |
|
|
716 | /* If SAVE_INTERVAL is commented out, we never want to save |
|
|
717 | * the player here. |
|
|
718 | */ |
|
|
719 | #ifdef SAVE_INTERVAL |
|
|
720 | /* I'm not sure why there is a value check - since the save |
|
|
721 | * is done every SAVE_INTERVAL seconds, why care the value |
|
|
722 | * of what he is dropping? |
|
|
723 | */ |
|
|
724 | if (op->type == PLAYER && !QUERY_FLAG (tmp, FLAG_UNPAID) && |
|
|
725 | (tmp->nrof ? tmp->value * tmp->nrof : tmp->value > 2000) && (op->contr->last_save_time + SAVE_INTERVAL) <= time (NULL)) |
|
|
726 | { |
|
|
727 | op->contr->save (); |
|
|
728 | op->contr->last_save_time = time (NULL); |
|
|
729 | } |
|
|
730 | #endif /* SAVE_INTERVAL */ |
|
|
731 | |
715 | |
732 | if (op->type == PLAYER) |
716 | if (op->type == PLAYER) |
733 | esrv_del_item (op->contr, tmp->count); |
717 | esrv_del_item (op->contr, tmp->count); |
734 | |
718 | |
735 | /* Call this before we update the various windows/players. At least |
719 | /* Call this before we update the various windows/players. At least |
… | |
… | |
994 | { |
978 | { |
995 | if (!params) |
979 | if (!params) |
996 | { |
980 | { |
997 | object *tmp = op->below; |
981 | object *tmp = op->below; |
998 | |
982 | |
999 | while (tmp && !LOOK_OBJ (tmp)) |
983 | while (tmp && !tmp->client_visible ()) |
1000 | tmp = tmp->below; |
984 | tmp = tmp->below; |
1001 | if (tmp) |
985 | if (tmp) |
1002 | examine (op, tmp); |
986 | examine (op, tmp); |
1003 | } |
987 | } |
1004 | else |
988 | else |