comparison arogue5/pack.c @ 218:56e748983fa8

Advanced Rogue 5: convert to ANSI function declarations. This still leaves over a thousand lines of warning messages, mostly related to the return types of daemons and fuses.
author John "Elwin" Edwards
date Sun, 07 Feb 2016 14:39:21 -0500
parents 0ed67132cf10
children
comparison
equal deleted inserted replaced
217:94a0d9dd5ce1 218:56e748983fa8
16 #include <ctype.h> 16 #include <ctype.h>
17 #include "rogue.h" 17 #include "rogue.h"
18 18
19 char outstring[512]; /* ridiculously long string for use with msg */ 19 char outstring[512]; /* ridiculously long string for use with msg */
20 20
21 bool is_type (struct object *obj, int type);
22
21 /* 23 /*
22 * add_pack: 24 * add_pack:
23 * Pick up an object and add it to the pack. If the argument is non-null 25 * Pick up an object and add it to the pack. If the argument is non-null
24 * use it as the linked_list pointer instead of gettting it off the ground. 26 * use it as the linked_list pointer instead of gettting it off the ground.
25 */ 27 */
26 bool 28 bool
27 add_pack(item, silent, packret) 29 add_pack(struct linked_list *item, bool silent, struct linked_list **packret)
28 register struct linked_list *item, **packret;
29 bool silent;
30 { 30 {
31 register struct linked_list *ip, *lp = NULL, *ap; 31 register struct linked_list *ip, *lp = NULL, *ap;
32 register struct object *obj, *op = NULL; 32 register struct object *obj, *op = NULL;
33 register bool exact, from_floor; 33 register bool exact, from_floor;
34 34
303 303
304 /* 304 /*
305 * inventory: 305 * inventory:
306 * list what is in the pack 306 * list what is in the pack
307 */ 307 */
308 inventory(list, type) 308 bool
309 register struct linked_list *list; 309 inventory(struct linked_list *list, int type)
310 register int type;
311 { 310 {
312 register struct object *obj; 311 register struct object *obj;
313 register char ch; 312 register char ch;
314 register int n_objs; 313 register int n_objs;
315 register int cnt; 314 register int cnt;
388 387
389 /* 388 /*
390 * pick_up: 389 * pick_up:
391 * Add something to characters pack. 390 * Add something to characters pack.
392 */ 391 */
393 pick_up(ch) 392 void
394 char ch; 393 pick_up(char ch)
395 { 394 {
396 switch (ch) { 395 switch (ch) {
397 default: 396 default:
398 debug("Where did you pick that up???"); 397 debug("Where did you pick that up???");
399 case GOLD: 398 case GOLD:
414 /* 413 /*
415 * picky_inven: 414 * picky_inven:
416 * Allow player to inventory a single item 415 * Allow player to inventory a single item
417 */ 416 */
418 void 417 void
419 picky_inven() 418 picky_inven(void)
420 { 419 {
421 register struct linked_list *item; 420 register struct linked_list *item;
422 register char ch, mch; 421 register char ch, mch;
423 422
424 if (pack == NULL) 423 if (pack == NULL)
469 468
470 469
471 /* 470 /*
472 * get_item: 471 * get_item:
473 * pick something out of a pack for a purpose 472 * pick something out of a pack for a purpose
473 * purpose: NULL if we should be silent (no prompts) *
474 */ 474 */
475 struct linked_list * 475 struct linked_list *
476 get_item(list, purpose, type) 476 get_item(struct linked_list *list, char *purpose, int type)
477 reg struct linked_list *list;
478 char *purpose; /* NULL if we should be silent (no prompts) */
479 int type;
480 { 477 {
481 reg struct linked_list *item; 478 reg struct linked_list *item;
482 reg struct object *obj; 479 reg struct object *obj;
483 reg int cnt, ch, och; 480 reg int cnt, ch, och;
484 struct linked_list *saveitem = NULL; 481 struct linked_list *saveitem = NULL;
608 else 605 else
609 msg ("You can't %s that!", purpose); 606 msg ("You can't %s that!", purpose);
610 } 607 }
611 } 608 }
612 609
613 pack_char(list, obj) 610 char
614 register struct object *obj; 611 pack_char(struct linked_list *list, struct object *obj)
615 struct linked_list *list;
616 { 612 {
617 register struct linked_list *item; 613 register struct linked_list *item;
618 register char c; 614 register char c;
619 615
620 c = 'a'; 616 c = 'a';
632 628
633 /* 629 /*
634 * cur_null: 630 * cur_null:
635 * This updates cur_weapon etc for dropping things 631 * This updates cur_weapon etc for dropping things
636 */ 632 */
637 cur_null(op) 633 void
638 reg struct object *op; 634 cur_null(struct object *op)
639 { 635 {
640 if (op == cur_weapon) cur_weapon = NULL; 636 if (op == cur_weapon) cur_weapon = NULL;
641 else if (op == cur_armor) cur_armor = NULL; 637 else if (op == cur_armor) cur_armor = NULL;
642 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL; 638 else if (op == cur_ring[LEFT_1]) cur_ring[LEFT_1] = NULL;
643 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL; 639 else if (op == cur_ring[LEFT_2]) cur_ring[LEFT_2] = NULL;
657 653
658 /* 654 /*
659 * idenpack: 655 * idenpack:
660 * Identify all the items in the pack 656 * Identify all the items in the pack
661 */ 657 */
662 idenpack() 658 void
659 idenpack(void)
663 { 660 {
664 reg struct linked_list *pc; 661 reg struct linked_list *pc;
665 662
666 for (pc = pack ; pc != NULL ; pc = next(pc)) 663 for (pc = pack ; pc != NULL ; pc = next(pc))
667 whatis(pc); 664 whatis(pc);
668 } 665 }
669 666
670 is_type (obj, type) 667 bool
671 register struct object *obj; 668 is_type (struct object *obj, int type)
672 register int type;
673 { 669 {
674 register bool current; 670 register bool current;
675 671
676 if (type == obj->o_type) 672 if (type == obj->o_type)
677 return (TRUE); 673 return (TRUE);
802 } 798 }
803 } 799 }
804 return(FALSE); 800 return(FALSE);
805 } 801 }
806 802
807 del_pack(item) 803 void
808 register struct linked_list *item; 804 del_pack(struct linked_list *item)
809 { 805 {
810 register struct object *obj; 806 register struct object *obj;
811 807
812 obj = OBJPTR(item); 808 obj = OBJPTR(item);
813 if (obj->o_count > 1) { 809 if (obj->o_count > 1) {
825 * carry_obj: 821 * carry_obj:
826 * Check to see if a monster is carrying something and, if so, give 822 * Check to see if a monster is carrying something and, if so, give
827 * it to him. 823 * it to him.
828 */ 824 */
829 825
830 carry_obj(mp, chance) 826 void
831 register struct thing *mp; 827 carry_obj(struct thing *mp, int chance)
832 int chance;
833 { 828 {
834 reg struct linked_list *item; 829 reg struct linked_list *item;
835 reg struct object *obj; 830 reg struct object *obj;
836 831
837 /* 832 /*
849 * the relic will be on top if there is a stack of item lying on the 844 * the relic will be on top if there is a stack of item lying on the
850 * floor and so the hero will know where it is if he's trying to 845 * floor and so the hero will know where it is if he's trying to
851 * avoid it 846 * avoid it
852 */ 847 */
853 if (on(*mp, CARRYDAGGER)) { 848 if (on(*mp, CARRYDAGGER)) {
854 item = spec_item(RELIC, MUSTY_DAGGER, NULL, NULL); 849 item = spec_item(RELIC, MUSTY_DAGGER, 0, 0);
855 obj = OBJPTR(item); 850 obj = OBJPTR(item);
856 obj->o_pos = mp->t_pos; 851 obj->o_pos = mp->t_pos;
857 attach(mp->t_pack, item); 852 attach(mp->t_pack, item);
858 } 853 }
859 854
860 if (on(*mp, CARRYCLOAK)) { 855 if (on(*mp, CARRYCLOAK)) {
861 item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); 856 item = spec_item(RELIC, EMORI_CLOAK, 0, 0);
862 obj = OBJPTR(item); 857 obj = OBJPTR(item);
863 obj->o_pos = mp->t_pos; 858 obj->o_pos = mp->t_pos;
864 attach(mp->t_pack, item); 859 attach(mp->t_pack, item);
865 } 860 }
866 861
867 if (on(*mp, CARRYANKH)) { 862 if (on(*mp, CARRYANKH)) {
868 item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); 863 item = spec_item(RELIC, HEIL_ANKH, 0, 0);
869 obj = OBJPTR(item); 864 obj = OBJPTR(item);
870 obj->o_pos = mp->t_pos; 865 obj->o_pos = mp->t_pos;
871 attach(mp->t_pack, item); 866 attach(mp->t_pack, item);
872 } 867 }
873 868
874 if (on(*mp, CARRYSTAFF)) { 869 if (on(*mp, CARRYSTAFF)) {
875 item = spec_item(RELIC, MING_STAFF, NULL, NULL); 870 item = spec_item(RELIC, MING_STAFF, 0, 0);
876 obj = OBJPTR(item); 871 obj = OBJPTR(item);
877 obj->o_pos = mp->t_pos; 872 obj->o_pos = mp->t_pos;
878 attach(mp->t_pack, item); 873 attach(mp->t_pack, item);
879 } 874 }
880 875
881 if (on(*mp, CARRYWAND)) { 876 if (on(*mp, CARRYWAND)) {
882 item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); 877 item = spec_item(RELIC, ORCUS_WAND, 0, 0);
883 obj = OBJPTR(item); 878 obj = OBJPTR(item);
884 obj->o_pos = mp->t_pos; 879 obj->o_pos = mp->t_pos;
885 attach(mp->t_pack, item); 880 attach(mp->t_pack, item);
886 } 881 }
887 882
888 if (on(*mp, CARRYROD)) { 883 if (on(*mp, CARRYROD)) {
889 item = spec_item(RELIC, ASMO_ROD, NULL, NULL); 884 item = spec_item(RELIC, ASMO_ROD, 0, 0);
890 obj = OBJPTR(item); 885 obj = OBJPTR(item);
891 obj->o_pos = mp->t_pos; 886 obj->o_pos = mp->t_pos;
892 attach(mp->t_pack, item); 887 attach(mp->t_pack, item);
893 } 888 }
894 889
895 if (on(*mp, CARRYAMULET)) { 890 if (on(*mp, CARRYAMULET)) {
896 item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); 891 item = spec_item(RELIC, YENDOR_AMULET, 0, 0);
897 obj = OBJPTR(item); 892 obj = OBJPTR(item);
898 obj->o_pos = mp->t_pos; 893 obj->o_pos = mp->t_pos;
899 attach(mp->t_pack, item); 894 attach(mp->t_pack, item);
900 } 895 }
901 896
902 if (on(*mp, CARRYMANDOLIN)) { 897 if (on(*mp, CARRYMANDOLIN)) {
903 item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); 898 item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0);
904 obj = OBJPTR(item); 899 obj = OBJPTR(item);
905 obj->o_pos = mp->t_pos; 900 obj->o_pos = mp->t_pos;
906 attach(mp->t_pack, item); 901 attach(mp->t_pack, item);
907 } 902 }
908 if (on(*mp, CARRYMSTAR)) { 903 if (on(*mp, CARRYMSTAR)) {
909 item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); 904 item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0);
910 obj = OBJPTR(item); 905 obj = OBJPTR(item);
911 obj->o_pos = mp->t_pos; 906 obj->o_pos = mp->t_pos;
912 attach(mp->t_pack, item); 907 attach(mp->t_pack, item);
913 } 908 }
914 if (on(*mp, CARRYFLAIL)) { 909 if (on(*mp, CARRYFLAIL)) {
915 item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); 910 item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0);
916 obj = OBJPTR(item); 911 obj = OBJPTR(item);
917 obj->o_pos = mp->t_pos; 912 obj->o_pos = mp->t_pos;
918 attach(mp->t_pack, item); 913 attach(mp->t_pack, item);
919 } 914 }
920 if (on(*mp, CARRYHORN)) { 915 if (on(*mp, CARRYHORN)) {
921 item = spec_item(RELIC, GERYON_HORN, NULL, NULL); 916 item = spec_item(RELIC, GERYON_HORN, 0, 0);
922 obj = OBJPTR(item); 917 obj = OBJPTR(item);
923 obj->o_pos = mp->t_pos; 918 obj->o_pos = mp->t_pos;
924 attach(mp->t_pack, item); 919 attach(mp->t_pack, item);
925 } 920 }
926 /* 921 /*
927 * If it carries gold, give it some 922 * If it carries gold, give it some
928 */ 923 */
929 if (on(*mp, CARRYGOLD) && rnd(100) < chance) { 924 if (on(*mp, CARRYGOLD) && rnd(100) < chance) {
930 item = spec_item(GOLD, NULL, NULL, NULL); 925 item = spec_item(GOLD, 0, 0, 0);
931 obj = OBJPTR(item); 926 obj = OBJPTR(item);
932 obj->o_count = GOLDCALC + GOLDCALC; 927 obj->o_count = GOLDCALC + GOLDCALC;
933 obj->o_pos = mp->t_pos; 928 obj->o_pos = mp->t_pos;
934 attach(mp->t_pack, item); 929 attach(mp->t_pack, item);
935 } 930 }
936 931
937 /* 932 /*
938 * If it carries food, give it some 933 * If it carries food, give it some
939 */ 934 */
940 if (on(*mp, CARRYFOOD) && rnd(100) < chance) { 935 if (on(*mp, CARRYFOOD) && rnd(100) < chance) {
941 item = spec_item(FOOD, NULL, NULL, NULL); 936 item = spec_item(FOOD, 0, 0, 0);
942 obj = OBJPTR(item); 937 obj = OBJPTR(item);
943 obj->o_weight = things[TYP_FOOD].mi_wght; 938 obj->o_weight = things[TYP_FOOD].mi_wght;
944 obj->o_pos = mp->t_pos; 939 obj->o_pos = mp->t_pos;
945 attach(mp->t_pack, item); 940 attach(mp->t_pack, item);
946 } 941 }
1039 * nothing is there, do nothing. If there is one thing, pick it 1034 * nothing is there, do nothing. If there is one thing, pick it
1040 * up. If there are multiple things, prompt the player for what 1035 * up. If there are multiple things, prompt the player for what
1041 * he wants (* means everything). 1036 * he wants (* means everything).
1042 */ 1037 */
1043 1038
1044 grab(y, x) 1039 int
1045 register y, x; 1040 grab(int y, int x)
1046 { 1041 {
1047 register struct linked_list *next_item, *item; 1042 register struct linked_list *next_item, *item;
1048 register struct object *obj; 1043 register struct object *obj;
1049 register int cnt; 1044 register int cnt;
1050 int num_there = 0, ch, och; 1045 int num_there = 0, ch, och;