1 | /* |
1 | /* |
2 | * static char *rcsid_c_object_c = |
2 | * static char *rcsid_c_object_c = |
3 | * "$Id: c_object.C,v 1.8 2006/08/28 07:07:42 root Exp $"; |
3 | * "$Id: c_object.C,v 1.9 2006/08/29 07:34:00 root Exp $"; |
4 | */ |
4 | */ |
5 | /* |
5 | /* |
6 | CrossFire, A Multiplayer game for X-windows |
6 | CrossFire, A Multiplayer game for X-windows |
7 | |
7 | |
8 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
8 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
… | |
… | |
498 | tag_t tmp_tag, tmp2_tag; |
498 | tag_t tmp_tag, tmp2_tag; |
499 | object *tmp2, *sack2; |
499 | object *tmp2, *sack2; |
500 | char buf[MAX_BUF]; |
500 | char buf[MAX_BUF]; |
501 | |
501 | |
502 | if (sack==tmp) return; /* Can't put an object in itself */ |
502 | if (sack==tmp) return; /* Can't put an object in itself */ |
503 | if (sack->type != CONTAINER && sack->type != TRANSPORT) { |
|
|
504 | new_draw_info_format(NDI_UNIQUE, 0,op, |
|
|
505 | "The %s is not a container.", query_name(sack)); |
|
|
506 | return; |
|
|
507 | } |
|
|
508 | if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) { |
503 | if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) { |
509 | new_draw_info_format(NDI_UNIQUE, 0,op, |
504 | new_draw_info_format(NDI_UNIQUE, 0,op, |
510 | "You cannot put the %s in the %s.", query_name(tmp), |
505 | "You cannot put the %s in the %s.", query_name(tmp), |
511 | query_name(sack)); |
506 | query_name(sack)); |
512 | return; |
507 | return; |
… | |
… | |
520 | sack2 = tmp; |
515 | sack2 = tmp; |
521 | new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", |
516 | new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", |
522 | query_name(tmp), query_name(sack)); |
517 | query_name(tmp), query_name(sack)); |
523 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { |
518 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { |
524 | tmp = tmp2->below; |
519 | tmp = tmp2->below; |
525 | if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof)) || |
520 | if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof))) { |
526 | (sack->type == TRANSPORT && transport_can_hold(sack, tmp2, tmp2->nrof))) { |
|
|
527 | put_object_in_sack (op, sack, tmp2, 0); |
521 | put_object_in_sack (op, sack, tmp2, 0); |
528 | } else { |
522 | } else { |
529 | sprintf(buf,"Your %s fills up.", query_name(sack)); |
523 | sprintf(buf,"Your %s fills up.", query_name(sack)); |
530 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
524 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
531 | break; |
525 | break; |
… | |
… | |
577 | if (tmp2 != tmp) |
571 | if (tmp2 != tmp) |
578 | esrv_del_item (op->contr, tmp_tag); |
572 | esrv_del_item (op->contr, tmp_tag); |
579 | |
573 | |
580 | esrv_send_item (op, tmp2); |
574 | esrv_send_item (op, tmp2); |
581 | |
575 | |
582 | /* If a transport, need to update all the players in the transport |
|
|
583 | * the view of what is in it. |
|
|
584 | */ |
|
|
585 | if (sack->type == TRANSPORT) { |
|
|
586 | for (tmp=sack->inv; tmp; tmp=tmp->below) { |
|
|
587 | if (tmp->type == PLAYER) tmp->contr->socket.update_look=1; |
|
|
588 | } |
|
|
589 | } else { |
|
|
590 | /* update the sacks weight */ |
576 | /* update the sacks weight */ |
591 | esrv_update_item (UPD_WEIGHT, op, sack); |
577 | esrv_update_item (UPD_WEIGHT, op, sack); |
592 | } |
|
|
593 | } |
578 | } |
594 | |
579 | |
595 | /* |
580 | /* |
596 | * This function was part of drop, now is own function. |
581 | * This function was part of drop, now is own function. |
597 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
582 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |