… | |
… | |
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. |
… | |
… | |
279 | 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."); |
280 | |
277 | |
281 | if (pl->type == PLAYER) |
278 | if (pl->type == PLAYER) |
282 | esrv_del_item (pl->contr, tmp->count); |
279 | esrv_del_item (pl->contr, tmp->count); |
283 | |
280 | |
284 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
281 | tmp->destroy (); |
285 | remove_ob (tmp); |
|
|
286 | |
|
|
287 | free_object (tmp); |
|
|
288 | return; |
282 | return; |
289 | } |
283 | } |
290 | |
284 | |
291 | if (nrof > tmp_nrof || nrof == 0) |
285 | if (nrof > tmp_nrof || nrof == 0) |
292 | nrof = tmp_nrof; |
286 | nrof = tmp_nrof; |
… | |
… | |
338 | */ |
332 | */ |
339 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
333 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
340 | { |
334 | { |
341 | if (tmp->env && pl->type == PLAYER) |
335 | if (tmp->env && pl->type == PLAYER) |
342 | esrv_del_item (pl->contr, tmp->count); |
336 | esrv_del_item (pl->contr, tmp->count); |
343 | remove_ob (tmp); /* Unlink it */ |
337 | tmp->remove (); /* Unlink it */ |
344 | } |
338 | } |
345 | } |
339 | } |
346 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
340 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
347 | (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)); |
348 | else |
342 | else |
… | |
… | |
376 | void |
370 | void |
377 | pick_up (object *op, object *alt) |
371 | pick_up (object *op, object *alt) |
378 | { |
372 | { |
379 | int need_fix_tmp = 0; |
373 | int need_fix_tmp = 0; |
380 | object *tmp = NULL; |
374 | object *tmp = NULL; |
381 | mapstruct *tmp_map = NULL; |
375 | maptile *tmp_map = NULL; |
382 | int count; |
376 | int count; |
383 | |
377 | |
384 | /* Decide which object to pick. */ |
378 | /* Decide which object to pick. */ |
385 | if (alt) |
379 | if (alt) |
386 | { |
380 | { |
… | |
… | |
439 | 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)) |
440 | break; /* General container comes next */ |
434 | break; /* General container comes next */ |
441 | if (!alt) |
435 | if (!alt) |
442 | alt = op; /* No free containers */ |
436 | alt = op; /* No free containers */ |
443 | } |
437 | } |
|
|
438 | |
444 | if (tmp->env == alt) |
439 | if (tmp->env == alt) |
445 | { |
440 | { |
446 | /* here it could be possible to check rent, |
441 | /* here it could be possible to check rent, |
447 | * if someone wants to implement it |
442 | * if someone wants to implement it |
448 | */ |
443 | */ |
… | |
… | |
490 | else |
485 | else |
491 | { |
486 | { |
492 | tmp = op->above; |
487 | tmp = op->above; |
493 | if (tmp) |
488 | if (tmp) |
494 | while (tmp->above) |
489 | while (tmp->above) |
495 | { |
|
|
496 | tmp = tmp->above; |
490 | tmp = tmp->above; |
497 | } |
491 | |
498 | if (!tmp) |
492 | if (!tmp) |
499 | tmp = op->below; |
493 | tmp = op->below; |
500 | } |
494 | } |
501 | |
495 | |
502 | if (tmp == NULL) |
496 | if (tmp == NULL) |
… | |
… | |
635 | esrv_del_item (op->contr, tmp2->count); |
629 | esrv_del_item (op->contr, tmp2->count); |
636 | else /* this can proably be replaced with an update */ |
630 | else /* this can proably be replaced with an update */ |
637 | esrv_send_item (op, tmp2); |
631 | esrv_send_item (op, tmp2); |
638 | } |
632 | } |
639 | else |
633 | else |
640 | remove_ob (tmp); |
634 | tmp->remove (); |
641 | |
635 | |
642 | 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)); |
643 | tmp2 = insert_ob_in_ob (tmp, sack); |
637 | tmp2 = insert_ob_in_ob (tmp, sack); |
644 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
638 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
645 | /* in object.c */ |
639 | /* in object.c */ |
… | |
… | |
673 | |
667 | |
674 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
668 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
675 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
669 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
676 | return; /* can't unapply it */ |
670 | return; /* can't unapply it */ |
677 | |
671 | |
678 | /* 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 |
679 | * off |
673 | * off |
680 | */ |
674 | */ |
681 | if (nrof && tmp->nrof != nrof) |
675 | if (nrof && tmp->nrof != nrof) |
682 | { |
676 | { |
683 | object *tmp2 = tmp; |
677 | object *tmp2 = tmp; |
… | |
… | |
698 | else |
692 | else |
699 | esrv_send_item (op, tmp2); |
693 | esrv_send_item (op, tmp2); |
700 | } |
694 | } |
701 | } |
695 | } |
702 | else |
696 | else |
703 | remove_ob (tmp); |
697 | tmp->remove (); |
704 | |
698 | |
705 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
699 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
706 | return; |
700 | return; |
707 | |
701 | |
708 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
702 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
… | |
… | |
710 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
704 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
711 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
705 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
712 | 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."); |
713 | if (op->type == PLAYER) |
707 | if (op->type == PLAYER) |
714 | esrv_del_item (op->contr, tmp->count); |
708 | esrv_del_item (op->contr, tmp->count); |
715 | free_object (tmp); |
709 | tmp->destroy (); |
716 | fix_player (op); |
710 | fix_player (op); |
717 | return; |
711 | return; |
718 | } |
712 | } |
719 | |
713 | |
720 | /* If SAVE_INTERVAL is commented out, we never want to save |
714 | /* If SAVE_INTERVAL is commented out, we never want to save |
… | |
… | |
776 | if (tmp->env && tmp->env->type != PLAYER) |
770 | if (tmp->env && tmp->env->type != PLAYER) |
777 | { |
771 | { |
778 | /* Just toss the object - probably shouldn't be hanging |
772 | /* Just toss the object - probably shouldn't be hanging |
779 | * around anyways |
773 | * around anyways |
780 | */ |
774 | */ |
781 | remove_ob (tmp); |
775 | tmp->remove (); |
782 | free_object (tmp); |
776 | tmp->destroy (); |
783 | return; |
777 | return; |
784 | } |
778 | } |
785 | else |
779 | else |
786 | { |
780 | { |
787 | while (tmp != NULL && tmp->invisible) |
781 | while (tmp != NULL && tmp->invisible) |
… | |
… | |
1047 | { |
1041 | { |
1048 | object *tmp; |
1042 | object *tmp; |
1049 | |
1043 | |
1050 | if (!op || !op->contr) |
1044 | if (!op || !op->contr) |
1051 | return NULL; |
1045 | return NULL; |
|
|
1046 | |
1052 | if (!op->contr->mark) |
1047 | if (!op->contr->mark) |
1053 | { |
1048 | { |
1054 | |
|
|
1055 | /* 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");*/ |
1056 | return NULL; |
1050 | return 0; |
1057 | } |
1051 | } |
|
|
1052 | |
1058 | /* 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 |
1059 | * 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 |
1060 | * an item got reincarnated at some point. |
1055 | * an item got reincarnated at some point. |
1061 | */ |
1056 | */ |
1062 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1057 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1063 | { |
1058 | { |
1064 | if (tmp->invisible) |
1059 | if (tmp->invisible) |
1065 | continue; |
1060 | continue; |
|
|
1061 | |
1066 | if (tmp == op->contr->mark) |
1062 | if (tmp == op->contr->mark) |
1067 | { |
1063 | { |
1068 | if (tmp->count == op->contr->mark_count) |
1064 | if (!tmp->destroyed ()) |
1069 | return tmp; |
1065 | return tmp; |
1070 | else |
1066 | else |
1071 | { |
1067 | { |
1072 | op->contr->mark = NULL; |
1068 | op->contr->mark = 0; |
1073 | op->contr->mark_count = 0; |
|
|
1074 | |
|
|
1075 | /* 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");*/ |
1076 | return NULL; |
1070 | return 0; |
1077 | } |
1071 | } |
1078 | } |
1072 | } |
1079 | } |
1073 | } |
|
|
1074 | |
1080 | return NULL; |
1075 | return 0; |
1081 | } |
1076 | } |
1082 | |
1077 | |
1083 | |
1078 | |
1084 | /* op should be a player, params is any params. |
1079 | /* op should be a player, params is any params. |
1085 | * If no params given, we print out the currently marked object. |
1080 | * If no params given, we print out the currently marked object. |
… | |
… | |
1088 | int |
1083 | int |
1089 | command_mark (object *op, char *params) |
1084 | command_mark (object *op, char *params) |
1090 | { |
1085 | { |
1091 | if (!op->contr) |
1086 | if (!op->contr) |
1092 | return 1; |
1087 | return 1; |
|
|
1088 | |
1093 | if (!params) |
1089 | if (!params) |
1094 | { |
1090 | { |
1095 | object *mark = find_marked_object (op); |
1091 | object *mark = find_marked_object (op); |
1096 | |
1092 | |
1097 | if (!mark) |
1093 | if (!mark) |
… | |
… | |
1109 | return 1; |
1105 | return 1; |
1110 | } |
1106 | } |
1111 | else |
1107 | else |
1112 | { |
1108 | { |
1113 | op->contr->mark = mark1; |
1109 | op->contr->mark = mark1; |
1114 | op->contr->mark_count = mark1->count; |
|
|
1115 | 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)); |
1116 | return 0; |
1111 | return 0; |
1117 | } |
1112 | } |
1118 | } |
1113 | } |
|
|
1114 | |
1119 | return 0; /*shouldnt get here */ |
1115 | return 0; /*shouldnt get here */ |
1120 | } |
1116 | } |
1121 | |
1117 | |
1122 | |
1118 | |
1123 | /* op is the player |
1119 | /* op is the player |
… | |
… | |
1456 | 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); |
1457 | |
1453 | |
1458 | 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); |
1459 | |
1455 | |
1460 | 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); |
1461 | |
1458 | |
1462 | new_draw_info_format (NDI_UNIQUE, 0, op, ""); |
1459 | new_draw_info_format (NDI_UNIQUE, 0, op, ""); |
1463 | } |
1460 | } |
1464 | |
1461 | |
1465 | int |
1462 | int |
… | |
… | |
1467 | { |
1464 | { |
1468 | uint32 i; |
1465 | uint32 i; |
1469 | static const char *names[] = { |
1466 | static const char *names[] = { |
1470 | "debug", "inhibit", "stop", "food", "drink", "valuables", "bow", "arrow", "helmet", |
1467 | "debug", "inhibit", "stop", "food", "drink", "valuables", "bow", "arrow", "helmet", |
1471 | "shield", "armour", "boots", "gloves", "cloak", "key", "missile", "allweapon", |
1468 | "shield", "armour", "boots", "gloves", "cloak", "key", "missile", "allweapon", |
1472 | "magical", "potion", "spellbook", "skillscroll", "readables", "magicdevice", "notcursed", "jewels", NULL |
1469 | "magical", "potion", "spellbook", "skillscroll", "readables", "magicdevice", "notcursed", |
|
|
1470 | "jewels", "flesh", NULL |
1473 | }; |
1471 | }; |
1474 | static uint32 modes[] = { |
1472 | static uint32 modes[] = { |
1475 | 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, |
1476 | 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, |
1477 | 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 |
1478 | }; |
1477 | }; |
1479 | |
1478 | |
1480 | if (!params) |
1479 | if (!params) |
1481 | { |
1480 | { |
1482 | /* if the new mode is used, just print the settings */ |
1481 | /* if the new mode is used, just print the settings */ |