… | |
… | |
16 | |
16 | |
17 | 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 |
18 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
20 | |
21 | The author can be reached via e-mail to crossfire-devel@real-time.com |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | |
22 | |
23 | Object (handling) commands |
23 | Object (handling) commands |
24 | */ |
24 | */ |
25 | |
25 | |
26 | #include <global.h> |
26 | #include <global.h> |
… | |
… | |
34 | |
34 | |
35 | /* |
35 | /* |
36 | * Object id parsing functions |
36 | * Object id parsing functions |
37 | */ |
37 | */ |
38 | |
38 | |
39 | #define OBLINKMALLOC(p) if(!((p)=(objectlink *)malloc(sizeof(objectlink))))\ |
|
|
40 | fatal(OUT_OF_MEMORY); |
|
|
41 | |
|
|
42 | #define ADD_ITEM(NEW,COUNT)\ |
39 | #define ADD_ITEM(NEW,COUNT)\ |
43 | if(!first) {\ |
40 | if(!first) {\ |
44 | OBLINKMALLOC(first);\ |
41 | first = new objectlink;\ |
45 | last=first;\ |
42 | last=first;\ |
46 | } else {\ |
43 | } else {\ |
47 | OBLINKMALLOC(last->next);\ |
44 | last->next = new objectlink;\ |
48 | last=last->next;\ |
45 | last=last->next;\ |
49 | }\ |
46 | }\ |
50 | last->next=NULL;\ |
47 | last->next=0;\ |
51 | last->ob=(NEW);\ |
48 | last->ob=(NEW);\ |
52 | last->id=(COUNT); |
49 | last->id=(COUNT); |
53 | |
50 | |
54 | /** |
51 | /** |
55 | * Search the inventory of 'pl' for what matches best with params. |
52 | * Search the inventory of 'pl' for what matches best with params. |
… | |
… | |
267 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && is_player_inv (tmp) != pl) |
264 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && is_player_inv (tmp) != pl) |
268 | { |
265 | { |
269 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
266 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
270 | return; |
267 | return; |
271 | } |
268 | } |
|
|
269 | |
272 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
270 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
273 | return; |
271 | return; |
|
|
272 | |
274 | if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
273 | if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
275 | { |
274 | { |
276 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff of smoke!"); |
275 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff of smoke!"); |
277 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
276 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
|
|
277 | |
278 | if (pl->type == PLAYER) |
278 | if (pl->type == PLAYER) |
279 | esrv_del_item (pl->contr, tmp->count); |
279 | esrv_del_item (pl->contr, tmp->count); |
280 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
280 | |
281 | remove_ob (tmp); |
281 | tmp->destroy (); |
282 | free_object (tmp); |
|
|
283 | return; |
282 | return; |
284 | } |
283 | } |
285 | |
284 | |
286 | if (nrof > tmp_nrof || nrof == 0) |
285 | if (nrof > tmp_nrof || nrof == 0) |
287 | nrof = tmp_nrof; |
286 | nrof = tmp_nrof; |
|
|
287 | |
288 | /* Figure out how much weight this object will add to the player */ |
288 | /* Figure out how much weight this object will add to the player */ |
289 | weight = tmp->weight * nrof; |
289 | weight = tmp->weight * nrof; |
290 | if (tmp->inv) |
290 | if (tmp->inv) |
291 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
291 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
|
|
292 | |
292 | if (pl->stats.Str <= MAX_STAT) |
293 | if (pl->stats.Str <= MAX_STAT) |
293 | effective_weight_limit = weight_limit[pl->stats.Str]; |
294 | effective_weight_limit = weight_limit[pl->stats.Str]; |
294 | else |
295 | else |
295 | effective_weight_limit = weight_limit[MAX_STAT]; |
296 | effective_weight_limit = weight_limit[MAX_STAT]; |
|
|
297 | |
296 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
298 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
297 | { |
299 | { |
298 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
300 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
299 | return; |
301 | return; |
300 | } |
302 | } |
|
|
303 | |
301 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
304 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
302 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
305 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
306 | |
303 | if (nrof != tmp_nrof) |
307 | if (nrof != tmp_nrof) |
304 | { |
308 | { |
305 | object *tmp2 = tmp; |
309 | object *tmp2 = tmp; |
306 | tag_t tmp2_tag = tmp2->count; |
|
|
307 | |
310 | |
308 | tmp = get_split_ob (tmp, nrof); |
311 | tmp = get_split_ob (tmp, nrof); |
309 | if (!tmp) |
312 | if (!tmp) |
310 | { |
313 | { |
311 | new_draw_info (NDI_UNIQUE, 0, pl, errmsg); |
314 | new_draw_info (NDI_UNIQUE, 0, pl, errmsg); |
312 | return; |
315 | return; |
313 | } |
316 | } |
|
|
317 | |
314 | /* Tell a client what happened rest of objects */ |
318 | /* Tell a client what happened rest of objects */ |
315 | if (pl->type == PLAYER) |
319 | if (pl->type == PLAYER) |
316 | { |
320 | { |
317 | if (was_destroyed (tmp2, tmp2_tag)) |
321 | if (tmp2->destroyed ()) |
318 | esrv_del_item (pl->contr, tmp2_tag); |
322 | esrv_del_item (pl->contr, tmp2->count); |
319 | else |
323 | else |
320 | esrv_send_item (pl, tmp2); |
324 | esrv_send_item (pl, tmp2); |
321 | } |
325 | } |
322 | } |
326 | } |
323 | else |
327 | else |
… | |
… | |
328 | */ |
332 | */ |
329 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
333 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
330 | { |
334 | { |
331 | if (tmp->env && pl->type == PLAYER) |
335 | if (tmp->env && pl->type == PLAYER) |
332 | esrv_del_item (pl->contr, tmp->count); |
336 | esrv_del_item (pl->contr, tmp->count); |
333 | remove_ob (tmp); /* Unlink it */ |
337 | tmp->remove (); /* Unlink it */ |
334 | } |
338 | } |
335 | } |
339 | } |
336 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
340 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
337 | (void) sprintf (buf, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); |
341 | (void) sprintf (buf, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); |
338 | else |
342 | else |
… | |
… | |
360 | /* Update the container the object was in */ |
364 | /* Update the container the object was in */ |
361 | if (env && env != pl && env != op) |
365 | if (env && env != pl && env != op) |
362 | esrv_update_item (UPD_WEIGHT, pl, env); |
366 | esrv_update_item (UPD_WEIGHT, pl, env); |
363 | } |
367 | } |
364 | |
368 | |
365 | |
369 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
366 | void |
370 | void |
367 | pick_up (object *op, object *alt) |
371 | pick_up (object *op, object *alt) |
368 | |
|
|
369 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
|
|
370 | { |
372 | { |
371 | int need_fix_tmp = 0; |
373 | int need_fix_tmp = 0; |
372 | object *tmp = NULL; |
374 | object *tmp = NULL; |
373 | mapstruct *tmp_map = NULL; |
375 | maptile *tmp_map = NULL; |
374 | int count; |
376 | int count; |
375 | tag_t tag; |
|
|
376 | |
377 | |
377 | /* Decide which object to pick. */ |
378 | /* Decide which object to pick. */ |
378 | if (alt) |
379 | if (alt) |
379 | { |
380 | { |
380 | if (!can_pick (op, alt)) |
381 | if (!can_pick (op, alt)) |
… | |
… | |
389 | if (op->below == NULL || !can_pick (op, op->below)) |
390 | if (op->below == NULL || !can_pick (op, op->below)) |
390 | { |
391 | { |
391 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up here."); |
392 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up here."); |
392 | goto leave; |
393 | goto leave; |
393 | } |
394 | } |
|
|
395 | |
394 | tmp = op->below; |
396 | tmp = op->below; |
395 | } |
397 | } |
396 | |
398 | |
397 | /* Try to catch it. */ |
399 | /* Try to catch it. */ |
398 | tmp_map = tmp->map; |
400 | tmp_map = tmp->map; |
… | |
… | |
431 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && sack_can_hold (NULL, alt, tmp, count)) |
433 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && sack_can_hold (NULL, alt, tmp, count)) |
432 | break; /* General container comes next */ |
434 | break; /* General container comes next */ |
433 | if (!alt) |
435 | if (!alt) |
434 | alt = op; /* No free containers */ |
436 | alt = op; /* No free containers */ |
435 | } |
437 | } |
|
|
438 | |
436 | if (tmp->env == alt) |
439 | if (tmp->env == alt) |
437 | { |
440 | { |
438 | /* here it could be possible to check rent, |
441 | /* here it could be possible to check rent, |
439 | * if someone wants to implement it |
442 | * if someone wants to implement it |
440 | */ |
443 | */ |
… | |
… | |
449 | { |
452 | { |
450 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
453 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
451 | goto leave; |
454 | goto leave; |
452 | } |
455 | } |
453 | |
456 | |
454 | tag = tmp->count; |
|
|
455 | pick_up_object (op, alt, tmp, count); |
457 | pick_up_object (op, alt, tmp, count); |
|
|
458 | |
456 | if (was_destroyed (tmp, tag) || tmp->env) |
459 | if (tmp->destroyed () || tmp->env) |
457 | need_fix_tmp = 0; |
460 | need_fix_tmp = 0; |
|
|
461 | |
458 | if (op->type == PLAYER) |
462 | if (op->type == PLAYER) |
459 | op->contr->count = 0; |
463 | op->contr->count = 0; |
|
|
464 | |
460 | goto leave; |
465 | goto leave; |
461 | |
466 | |
462 | leave: |
467 | leave: |
463 | if (need_fix_tmp) |
468 | if (need_fix_tmp) |
464 | fix_stopped_item (tmp, tmp_map, op); |
469 | fix_stopped_item (tmp, tmp_map, op); |
… | |
… | |
480 | else |
485 | else |
481 | { |
486 | { |
482 | tmp = op->above; |
487 | tmp = op->above; |
483 | if (tmp) |
488 | if (tmp) |
484 | while (tmp->above) |
489 | while (tmp->above) |
485 | { |
|
|
486 | tmp = tmp->above; |
490 | tmp = tmp->above; |
487 | } |
491 | |
488 | if (!tmp) |
492 | if (!tmp) |
489 | tmp = op->below; |
493 | tmp = op->below; |
490 | } |
494 | } |
491 | |
495 | |
492 | if (tmp == NULL) |
496 | if (tmp == NULL) |
… | |
… | |
554 | * so this function isn't named very good anymore. |
558 | * so this function isn't named very good anymore. |
555 | */ |
559 | */ |
556 | void |
560 | void |
557 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
561 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
558 | { |
562 | { |
559 | tag_t tmp_tag, tmp2_tag; |
|
|
560 | object *tmp2, *sack2; |
563 | object *tmp2, *sack2; |
561 | char buf[MAX_BUF]; |
564 | char buf[MAX_BUF]; |
562 | |
565 | |
563 | if (sack == tmp) |
566 | if (sack == tmp) |
564 | return; /* Can't put an object in itself */ |
567 | return; /* Can't put an object in itself */ |
|
|
568 | |
565 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
569 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
566 | { |
570 | { |
567 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
571 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
568 | return; |
572 | return; |
569 | } |
573 | } |
|
|
574 | |
570 | if (tmp->type == CONTAINER && tmp->inv) |
575 | if (tmp->type == CONTAINER && tmp->inv) |
571 | { |
576 | { |
572 | |
577 | |
573 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
578 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
574 | * we instead move the contents of that container into the active |
579 | * we instead move the contents of that container into the active |
575 | * container, this is only done if the object has something in it. |
580 | * container, this is only done if the object has something in it. |
576 | */ |
581 | */ |
577 | sack2 = tmp; |
582 | sack2 = tmp; |
578 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
583 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
|
|
584 | |
579 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
585 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
580 | { |
586 | { |
581 | tmp = tmp2->below; |
587 | tmp = tmp2->below; |
|
|
588 | |
582 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
589 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
583 | { |
590 | { |
584 | put_object_in_sack (op, sack, tmp2, 0); |
591 | put_object_in_sack (op, sack, tmp2, 0); |
585 | } |
592 | } |
586 | else |
593 | else |
… | |
… | |
588 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
595 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
589 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
596 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
590 | break; |
597 | break; |
591 | } |
598 | } |
592 | } |
599 | } |
|
|
600 | |
593 | esrv_update_item (UPD_WEIGHT, op, sack2); |
601 | esrv_update_item (UPD_WEIGHT, op, sack2); |
594 | return; |
602 | return; |
595 | } |
603 | } |
596 | |
604 | |
597 | /* Don't worry about this for containers - our caller should have |
605 | /* Don't worry about this for containers - our caller should have |
… | |
… | |
599 | */ |
607 | */ |
600 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
608 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
601 | return; |
609 | return; |
602 | |
610 | |
603 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
611 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
604 | { |
|
|
605 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
612 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
606 | return; |
613 | return; |
607 | } |
|
|
608 | |
614 | |
609 | /* we want to put some portion of the item into the container */ |
615 | /* we want to put some portion of the item into the container */ |
610 | if (nrof && tmp->nrof != nrof) |
616 | if (nrof && tmp->nrof != nrof) |
611 | { |
617 | { |
612 | object *tmp2 = tmp; |
618 | object *tmp2 = tmp; |
613 | |
619 | |
614 | tmp2_tag = tmp2->count; |
|
|
615 | tmp = get_split_ob (tmp, nrof); |
620 | tmp = get_split_ob (tmp, nrof); |
616 | |
621 | |
617 | if (!tmp) |
622 | if (!tmp) |
618 | { |
623 | { |
619 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
624 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
620 | return; |
625 | return; |
621 | } |
626 | } |
622 | /* Tell a client what happened other objects */ |
627 | /* Tell a client what happened other objects */ |
623 | if (was_destroyed (tmp2, tmp2_tag)) |
628 | if (tmp2->destroyed ()) |
624 | esrv_del_item (op->contr, tmp2_tag); |
629 | esrv_del_item (op->contr, tmp2->count); |
625 | else /* this can proably be replaced with an update */ |
630 | else /* this can proably be replaced with an update */ |
626 | esrv_send_item (op, tmp2); |
631 | esrv_send_item (op, tmp2); |
627 | } |
632 | } |
628 | else |
633 | else |
629 | remove_ob (tmp); |
634 | tmp->remove (); |
630 | |
635 | |
631 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
636 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
632 | tmp_tag = tmp->count; |
|
|
633 | tmp2 = insert_ob_in_ob (tmp, sack); |
637 | tmp2 = insert_ob_in_ob (tmp, sack); |
634 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
638 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
635 | /* in object.c */ |
639 | /* in object.c */ |
636 | |
640 | |
637 | /* If an object merged (and thus, different object), we need to |
641 | /* If an object merged (and thus, different object), we need to |
638 | * delete the original. |
642 | * delete the original. |
639 | */ |
643 | */ |
640 | if (tmp2 != tmp) |
644 | if (tmp2 != tmp) |
641 | esrv_del_item (op->contr, tmp_tag); |
645 | esrv_del_item (op->contr, tmp->count); |
642 | |
646 | |
643 | esrv_send_item (op, tmp2); |
647 | esrv_send_item (op, tmp2); |
644 | |
648 | |
645 | /* update the sacks weight */ |
649 | /* update the sacks weight */ |
646 | esrv_update_item (UPD_WEIGHT, op, sack); |
650 | esrv_update_item (UPD_WEIGHT, op, sack); |
… | |
… | |
663 | |
667 | |
664 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
668 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
665 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
669 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
666 | return; /* can't unapply it */ |
670 | return; /* can't unapply it */ |
667 | |
671 | |
668 | /* We are only dropping some of the items. We split the current objec |
672 | /* We are only dropping some of the items. We split the current object |
669 | * off |
673 | * off |
670 | */ |
674 | */ |
671 | if (nrof && tmp->nrof != nrof) |
675 | if (nrof && tmp->nrof != nrof) |
672 | { |
676 | { |
673 | object *tmp2 = tmp; |
677 | object *tmp2 = tmp; |
674 | tag_t tmp2_tag = tmp2->count; |
|
|
675 | |
678 | |
676 | tmp = get_split_ob (tmp, nrof); |
679 | tmp = get_split_ob (tmp, nrof); |
677 | if (!tmp) |
680 | if (!tmp) |
678 | { |
681 | { |
679 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
682 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
… | |
… | |
682 | /* Tell a client what happened rest of objects. tmp2 is now the |
685 | /* Tell a client what happened rest of objects. tmp2 is now the |
683 | * original object |
686 | * original object |
684 | */ |
687 | */ |
685 | if (op->type == PLAYER) |
688 | if (op->type == PLAYER) |
686 | { |
689 | { |
687 | if (was_destroyed (tmp2, tmp2_tag)) |
690 | if (tmp2->destroyed ()) |
688 | esrv_del_item (op->contr, tmp2_tag); |
691 | esrv_del_item (op->contr, tmp2->count); |
689 | else |
692 | else |
690 | esrv_send_item (op, tmp2); |
693 | esrv_send_item (op, tmp2); |
691 | } |
694 | } |
692 | } |
695 | } |
693 | else |
696 | else |
694 | remove_ob (tmp); |
697 | tmp->remove (); |
695 | |
698 | |
696 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
699 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
697 | return; |
700 | return; |
698 | |
701 | |
699 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
702 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
… | |
… | |
701 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
704 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
702 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
705 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
703 | new_draw_info (NDI_UNIQUE, 0, op, "The gods who lent it to you retrieves it."); |
706 | new_draw_info (NDI_UNIQUE, 0, op, "The gods who lent it to you retrieves it."); |
704 | if (op->type == PLAYER) |
707 | if (op->type == PLAYER) |
705 | esrv_del_item (op->contr, tmp->count); |
708 | esrv_del_item (op->contr, tmp->count); |
706 | free_object (tmp); |
709 | tmp->destroy (); |
707 | fix_player (op); |
710 | fix_player (op); |
708 | return; |
711 | return; |
709 | } |
712 | } |
710 | |
713 | |
711 | /* If SAVE_INTERVAL is commented out, we never want to save |
714 | /* If SAVE_INTERVAL is commented out, we never want to save |
… | |
… | |
767 | if (tmp->env && tmp->env->type != PLAYER) |
770 | if (tmp->env && tmp->env->type != PLAYER) |
768 | { |
771 | { |
769 | /* Just toss the object - probably shouldn't be hanging |
772 | /* Just toss the object - probably shouldn't be hanging |
770 | * around anyways |
773 | * around anyways |
771 | */ |
774 | */ |
772 | remove_ob (tmp); |
775 | tmp->remove (); |
773 | free_object (tmp); |
776 | tmp->destroy (); |
774 | return; |
777 | return; |
775 | } |
778 | } |
776 | else |
779 | else |
777 | { |
780 | { |
778 | while (tmp != NULL && tmp->invisible) |
781 | while (tmp != NULL && tmp->invisible) |
… | |
… | |
1038 | { |
1041 | { |
1039 | object *tmp; |
1042 | object *tmp; |
1040 | |
1043 | |
1041 | if (!op || !op->contr) |
1044 | if (!op || !op->contr) |
1042 | return NULL; |
1045 | return NULL; |
|
|
1046 | |
1043 | if (!op->contr->mark) |
1047 | if (!op->contr->mark) |
1044 | { |
1048 | { |
1045 | |
|
|
1046 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1049 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1047 | return NULL; |
1050 | return 0; |
1048 | } |
1051 | } |
|
|
1052 | |
1049 | /* This may seem like overkill, but we need to make sure that they |
1053 | /* This may seem like overkill, but we need to make sure that they |
1050 | * player hasn't dropped the item. We use count on the off chance that |
1054 | * player hasn't dropped the item. We use count on the off chance that |
1051 | * an item got reincarnated at some point. |
1055 | * an item got reincarnated at some point. |
1052 | */ |
1056 | */ |
1053 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1057 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1054 | { |
1058 | { |
1055 | if (tmp->invisible) |
1059 | if (tmp->invisible) |
1056 | continue; |
1060 | continue; |
|
|
1061 | |
1057 | if (tmp == op->contr->mark) |
1062 | if (tmp == op->contr->mark) |
1058 | { |
1063 | { |
1059 | if (tmp->count == op->contr->mark_count) |
1064 | if (!tmp->destroyed ()) |
1060 | return tmp; |
1065 | return tmp; |
1061 | else |
1066 | else |
1062 | { |
1067 | { |
1063 | op->contr->mark = NULL; |
1068 | op->contr->mark = 0; |
1064 | op->contr->mark_count = 0; |
|
|
1065 | |
|
|
1066 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1069 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1067 | return NULL; |
1070 | return 0; |
1068 | } |
1071 | } |
1069 | } |
1072 | } |
1070 | } |
1073 | } |
|
|
1074 | |
1071 | return NULL; |
1075 | return 0; |
1072 | } |
1076 | } |
1073 | |
1077 | |
1074 | |
1078 | |
1075 | /* op should be a player, params is any params. |
1079 | /* op should be a player, params is any params. |
1076 | * If no params given, we print out the currently marked object. |
1080 | * If no params given, we print out the currently marked object. |
… | |
… | |
1079 | int |
1083 | int |
1080 | command_mark (object *op, char *params) |
1084 | command_mark (object *op, char *params) |
1081 | { |
1085 | { |
1082 | if (!op->contr) |
1086 | if (!op->contr) |
1083 | return 1; |
1087 | return 1; |
|
|
1088 | |
1084 | if (!params) |
1089 | if (!params) |
1085 | { |
1090 | { |
1086 | object *mark = find_marked_object (op); |
1091 | object *mark = find_marked_object (op); |
1087 | |
1092 | |
1088 | if (!mark) |
1093 | if (!mark) |
… | |
… | |
1100 | return 1; |
1105 | return 1; |
1101 | } |
1106 | } |
1102 | else |
1107 | else |
1103 | { |
1108 | { |
1104 | op->contr->mark = mark1; |
1109 | op->contr->mark = mark1; |
1105 | op->contr->mark_count = mark1->count; |
|
|
1106 | new_draw_info_format (NDI_UNIQUE, 0, op, "Marked item %s", query_name (mark1)); |
1110 | new_draw_info_format (NDI_UNIQUE, 0, op, "Marked item %s", query_name (mark1)); |
1107 | return 0; |
1111 | return 0; |
1108 | } |
1112 | } |
1109 | } |
1113 | } |
|
|
1114 | |
1110 | return 0; /*shouldnt get here */ |
1115 | return 0; /*shouldnt get here */ |
1111 | } |
1116 | } |
1112 | |
1117 | |
1113 | |
1118 | |
1114 | /* op is the player |
1119 | /* op is the player |
… | |
… | |
1447 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d MAGICDEVICE", i & PU_MAGIC_DEVICE ? 1 : 0); |
1452 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d MAGICDEVICE", i & PU_MAGIC_DEVICE ? 1 : 0); |
1448 | |
1453 | |
1449 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d NOT CURSED", i & PU_NOT_CURSED ? 1 : 0); |
1454 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d NOT CURSED", i & PU_NOT_CURSED ? 1 : 0); |
1450 | |
1455 | |
1451 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d JEWELS", i & PU_JEWELS ? 1 : 0); |
1456 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d JEWELS", i & PU_JEWELS ? 1 : 0); |
|
|
1457 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d FLESH", i & PU_FLESH ? 1 : 0); |
1452 | |
1458 | |
1453 | new_draw_info_format (NDI_UNIQUE, 0, op, ""); |
1459 | new_draw_info_format (NDI_UNIQUE, 0, op, ""); |
1454 | } |
1460 | } |
1455 | |
1461 | |
1456 | int |
1462 | int |
… | |
… | |
1458 | { |
1464 | { |
1459 | uint32 i; |
1465 | uint32 i; |
1460 | static const char *names[] = { |
1466 | static const char *names[] = { |
1461 | "debug", "inhibit", "stop", "food", "drink", "valuables", "bow", "arrow", "helmet", |
1467 | "debug", "inhibit", "stop", "food", "drink", "valuables", "bow", "arrow", "helmet", |
1462 | "shield", "armour", "boots", "gloves", "cloak", "key", "missile", "allweapon", |
1468 | "shield", "armour", "boots", "gloves", "cloak", "key", "missile", "allweapon", |
1463 | "magical", "potion", "spellbook", "skillscroll", "readables", "magicdevice", "notcursed", "jewels", NULL |
1469 | "magical", "potion", "spellbook", "skillscroll", "readables", "magicdevice", "notcursed", |
|
|
1470 | "jewels", "flesh", NULL |
1464 | }; |
1471 | }; |
1465 | static uint32 modes[] = { |
1472 | static uint32 modes[] = { |
1466 | PU_DEBUG, PU_INHIBIT, PU_STOP, PU_FOOD, PU_DRINK, PU_VALUABLES, PU_BOW, PU_ARROW, PU_HELMET, |
1473 | PU_DEBUG, PU_INHIBIT, PU_STOP, PU_FOOD, PU_DRINK, PU_VALUABLES, PU_BOW, PU_ARROW, PU_HELMET, |
1467 | PU_SHIELD, PU_ARMOUR, PU_BOOTS, PU_GLOVES, PU_CLOAK, PU_KEY, PU_MISSILEWEAPON, PU_ALLWEAPON, |
1474 | PU_SHIELD, PU_ARMOUR, PU_BOOTS, PU_GLOVES, PU_CLOAK, PU_KEY, PU_MISSILEWEAPON, PU_ALLWEAPON, |
1468 | PU_MAGICAL, PU_POTION, PU_SPELLBOOK, PU_SKILLSCROLL, PU_READABLES, PU_MAGIC_DEVICE, PU_NOT_CURSED, PU_JEWELS, 0 |
1475 | PU_MAGICAL, PU_POTION, PU_SPELLBOOK, PU_SKILLSCROLL, PU_READABLES, PU_MAGIC_DEVICE, PU_NOT_CURSED, |
|
|
1476 | PU_JEWELS, PU_FLESH, 0 |
1469 | }; |
1477 | }; |
1470 | |
1478 | |
1471 | if (!params) |
1479 | if (!params) |
1472 | { |
1480 | { |
1473 | /* if the new mode is used, just print the settings */ |
1481 | /* if the new mode is used, just print the settings */ |